From 38fae0d44265dedb44990d1eddb9731b42570c8e Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 17 Apr 2011 16:55:18 +0000 Subject: [PATCH] trying to track down flickering issue with chrome --- core/src/processing/core/PApplet.java | 28 +++++++++++++++++++ core/src/processing/core/PGraphicsJava2D.java | 6 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 9d6a63226..87db2a132 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1423,6 +1423,10 @@ public class PApplet extends Applet public void paint(Graphics screen) { +// int r = (int) random(10000); +// System.out.println("into paint " + r); + //super.paint(screen); + // ignore the very first call to paint, since it's coming // from the o.s., and the applet will soon update itself anyway. if (frameCount == 0) { @@ -1432,6 +1436,20 @@ public class PApplet extends Applet return; } +// //MACOSX +// // every public entry point for drawing should +// // disable/enable flushing to avoid screen flickering +// sun.java2d.SurfaceData sd = null; +// if (platform == MACOSX) { +// if (screen instanceof sun.java2d.SunGraphics2D) { +// sd = ((sun.java2d.SunGraphics2D) screen).surfaceData; +// } +// if (sd != null) { +// sd.disableFlushing(); +// } +// } +// try { + // without ignoring the first call, the first several frames // are confused because paint() gets called in the midst of // the initial nextFrame() call, so there are multiple @@ -1453,6 +1471,16 @@ public class PApplet extends Applet } } } + +// System.out.println(" out paint " + r); + +// } finally { +// if (platform == MACOSX) { +// if (sd != null) { +// sd.enableFlushing(); +// } +// } +// } } diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index 7a1f5968f..01552ba19 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -182,8 +182,10 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ { // don't copy the pixels/data elements of the buffered image directly, // since it'll disable the nice speedy pipeline stuff, sending all drawing // into a world of suck that's rough 6 trillion times slower. - image.getGraphics().drawImage(offscreen, 0, 0, null); - + synchronized (image) { + //System.out.println("inside j2d sync"); + image.getGraphics().drawImage(offscreen, 0, 0, null); + } } else { // TODO this is probably overkill for most tasks... loadPixels();