diff options
author | Sven Gothel <[email protected]> | 2015-09-16 07:09:59 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-09-16 07:09:59 +0200 |
commit | f9402bb9cfbdaff468f2dee7959f4935ba935a97 (patch) | |
tree | b34588ef3a2e60e25aa0d308e078851593204d7c /src/jogl/classes/javax | |
parent | 78f641de80d1c37cd61e5300eeba369c6aa9b1a1 (diff) |
Backport detection of pixel-scale change JAWTWindow/GLCanvas and GLJPanel
Partial backport of commit 6516a52d3da5cced924db63b64af911d55355325:
- Detect change of pixel-scale and propagate accordingly.
This allows GLCanvas, GLJPanel instances
to be dragged between monitor devices w/ different pixel-scale.
- NOT NewtCanvasAWT
Partial backport of commit b0af5159bc6100a6262afe6b52f9092a207ac2b3:
Bug 1181 - JOGL WebStart Applications using GLCanvas/AWT may Deadlock by two AWT-EDT on Java >= 1.8.0_45
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 16 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 15 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index a648e3bf6..ed64914d1 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -659,6 +659,17 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } + final boolean updatePixelScale() { + if( jawtWindow.hasPixelScaleChanged() ) { + jawtWindow.getNativeSurfaceScale(nativePixelScale); + jawtWindow.setSurfaceScale(reqPixelScale); + jawtWindow.getCurrentSurfaceScale(hasPixelScale); + return true; + } else { + return false; + } + } + @Override public final int[] getRequestedSurfaceScale(final int[] result) { System.arraycopy(reqPixelScale, 0, result, 0, 2); @@ -786,7 +797,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - private void reshapeImpl(final int width, final int height) { + void reshapeImpl(final int width, final int height) { final int scaledWidth = width * hasPixelScale[0]; final int scaledHeight = height * hasPixelScale[1]; @@ -1391,6 +1402,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing _lock.lock(); try { if( null != drawable && drawable.isRealized() ) { + if( GLCanvas.this.updatePixelScale() ) { + GLCanvas.this.reshapeImpl(getWidth(), getHeight()); + } helper.invokeGL(drawable, context, displayAction, initAction); } } finally { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index a09644951..4bb44596d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -559,6 +559,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // re-creating it -- tricky to do properly while the context is // current if( !printActive ) { + updatePixelScale(backend); if ( handleReshape ) { handleReshape = false; sendReshape = handleReshape(); @@ -597,6 +598,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } + private final boolean updatePixelScale(final Backend b) { + final int ps = JAWTUtil.getPixelScale(getGraphicsConfiguration()); + nativePixelScale[0] = ps; + nativePixelScale[1] = ps; + if( SurfaceScaleUtils.computePixelScale(hasPixelScale, hasPixelScale, reqPixelScale, nativePixelScale, DEBUG ? getClass().getSimpleName() : null) ) { + updateWrappedSurfaceScale(b.getDrawable()); + reshapeImpl(getWidth(), getHeight()); + return true; + } else { + return false; + } + } + + @Override public final int[] getRequestedSurfaceScale(final int[] result) { System.arraycopy(reqPixelScale, 0, result, 0, 2); |