moving back to load/updatePixels again

This commit is contained in:
benfry
2006-09-19 19:05:51 +00:00
parent 6e474a099b
commit 5f3efe3be8
10 changed files with 320 additions and 319 deletions
+4 -1
View File
@@ -35,7 +35,7 @@ public class Archiver {
Editor editor;
// someday these will be settable
boolean useDate = true; //false;
boolean useDate;
int digits = 3;
NumberFormat numberFormat;
@@ -79,6 +79,9 @@ public class Archiver {
String namely = null;
int index = 0;
do {
// only use the date if the sketch name isn't the default name
useDate = !name.startsWith("sketch_");
if (useDate) {
String purty = dateFormat.format(new Date());
String stamp = purty + ((char) ('a' + index));
+14 -15
View File
@@ -184,7 +184,7 @@ public class PApplet extends Applet
* Pixel buffer from this applet's PGraphics.
* <P>
* When used with OpenGL or Java2D, this value will
* be null until beginPixels() has been called.
* be null until loadPixels() has been called.
*/
public int pixels[];
@@ -1137,7 +1137,7 @@ public class PApplet extends Applet
// if depth() is called inside setup, pixels/width/height
// will be ok by the time it's back out again
//this.pixels = g.pixels; // make em call beginPixels
//this.pixels = g.pixels; // make em call loadPixels
// now for certain that we've got a valid size
this.width = g.width;
this.height = g.height;
@@ -6429,14 +6429,13 @@ public class PApplet extends Applet
//////////////////////////////////////////////////////////////
/**
* Override the g.pixels[] function to set the pixels[] array
* that's part of the PApplet object. Allows the use of
* pixels[] in the code, rather than g.pixels[].
*/
public void loadPixels() {
System.err.println("Use beginPixels() instead of loadPixels() " +
"with release 0116 and later.");
}
public void beginPixels() {
g.beginPixels();
g.loadPixels();
pixels = g.pixels;
}
@@ -6465,15 +6464,15 @@ public class PApplet extends Applet
}
public void endPixels() {
if (recorder != null) recorder.endPixels();
g.endPixels();
public void updatePixels() {
if (recorder != null) recorder.updatePixels();
g.updatePixels();
}
public void endPixels(int x1, int y1, int x2, int y2) {
if (recorder != null) recorder.endPixels(x1, y1, x2, y2);
g.endPixels(x1, y1, x2, y2);
public void updatePixels(int x1, int y1, int x2, int y2) {
if (recorder != null) recorder.updatePixels(x1, y1, x2, y2);
g.updatePixels(x1, y1, x2, y2);
}
+7 -7
View File
@@ -2279,19 +2279,19 @@ public abstract class PGraphics extends PImage implements PConstants {
/**
* Draw a single character on screen.
* Extremely slow when used with textMode(SCREEN) and Java 2D,
* because beginPixels has to be called first and updatePixels last.
* because loadPixels has to be called first and updatePixels last.
*/
public void text(char c, float x, float y) {
if (textFont == null) {
throw new RuntimeException("use textFont() before text()");
}
if (textMode == SCREEN) beginPixels();
if (textMode == SCREEN) loadPixels();
textBuffer[0] = c;
textLineImpl(textBuffer, 0, 1, x, y);
if (textMode == SCREEN) endPixels();
if (textMode == SCREEN) updatePixels();
}
@@ -2332,7 +2332,7 @@ public abstract class PGraphics extends PImage implements PConstants {
throw new RuntimeException("use textFont() before text()");
}
if (textMode == SCREEN) beginPixels();
if (textMode == SCREEN) loadPixels();
int length = str.length();
if (length > textBuffer.length) {
@@ -2353,7 +2353,7 @@ public abstract class PGraphics extends PImage implements PConstants {
if (start < length) {
textLineImpl(textBuffer, start, index, x, y);
}
if (textMode == SCREEN) endPixels();
if (textMode == SCREEN) updatePixels();
}
@@ -2423,7 +2423,7 @@ public abstract class PGraphics extends PImage implements PConstants {
throw new RuntimeException("use textFont() before text()");
}
if (textMode == SCREEN) beginPixels();
if (textMode == SCREEN) loadPixels();
float hradius, vradius;
switch (rectMode) {
@@ -2551,7 +2551,7 @@ public abstract class PGraphics extends PImage implements PConstants {
textLineImpl(textBuffer, lineStart, index, lineX, currentY);
}
if (textMode == SCREEN) endPixels();
if (textMode == SCREEN) updatePixels();
}
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -228,7 +228,7 @@ public class PGraphics3D extends PGraphics {
}
*/
insideResize = true;
width = iwidth;
height = iheight;
width1 = width - 1;
@@ -325,7 +325,7 @@ public class PGraphics3D extends PGraphics {
public void beginDraw() {
insideResizeWait();
insideDraw = true;
// need to call defaults(), but can only be done when it's ok
// to draw (i.e. for opengl, no drawing can be done outside
// beginDraw/endDraw).
@@ -384,7 +384,7 @@ public class PGraphics3D extends PGraphics {
}
// mark pixels as having been updated, so that they'll work properly
// when this PGraphics is drawn using image().
endPixels();
updatePixels();
//System.out.println(this + " end draw");
insideDraw = false;
+26 -26
View File
@@ -132,7 +132,7 @@ public class PGraphicsJava2D extends PGraphics {
public void endDraw() {
// hm, mark pixels as changed, because this will instantly do a full
// copy of all the pixels to the surface.. so that's kind of a mess.
//endPixels();
//updatePixels();
}
@@ -557,7 +557,7 @@ public class PGraphicsJava2D extends PGraphics {
int u1, int v1, int u2, int v2) {
if (who.cache == null) {
who.cache = new ImageCache(who);
who.endPixels(); // mark the whole thing for update
who.updatePixels(); // mark the whole thing for update
}
ImageCache cash = (ImageCache) who.cache;
@@ -567,7 +567,7 @@ public class PGraphicsJava2D extends PGraphics {
(tint && (cash.tintedColor != tintColor)) ||
(!tint && cash.tinted)) {
// for tint change, mark all pixels as needing update
who.endPixels();
who.updatePixels();
}
if (who.modified) {
@@ -1009,7 +1009,7 @@ public class PGraphicsJava2D extends PGraphics {
//////////////////////////////////////////////////////////////
public void beginPixels() {
public void loadPixels() {
if ((pixels == null) || (pixels.length != width * height)) {
pixels = new int[width * height];
}
@@ -1022,11 +1022,11 @@ public class PGraphicsJava2D extends PGraphics {
/**
* Update the pixels[] buffer to the PGraphics image.
* <P>
* Unlike in PImage, where endPixels() only asks that the
* Unlike in PImage, where updatePixels() only asks that the
* update happens, in PGraphicsJava, this will happen immediately.
*/
public void endPixels() {
//endPixels(0, 0, width, height);
public void updatePixels() {
//updatePixels(0, 0, width, height);
WritableRaster raster = ((BufferedImage) image).getRaster();
raster.setDataElements(0, 0, width, height, pixels);
}
@@ -1035,14 +1035,14 @@ public class PGraphicsJava2D extends PGraphics {
/**
* Update the pixels[] buffer to the PGraphics image.
* <P>
* Unlike in PImage, where endPixels() only asks that the
* Unlike in PImage, where updatePixels() only asks that the
* update happens, in PGraphicsJava, this will happen immediately.
*/
public void endPixels(int x, int y, int c, int d) {
public void updatePixels(int x, int y, int c, int d) {
if ((x == 0) && (y == 0) && (c == width) && (d == height)) {
endPixels();
updatePixels();
} else {
throw new RuntimeException("endPixels(x, y, c, d) not implemented");
throw new RuntimeException("updatePixels(x, y, c, d) not implemented");
}
/*
((BufferedImage) image).setRGB(x, y,
@@ -1194,16 +1194,16 @@ public class PGraphicsJava2D extends PGraphics {
public void filter(int kind) {
beginPixels();
loadPixels();
super.filter(kind);
endPixels();
updatePixels();
}
public void filter(int kind, float param) {
beginPixels();
loadPixels();
super.filter(kind, param);
endPixels();
updatePixels();
}
@@ -1229,9 +1229,9 @@ public class PGraphicsJava2D extends PGraphics {
public void copy(PImage src,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2) {
beginPixels();
loadPixels();
super.copy(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
endPixels();
updatePixels();
}
@@ -1239,32 +1239,32 @@ public class PGraphicsJava2D extends PGraphics {
public void blend(PImage src, int sx, int sy, int dx, int dy, int mode) {
beginPixels();
loadPixels();
super.blend(src, sx, sy, dx, dy, mode);
endPixels();
updatePixels();
}
public void blend(int sx, int sy, int dx, int dy, int mode) {
beginPixels();
loadPixels();
super.blend(sx, sy, dx, dy, mode);
endPixels();
updatePixels();
}
public void blend(int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2, int mode) {
beginPixels();
loadPixels();
super.blend(sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode);
endPixels();
updatePixels();
}
public void blend(PImage src, int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2, int mode) {
beginPixels();
loadPixels();
super.blend(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode);
endPixels();
updatePixels();
}
@@ -1273,7 +1273,7 @@ public class PGraphicsJava2D extends PGraphics {
public void save(String filename) {
//System.out.println("start load");
beginPixels();
loadPixels();
//System.out.println("end load, start save");
super.save(filename);
//System.out.println("done with save");
+13 -13
View File
@@ -296,17 +296,17 @@ public class PImage implements PConstants, Cloneable {
/*
public void loadPixels() { // ignore
System.err.println("Use beginPixels() instead of loadPixels() " +
System.err.println("Use loadPixels() instead of loadPixels() " +
"with release 0116 and later.");
beginPixels();
loadPixels();
}
public void updatePixels() {
System.err.println("Use endPixels() instead of updatePixels() " +
System.err.println("Use updatePixels() instead of updatePixels() " +
"with release 0116 and later.");
System.err.flush();
endPixels();
updatePixels();
}
*/
@@ -318,7 +318,7 @@ public class PImage implements PConstants, Cloneable {
* For subclasses where the pixels[] buffer isn't set by default,
* this should copy all data into the pixels[] array
*/
public void beginPixels() { // ignore
public void loadPixels() { // ignore
}
@@ -328,8 +328,8 @@ public class PImage implements PConstants, Cloneable {
* <p/>
* Mark all pixels as needing update.
*/
public void endPixels() {
endPixels(0, 0, width, height);
public void updatePixels() {
updatePixels(0, 0, width, height);
}
@@ -343,7 +343,7 @@ public class PImage implements PConstants, Cloneable {
* Note that when using imageMode(CORNERS),
* the x2 and y2 positions are non-inclusive.
*/
public void endPixels(int x1, int y1, int x2, int y2) {
public void updatePixels(int x1, int y1, int x2, int y2) {
//if (!modified) { // could just set directly, but..
//}
@@ -587,7 +587,7 @@ public class PImage implements PConstants, Cloneable {
* <A HREF="http://incubator.quasimondo.com">Mario Klingemann</A>
*/
public void filter(int kind) {
beginPixels();
loadPixels();
switch (kind) {
case BLUR:
@@ -643,7 +643,7 @@ public class PImage implements PConstants, Cloneable {
dilate(false);
break;
}
endPixels(); // mark as modified
updatePixels(); // mark as modified
}
@@ -664,7 +664,7 @@ public class PImage implements PConstants, Cloneable {
* and later updated by toxi for better speed.
*/
public void filter(int kind, float param) {
beginPixels();
loadPixels();
switch (kind) {
case BLUR:
@@ -732,7 +732,7 @@ public class PImage implements PConstants, Cloneable {
throw new RuntimeException("Use filter(DILATE) instead of " +
"filter(DILATE, param)");
}
endPixels(); // mark as modified
updatePixels(); // mark as modified
}
@@ -1829,7 +1829,7 @@ public class PImage implements PConstants, Cloneable {
// spew the header to the disk
output.write(tiff);
for (int i = 0; i < pixels.length; i++) {
output.write((pixels[i] >> 16) & 0xff);
output.write((pixels[i] >> 8) & 0xff);
+1 -2
View File
@@ -80,11 +80,10 @@ o right now the camera doesn't get set up unless you call depth()
o box and sphere are broken in gl
o what should the update image function be called?
_ does ENABLE_DEPTH_SORT not work with opengl?
needs to be tested
_ jogl issues with some cards on linux, might be fixed with newer jogl
_ http://dev.processing.org/bugs/show_bug.cgi?id=367
_ does ENABLE_DEPTH_SORT not work with opengl?
still not fixed
_ things not showing up in linux
+2 -2
View File
@@ -281,7 +281,7 @@ public class Capture extends PImage implements Runnable {
public void read() {
//try {
//synchronized (capture) {
beginPixels();
loadPixels();
synchronized (pixels) {
//System.out.println("read1");
if (crop) {
@@ -311,7 +311,7 @@ public class Capture extends PImage implements Runnable {
// mark this image as modified so that PGraphicsJava and PGraphicsGL
// will properly re-blit and draw this guy
//updatePixels();
endPixels();
updatePixels();
//System.out.println("read4");
}
}
+2 -2
View File
@@ -302,7 +302,7 @@ public class Movie extends PImage implements PConstants, Runnable {
// this happens later (found by hernando)
//raw.copyToArray(0, image.pixels, 0, image.width * image.height);
beginPixels();
loadPixels();
// this is identical to a chunk of code inside PCamera
// this might be a candidate to move up to PVideo or something
if (borderImage != null) { // need to remove borders
@@ -323,7 +323,7 @@ public class Movie extends PImage implements PConstants, Runnable {
// ready to rock
//System.out.println("updating pixels");
//updatePixels(); // mark as modified
endPixels();
updatePixels();
} catch (QTException qte) {
qte.printStackTrace();