diff options
Diffstat (limited to 'src/nativewindow/classes/jogamp')
32 files changed, 385 insertions, 286 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index f2a45377e..8d8fd0667 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -51,7 +51,7 @@ public class Debug extends PropertyAccess { verbose = isPropertyDefined("nativewindow.verbose", true); debugAll = isPropertyDefined("nativewindow.debug", true); if (verbose) { - final Package p = Package.getPackage("javax.media.nativewindow"); + final Package p = Package.getPackage("com.jogamp.nativewindow"); System.err.println("NativeWindow specification version " + p.getSpecificationVersion()); System.err.println("NativeWindow implementation version " + p.getImplementationVersion()); System.err.println("NativeWindow implementation vendor " + p.getImplementationVendor()); diff --git a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java index 6061c4e79..6fb29e6c0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java @@ -33,7 +33,7 @@ package jogamp.nativewindow; -import javax.media.nativewindow.*; +import com.jogamp.nativewindow.*; public class DefaultGraphicsConfigurationFactoryImpl extends GraphicsConfigurationFactory { @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java index 4f6c0d155..40c0be965 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java @@ -28,13 +28,13 @@ package jogamp.nativewindow; -import javax.media.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.ToolkitLock; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; /** - * Implementing a global recursive {@link javax.media.nativewindow.ToolkitLock}. + * Implementing a global recursive {@link com.jogamp.nativewindow.ToolkitLock}. * <p> * This is the last resort for unstable driver where multiple X11 display connections * to the same connection name are not treated thread safe within the GL/X11 driver. diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index 40fca0f7b..a4fcb1d6b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -34,10 +34,10 @@ package jogamp.nativewindow; import java.lang.reflect.Constructor; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.NativeWindow; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.ToolkitLock; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.ReflectionUtil.AWTNames; @@ -68,7 +68,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { throw new IllegalArgumentException("Target window object type " + winObj.getClass().getName() + " is unsupported; expected " + - "javax.media.nativewindow.NativeWindow or "+AWTNames.ComponentClass); + "com.jogamp.nativewindow.NativeWindow or "+AWTNames.ComponentClass); } private Constructor<?> nativeWindowConstructor = null; diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index bbfb585ac..afe434a37 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -28,11 +28,11 @@ package jogamp.nativewindow; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.ToolkitLock; /** - * Implementing a singleton global NOP {@link javax.media.nativewindow.ToolkitLock} + * Implementing a singleton global NOP {@link com.jogamp.nativewindow.ToolkitLock} * without any locking. Since there is no locking it all, it is intrinsically recursive. */ public class NullToolkitLock implements ToolkitLock { diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java index deb685b51..4c53ddb94 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -28,13 +28,15 @@ package jogamp.nativewindow; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.SurfaceUpdatedListener; -import javax.media.nativewindow.UpstreamSurfaceHook; +import java.io.PrintStream; + +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.SurfaceUpdatedListener; +import com.jogamp.nativewindow.UpstreamSurfaceHook; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -279,6 +281,13 @@ public abstract class ProxySurfaceImpl implements ProxySurface { sink.append("WINDOW_INVISIBLE"); needsOr = true; } + if( 0 != ( implBitfield & OPT_UPSTREAM_SURFACELESS ) ) { + if(needsOr) { + sink.append(" | "); + } + sink.append("SURFACELESS"); + needsOr = true; + } sink.append(" ]"); return sink; } @@ -297,6 +306,34 @@ public abstract class ProxySurfaceImpl implements ProxySurface { @Override public final void clearUpstreamOptionBits(final int v) { implBitfield &= ~v; } + public static void dumpHierarchy(final PrintStream out, final ProxySurface s) { + out.println("Surface Hierarchy of "+s.getClass().getName()); + dumpHierarchy(out, s, ""); + out.println(); + } + private static void dumpHierarchy(final PrintStream out, final NativeSurface s, String indentation) { + indentation = indentation + " "; + out.println(indentation+"Surface device "+s.getGraphicsConfiguration().getScreen().getDevice()); + out.println(indentation+"Surface size "+s.getSurfaceWidth()+"x"+s.getSurfaceHeight()+", handle 0x"+Long.toHexString(s.getSurfaceHandle())); + if( s instanceof ProxySurfaceImpl ) { + final ProxySurface ps = (ProxySurface)s; + out.println(indentation+"Upstream options "+ps.getUpstreamOptionBits(null).toString()); + + final UpstreamSurfaceHook psUSH = ps.getUpstreamSurfaceHook(); + if( null != psUSH ) { + out.println(indentation+"Upstream Hook "+psUSH.getClass().getName()); + final NativeSurface upstreamSurface = psUSH.getUpstreamSurface(); + indentation = indentation + " "; + if( null != upstreamSurface ) { + out.println(indentation+"Upstream Hook's Surface "+upstreamSurface.getClass().getName()); + dumpHierarchy(out, upstreamSurface, indentation); + } else { + out.println(indentation+"Upstream Hook's Surface NULL"); + } + } + } + } + @Override public StringBuilder toString(StringBuilder sink) { if(null == sink) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java index e4e557d36..d7090f3b3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -28,13 +28,13 @@ package jogamp.nativewindow; -import javax.media.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.ToolkitLock; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; /** - * Implementing a resource based recursive {@link javax.media.nativewindow.ToolkitLock}. + * Implementing a resource based recursive {@link com.jogamp.nativewindow.ToolkitLock}. * <p> * A resource handle maybe used within a unique object * and can be synchronized across threads via an instance of ResourceToolkitLock. diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java index 881fd56a6..823d97491 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -31,14 +31,15 @@ package jogamp.nativewindow; import java.util.Iterator; import java.util.concurrent.atomic.AtomicInteger; -import javax.media.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.ToolkitLock; +import com.jogamp.common.ExceptionUtils; import com.jogamp.common.util.LongObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; /** - * Implementing a shared resource based recursive {@link javax.media.nativewindow.ToolkitLock}. + * Implementing a shared resource based recursive {@link com.jogamp.nativewindow.ToolkitLock}. * <p> * A resource handle maybe used within many objects * and can be synchronized across threads via an unique instance of SharedResourceToolkitLock. @@ -63,7 +64,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { if(DEBUG || verbose || handle2Lock.size() > 0 ) { System.err.println("SharedResourceToolkitLock: Shutdown (open: "+handle2Lock.size()+")"); if(DEBUG) { - Thread.dumpStack(); + ExceptionUtils.dumpStack(System.err); } if( handle2Lock.size() > 0) { dumpOpenDisplayConnections(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java index 73413cf59..c42dc613d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java @@ -27,146 +27,169 @@ */ package jogamp.nativewindow; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.ScalableSurface; +import com.jogamp.nativewindow.ScalableSurface; /** * Basic {@link ScalableSurface} utility to validate and compute pixel-scale values. */ public class SurfaceScaleUtils { - private static final int[] PlatformMaxPixelScale; - private static final boolean PlatformUniformPixelScale; - private static final boolean PlatformPixelScaleSupported; + private static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d - static { - if( NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(true) ) { - PlatformMaxPixelScale = new int[] { jogamp.nativewindow.macosx.OSXUtil.MAX_PIXELSCALE, jogamp.nativewindow.macosx.OSXUtil.MAX_PIXELSCALE }; - PlatformUniformPixelScale = true; - PlatformPixelScaleSupported = true; - } else { - PlatformMaxPixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; - PlatformUniformPixelScale = false; - PlatformPixelScaleSupported = false; - } + private static boolean isZero(final float a) { + return Math.abs(a) < EPSILON; } /** - * Compute a new valid pixelScale to be used by {@link NativeSurface} implementations, - * based on the given request and surface's pixelScale + * Returns integer rounded product, i.e. {@code (int) ( a * pixelScale + 0.5f )} * - * @param result int[2] storage for result, maybe same as <code>prePixelScale</code> for in-place - * @param prePixelScale previous pixelScale - * @param reqPixelScale requested pixelScale, validated via {@link #validateReqPixelScale(int[], int, String)}. - * @param newPixelScaleRaw new raw surface pixelScale - * @param DEBUG_PREFIX if set, dumps debug info on stderr using this prefix - * @return true if pixelScale has changed, otherwise false + * @param a the int value + * @param pixelScale the float scale factor + * @return the integer rounded product */ - public static boolean computePixelScale(final int[] result, final int[] prePixelScale, final int[] reqPixelScale, final int[] newPixelScaleRaw, final String DEBUG_PREFIX) { - final int newPixelScaleSafeX = 0 < newPixelScaleRaw[0] ? newPixelScaleRaw[0] : ScalableSurface.IDENTITY_PIXELSCALE; - final int newPixelScaleSafeY = 0 < newPixelScaleRaw[1] ? newPixelScaleRaw[1] : ScalableSurface.IDENTITY_PIXELSCALE; - final boolean useHiDPI = ScalableSurface.IDENTITY_PIXELSCALE != reqPixelScale[0] || ScalableSurface.IDENTITY_PIXELSCALE != reqPixelScale[1]; - final int prePixelScaleX = prePixelScale[0]; - final int prePixelScaleY = prePixelScale[1]; - - if( useHiDPI ) { - result[0] = newPixelScaleSafeX; - result[1] = newPixelScaleSafeY; - } else { - result[0] = ScalableSurface.IDENTITY_PIXELSCALE; - result[1] = ScalableSurface.IDENTITY_PIXELSCALE; - } - - final boolean changed = result[0] != prePixelScaleX || result[1] != prePixelScaleY; - if( null != DEBUG_PREFIX ) { - System.err.println(DEBUG_PREFIX+".computePixelScale: useHiDPI "+useHiDPI+", ["+prePixelScaleX+"x"+prePixelScaleY+" (pre), "+ - reqPixelScale[0]+"x"+reqPixelScale[1]+" (req)] -> "+ - newPixelScaleRaw[0]+"x"+newPixelScaleRaw[1]+" (raw) -> "+ - newPixelScaleSafeX+"x"+newPixelScaleSafeY+" (safe) -> "+ - result[0]+"x"+result[1]+" (use), changed "+changed); - } - return changed; + public static int scale(final int a, final float pixelScale) { + return (int) ( a * pixelScale + 0.5f ); } /** - * Validate the given requested pixelScale value pair, i.e. clip it to the - * limits of {@link ScalableSurface#AUTOMAX_PIXELSCALE} and {@link #getPlatformMaxPixelScale(int[])} - * <p> - * To be used by {@link ScalableSurface#setSurfaceScale(int[])} implementations. - * </p> + * Returns integer rounded product, i.e. {@code (int) ( a / pixelScale + 0.5f )} * - * @param result int[2] storage for result - * @param reqPixelScale requested pixelScale - * @param DEBUG_PREFIX if set, dumps debug info on stderr using this prefix + * @param a the int value + * @param pixelScale the float scale factor + * @return the integer rounded product */ - public static void validateReqPixelScale(final int[] result, final int[] reqPixelScale, final String DEBUG_PREFIX) { - final int minPS = Math.min(reqPixelScale[0], reqPixelScale[1]); - if( ScalableSurface.AUTOMAX_PIXELSCALE >= minPS ) { - result[0] = ScalableSurface.AUTOMAX_PIXELSCALE; - result[1] = ScalableSurface.AUTOMAX_PIXELSCALE; - } else if( PlatformUniformPixelScale ) { - final int maxPS = Math.max(reqPixelScale[0], reqPixelScale[1]); - if( maxPS >= PlatformMaxPixelScale[0] ) { - result[0] = PlatformMaxPixelScale[0]; - result[1] = PlatformMaxPixelScale[1]; - } else { - result[0] = maxPS; - result[1] = maxPS; - } - } else { - if( reqPixelScale[0] >= PlatformMaxPixelScale[0] ) { - result[0] = PlatformMaxPixelScale[0]; - } else { - result[0] = reqPixelScale[0]; - } - if( reqPixelScale[1] >= PlatformMaxPixelScale[1] ) { - result[1] = PlatformMaxPixelScale[1]; - } else { - result[1] = reqPixelScale[1]; - } - } - if( null != DEBUG_PREFIX ) { - System.err.println(DEBUG_PREFIX+".validateReqPixelScale: ["+reqPixelScale[0]+"x"+reqPixelScale[1]+" (req), "+ - PlatformMaxPixelScale[0]+"x"+PlatformMaxPixelScale[1]+" (max)] -> "+ - result[0]+"x"+result[1]+" (valid)"); - } + public static int scaleInv(final int a, final float pixelScale) { + return (int) ( a / pixelScale + 0.5f ); } /** - * Replaces {@link ScalableSurface#AUTOMAX_PIXELSCALE} with {@link #getPlatformMaxPixelScale(int[])}, - * for each component. + * Returns integer rounded product, i.e. {@code (int) ( a * pixelScale + 0.5f )} * - * @param pixelScale int[2] value array to be tested and replaced + * @param result the int[2] result, may be {@code a} for in-place operation + * @param a the int[2] values + * @param pixelScale the float[2] scale factors + * @return the result for chaining */ - public static void replaceAutoMaxWithPlatformMax(final int[] pixelScale) { - if( ScalableSurface.AUTOMAX_PIXELSCALE == pixelScale[0] ) { - pixelScale[0] = PlatformMaxPixelScale[0]; - } - if( ScalableSurface.AUTOMAX_PIXELSCALE == pixelScale[1] ) { - pixelScale[1] = PlatformMaxPixelScale[1]; - } + public static int[] scale(final int[] result, final int[] a, final float[] pixelScale) { + result[0] = (int) ( a[0] * pixelScale[0] + 0.5f ); + result[1] = (int) ( a[1] * pixelScale[1] + 0.5f ); + return result; } - /** - * Returns the maximum platform pixelScale + * Returns integer rounded product, i.e. {@code (int) ( a / pixelScale + 0.5f )} + * + * @param result the int[2] result, may be {@code a} for in-place operation + * @param a the int[2] values + * @param pixelScale the float[2] scale factors + * @return the result for chaining */ - public static int[] getPlatformMaxPixelScale(final int[] result) { - System.arraycopy(PlatformMaxPixelScale, 0, result, 0, 2); + public static int[] scaleInv(final int[] result, final int[] a, final float[] pixelScale) { + result[0] = (int) ( a[0] / pixelScale[0] + 0.5f ); + result[1] = (int) ( a[1] / pixelScale[1] + 0.5f ); return result; } /** - * Returns true if platform pixelScale is uniform, i.e. same scale factor for x- and y-direction, otherwise false. + * Method constrains the given pixel-scale within ]0..{@code maxPixelScale}], as described below. + * <p> + * Method returns {@link ScalableSurface#IDENTITY_PIXELSCALE IDENTITY_PIXELSCALE} if: + * <ul> + * <li>{@code pixelScale} ~= {@link ScalableSurface#IDENTITY_PIXELSCALE IDENTITY_PIXELSCALE}</li> + * </ul> + * </p> + * <p> + * Method returns {@code maxPixelScale} if + * <ul> + * <li>{@code pixelScale} ~= {@link ScalableSurface#AUTOMAX_PIXELSCALE AUTOMAX_PIXELSCALE}</li> + * <li>{@code pixelScale} > {@code maxPixelScale}</li> + * <li>{@code pixelScale} ~= {@code maxPixelScale}</li> + * </ul> + * </p> + * <p> + * Method returns {@code minPixelScale} if + * <ul> + * <li>{@code pixelScale} < {@code minPixelScale}</li> + * <li>{@code pixelScale} ~= {@code minPixelScale}</li> + * </ul> + * </p> + * <p> + * Otherwise method returns the given {@code pixelScale}. + * </p> + * <p> + * <i>~=</i> denominates a delta ≤ {@link FloatUtil#EPSILON}. + * </p> + * @param pixelScale pixel-scale to be constrained + * @param minPixelScale minimum pixel-scale + * @param maxPixelScale maximum pixel-scale + * @return the constrained pixel-scale */ - public static boolean isPlatformPixelScaleUniform() { - return PlatformUniformPixelScale; + public static float clampPixelScale(final float pixelScale, final float minPixelScale, final float maxPixelScale) { + if( isZero(pixelScale-ScalableSurface.IDENTITY_PIXELSCALE) ) { + return ScalableSurface.IDENTITY_PIXELSCALE; + } else if( isZero(pixelScale-ScalableSurface.AUTOMAX_PIXELSCALE) || + pixelScale > maxPixelScale || + isZero(pixelScale-maxPixelScale) + ) + { + return maxPixelScale; + } else if( pixelScale < minPixelScale || isZero(pixelScale-minPixelScale) ) + { + return minPixelScale; + } else { + return pixelScale; + } } /** - * Returns whether the platform supports pixelScale + * Method {@link #clampPixelScale(float, float, float) constrains} the given float[2] pixel-scale + * within ]0..{@code maxPixelScale}], as described in {@link #clampPixelScale(float, float, float)}. + * + * @param result float[2] storage for result, maybe same as <code>s</code> for in-place + * @param pixelScale float[2] pixelScale to be constrained + * @param minPixelScale float[2] minimum pixel-scale + * @param maxPixelScale float[2] maximum pixel-scale + * @return the constrained result for chaining */ - public static boolean isPlatformPixelScaleSupported() { - return PlatformPixelScaleSupported; + public static float[] clampPixelScale(final float[] result, final float[] pixelScale, + final float[] minPixelScale, final float[] maxPixelScale) { + result[0] = clampPixelScale(pixelScale[0], minPixelScale[0], maxPixelScale[0]); + result[1] = clampPixelScale(pixelScale[1], minPixelScale[1], maxPixelScale[1]); + return result; } + /** + * Method writes the given float[2] requested pixel-scale {@code reqPixelScale} + * into {@code result} within its constraints ]0..{@code maxPixelScale}], as described in {@link #clampPixelScale(float, float, float)}. + * <p> + * Method only differs from {@link #clampPixelScale(float[], float[], float[], float[])} + * by returning the whether the value has changed, i.e. different from the given {@code prePixelScale}. + * </p> + * + * @param result int[2] storage for result, maybe same as <code>prePixelScale</code> for in-place + * @param prePixelScale float[2] previous pixel-scale + * @param reqPixelScale float[2] requested pixel-scale, validated via {@link #validateReqPixelScale(float[], float[], String)}. + * @param minPixelScale float[2] minimum pixel-scale + * @param maxPixelScale float[2] maximum pixel-scale + * @param DEBUG_PREFIX if set, dumps debug info on stderr using this prefix + * @param newPixelScaleRaw new raw surface pixel-scale + * @return {@code true} if pixel-scale has changed, otherwise {@code false}. + */ + public static boolean setNewPixelScale(final float[] result, + final float[] prePixelScale, final float[] reqPixelScale, + final float[] minPixelScale, final float[] maxPixelScale, + final String DEBUG_PREFIX) { + final float resultX = clampPixelScale(reqPixelScale[0], minPixelScale[0], maxPixelScale[0]); + final float resultY = clampPixelScale(reqPixelScale[1], minPixelScale[1], maxPixelScale[1]); + final boolean changed = resultX != prePixelScale[0] || resultY != prePixelScale[1]; + if( null != DEBUG_PREFIX ) { + System.err.println(DEBUG_PREFIX+".setNewPixelScale: pre["+prePixelScale[0]+", "+prePixelScale[1]+"], req["+ + reqPixelScale[0]+", "+reqPixelScale[1]+"], min["+ + minPixelScale[0]+", "+minPixelScale[1]+"], max["+ + maxPixelScale[0]+", "+maxPixelScale[1]+"] -> result["+ + resultX+", "+resultY+"], changed "+changed); + } + result[0] = resultX; + result[1] = resultY; + return changed; + } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index a7e136f76..130caff3c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -30,8 +30,8 @@ package jogamp.nativewindow; import java.util.ArrayList; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceUpdatedListener; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.SurfaceUpdatedListener; public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { private final Object surfaceUpdatedListenersLock = new Object(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java index 47b3e63fa..b980922b1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java @@ -1,6 +1,6 @@ package jogamp.nativewindow; -import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.NativeWindowFactory; /** * Marker interface. diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java index d3439b53f..a417de4cb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -28,11 +28,11 @@ package jogamp.nativewindow; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ScalableSurface; -import javax.media.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.ScalableSurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; @@ -42,7 +42,7 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; * @see ProxySurface */ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface { - private final int[] hasPixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; + private final float[] hasPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; private long surfaceHandle; /** @@ -104,27 +104,23 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface /** * {@inheritDoc} * <p> - * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly. + * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(float[]) given pixelScale} directly. * </p> */ @Override public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { - pixelUnitsAndResult[0] /= hasPixelScale[0]; - pixelUnitsAndResult[1] /= hasPixelScale[1]; - return pixelUnitsAndResult; + return SurfaceScaleUtils.scaleInv(pixelUnitsAndResult, pixelUnitsAndResult, hasPixelScale); } /** * {@inheritDoc} * <p> - * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly. + * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(float[]) given pixelScale} directly. * </p> */ @Override public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) { - windowUnitsAndResult[0] *= hasPixelScale[0]; - windowUnitsAndResult[1] *= hasPixelScale[1]; - return windowUnitsAndResult; + return SurfaceScaleUtils.scale(windowUnitsAndResult, windowUnitsAndResult, hasPixelScale); } /** @@ -147,25 +143,32 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface * </p> */ @Override - public final void setSurfaceScale(final int[] pixelScale) { - hasPixelScale[0] = pixelScale[0]; - hasPixelScale[1] = pixelScale[1]; + public final boolean setSurfaceScale(final float[] pixelScale) { + final boolean changed = hasPixelScale[0] != pixelScale[0] || hasPixelScale[1] != pixelScale[1]; + System.arraycopy(pixelScale, 0, hasPixelScale, 0, 2); + return changed; } @Override - public final int[] getRequestedSurfaceScale(final int[] result) { + public final float[] getRequestedSurfaceScale(final float[] result) { System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } @Override - public final int[] getCurrentSurfaceScale(final int[] result) { + public final float[] getCurrentSurfaceScale(final float[] result) { System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } @Override - public final int[] getNativeSurfaceScale(final int[] result) { + public float[] getMinimumSurfaceScale(final float[] result) { + System.arraycopy(hasPixelScale, 0, result, 0, 2); + return result; + } + + @Override + public final float[] getMaximumSurfaceScale(final float[] result) { System.arraycopy(hasPixelScale, 0, result, 0, 2); return result; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java index fd39a3b4a..4231402c7 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java @@ -1,14 +1,14 @@ package jogamp.nativewindow; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.UpstreamSurfaceHook; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindow; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.util.Insets; +import com.jogamp.nativewindow.util.InsetsImmutable; +import com.jogamp.nativewindow.util.Point; import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos; diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index b0eda63b6..0c072d05b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -37,19 +37,22 @@ import java.awt.Component; import java.awt.Container; import java.awt.Frame; import java.awt.image.BufferedImage; +import java.nio.ByteBuffer; import java.util.HashMap; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JRootPane; import javax.swing.WindowConstants; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.WindowClosingProtocol; -import javax.media.nativewindow.util.PixelRectangle; -import javax.media.nativewindow.util.PixelFormat; -import javax.media.nativewindow.util.PixelFormatUtil; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.WindowClosingProtocol; +import com.jogamp.nativewindow.util.PixelRectangle; +import com.jogamp.nativewindow.util.PixelFormat; +import com.jogamp.nativewindow.util.PixelFormatUtil; import javax.swing.MenuSelectionManager; +import com.jogamp.nativewindow.awt.DirectDataBufferInt; + import jogamp.nativewindow.jawt.JAWTUtil; public class AWTMisc { @@ -210,25 +213,13 @@ public class AWTMisc { private static synchronized Cursor createCursor(final PixelRectangle pixelrect, final Point hotSpot) { final int width = pixelrect.getSize().getWidth(); final int height = pixelrect.getSize().getHeight(); - final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // PixelFormat.BGRA8888 - final PixelFormatUtil.PixelSink32 imgSink = new PixelFormatUtil.PixelSink32() { - public void store(final int x, final int y, final int pixel) { - img.setRGB(x, y, pixel); - } - @Override - public final PixelFormat getPixelformat() { - return PixelFormat.BGRA8888; - } - @Override - public int getStride() { - return width*4; - } - @Override - public final boolean isGLOriented() { - return false; - } - }; - PixelFormatUtil.convert32(imgSink, pixelrect); + // final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // PixelFormat.BGRA8888 + final DirectDataBufferInt.BufferedImageInt img = + DirectDataBufferInt.createBufferedImage(width, height, BufferedImage.TYPE_INT_ARGB, + null /* location */, null /* properties */); + final ByteBuffer imgBuffer = img.getDataBuffer().getDataBytes(); + PixelFormatUtil.convert(pixelrect, imgBuffer, PixelFormat.BGRA8888, false /* dst_glOriented */, width*4 /* dst_lineStride */); + final Toolkit toolkit = Toolkit.getDefaultToolkit(); return toolkit.createCustomCursor(img, hotSpot, pixelrect.toString()); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java index 8aaffbd84..fe83ebc76 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java @@ -39,7 +39,7 @@ package jogamp.nativewindow.jawt; -import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.NativeWindowFactory; import jogamp.nativewindow.NWJNILibLoader; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 231a89c26..e733b7233 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -49,13 +49,14 @@ import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Map; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.ToolkitLock; import jogamp.common.os.PlatformPropsImpl; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; +import jogamp.nativewindow.macosx.OSXUtil; import com.jogamp.common.os.Platform; import com.jogamp.common.util.PropertyAccess; @@ -93,6 +94,7 @@ public class JAWTUtil { private static final ToolkitLock jawtToolkitLock; private static final Method getScaleFactorMethod; + private static final Method getCGDisplayIDMethodOnOSX; private static class PrivilegedDataBlob1 { PrivilegedDataBlob1() { @@ -101,6 +103,7 @@ public class JAWTUtil { Method sunToolkitAWTLockMethod; Method sunToolkitAWTUnlockMethod; Method getScaleFactorMethod; + Method getCGDisplayIDMethodOnOSX; boolean ok; } @@ -321,6 +324,7 @@ public class JAWTUtil { hasSunToolkitAWTLock = false; // hasSunToolkitAWTLock = false; getScaleFactorMethod = null; + getCGDisplayIDMethodOnOSX = null; } else { // Non-headless case JAWTJNILibLoader.initSingleton(); // load libjawt.so @@ -357,8 +361,13 @@ public class JAWTUtil { } try { final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - d.getScaleFactorMethod = gd.getClass().getDeclaredMethod("getScaleFactor"); + final Class<?> gdClass = gd.getClass(); + d.getScaleFactorMethod = gdClass.getDeclaredMethod("getScaleFactor"); d.getScaleFactorMethod.setAccessible(true); + if( Platform.OSType.MACOS == PlatformPropsImpl.OS_TYPE ) { + d.getCGDisplayIDMethodOnOSX = gdClass.getDeclaredMethod("getCGDisplayID"); + d.getCGDisplayIDMethodOnOSX.setAccessible(true); + } } catch (final Throwable t) {} return d; } @@ -366,6 +375,7 @@ public class JAWTUtil { sunToolkitAWTLockMethod = pdb1.sunToolkitAWTLockMethod; sunToolkitAWTUnlockMethod = pdb1.sunToolkitAWTUnlockMethod; getScaleFactorMethod = pdb1.getScaleFactorMethod; + getCGDisplayIDMethodOnOSX = pdb1.getCGDisplayIDMethodOnOSX; boolean _hasSunToolkitAWTLock = false; if ( pdb1.ok ) { @@ -545,20 +555,46 @@ public class JAWTUtil { * Note: Currently only supported on OSX since 1.7.0_40 for HiDPI retina displays * </p> * @param device the {@link GraphicsDevice} instance used to query the pixel scale - * @return the pixel scale factor + * @param minScale current and output min scale values + * @param maxScale current and output max scale values + * @return {@code true} if the given min and max scale values have changed, otherwise {@code false}. */ - public static final int getPixelScale(final GraphicsDevice device) { + public static final boolean getPixelScale(final GraphicsDevice device, final float[] minScale, final float[] maxScale) { + // Shall we allow ]0..1[ minimum scale? + boolean changed = minScale[0] != 1f || minScale[1] != 1f; + minScale[0] = 1f; + minScale[1] = 1f; + float sx = 1f; + float sy = 1f; if( !SKIP_AWT_HIDPI ) { + if( null != getCGDisplayIDMethodOnOSX ) { + // OSX specific, preserving double type + try { + final Object res = getCGDisplayIDMethodOnOSX.invoke(device); + if (res instanceof Integer) { + final int displayID = ((Integer)res).intValue(); + sx = (float) OSXUtil.GetPixelScaleByDisplayID(displayID); + sy = sx; + } + } catch (final Throwable t) {} + } if( null != getScaleFactorMethod ) { + // Generic (?) try { final Object res = getScaleFactorMethod.invoke(device); if (res instanceof Integer) { - return ((Integer)res).intValue(); + sx = ((Integer)res).floatValue(); + } else if ( res instanceof Double) { + sx = ((Double)res).floatValue(); } + sy = sx; } catch (final Throwable t) {} } } - return 1; + changed = maxScale[0] != sx || maxScale[1] != sy; + maxScale[0] = sx; + maxScale[1] = sy; + return changed; } /** @@ -574,20 +610,23 @@ public class JAWTUtil { * Note: Currently only supported on OSX since 1.7.0_40 for HiDPI retina displays * </p> * @param gc the {@link GraphicsConfiguration} instance used to query the pixel scale - * @return the pixel scale factor + * @param minScale current and output min scale values + * @param maxScale current and output max scale values + * @return {@code true} if the given min and max scale values have changed, otherwise {@code false}. */ - public static final int getPixelScale(final GraphicsConfiguration gc) { + public static final boolean getPixelScale(final GraphicsConfiguration gc, final float[] minScale, final float[] maxScale) { final GraphicsDevice device = null != gc ? gc.getDevice() : null; - final int ps; + boolean changed; if( null == device ) { - ps = 0; + changed = minScale[0] != 1f || minScale[1] != 1f || maxScale[0] != 1f || maxScale[1] != 1f; + minScale[0] = 1f; + minScale[1] = 1f; + maxScale[0] = 1f; + maxScale[1] = 1f; } else { - ps = JAWTUtil.getPixelScale(device); - } - if( DEBUG ) { - System.err.println("JAWTUtil.updatePixelScale: Fetched "+ps); + changed = JAWTUtil.getPixelScale(device, minScale, maxScale); } - return ps; + return changed; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index fae8db52a..6ac480120 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -45,13 +45,12 @@ import java.nio.Buffer; import java.security.AccessController; import java.security.PrivilegedAction; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.Capabilities; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.MutableSurface; +import com.jogamp.nativewindow.util.Point; import com.jogamp.common.util.PropertyAccess; import com.jogamp.nativewindow.awt.JAWTWindow; @@ -116,13 +115,10 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } @Override - public void setSurfaceScale(final int[] pixelScale) { + public boolean setSurfaceScale(final float[] pixelScale) { super.setSurfaceScale(pixelScale); - if( 0 != getWindowHandle() ) { // locked at least once ! - final int hadPixelScaleX = getPixelScaleX(); - updatePixelScale(); - - if( hadPixelScaleX != getPixelScaleX() && 0 != getAttachedSurfaceLayer() ) { + if( 0 != getWindowHandle() && setReqPixelScale() ) { // locked at least once _and_ updated pixel-scale + if( 0 != getAttachedSurfaceLayer() ) { OSXUtil.RunOnMainThread(false, false, new Runnable() { @Override public void run() { @@ -133,6 +129,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } }); } + return true; + } else { + return false; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java index 5d191f7e5..40fdaa296 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java @@ -47,7 +47,7 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; -import javax.media.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java index 7ad914e0a..a6c9452af 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java @@ -40,11 +40,11 @@ package jogamp.nativewindow.jawt.windows; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindow; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.util.Point; import com.jogamp.nativewindow.awt.JAWTWindow; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 9abaed731..2620b60e0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -37,11 +37,11 @@ package jogamp.nativewindow.jawt.x11; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindow; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.util.Point; import com.jogamp.nativewindow.awt.JAWTWindow; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java index fea1be11a..3ae3b4840 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java @@ -47,7 +47,7 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; -import javax.media.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java index 6b54c32ea..e800e9ea8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java @@ -1,9 +1,9 @@ package jogamp.nativewindow.macosx; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index cf163bd82..8ec7b7e95 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -27,10 +27,10 @@ */ package jogamp.nativewindow.macosx; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.util.Insets; +import com.jogamp.nativewindow.util.Point; import com.jogamp.common.util.Function; import com.jogamp.common.util.FunctionTask; @@ -107,12 +107,14 @@ public class OSXUtil implements ToolkitProperties { return (Insets) GetInsets0(windowOrView); } - public static double GetPixelScale(final int screenIndex) { + public static double GetPixelScaleByScreenIdx(final int screenIndex) { return GetPixelScale0(screenIndex); } - + public static double GetPixelScaleByDisplayID(final int displayID) { + return GetPixelScale1(displayID); + } public static double GetPixelScale(final long windowOrView) { - return GetPixelScale1(windowOrView); + return GetPixelScale2(windowOrView); } public static long CreateNSWindow(final int x, final int y, final int width, final int height) { @@ -394,7 +396,8 @@ public class OSXUtil implements ToolkitProperties { private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); private static native Object GetInsets0(long windowOrView); private static native double GetPixelScale0(int screenIndex); - private static native double GetPixelScale1(long windowOrView); + private static native double GetPixelScale1(int displayID); + private static native double GetPixelScale2(long windowOrView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java index a08cf9b51..9366308c1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java @@ -1,9 +1,9 @@ package jogamp.nativewindow.windows; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index 2f335c428..faa0b2cac 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -28,11 +28,11 @@ package jogamp.nativewindow.windows; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; import jogamp.nativewindow.ProxySurfaceImpl; import jogamp.nativewindow.windows.GDI; diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index c409b6a39..bdf9630af 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -27,9 +27,11 @@ */ package jogamp.nativewindow.windows; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.util.Point; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.NativeWindowFactory; + +import com.jogamp.common.ExceptionUtils; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.Debug; @@ -132,7 +134,7 @@ public class GDIUtil implements ToolkitProperties { SetProcessThreadsAffinityMask0(affinityMask, verbose); } - private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + private static final void dumpStack() { ExceptionUtils.dumpStack(System.err); } // Callback for JNI /** Creates WNDCLASSEX instance */ static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc, long iconSmallHandle, long iconBigHandle); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index e3ea49314..2f62b7a4d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -32,7 +32,7 @@ import jogamp.nativewindow.Debug; import java.util.ArrayList; -import javax.media.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.NativeWindowException; public class RegisteredClassFactory { private static final boolean DEBUG = Debug.debug("RegisteredClass"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java index 0ac3d4a2e..99cfca97b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java @@ -28,9 +28,9 @@ package jogamp.nativewindow.x11; -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; +import com.jogamp.nativewindow.Capabilities; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.VisualIDHolder; public class X11Capabilities extends Capabilities { final private XVisualInfo xVisualInfo; // maybe null if !onscreen diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java index 7e61ba6d0..06176934b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -1,9 +1,9 @@ package jogamp.nativewindow.x11; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.UpstreamSurfaceHook; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.ProxySurface; +import com.jogamp.nativewindow.UpstreamSurfaceHook; import jogamp.nativewindow.x11.X11Lib; @@ -44,7 +44,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize s.setSurfaceHandle(windowHandle); s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } - s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + s.addUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); } finally { device.unlock(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java index e12c3fd13..f8a11f91e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java @@ -33,13 +33,13 @@ package jogamp.nativewindow.x11; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsScreen; -import javax.media.nativewindow.CapabilitiesChooser; -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsScreen; +import com.jogamp.nativewindow.CapabilitiesChooser; +import com.jogamp.nativewindow.CapabilitiesImmutable; +import com.jogamp.nativewindow.GraphicsConfigurationFactory; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.VisualIDHolder; import com.jogamp.nativewindow.x11.X11GraphicsConfiguration; import com.jogamp.nativewindow.x11.X11GraphicsScreen; diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 2414248b4..e59ff2ea8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -37,14 +37,15 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.NativeWindowFactory; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.ToolkitProperties; +import com.jogamp.common.ExceptionUtils; import com.jogamp.common.util.LongObjectHashMap; import com.jogamp.common.util.PropertyAccess; import com.jogamp.nativewindow.x11.X11GraphicsDevice; @@ -196,7 +197,7 @@ public class X11Util implements ToolkitProperties { ", pending (open in creation order): "+pendingDisplayList.size()+ ")"); if(DEBUG) { - Thread.dumpStack(); + ExceptionUtils.dumpStack(System.err); } if( openDisplayList.size() > 0) { X11Util.dumpOpenDisplayConnections(); @@ -615,7 +616,7 @@ public class X11Util implements ToolkitProperties { } private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI - private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + private static final void dumpStack() { ExceptionUtils.dumpStack(System.err); } // Callback for JNI private static native boolean initialize0(boolean debug); private static native void shutdown0(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index 6b606df97..b022a3089 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -36,17 +36,17 @@ package jogamp.nativewindow.x11.awt; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.AbstractGraphicsScreen; -import javax.media.nativewindow.CapabilitiesChooser; -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.ToolkitLock; -import javax.media.nativewindow.VisualIDHolder.VIDType; +import com.jogamp.nativewindow.AbstractGraphicsConfiguration; +import com.jogamp.nativewindow.AbstractGraphicsDevice; +import com.jogamp.nativewindow.AbstractGraphicsScreen; +import com.jogamp.nativewindow.CapabilitiesChooser; +import com.jogamp.nativewindow.CapabilitiesImmutable; +import com.jogamp.nativewindow.GraphicsConfigurationFactory; +import com.jogamp.nativewindow.VisualIDHolder; +import com.jogamp.nativewindow.NativeWindowException; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.ToolkitLock; +import com.jogamp.nativewindow.VisualIDHolder.VIDType; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; |