diff options
Diffstat (limited to 'src/nativewindow/classes')
5 files changed, 68 insertions, 26 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java index 1a2d212da..85340f29c 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java @@ -42,6 +42,7 @@ package com.jogamp.nativewindow; import com.jogamp.nativewindow.util.InsetsImmutable; import com.jogamp.nativewindow.util.Point; +import com.jogamp.nativewindow.util.Rectangle; /** * Extend the {@link NativeSurface} interface with windowing @@ -178,6 +179,17 @@ public interface NativeWindow extends NativeSurface, NativeSurfaceHolder { public int getHeight(); /** + * Returns a newly created {@link Rectangle} containing window origin, {@link #getX()} & {@link #getY()}, + * and size, {@link #getWidth()} & {@link #getHeight()}, in window units. + */ + Rectangle getBounds(); + + /** + * Returns a newly created {@link Rectangle} containing window's surface origin and size in pixel units. + */ + Rectangle getSurfaceBounds(); + + /** * Returns the window's top-left client-area position in the screen. * <p> * If {@link Point} is not <code>null</code>, it is translated about the resulting screen position diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 0c25b3e28..6df43bd0f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -98,7 +98,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private JAWT jawt; private boolean isOffscreenLayerSurface; protected long drawable; - protected Rectangle bounds; + protected Rectangle jawt_surface_bounds; protected Insets insets; private volatile long offscreenSurfaceLayer; @@ -279,7 +279,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, isOffscreenLayerSurface = false; drawable= 0; drawable_old = 0; - bounds = new Rectangle(); + jawt_surface_bounds = new Rectangle(); insets = new Insets(); hasPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE; hasPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE; @@ -359,13 +359,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, */ protected final boolean updateLockedData(final JAWT_Rectangle jawtBounds, final GraphicsConfiguration gc) { final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); - final boolean changedBounds = !bounds.equals(jb); + final boolean changedBounds = !jawt_surface_bounds.equals(jb); if( changedBounds ) { if( DEBUG ) { - System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); + System.err.println("JAWTWindow.updateBounds: "+jawt_surface_bounds+" -> "+jb); } - bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); + jawt_surface_bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); if(component instanceof Container) { final java.awt.Insets contInsets = ((Container)component).getInsets(); @@ -435,8 +435,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, reqPixelScale, minPixelScale, maxPixelScale, DEBUG ? getClass().getSimpleName() : null); } - /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ - public final RectangleImmutable getBounds() { return bounds; } + /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds in pixel units, updated with lock */ + public final RectangleImmutable getJAWTSurfaceBounds() { return jawt_surface_bounds; } /** @return the safe pixelScale value for x-direction, i.e. never negative or zero. Updated with lock. */ protected final float getPixelScaleX() { return hasPixelScale[0]; } @@ -816,6 +816,16 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // @Override + public final int getX() { + return component.getX(); + } + + @Override + public final int getY() { + return component.getY(); + } + + @Override public final int getWidth() { return component.getWidth(); } @@ -826,6 +836,18 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override + public final Rectangle getBounds() { + return new Rectangle(getX(), getY(), getWidth(), getHeight()); + } + + @Override + public final Rectangle getSurfaceBounds() { + return new Rectangle(SurfaceScaleUtils.scale(getX(), getPixelScaleX()), + SurfaceScaleUtils.scale(getY(), getPixelScaleY()), + getSurfaceWidth(), getSurfaceHeight()); + } + + @Override public void destroy() { surfaceLock.lock(); try { @@ -849,16 +871,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return drawable; } - @Override - public final int getX() { - return component.getX(); - } - - @Override - public final int getY() { - return component.getY(); - } - /** * {@inheritDoc} * @@ -922,10 +934,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, sb.append("JAWT version: ").append(toHexString(jawt.getCachedVersion())). append(", CA_LAYER: ").append(JAWTUtil.isJAWTUsingOffscreenLayer(jawt)). append(", isLayeredSurface ").append(isOffscreenLayerSurfaceEnabled()). - append(", bounds ").append(bounds).append(", insets ").append(insets). + append(", bounds ").append(jawt_surface_bounds).append(", insets ").append(insets). append(", pixelScale ").append(getPixelScaleX()).append("x").append(getPixelScaleY()); } else { - sb.append("JAWT n/a, bounds ").append(bounds).append(", insets ").append(insets); + sb.append("JAWT n/a, bounds ").append(jawt_surface_bounds).append(", insets ").append(insets); } return sb; } @@ -940,7 +952,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, ", attachedSurfaceLayer "+toHexString(getAttachedSurfaceLayer())+ ", windowHandle "+toHexString(getWindowHandle())+ ", surfaceHandle "+toHexString(getSurfaceHandle())+ - ", bounds "+bounds+", insets "+insets + ", bounds "+jawt_surface_bounds+", insets "+insets ); sb.append(", window ["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+ "], pixels[scale "+getPixelScaleX()+", "+getPixelScaleY()+" -> "+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"+ diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java index a417de4cb..769041f10 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -101,6 +101,12 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface protected final void unlockSurfaceImpl() { } + /** @return the safe pixelScale value for x-direction, i.e. never negative or zero. Updated with lock. */ + protected final float getPixelScaleX() { return hasPixelScale[0]; } + + /** @return the safe pixelScale value for y-direction, i.e. never negative or zero. Updated with lock. */ + protected final float getPixelScaleY() { return hasPixelScale[1]; } + /** * {@inheritDoc} * <p> diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java index 4231402c7..9da127666 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java @@ -9,7 +9,7 @@ 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.util.Rectangle; import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos; public class WrappedWindow extends WrappedSurface implements NativeWindow { @@ -105,6 +105,18 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { } @Override + public final Rectangle getBounds() { + return new Rectangle(getX(), getY(), getWidth(), getHeight()); + } + + @Override + public final Rectangle getSurfaceBounds() { + return new Rectangle(SurfaceScaleUtils.scale(getX(), getPixelScaleX()), + SurfaceScaleUtils.scale(getY(), getPixelScaleY()), + getSurfaceWidth(), getSurfaceHeight()); + } + + @Override public Point getLocationOnScreen(final Point point) { if(null!=point) { return point; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index e754bb262..40fb48f33 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -171,9 +171,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { pA1.translate(-outterInsets.left, -outterInsets.top); } System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(_offscreenSurfaceLayer) + ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+ - ", p0 "+p0+" -> "+p1+", bounds "+bounds); + ", p0 "+p0+" -> "+p1+", bounds "+jawt_surface_bounds); } else if( DEBUG ) { - System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(_offscreenSurfaceLayer) + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds); + System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(_offscreenSurfaceLayer) + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+jawt_surface_bounds); } // HiDPI: uniform pixel scale OSXUtil.AddCASublayer(rootSurfaceLayer, _offscreenSurfaceLayer, p1.getX(), p1.getY(), getWidth(), getHeight(), getPixelScaleX(), JAWTUtil.getOSXCALayerQuirks()); @@ -205,10 +205,10 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(getAttachedSurfaceLayer()) + ", quirks "+caLayerQuirks+", visible "+visible+ ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+ - ", p0 "+p0+" -> "+p1+", bounds "+bounds); + ", p0 "+p0+" -> "+p1+", bounds "+jawt_surface_bounds); } else if( DEBUG ) { System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(getAttachedSurfaceLayer()) + ", quirks "+caLayerQuirks+", visible "+visible+ - ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds); + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+jawt_surface_bounds); } OSXUtil.RunOnMainThread(false /* wait */, false, new Runnable() { @Override @@ -352,7 +352,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(), getPixelScaleX()); // HiDPI: uniform pixel scale + rootSurfaceLayer = OSXUtil.CreateCALayer(jawt_surface_bounds.getWidth(), jawt_surface_bounds.getHeight(), getPixelScaleX()); // HiDPI: uniform pixel scale if(0 == rootSurfaceLayer) { errMsg = "Could not create root CALayer"; } else { |