aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/com/jogamp')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java12
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java22
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java36
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/UpstreamWindowHookMutableSizePos.java53
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java90
6 files changed, 129 insertions, 86 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java
index c98bf5436..7ae614158 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java
@@ -32,7 +32,7 @@ public class DelegatedUpstreamSurfaceHookMutableSize extends UpstreamSurfaceHook
@Override
public String toString() {
- return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]";
+ return getClass().getSimpleName()+"[ "+ pixWidth + "x" + pixHeight + ", " + upstream + "]";
}
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java
index 1557f4e51..db4a979d1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java
@@ -10,7 +10,7 @@ public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurf
/**
* @param upstream optional upstream UpstreamSurfaceHook used for {@link #create(ProxySurface)} and {@link #destroy(ProxySurface)}.
- * @param surface mandatory {@link NativeSurface} used for {@link #getWidth(ProxySurface)} and {@link #getHeight(ProxySurface)}
+ * @param surface mandatory {@link NativeSurface} used for {@link #getPixelWidth(ProxySurface)} and {@link #getPixelHeight(ProxySurface)}
*/
public DelegatedUpstreamSurfaceHookWithSurfaceSize(UpstreamSurfaceHook upstream, NativeSurface surface) {
this.upstream = upstream;
@@ -35,18 +35,18 @@ public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurf
}
@Override
- public final int getWidth(ProxySurface s) {
- return surface.getWidth();
+ public final int getPixelWidth(ProxySurface s) {
+ return surface.getSurfaceWidth();
}
@Override
- public final int getHeight(ProxySurface s) {
- return surface.getHeight();
+ public final int getPixelHeight(ProxySurface s) {
+ return surface.getSurfaceHeight();
}
@Override
public String toString() {
- final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil";
+ final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getSurfaceWidth() + "x" + surface.getSurfaceHeight() ) : "nil";
return getClass().getSimpleName()+"["+upstream+", "+us_s+"]";
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java
index 5838c7a56..5910f5fea 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java
@@ -4,31 +4,31 @@ import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.UpstreamSurfaceHook;
public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.MutableSize {
- int width, height;
+ int pixWidth, pixHeight;
/**
* @param width initial width
* @param height initial height
*/
public UpstreamSurfaceHookMutableSize(int width, int height) {
- this.width = width;
- this.height = height;
+ this.pixWidth = width;
+ this.pixHeight = height;
}
@Override
- public final void setSize(int width, int height) {
- this.width = width;
- this.height = height;
+ public final void setPixelSize(int width, int height) {
+ this.pixWidth = width;
+ this.pixHeight = height;
}
@Override
- public final int getWidth(ProxySurface s) {
- return width;
+ public final int getPixelWidth(ProxySurface s) {
+ return pixWidth;
}
@Override
- public final int getHeight(ProxySurface s) {
- return height;
+ public final int getPixelHeight(ProxySurface s) {
+ return pixHeight;
}
@Override
public void create(ProxySurface s) { /* nop */ }
@@ -38,7 +38,7 @@ public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.Mutab
@Override
public String toString() {
- return getClass().getSimpleName()+"[ "+ width + "x" + height + "]";
+ return getClass().getSimpleName()+"[pixel "+ pixWidth + "x" + pixHeight + "]";
}
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java
deleted file mode 100644
index e6fcc049c..000000000
--- a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.jogamp.nativewindow;
-
-public class UpstreamSurfaceHookMutableSizePos extends UpstreamSurfaceHookMutableSize {
- int x, y;
-
- /**
- * @param width initial width
- * @param height initial height
- */
- public UpstreamSurfaceHookMutableSizePos(int x, int y, int width, int height) {
- super(width, height);
- this.x= x;
- this.y= y;
- }
-
- // @Override
- public final void setPos(int x, int y) {
- this.x= x;
- this.y= y;
- }
-
- public final int getX() {
- return x;
- }
-
- public final int getY() {
- return y;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"[ "+ x + "/" + y + " " + width + "x" + height + "]";
- }
-
-}
-
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamWindowHookMutableSizePos.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamWindowHookMutableSizePos.java
new file mode 100644
index 000000000..f761b522a
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamWindowHookMutableSizePos.java
@@ -0,0 +1,53 @@
+package com.jogamp.nativewindow;
+
+public class UpstreamWindowHookMutableSizePos extends UpstreamSurfaceHookMutableSize {
+ int winX, winY, winWidth, winHeight;
+
+ /**
+ * @param winX initial window x-pos
+ * @param winY initial window y-pos
+ * @param winWidth initial window width
+ * @param winHeight initial window height
+ * @param pixWidth initial surface pixel width, FIXME: pixel-dim == window-dim 'for now' ?
+ * @param pixHeight initial surface pixel height, FIXME: pixel-dim == window-dim 'for now' ?
+ */
+ public UpstreamWindowHookMutableSizePos(int winX, int winY, int winWidth, int winHeight, int pixWidth, int pixHeight) {
+ super(pixWidth, pixHeight);
+ this.winX= winX;
+ this.winY= winY;
+ this.winWidth = winWidth;
+ this.winHeight = winHeight;
+ }
+
+ // @Override
+ public final void setWinPos(int winX, int winY) {
+ this.winX= winX;
+ this.winY= winY;
+ }
+ // @Override
+ public final void setWinSize(int winWidth, int winHeight) {
+ this.winWidth= winWidth;
+ this.winHeight= winHeight;
+ }
+
+ public final int getX() {
+ return winX;
+ }
+
+ public final int getY() {
+ return winY;
+ }
+ public final int getWindowWidth() {
+ return winWidth;
+ }
+ public final int getWindowHeight() {
+ return winHeight;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+"[window "+ winX + "/" + winY + " " + winWidth + "x" + winHeight + ", pixel " + pixWidth + "x" + pixHeight + "]";
+ }
+
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 8d7c382ee..e35716c49 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -46,7 +46,6 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
-import java.awt.GraphicsDevice;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
@@ -99,7 +98,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected Rectangle bounds;
protected Insets insets;
private volatile long offscreenSurfaceLayer;
-
+ private volatile int pixelScale;
private long drawable_old;
/**
@@ -123,6 +122,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
invalidate();
this.isApplet = false;
this.offscreenSurfaceLayer = 0;
+ this.pixelScale = 1;
}
private static String id(Object obj) { return ( null!=obj ? toHexString(obj.hashCode()) : "nil" ); }
private String jawtStr() { return "JAWTWindow["+id(JAWTWindow.this)+"]"; }
@@ -260,17 +260,26 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
drawable_old = 0;
bounds = new Rectangle();
insets = new Insets();
+ pixelScale = 1;
}
protected abstract void invalidateNative();
- protected final boolean updateBounds(JAWT_Rectangle jawtBounds) {
+ /**
+ * Updates bounds and pixelScale
+ */
+ protected final boolean updateLockedData(JAWT_Rectangle jawtBounds) {
final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight());
- final boolean changed = !bounds.equals(jb);
+ final int newPixelScale;
+ {
+ final int s = JAWTUtil.getPixelScale(component);
+ newPixelScale = 0 < s ? s : 1;
+ }
+ final boolean changedBounds = !bounds.equals(jb);
+ final boolean changedPixelScale = newPixelScale != pixelScale;
- if(changed) {
- if(DEBUG) {
+ if( changedBounds ) {
+ if( DEBUG ) {
System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb);
- // Thread.dumpStack();
}
bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight());
@@ -279,12 +288,21 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom);
}
}
- return changed;
+ if( changedPixelScale ) {
+ if( DEBUG ) {
+ System.err.println("JAWTWindow.updatePixelScale: "+pixelScale+" -> "+newPixelScale);
+ }
+ pixelScale = newPixelScale;
+ }
+ return changedBounds || changedPixelScale;
}
/** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
public final RectangleImmutable getBounds() { return bounds; }
+ /** @return the safe pixelScale value, i.e. never negative or zero. Updated with lock. */
+ public final int getPixelScale() { return pixelScale; }
+
@Override
public final InsetsImmutable getInsets() { return insets; }
@@ -606,13 +624,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
@Override
- public final int getWidth() {
- return component.getWidth();
+ public final int getSurfaceWidth() {
+ return getWindowWidth() * getPixelScale();
}
@Override
- public final int getHeight() {
- return component.getHeight();
+ public final int getSurfaceHeight() {
+ return getWindowHeight() * getPixelScale();
}
//
@@ -620,6 +638,32 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
//
@Override
+ public final int getWindowWidth() {
+ return component.getWidth();
+ }
+
+ @Override
+ public final int getWindowHeight() {
+ return component.getHeight();
+ }
+
+ @Override
+ public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) {
+ final int scale = getPixelScale();
+ 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 = getPixelScale();
+ result[0] = windowUnitXY[0] * scale;
+ result[1] = windowUnitXY[1] * scale;
+ return result;
+ }
+
+ @Override
public void destroy() {
surfaceLock.lock();
try {
@@ -751,25 +795,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
return component.hasFocus();
}
- /**
- * Returns the pixel scale factor of this {@link Component}'s {@link GraphicsDevice}, if supported.
- * <p>
- * If the component is not yet {@link Component#isDisplayable() displayable},
- * <code>zero</code> is returned.
- * </p>
- * <p>
- * If the component does not support pixel scaling the default
- * <code>one</code> is returned.
- * </p>
- * <p>
- * Note: Currently only supported on OSX since 1.7.0_40 for HiDPI retina displays
- * </p>
- * @return the pixel scale factor
- */
- protected final int getPixelScale() {
- return JAWTUtil.getPixelScale(component);
- }
-
protected StringBuilder jawt2String(StringBuilder sb) {
if( null == sb ) {
sb = new StringBuilder();
@@ -801,7 +826,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
", surfaceHandle "+toHexString(getSurfaceHandle())+
", bounds "+bounds+", insets "+insets
);
- sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
+ sb.append(", window ["+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+
+ "], pixels[x"+getPixelScale()+" -> "+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"+
", visible "+component.isVisible());
sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
",\n\tconfig "+config+