diff options
author | Sven Gothel <[email protected]> | 2014-06-08 15:57:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-06-08 15:57:53 +0200 |
commit | 3fb76fcef1e6dd552ec0f677af67baf3186a1434 (patch) | |
tree | 00ff910246e857cf53d56f58f79e1c38896b912d /src/jogl/classes | |
parent | 2571ed0b5ef14155d204540d38b564a7d4cd47b6 (diff) |
Bug 741 HiDPI: Simplify ScalableSurface [set|get]SurfaceScale(..) spec, which also fixed JAWTWindow getSurfaceScale() issue on Windows
Let setSurfaceScale(..) return the validated requested values
and getSurfaceScale(..) always the current values.
This removes complication and solves a bug w/ JAWTWindow on Windows,
where we used 'drawable' as an indicator for 'previous locked' state.
The latter is not true since on Windows 'drawable' is set to null in unlock,
getWindowHandle() should be taken instead.
Diffstat (limited to 'src/jogl/classes')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 19 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 10 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index bdd12dfea..e95491f6b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -663,12 +663,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public final void setSurfaceScale(final int[] pixelScale) { + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } if( isRealized() ) { final ScalableSurface ns = jawtWindow; if( null != ns ) { - ns.setSurfaceScale(reqPixelScale); + ns.setSurfaceScale(result, reqPixelScale); final int hadPixelScaleX = hasPixelScale[0]; final int hadPixelScaleY = hasPixelScale[1]; ns.getSurfaceScale(hasPixelScale); @@ -678,24 +681,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } } + return result; } @Override public final int[] getSurfaceScale(final int[] result) { - final ScalableSurface ns = jawtWindow; - if( null != ns ) { - return ns.getSurfaceScale(result); - } else { - System.arraycopy(reqPixelScale, 0, result, 0, 2); - return result; - } + System.arraycopy(hasPixelScale, 0, result, 0, 2); + return result; } private void createJAWTDrawableAndContext() { if ( !Beans.isDesignTime() ) { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - jawtWindow.setSurfaceScale(reqPixelScale); + jawtWindow.setSurfaceScale(null, reqPixelScale); jawtWindow.lockSurface(); try { drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 18de5a791..2f3cead4f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -559,13 +559,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final void updateWrappedSurfaceScale(final GLDrawable d) { final NativeSurface s = d.getNativeSurface(); if( s instanceof WrappedSurface ) { - ((WrappedSurface)s).setSurfaceScale( hasPixelScale ); + ((WrappedSurface)s).setSurfaceScale(null, hasPixelScale); } } @Override - public final void setSurfaceScale(final int[] pixelScale) { // HiDPI support + public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { // HiDPI support SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null); + if( null != result ) { + System.arraycopy(reqPixelScale, 0, result, 0, 2); + } final Backend b = backend; if ( isInitialized && null != b ) { final int[] pixelScaleInt; @@ -582,11 +585,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing display(); } } + return result; } @Override public final int[] getSurfaceScale(final int[] result) { - System.arraycopy(isInitialized ? hasPixelScale : reqPixelScale, 0, result, 0, 2); + System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } |