Skip to content

Commit 0a6da51

Browse files
committed
moving blit() around a bit, change basic surface name
1 parent 1512b27 commit 0a6da51

File tree

7 files changed

+61
-21
lines changed

7 files changed

+61
-21
lines changed

core/src/processing/core/PApplet.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,8 +1884,6 @@ public void handleDraw() {
18841884
}
18851885
insideDraw = false;
18861886

1887-
surface.blit();
1888-
18891887
if (frameCount != 0) {
18901888
handleMethods("post");
18911889
}

core/src/processing/core/PSurface.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public Frame initFrame(PApplet sketch, Color backgroundColor,
111111
// receive key and mouse events
112112
public void requestFocus();
113113

114-
// finish rendering to the screen (called by PApplet)
115-
public void blit();
114+
// // finish rendering to the screen (called by PApplet)
115+
// public void blit();
116116

117117
//
118118

core/src/processing/core/PSurfaceAWT.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import processing.event.MouseEvent;
3737

3838

39-
public class PSurfaceAWT extends PSurfaceBasic {
39+
public class PSurfaceAWT extends PSurfaceNone {
4040
GraphicsDevice displayDevice;
4141

4242
// used for canvas to determine whether resizable or not
@@ -316,7 +316,7 @@ protected synchronized void render() {
316316
BufferedImage onscreen;
317317
// Graphics off;
318318

319-
@Override
319+
320320
public void blit() {
321321
// Other folks that call render() (i.e. paint()) are already on the EDT.
322322
// We need to be using the EDT since we're messing with the Canvas
@@ -1380,6 +1380,18 @@ public void hideCursor() {
13801380
}
13811381

13821382

1383+
@Override
1384+
public Thread createThread() {
1385+
return new AnimationThread() {
1386+
@Override
1387+
public void render() {
1388+
super.render();
1389+
blit();
1390+
}
1391+
};
1392+
}
1393+
1394+
13831395
void debug(String format, Object ... args) {
13841396
System.out.format(format + "%n", args);
13851397
}

core/src/processing/core/PSurfaceBasic.java renamed to core/src/processing/core/PSurfaceNone.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
import java.awt.Frame;
2828

2929

30-
public class PSurfaceBasic implements PSurface {
30+
/**
31+
* Surface that's not really visible. Used for PDF and friends, or as a base
32+
* class for other drawing surfaces. It includes the standard rendering loop.
33+
*/
34+
public class PSurfaceNone implements PSurface {
3135
PApplet sketch;
3236

3337
Thread thread;
@@ -38,7 +42,7 @@ public class PSurfaceBasic implements PSurface {
3842
protected long frameRatePeriod = 1000000000L / 60L;
3943

4044

41-
public PSurfaceBasic() { }
45+
public PSurfaceNone() { }
4246

4347

4448
public void initOffscreen(PApplet sketch) {
@@ -94,9 +98,9 @@ public void requestFocus() {
9498

9599
}
96100

97-
public void blit() {
98-
// TODO Auto-generated method stub
99-
}
101+
// public void blit() {
102+
// // TODO Auto-generated method stub
103+
// }
100104

101105
public void setCursor(int kind) { }
102106

@@ -110,9 +114,14 @@ public void hideCursor() { }
110114
//
111115

112116

117+
public Thread createThread() {
118+
return new AnimationThread();
119+
}
120+
121+
113122
public void startThread() {
114123
if (thread == null) {
115-
thread = new AnimationThread();
124+
thread = createThread();
116125
thread.start();
117126
} else {
118127
throw new IllegalStateException("Thread already started in " +
@@ -172,12 +181,17 @@ public void setFrameRate(float fps) {
172181
//g.setFrameRate(fps);
173182
}
174183

184+
175185
class AnimationThread extends Thread {
176186

177187
public AnimationThread() {
178188
super("Animation Thread");
179189
}
180190

191+
public void render() {
192+
sketch.handleDraw();
193+
}
194+
181195
/**
182196
* Main method for the primary animation thread.
183197
* <A HREF="http://java.sun.com/products/jfc/tsc/articles/painting/">Painting in AWT and Swing</A>
@@ -229,7 +243,7 @@ public void run() {
229243
// try {
230244
// EventQueue.invokeAndWait(new Runnable() {
231245
// public void run() {
232-
sketch.handleDraw();
246+
render();
233247

234248
// EventQueue.invokeLater(new Runnable() {
235249
// public void run() {

core/src/processing/opengl/PSurfaceLWJGL.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,10 @@ public void requestFocus() {
453453
}
454454

455455

456-
@Override
457-
public void blit() {
458-
// Nothing to do here
459-
}
456+
// @Override
457+
// public void blit() {
458+
// // Nothing to do here
459+
// }
460460

461461

462462
@Override

core/todo.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ o downside: breaks compatibility big time
2020
X would have to use ALIGN_CENTER eta al, so no
2121
X noSmooth() not sticking, has to be called again inside draw()
2222
X https://github.com/processing/processing/issues/3113
23+
X performance issues on OS X (might be threading due to Applet)
24+
X https://github.com/processing/processing/issues/2423
25+
X can't fix, it's all Oracle stuff
2326

2427
showstoppers
2528
_ static mode - no setup() / draw() - broken in OpenGL
2629
_ https://github.com/processing/processing/issues/3163
30+
31+
high priority
2732
_ sketch window is not placed at correct location when running a second time
2833
_ https://github.com/processing/processing/issues/3125
34+
_ present mode is 30-40% slower than windowed
35+
_ w/ this example: https://github.com/processing/processing/issues/2423
2936

3037
head
3138
X Sketch window dimensions off in Java2D
@@ -120,9 +127,11 @@ X https://github.com/processing/processing/wiki/Window-Size-and-Full-Screen
120127
X Linux throwing IllegalStateException: Buffers have not been created
121128
X in render() (called from blit) PSurfaceAWT:301
122129

130+
123131
_ remove setTitle() etc methods from PSurface, just use the ones from Frame?
124132
_ and with that, encourage the use of the dummy frame object in renderers
125-
_ destroy() removed, but bring back? is that better than dispose()?
133+
o destroy() removed, but bring back? is that better than dispose()?
134+
_ destroy() only called dispose(), so no difference
126135
_ Python Mode has a hook for when it's called
127136
_ move checkRetina()/highResDisplay() to PApplet
128137
_ and out of Toolkit and PSurfaceAWT
@@ -135,6 +144,15 @@ _ or split them when sketchWidth/Height are implemented?
135144
_ check on performance of the new EDT setup
136145

137146

147+
rendering performance
148+
_ can't do version that draws to BufferStrategy directly
149+
_ pixel operations (get/set/loadPixels/saveFrame) might be fixable
150+
_ but can't re-run draw() to re-blit the screen
151+
_ because we don't split calc() and draw()
152+
_ even with the split, handleDraw() might need to live in PSurface
153+
_ add calc() option? this could ease transition
154+
155+
138156
opengl misc
139157
_ sketchQuality() vs sketchSmooth()?
140158
_ move glsl entries to their own subdirectory?
@@ -145,8 +163,6 @@ _ right now it has a bunch of JOGL-specific code
145163

146164

147165
applet/sketch
148-
_ performance issues on OS X (might be threading due to Applet)
149-
_ https://github.com/processing/processing/issues/2423
150166
_ clean up requestFocus() stuff
151167
_ make sure it works with retina/canvas/strategy as well
152168
_ requestFocus() method probably needs to be added to PApplet

java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected void allocate() {
102102

103103
@Override
104104
public PSurface createSurface() {
105-
return surface = new PSurfaceBasic();
105+
return surface = new PSurfaceNone();
106106
}
107107

108108

0 commit comments

Comments
 (0)