mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
use acceleration
This commit is contained in:
+5
-5
@@ -51,9 +51,9 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
private Image bufferImage;
|
private Image bufferImage;
|
||||||
private GraphicsConfiguration screenGraphicsConfiguration;
|
private GraphicsConfiguration screenGraphicsConfiguration;
|
||||||
|
|
||||||
private static boolean USE_HARDWARE_ACCELLERATION = false;
|
private static boolean USE_HARDWARE_ACCELLERATION = true;
|
||||||
|
|
||||||
private static final EnumSet<DrawOption> drawOptions = EnumSet.of(DrawOption.GRID,
|
static final EnumSet<DrawOption> DRAW_OPTIONS = EnumSet.of(DrawOption.GRID,
|
||||||
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
||||||
DrawOption.CONTROL_POINTS);
|
DrawOption.CONTROL_POINTS);
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
bufferImage = createImage(getWidth(), getHeight());
|
bufferImage = createImage(getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||||
plugInPort.draw(g2d, drawOptions, null);
|
plugInPort.draw(g2d, DRAW_OPTIONS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,7 +119,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
createBufferImage();
|
createBufferImage();
|
||||||
} else {
|
} else {
|
||||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||||
plugInPort.draw(g2d, drawOptions, null);
|
plugInPort.draw(g2d, DRAW_OPTIONS, null);
|
||||||
}
|
}
|
||||||
if (USE_HARDWARE_ACCELLERATION) {
|
if (USE_HARDWARE_ACCELLERATION) {
|
||||||
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
||||||
@@ -139,7 +139,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
} while (volatileImage == null || volatileImage.contentsLost());
|
} while (volatileImage == null || volatileImage.contentsLost());
|
||||||
} else {
|
} else {
|
||||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||||
plugInPort.draw(g2d, drawOptions, null);
|
plugInPort.draw(g2d, DRAW_OPTIONS, null);
|
||||||
g.drawImage(bufferImage, 0, 0, this);
|
g.drawImage(bufferImage, 0, 0, this);
|
||||||
bufferImage.flush();
|
bufferImage.flush();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user