Allow bypassing VolatileImage rendering to gain performance 33/333/1
authorMarko Luukkainen <marko.luukkainen@vtt.fi>
Wed, 15 Feb 2017 14:14:32 +0000 (16:14 +0200)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Wed, 15 Feb 2017 14:14:32 +0000 (16:14 +0200)
refs #7034

Change-Id: I3a53175ed86ba9b0705498f8c0652fec69cc1cd1

bundles/org.simantics.g2d/src/org/simantics/g2d/chassis/AWTChassis.java

index 17304ef3e548da3642672c21993c6f4e4042e6c8..2679ef620ac5c87b65de2337c9a188219895a88e 100644 (file)
@@ -81,6 +81,8 @@ public class AWTChassis extends JComponent implements ICanvasChassis {
     private transient boolean                    closed           = false;
     protected ICanvasContext                     canvasContext;
 
+    private boolean useVolatileImage = true;
+    
     // Marks the content dirty
     protected IContentListener contentListener = new IContentListener() {
         @Override
@@ -277,6 +279,14 @@ public class AWTChassis extends JComponent implements ICanvasChassis {
     public IHintContext getHintContext() {
         return hintCtx;
     }
+    
+    public void setUseVolatileImage(boolean useVolatileImage) {
+               this.useVolatileImage = useVolatileImage;
+       }
+    
+    public boolean isUseVolatileImage() {
+               return useVolatileImage;
+       }
 
     private void paintScenegraph(Graphics2D g2d, Rectangle controlBounds) {
         Color bg = getBackground();
@@ -355,7 +365,9 @@ public class AWTChassis extends JComponent implements ICanvasChassis {
             startmem = Runtime.getRuntime().freeMemory();
             start = System.nanoTime();
         }
-        VolatileImage buffer = paintToVolatileImage(g2d, b);
+        VolatileImage buffer = null;
+        if (useVolatileImage)
+               buffer = paintToVolatileImage(g2d, b);
         if (closed)
             return;
         if (DebugPolicy.PERF_CHASSIS_RENDER_FRAME) {