Skip to content

Commit 340f514

Browse files
committed
add more notes and continue the destruction
1 parent 1259edd commit 340f514

5 files changed

Lines changed: 19 additions & 44 deletions

File tree

core/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
We're removing `Applet` as the base class for `PApplet` and redoing the entire rendering and threading model for Processing sketches.
55

66
#### Why?
7-
1. The changes will improve performance--greatly, in some cases--and reduce flicker and quirkiness in others. Using AWT objects like Applet (which subclasses Component) cause (sometimes major) performance restrictions or other visual glitches like flicker.
7+
1. The changes will improve performance--greatly, in some cases--and reduce flicker and quirkiness in others. Using AWT objects like `Applet` (which subclasses `Component`) cause (sometimes major) performance restrictions or other visual glitches like flicker.
88
2. The code to mitigate the issues from #1 is very difficult to debug and make work properly across the many platforms we support (Macs, Macs with retina displays, Windows 7, Windows 8, 32- and 64-bit machines, Linux who-knows-what, and so on)
99
3. The design of `core` is 13 years old, and the graphics features available (OpenGL, VolatileImage, BufferStrategy, etc) have changed drastically since then. I've papered over these changes and done my best to keep performance on-pace so that we don't break a lot of old code (or libraries), but now is the time for a clean break.
1010
4. With the death of applets, keeping the Applet base class is anachronistic. However, we're keeping the name `PApplet` because with any luck, these changes will only require a recompile of any sketch (or library) code.
@@ -13,6 +13,8 @@ We're removing `Applet` as the base class for `PApplet` and redoing the entire r
1313
1. A new `PSurface` object has been added that acts as the layer between `PApplet` and `PGraphics`. It will handle interaction with the OS (creation of a window, placement on screen, getting events) as well as the animation thread (because OpenGL's animation thread is very different from an AWT animation thread).
1414
2. Many deprecated functions (notably, the pre-2.0 only method registration mechanism used by libraries) are being removed. (Not a final decision.)
1515
3. Undocumented features (such as the `image` object in `PGraphics`) may disappear and break code from advanced users.
16+
4. We're working to add the ability to span multiple screens in "full screen" mode.
17+
5. In 3.0a2 we introduced a change on OS X to use Apple's "official" full screen mode. With this comes a dorky animation and the inability to span multiple screens. We've rolled that back.
1618

1719
#### But what about...?
1820
1. One downside is that you'll no longer be able to just drop a Processing sketch into other Java code, because `PApplet` will no longer subclass `Applet` (and therefore, `Component`). This is a huge downside for a tiny number of users. For the majority of users, re-read the "why" section. We'll try to figure out ways to continue embedding in other Java code, however, since we use this in our own work, and even within Processing itself (the Color Selector).

core/src/processing/core/PApplet.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9339,7 +9339,11 @@ static public void runSketch(final String args[], final PApplet constructedApple
93399339
}
93409340
}
93419341

9342-
surface.placeSketch();
9342+
if (present) {
9343+
surface.placeFullScreen();
9344+
} else {
9345+
surface.placeWindow();
9346+
}
93439347
}
93449348

93459349

core/src/processing/core/PSurface.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public interface PSurface {
1313
public Frame initFrame(int width, int height, Color backgroundColor,
1414
int deviceIndex, boolean fullScreen, boolean spanDisplays);
1515

16-
public void placeSketch();
16+
public void placeWindow();
17+
18+
public void placeFullScreen();
1719

1820
// sets displayWidth/Height inside PApplet
1921
public void checkDisplaySize();

core/src/processing/core/PSurfaceAWT.java

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ public void blit() {
287287
if (useStrategy) {
288288
render();
289289
} else {
290-
Graphics screen = getGraphics();
290+
Graphics screen = canvas.getGraphics();
291291
if (screen != null) {
292292
screen.drawImage(g.image, 0, 0, width, height, null);
293293
}
294294
}
295295
} else {
296-
repaint();
296+
canvas.repaint();
297297
}
298298
// getToolkit().sync(); // force repaint now (proper method)
299299
}
@@ -397,37 +397,7 @@ public void initFrame(int width, int height, Color backgroundColor,
397397
}
398398

399399

400-
public void placeSketch() {
401-
// // If 'present' wasn't already set, but the applet initializes
402-
// // to full screen, attempt to make things full screen anyway.
403-
// if (!present &&
404-
// applet.width == screenRect.width &&
405-
// applet.height == screenRect.height) {
406-
// // bounds will be set below, but can't change to setUndecorated() now
407-
// present = true;
408-
// }
409-
// // Opting not to do this, because we can't remove the decorations on the
410-
// // window at this point. And re-opening a new winodw is a lot of mess.
411-
// // Better all around to just encourage the use of sketchFullScreen()
412-
// // or cmd/ctrl-shift-R in the PDE.
413-
414-
if (present) {
415-
// if (platform == MACOSX) {
416-
// println("before");
417-
// println(screenRect);
418-
// println(frame.getBounds());
419-
//
420-
// // Call some native code to remove the menu bar on OS X. Not necessary
421-
// // on Linux and Windows, who are happy to make full screen windows.
422-
//// japplemenubar.JAppleMenuBar.hide();
423-
// toggleFullScreen(frame);
424-
// println("after");
425-
// println(screenRect);
426-
// println(frame.getBounds());
427-
//
428-
// println(applet.width + " " + applet.height);
429-
// }
430-
400+
public void placeFullScreen() {
431401
// After the pack(), the screen bounds are gonna be 0s
432402
frame.setBounds(screenRect);
433403
applet.setBounds((screenRect.width - applet.width) / 2,
@@ -438,13 +408,6 @@ public void placeSketch() {
438408
macosxFullScreenEnable(frame);
439409
macosxFullScreenToggle(frame);
440410

441-
// toggleFullScreen(frame);
442-
// println("after");
443-
// println(screenRect);
444-
// println(frame.getBounds());
445-
// println(applet.width + " " + applet.height);
446-
}
447-
448411
if (!hideStop) {
449412
Label label = new Label("stop");
450413
label.setForeground(stopColor);
@@ -468,8 +431,10 @@ public void mousePressed(java.awt.event.MouseEvent e) {
468431
if (external) {
469432
applet.setupExternalMessages();
470433
}
434+
}
435+
471436

472-
} else { // if not presenting
437+
public void placeWindow() {
473438
// can't do pack earlier cuz present mode don't like it
474439
// (can't go full screen with a frame after calling pack)
475440
// frame.pack();

core/todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
0232 core (3.0a5)
2+
X roll back full screen changes
3+
X https://github.com/processing/processing/issues/2641
24

35

46
pulls

0 commit comments

Comments
 (0)