@@ -228,6 +228,9 @@ public class PApplet extends Applet
228228 * This setting must be called before any AWT work happens, so that's why
229229 * it's such a terrible hack in how it's employed here. Calling setProperty()
230230 * inside setup() is a joke, since it's long since the AWT has been invoked.
231+ * <p/>
232+ * On OS X with a retina display, this option is ignored, because Apple's
233+ * Java implementation takes over and forces the Quartz renderer.
231234 */
232235// static public boolean useQuartz = true;
233236 static public boolean useQuartz = false;
@@ -254,6 +257,13 @@ public class PApplet extends Applet
254257 /** The frame containing this applet (if any) */
255258 public Frame frame;
256259
260+ // disabled on retina inside init()
261+ boolean useActive = true;
262+ // boolean useActive = false;
263+ // boolean useStrategy = true;
264+ boolean useStrategy = false;
265+ Canvas canvas;
266+
257267// /**
258268// * Usually just 0, but with multiple displays, the X and Y coordinates of
259269// * the screen will depend on the current screen's position relative to
@@ -818,6 +828,11 @@ static public class RendererChangeException extends RuntimeException { }
818828 /** true if this sketch is being run by the PDE */
819829 boolean external = false;
820830
831+ /**
832+ * Not official API, using internally because of the tweaks required.
833+ */
834+ boolean retina;
835+
821836
822837 static final String ERROR_MIN_MAX =
823838 "Cannot use min() or max() on an empty array.";
@@ -841,6 +856,20 @@ public void init() {
841856// screenWidth = screen.width;
842857// screenHeight = screen.height;
843858
859+ if (platform == MACOSX) {
860+ Float prop = (Float)
861+ getToolkit().getDesktopProperty("apple.awt.contentScaleFactor");
862+ if (prop != null) {
863+ retina = prop == 2;
864+ if (retina) {
865+ // The active-mode rendering seems to be 2x slower, so disable it
866+ // with retina. On a non-retina machine, however, useActive seems
867+ // the only (or best?) way to handle the rendering.
868+ useActive = false;
869+ }
870+ }
871+ }
872+
844873 // send tab keys through to the PApplet
845874 setFocusTraversalKeysEnabled(false);
846875
@@ -1930,6 +1959,10 @@ public void paint(Graphics screen) {
19301959 }
19311960*/
19321961
1962+ // if (useActive) {
1963+ // return;
1964+ // }
1965+
19331966// if (insideDraw) {
19341967// new Exception().printStackTrace(System.out);
19351968// }
@@ -1947,11 +1980,6 @@ public void paint(Graphics screen) {
19471980 }
19481981
19491982
1950- boolean useActive = true ;
1951- // boolean useStrategy = true;
1952- boolean useStrategy = false ;
1953- Canvas canvas ;
1954-
19551983 protected synchronized void render() {
19561984 if (canvas == null) {
19571985 removeListeners(this);
0 commit comments