diff options
Diffstat (limited to 'src/nativewindow/classes/jogamp')
12 files changed, 118 insertions, 47 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java index fbff7128e..dd1b6f185 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -149,13 +149,13 @@ public abstract class ProxySurfaceImpl implements ProxySurface { public abstract void setSurfaceHandle(long surfaceHandle); @Override - public final int getWidth() { - return upstream.getWidth(this); + public final int getSurfaceWidth() { + return upstream.getPixelWidth(this); } @Override - public final int getHeight() { - return upstream.getHeight(this); + public final int getSurfaceHeight() { + return upstream.getPixelHeight(this); } @Override @@ -303,7 +303,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { } sink.append("displayHandle 0x" + Long.toHexString(getDisplayHandle())). append("\n, surfaceHandle 0x" + Long.toHexString(getSurfaceHandle())). - append("\n, size " + getWidth() + "x" + getHeight()).append("\n, "); + append("\n, size " + getSurfaceWidth() + "x" + getSurfaceHeight()).append("\n, "); getUpstreamOptionBits(sink); sink.append("\n, "+config). append("\n, surfaceLock "+surfaceLock+"\n, "). diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java index f622db8cc..5601dac02 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -97,4 +97,21 @@ public class WrappedSurface extends ProxySurfaceImpl { protected final void unlockSurfaceImpl() { } + @Override + public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) { + final int scale = 1; // FIXME: Use 'scale' .. + result[0] = pixelUnitXY[0] / scale; + result[1] = pixelUnitXY[1] / scale; + return result; + } + + @Override + public final int[] getPixelUnitXY(int[] result, final int[] windowUnitXY) { + final int scale = 1; // FIXME: Use 'scale' .. + result[0] = windowUnitXY[0] * scale; + result[1] = windowUnitXY[1] * scale; + return result; + } + + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java index edb65eb06..3cbfcd4d9 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java @@ -9,28 +9,36 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; -import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSizePos; +import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos; public class WrappedWindow extends WrappedSurface implements NativeWindow { private final InsetsImmutable insets = new Insets(0, 0, 0, 0); private long windowHandle; /** - * Utilizes a {@link UpstreamSurfaceHookMutableSizePos} to hold the size and postion information, + * Utilizes a {@link UpstreamWindowHookMutableSizePos} to hold the size and postion information, * which is being passed to the {@link ProxySurface} instance. * * @param cfg the {@link AbstractGraphicsConfiguration} to be used * @param surfaceHandle the wrapped pre-existing native surface handle, maybe 0 if not yet determined - * @param initialX - * @param initialY - * @param initialWidth - * @param initialHeight + * @param initialWinX + * @param initialWinY + * @param initialWinWidth + * @param initialWinHeight + * @param initialPixelWidth FIXME: pixel-dim == window-dim 'for now' ? + * @param initialPixelHeight FIXME: pixel-dim == window-dim 'for now' ? * @param ownsDevice <code>true</code> if this {@link ProxySurface} instance * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, * otherwise <code>false</code>. Owning the device implies closing it at {@link #destroyNotify()}. */ - public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, int initialX, int initialY, int initialWidth, int initialHeight, boolean ownsDevice, long windowHandle) { - this(cfg, surfaceHandle, new UpstreamSurfaceHookMutableSizePos(initialX, initialY, initialWidth, initialHeight), ownsDevice, windowHandle); + public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, + int initialWinX, int initialWinY, int initialWinWidth, int initialWinHeight, + int initialPixelWidth, int initialPixelHeight, + boolean ownsDevice, long windowHandle) { + this(cfg, surfaceHandle, + new UpstreamWindowHookMutableSizePos(initialWinX, initialWinY, initialWinWidth, initialWinHeight, + initialPixelWidth, initialPixelHeight), + ownsDevice, windowHandle); } /** @@ -41,7 +49,7 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, * otherwise <code>false</code>. */ - public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, UpstreamSurfaceHookMutableSizePos upstream, boolean ownsDevice, long windowHandle) { + public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, UpstreamWindowHookMutableSizePos upstream, boolean ownsDevice, long windowHandle) { super(cfg, surfaceHandle, upstream, ownsDevice); this.windowHandle = windowHandle; } @@ -74,12 +82,22 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { @Override public int getX() { - return ((UpstreamSurfaceHookMutableSizePos)getUpstreamSurfaceHook()).getX(); + return ((UpstreamWindowHookMutableSizePos)getUpstreamSurfaceHook()).getX(); } @Override public int getY() { - return ((UpstreamSurfaceHookMutableSizePos)getUpstreamSurfaceHook()).getY(); + return ((UpstreamWindowHookMutableSizePos)getUpstreamSurfaceHook()).getY(); + } + + @Override + public int getWindowWidth() { + return ((UpstreamWindowHookMutableSizePos)getUpstreamSurfaceHook()).getWindowWidth(); + } + + @Override + public int getWindowHeight() { + return ((UpstreamWindowHookMutableSizePos)getUpstreamSurfaceHook()).getWindowHeight(); } @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index fb979d440..387f40f89 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -64,6 +64,8 @@ import com.jogamp.common.util.locks.RecursiveLock; public class JAWTUtil { public static final boolean DEBUG = Debug.debug("JAWT"); + private static final boolean SKIP_AWT_HIDPI; + /** OSX JAWT version option to use CALayer */ public static final int JAWT_MACOSX_USE_CALAYER = 0x80000000; @@ -298,8 +300,10 @@ public class JAWTUtil { } static { + SKIP_AWT_HIDPI = Debug.isPropertyDefined("nativewindow.awt.nohidpi", true); + if(DEBUG) { - System.err.println("JAWTUtil initialization (JAWT/JNI/..."); + System.err.println("JAWTUtil initialization (JAWT/JNI/...); SKIP_AWT_HIDPI "+SKIP_AWT_HIDPI); // Thread.dumpStack(); } @@ -542,13 +546,15 @@ public class JAWTUtil { * @return the pixel scale factor */ public static final int getPixelScale(final GraphicsDevice device) { - if( null != getScaleFactorMethod ) { - try { - final Object res = getScaleFactorMethod.invoke(device); - if (res instanceof Integer) { - return ((Integer)res).intValue(); - } - } catch (Throwable t) {} + if( !SKIP_AWT_HIDPI ) { + if( null != getScaleFactorMethod ) { + try { + final Object res = getScaleFactorMethod.invoke(device); + if (res instanceof Integer) { + return ((Integer)res).intValue(); + } + } catch (Throwable t) {} + } } return 1; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 8d46d805a..58dc7e47e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -143,7 +143,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } else if( DEBUG ) { System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds); } - OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks()); + OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWindowWidth(), getWindowHeight(), getPixelScale(), JAWTUtil.getOSXCALayerQuirks()); } } ); } @@ -177,7 +177,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", quirks "+caLayerQuirks+", visible "+visible+ ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds); } - OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks); + OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWindowWidth(), getWindowHeight(), caLayerQuirks); } @Override @@ -256,7 +256,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { unlockSurfaceImpl(); return NativeWindow.LOCK_SURFACE_NOT_READY; } - updateBounds(dsi.getBounds()); + updateLockedData(dsi.getBounds()); if (DEBUG && firstLock ) { dumpInfo(); } @@ -309,7 +309,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { public void run() { String errMsg = null; if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { - rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getWidth(), bounds.getHeight()); + rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getWidth(), bounds.getHeight(), getPixelScale()); if(0 == rootSurfaceLayer) { errMsg = "Could not create root CALayer"; } else { diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java index 54bdb34f6..90688258d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java @@ -98,7 +98,7 @@ public class WindowsJAWTWindow extends JAWTWindow { unlockSurfaceImpl(); return LOCK_SURFACE_NOT_READY; } - updateBounds(dsi.getBounds()); + updateLockedData(dsi.getBounds()); win32dsi = (JAWT_Win32DrawingSurfaceInfo) dsi.platformInfo(getJAWT()); if (win32dsi == null) { unlockSurfaceImpl(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 4599b9021..b5a519fcc 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -93,7 +93,7 @@ public class X11JAWTWindow extends JAWTWindow { unlockSurfaceImpl(); return LOCK_SURFACE_NOT_READY; } - updateBounds(dsi.getBounds()); + updateLockedData(dsi.getBounds()); x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo(getJAWT()); if (x11dsi == null) { unlockSurfaceImpl(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java index b71af1042..5a51aca3e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java @@ -11,10 +11,10 @@ public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize long nsWindow; /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getPixelWidth(ProxySurface)}, * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()} via {@link UpstreamSurfaceHook#getPixelHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index bac07b85a..88ba531d1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -137,11 +137,15 @@ public class OSXUtil implements ToolkitProperties { /** * Create a CALayer suitable to act as a root CALayer. + * @param width width of the CALayer in window units (points) + * @param height height of the CALayer in window units (points) + * @param contentsScale scale for HiDPI support: pixel-dim = window-dim x scale + * @return the new CALayer object * @see #DestroyCALayer(long) * @see #AddCASublayer(long, long) */ - public static long CreateCALayer(final int width, final int height) { - final long l = CreateCALayer0(width, height); + public static long CreateCALayer(final int width, final int height, final float contentsScale) { + final long l = CreateCALayer0(width, height, contentsScale); if(DEBUG) { System.err.println("OSXUtil.CreateCALayer: 0x"+Long.toHexString(l)+" - "+Thread.currentThread().getName()); } @@ -158,18 +162,27 @@ public class OSXUtil implements ToolkitProperties { * Hence it is important that related resources are not locked <i>if</i> * they will be used for creation. * </p> - * @param caLayerQuirks TODO - * @see #CreateCALayer(int, int) + * @param rootCALayer + * @param subCALayer + * @param x x-coord of the sub-CALayer in window units (points) + * @param y y-coord of the sub-CALayer in window units (points) + * @param width width of the sub-CALayer in window units (points) + * @param height height of the sub-CALayer in window units (points) + * @param contentsScale scale for HiDPI support: pixel-dim = window-dim x scale + * @param caLayerQuirks + * @see #CreateCALayer(int, int, float) * @see #RemoveCASublayer(long, long, boolean) */ - public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) { + public static void AddCASublayer(final long rootCALayer, final long subCALayer, + final int x, final int y, final int width, final int height, + final float contentsScale, final int caLayerQuirks) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } if(DEBUG) { System.err.println("OSXUtil.AttachCALayer: caLayerQuirks "+caLayerQuirks+", 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName()); } - AddCASublayer0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks); + AddCASublayer0(rootCALayer, subCALayer, x, y, width, height, contentsScale, caLayerQuirks); } /** @@ -186,8 +199,8 @@ public class OSXUtil implements ToolkitProperties { * @param rootCALayer the root surface layer, maybe null. * @param subCALayer the client surface layer, maybe null. * @param visible TODO - * @param width the expected width - * @param height the expected height + * @param width the expected width in window units (points) + * @param height the expected height in window units (points) * @param caLayerQuirks TODO */ public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final boolean visible, final int x, final int y, final int width, final int height, final int caLayerQuirks) { @@ -212,7 +225,7 @@ public class OSXUtil implements ToolkitProperties { /** * Destroy a CALayer. - * @see #CreateCALayer(int, int) + * @see #CreateCALayer(int, int, float) */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { @@ -356,8 +369,8 @@ public class OSXUtil implements ToolkitProperties { private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); private static native long GetNSWindow0(long nsView); - private static native long CreateCALayer0(int width, int height); - private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks); + private static native long CreateCALayer0(int width, int height, float contentsScale); + private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, float contentsScale, int caLayerQuirks); private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, boolean visible, int x, int y, int width, int height, int caLayerQuirks); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java index e5de43c0a..9c74950e0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java @@ -9,10 +9,10 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getPixelWidth(ProxySurface)}, * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()} via {@link UpstreamSurfaceHook#getPixelHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index 3e07b2a9e..c4ec0f653 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -128,4 +128,21 @@ public class GDISurface extends ProxySurfaceImpl { final public long getSurfaceHandle() { return surfaceHandle; } + + @Override + public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) { + if( pixelUnitXY != result ) { // no scale factor, window units == pixel units + System.arraycopy(pixelUnitXY, 0, result, 0, 2); + } + return result; + } + + @Override + public final int[] getPixelUnitXY(int[] result, final int[] windowUnitXY) { + if( windowUnitXY != result ) { // no scale factor, window units == pixel units + System.arraycopy(windowUnitXY, 0, result, 0, 2); + } + return result; + } + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java index 2c8ef642c..31d168fea 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -14,10 +14,10 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getPixelWidth(ProxySurface)}, * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()} via {@link UpstreamSurfaceHook#getPixelHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ |