deal with blank canvas performance and Java2D (issue #729)

This commit is contained in:
benfry
2011-11-12 21:08:00 +00:00
parent 522c92e4a4
commit f9ddbadb61
3 changed files with 13 additions and 14 deletions
+2 -3
View File
@@ -236,7 +236,6 @@ public class PApplet extends Applet
* inside setup() is a joke, since it's long since the AWT has been invoked.
*/
static public boolean useQuartz = true;
//static public String useQuartz = "true";
/**
* Modifier flags for the shortcut key used to trigger menus.
@@ -973,11 +972,11 @@ public class PApplet extends Applet
int count;
Object objects[];
Method methods[];
Object[] convArgs = new Object[] { };
// convenience version for no args
public void handle() {
handle(new Object[] { });
handle(convArgs);
}
public void handle(Object oargs[]) {
@@ -122,22 +122,22 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ {
// broken out because of subclassing for opengl
protected void allocate() {
// System.out.println("PGraphicsJava2D allocate() " + width + " " + height);
// System.out.println("allocate " + Thread.currentThread().getName());
// Tried this with RGB instead of ARGB for the primarySurface version,
// but didn't see any performance difference (OS X 10.6, Java 6u24).
// For 0196, also attempted RGB instead of ARGB, but that causes
// strange things to happen with blending.
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
if (primarySurface) {
// image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// offscreen = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// Needs to be RGB otherwise there's a major performance hit [0204]
// http://code.google.com/p/processing/issues/detail?id=729
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
offscreen = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
g2 = (Graphics2D) offscreen.getGraphics();
} else {
// image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// if the buffer's offscreen anyway, no need for the extra offscreen buffer
// Since this buffer's offscreen anyway, no need for the extra offscreen
// buffer. However, unlike the primary surface, this feller needs to be
// ARGB so that blending ("alpha" compositing) will work properly.
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
g2 = (Graphics2D) image.getGraphics();
}
+3 -3
View File
@@ -1,4 +1,7 @@
0204 core
X Abnormal high Java CPU usage at empty sketch with draw()
X http://code.google.com/p/processing/issues/detail?id=729
X https://forum.processing.org/topic/absurd-java-cpu-usage-at-empty-sketch-with-draw
_ add inputPath() and outputPath() -> sketch folder or sd card
@@ -147,9 +150,6 @@ X remove textMode(SCREEN) references
2.0
_ Abnormal high Java CPU usage at empty sketch with draw()
_ http://code.google.com/p/processing/issues/detail?id=729
_ https://forum.processing.org/topic/absurd-java-cpu-usage-at-empty-sketch-with-draw
_ PNode.getChildren() shouldn't make a new array.. toArray() can do that
_ text using textMode(SCREEN) not displayed in Processing 1.5.1
_ http://code.google.com/p/processing/issues/detail?id=741