deal with VerifyError with new 7u72 and bad tools, also convert line endings, continue work with Canvas embedding

This commit is contained in:
Ben Fry
2014-11-16 17:14:40 -07:00
parent 51d2214347
commit c0b19b02eb
5 changed files with 211 additions and 188 deletions

View File

@@ -739,19 +739,20 @@ public class PGraphics extends PImage implements PConstants {
public void setSize(int w, int h) { // ignore
width = w;
height = h;
// width1 = width - 1;
// height1 = height - 1;
allocate();
pixelWidth = width * pixelFactor;
pixelHeight = height * pixelFactor;
// allocate();
reapplySettings();
}
/**
* Allocate memory for this renderer. Generally will need to be implemented
* for all renderers.
*/
protected void allocate() { }
// /**
// * Allocate memory for this renderer. Generally will need to be implemented
// * for all renderers.
// */
// protected void allocate() { }
/**

View File

@@ -120,26 +120,26 @@ public class PGraphicsJava2D extends PGraphics {
//public void setPath(String path)
/**
* Called in response to a resize event, handles setting the
* new width and height internally, as well as re-allocating
* the pixel buffer for the new size.
*
* Note that this will nuke any cameraMode() settings.
*/
@Override
public void setSize(int iwidth, int iheight) { // ignore
width = iwidth;
height = iheight;
allocate();
reapplySettings();
}
// /**
// * Called in response to a resize event, handles setting the
// * new width and height internally, as well as re-allocating
// * the pixel buffer for the new size.
// *
// * Note that this will nuke any cameraMode() settings.
// */
// @Override
// public void setSize(int iwidth, int iheight) { // ignore
// width = iwidth;
// height = iheight;
//
// allocate();
// reapplySettings();
// }
/*
@Override
protected void allocate() {
/*
// 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
@@ -230,8 +230,8 @@ public class PGraphicsJava2D extends PGraphics {
}
g2 = (Graphics2D) image.getGraphics();
*/
}
*/
//public void dispose()
@@ -2626,9 +2626,11 @@ public class PGraphicsJava2D extends PGraphics {
@Override
public void updatePixels(int x, int y, int c, int d) {
//if ((x == 0) && (y == 0) && (c == width) && (d == height)) {
if ((x != 0) || (y != 0) || (c != width) || (d != height)) {
System.err.format("%d %d %d %d .. w/h = %d %d .. pw/ph = %d %d %n", x, y, c, d, width, height, pixelWidth, pixelHeight);
if ((x != 0) || (y != 0) || (c != pixelWidth) || (d != pixelHeight)) {
// Show a warning message, but continue anyway.
showVariationWarning("updatePixels(x, y, w, h)");
// new Exception().printStackTrace(System.out);
}
// updatePixels();
if (pixels != null) {

View File

@@ -164,7 +164,7 @@ public class PSurfaceAWT implements PSurface {
newSize.width = getWidth();
newSize.height = getHeight();
if (oldSize.equals(newSize)) {
System.out.println("validate() return " + oldSize);
// System.out.println("validate() return " + oldSize);
return;
} else {
// System.out.println("validate() render old=" + oldSize + " -> new=" + newSize);
@@ -410,11 +410,10 @@ public class PSurfaceAWT implements PSurface {
public Canvas initCanvas(PApplet sketch) {
this.sketch = sketch;
// needed for getPreferredSize() et al
sketchWidth = sketch.sketchWidth();
sketchHeight = sketch.sketchHeight();
setSize(sketchWidth, sketchHeight);
return canvas;
}
@@ -751,8 +750,12 @@ public class PSurfaceAWT implements PSurface {
public void startThread() {
thread = new AnimationThread();
thread.start();
if (thread == null) {
thread = new AnimationThread();
thread.start();
} else {
throw new IllegalStateException("Thread already started in PSurfaceAWT");
}
}
@@ -819,6 +822,9 @@ public class PSurfaceAWT implements PSurface {
//throw new RuntimeException("implement me, see readme.md");
sketchWidth = sketch.width = wide;
sketchHeight = sketch.height = high;
// sets internal variables for width/height/pixelWidth/pixelHeight
graphics.setSize(wide, high);
}
@@ -1357,6 +1363,14 @@ public class PSurfaceAWT implements PSurface {
// animation thread yields to other running threads.
final int NO_DELAYS_PER_YIELD = 15;
// If size un-initialized, might be a Canvas. Call setSize() here since
// we now have a parent object that this Canvas can use as a peer.
if (graphics.image == null) {
// System.out.format("it's null, sketchW/H already set to %d %d%n", sketchWidth, sketchHeight);
setSize(sketchWidth, sketchHeight);
// System.out.format(" but now, sketchW/H changed to %d %d%n", sketchWidth, sketchHeight);
}
// un-pause the sketch and get rolling
sketch.start();
@@ -1370,7 +1384,7 @@ public class PSurfaceAWT implements PSurface {
if (currentSize.width != sketchWidth || currentSize.height != sketchHeight) {
//resizeRenderer(currentSize.width, currentSize.height);
//System.err.format("need to resize from %s to %d, %d", currentSize, graphics.width, graphics.height);
System.err.format("need to resize from %s to %d, %d", currentSize, sketchWidth, sketchHeight);
System.err.format("need to resize from %s to %d, %d%n", currentSize, sketchWidth, sketchHeight);
}
// }