aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsConfiguration.java (renamed from src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsDevice.java (renamed from src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java)6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsScreen.java (renamed from src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java (renamed from src/nativewindow/classes/javax/media/nativewindow/Capabilities.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesChooser.java (renamed from src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java)4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DefaultCapabilitiesChooser.java (renamed from src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java (renamed from src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java)4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsDevice.java (renamed from src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java)8
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsScreen.java (renamed from src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java88
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/GraphicsConfigurationFactory.java (renamed from src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java)10
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/MutableSurface.java (renamed from src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java (renamed from src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java)6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeSurfaceHolder.java (renamed from src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java (renamed from src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java)6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowException.java (renamed from src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java (renamed from src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java)12
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerOption.java (renamed from src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerSurface.java (renamed from src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java)6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/ProxySurface.java (renamed from src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java)10
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/ScalableSurface.java (renamed from src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java)54
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/SurfaceUpdatedListener.java (renamed from src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java)4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/ToolkitLock.java (renamed from src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHook.java (renamed from src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java (renamed from src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/WindowClosingProtocol.java (renamed from src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java5
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java93
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java165
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java30
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/package.html (renamed from src/nativewindow/classes/javax/media/nativewindow/package.html)34
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java10
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/Dimension.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/DimensionImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/Insets.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/Insets.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/InsetsImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java739
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java600
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/PixelRectangle.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/PixelRectangle.java)10
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/Point.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/Point.java)33
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/PointImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/RectangleImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java)2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/SurfaceSize.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java)6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java16
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java10
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java197
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java373
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/Debug.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java4
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java6
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java51
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java4
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java7
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java235
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java4
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java43
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java18
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java39
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java73
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java25
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java8
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java19
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java8
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java6
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java14
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java11
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java22
93 files changed, 2208 insertions, 1090 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsConfiguration.java
index 48f72e574..684f1f86a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsConfiguration.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/** A marker interface describing a graphics configuration, visual, or
pixel format in a toolkit-independent manner. */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsDevice.java
index 31b64269f..7b630b1ea 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsDevice.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import jogamp.nativewindow.Debug;
@@ -109,13 +109,13 @@ public interface AbstractGraphicsDevice extends Cloneable {
public long getHandle();
/**
- * Optionally locking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#lock()}.
+ * Optionally locking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#lock()}.
* The lock implementation must be recursive.
*/
public void lock();
/**
- * Optionally unlocking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#unlock()}.
+ * Optionally unlocking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#unlock()}.
* The lock implementation must be recursive.
*
* @throws RuntimeException in case the lock is not acquired by this thread.
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsScreen.java
index da8f12f3e..7767cf9e4 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsScreen.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/** A interface describing a graphics screen in a
toolkit-independent manner.
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
index bf8952565..fa172b201 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/** Specifies a set of capabilities that a window's rendering context
must support, such as color depth per channel. It currently
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesChooser.java
index 1f4db7997..c33ff5a3f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesChooser.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import java.util.List;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
index c496a1535..780d537b8 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import com.jogamp.common.type.WriteCloneable;
@@ -34,7 +34,7 @@ import com.jogamp.common.type.WriteCloneable;
* Specifies an immutable set of capabilities that a window's rendering context
* must support, such as color depth per channel.
*
- * @see javax.media.nativewindow.Capabilities
+ * @see com.jogamp.nativewindow.Capabilities
*/
public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, Comparable<CapabilitiesImmutable> {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultCapabilitiesChooser.java
index d0c1a9b85..33c3f8458 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultCapabilitiesChooser.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import java.util.List;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
index cae37c36c..d20a6824d 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
@@ -30,7 +30,7 @@
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import jogamp.nativewindow.Debug;
@@ -98,7 +98,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
* The use case for setting the Capabilities at a later time is
* a change or re-validation of capabilities.
* </p>
- * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
protected void setChosenCapabilities(final CapabilitiesImmutable capsChosen) {
this.capabilitiesChosen = capsChosen;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsDevice.java
index ab9286b3f..070b6bb28 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsDevice.java
@@ -31,7 +31,7 @@
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import jogamp.nativewindow.NativeWindowFactoryImpl;
@@ -119,7 +119,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
* </p>
*
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
*/
@Override
public final void lock() {
@@ -138,7 +138,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
* </p>
*
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
*/
@Override
public final void unlock() {
@@ -237,7 +237,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
* @return the used ToolkitLock
*
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
*/
public final ToolkitLock getToolkitLock() {
return toolkitLock;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsScreen.java
index 3ee775904..63c79af55 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsScreen.java
@@ -30,7 +30,7 @@
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen {
private final AbstractGraphicsDevice device;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java
index e785af788..da088ab09 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java
@@ -1,7 +1,7 @@
package com.jogamp.nativewindow;
-import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.UpstreamSurfaceHook;
+import com.jogamp.nativewindow.ProxySurface;
+import com.jogamp.nativewindow.UpstreamSurfaceHook;
public class DelegatedUpstreamSurfaceHookMutableSize extends UpstreamSurfaceHookMutableSize {
final UpstreamSurfaceHook upstream;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java
index abcc166cb..22e99deaf 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java
@@ -1,8 +1,8 @@
package com.jogamp.nativewindow;
-import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.UpstreamSurfaceHook;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.ProxySurface;
+import com.jogamp.nativewindow.UpstreamSurfaceHook;
public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurfaceHook {
final UpstreamSurfaceHook upstream;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java b/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java
new file mode 100644
index 000000000..044aebc21
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/GenericUpstreamSurfacelessHook.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.nativewindow;
+
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.ProxySurface;
+import com.jogamp.nativewindow.UpstreamSurfaceHook;
+
+import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize;
+
+public class GenericUpstreamSurfacelessHook extends UpstreamSurfaceHookMutableSize {
+ /**
+ * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getSurfaceWidth(ProxySurface)},
+ * not the actual dummy surface width.
+ * The latter is platform specific and small
+ * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()} via {@link UpstreamSurfaceHook#getSurfaceHeight(ProxySurface)},
+ * not the actual dummy surface height,
+ * The latter is platform specific and small
+ */
+ public GenericUpstreamSurfacelessHook(final int width, final int height) {
+ super(width, height);
+ }
+
+ @Override
+ public final void create(final ProxySurface s) {
+ final AbstractGraphicsDevice device = s.getGraphicsConfiguration().getScreen().getDevice();
+ device.lock();
+ try {
+ if(0 == device.getHandle()) {
+ device.open();
+ s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE );
+ }
+ if( 0 != s.getSurfaceHandle() ) {
+ throw new InternalError("Upstream surface not null: "+s);
+ }
+ s.addUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_SURFACELESS |
+ ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE |
+ ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE );
+ } finally {
+ device.unlock();
+ }
+ }
+
+ @Override
+ public final void destroy(final ProxySurface s) {
+ if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) {
+ final AbstractGraphicsDevice device = s.getGraphicsConfiguration().getScreen().getDevice();
+ if( !s.containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_SURFACELESS ) ) {
+ throw new InternalError("Owns upstream surface, but not a valid zero surface: "+s);
+ }
+ if( 0 != s.getSurfaceHandle() ) {
+ throw new InternalError("Owns upstream valid zero surface, but non zero surface: "+s);
+ }
+ device.lock();
+ try {
+ s.clearUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_SURFACELESS | ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE );
+ } finally {
+ device.unlock();
+ }
+ }
+ }
+}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/GraphicsConfigurationFactory.java
index 3f8113baa..929af054e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/GraphicsConfigurationFactory.java
@@ -31,9 +31,11 @@
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
+import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.util.ReflectionUtil;
+
import jogamp.nativewindow.Debug;
import jogamp.nativewindow.DefaultGraphicsConfigurationFactoryImpl;
@@ -226,7 +228,7 @@ public abstract class GraphicsConfigurationFactory {
throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable");
}
if(DEBUG) {
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
System.err.println("GraphicsConfigurationFactory.getFactory: "+deviceType.getName()+", "+capabilitiesType.getName());
dumpFactories();
}
@@ -396,8 +398,8 @@ public abstract class GraphicsConfigurationFactory {
* @throws NativeWindowException if any window system-specific errors caused
* the selection of the graphics configuration to fail.
*
- * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
- * @see javax.media.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
+ * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ * @see com.jogamp.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
*/
public final AbstractGraphicsConfiguration
chooseGraphicsConfiguration(final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested,
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java
index a137d46c3..4357233c4 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java
@@ -27,9 +27,9 @@
*/
package com.jogamp.nativewindow;
-import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.CapabilitiesImmutable;
-import javax.media.nativewindow.DefaultGraphicsConfiguration;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+import com.jogamp.nativewindow.DefaultGraphicsConfiguration;
public class MutableGraphicsConfiguration extends DefaultGraphicsConfiguration {
public MutableGraphicsConfiguration(final AbstractGraphicsScreen screen,
diff --git a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/MutableSurface.java
index a0db11ad9..7686f270b 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/MutableSurface.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Provides a {@link NativeSurface} with a mutable <code>surfaceHandle</code>
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
index 4d764dc4f..ce0699c56 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Provides low-level information required for
@@ -198,6 +198,7 @@ public interface NativeSurface extends SurfaceUpdatedListener {
* @param pixelUnitsAndResult int[2] storage holding the pixel units for the x- and y-coord to convert
* and the resulting values.
* @return result int[2] storage pixelUnitsAndResult for chaining holding the converted values
+ * @see ScalableSurface
*/
public int[] convertToWindowUnits(final int[] pixelUnitsAndResult);
@@ -206,6 +207,7 @@ public interface NativeSurface extends SurfaceUpdatedListener {
* @param windowUnitsAndResult int[2] storage holding the window units for the x- and y-coord to convert
* and the resulting values.
* @return result int[2] storage windowUnitsAndResult for chaining holding the converted values
+ * @see ScalableSurface
*/
public int[] convertToPixelUnits(final int[] windowUnitsAndResult);
@@ -216,7 +218,7 @@ public interface NativeSurface extends SurfaceUpdatedListener {
* this method shall return the native {@link AbstractGraphicsConfiguration} via {@link AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()}.
* </p>
* @see AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()
- * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
public AbstractGraphicsConfiguration getGraphicsConfiguration();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurfaceHolder.java
index b459ab74a..667f5d8af 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurfaceHolder.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Accessor interface for implementing classes with ownership of a {@link NativeSurface}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java
index 7f71bc33b..1a2d212da 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java
@@ -38,10 +38,10 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
-import javax.media.nativewindow.util.InsetsImmutable;
-import javax.media.nativewindow.util.Point;
+import com.jogamp.nativewindow.util.InsetsImmutable;
+import com.jogamp.nativewindow.util.Point;
/**
* Extend the {@link NativeSurface} interface with windowing
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowException.java
index 16355032f..8f841e7ea 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowException.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/** A generic exception for OpenGL errors used throughout the binding
as a substitute for {@link RuntimeException}. */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
index 58542f07d..cba3a9214 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
@@ -31,7 +31,7 @@
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import java.io.File;
import java.lang.reflect.Method;
@@ -43,7 +43,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.media.nativewindow.util.PointImmutable;
+import com.jogamp.nativewindow.util.PointImmutable;
import jogamp.common.os.PlatformPropsImpl;
import jogamp.nativewindow.Debug;
@@ -385,7 +385,7 @@ public abstract class NativeWindowFactory {
// register our default factory -> NativeWindow
final NativeWindowFactory factory = new NativeWindowFactoryImpl();
- nativeWindowClass = javax.media.nativewindow.NativeWindow.class;
+ nativeWindowClass = com.jogamp.nativewindow.NativeWindow.class;
registerFactory(nativeWindowClass, factory);
defaultFactory = factory;
@@ -560,10 +560,10 @@ public abstract class NativeWindowFactory {
/** Converts the given window object and it's
{@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a
{@link NativeWindow NativeWindow} which can be operated upon by a custom
- toolkit, e.g. {@link javax.media.opengl.GLDrawableFactory javax.media.opengl.GLDrawableFactory}.<br>
+ toolkit, e.g. {@link com.jogamp.opengl.GLDrawableFactory com.jogamp.opengl.GLDrawableFactory}.<br>
The object may be a component for a particular window toolkit, such as an AWT
Canvas. It may also be a NativeWindow object itself.<br>
- You shall utilize {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
+ You shall utilize {@link com.jogamp.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
to construct a proper {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}.<br>
The particular implementation of the
NativeWindowFactory is responsible for handling objects from a
@@ -574,7 +574,7 @@ public abstract class NativeWindowFactory {
could not be handled by any of the registered
NativeWindowFactory instances
- @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
public static NativeWindow getNativeWindow(final Object winObj, final AbstractGraphicsConfiguration config) throws IllegalArgumentException, NativeWindowException {
if (winObj == null) {
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java
index 7c1a88e6a..6bbb3c15f 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java
@@ -46,8 +46,8 @@ public class NativeWindowVersion extends JogampVersion {
if(null == jogampCommonVersionInfo) { // volatile: ok
synchronized(NativeWindowVersion.class) {
if( null == jogampCommonVersionInfo ) {
- final String packageName1 = "javax.media.nativewindow"; // atomic packaging - and identity
- final String packageName2 = "javax.media.opengl"; // all packaging
+ final String packageName1 = "com.jogamp.nativewindow"; // atomic packaging - and identity
+ final String packageName2 = "com.jogamp.opengl"; // all packaging
final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), new String[]{ packageName1, packageName2 } );
jogampCommonVersionInfo = new NativeWindowVersion(packageName1, mf);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerOption.java
index 11496899a..2e9f2c172 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerOption.java
@@ -25,7 +25,7 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Handling requests for using an {@link OffscreenLayerSurface}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerSurface.java
index cf8cf89d2..abba2c126 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerSurface.java
@@ -25,10 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
-import javax.media.nativewindow.util.PixelRectangle;
-import javax.media.nativewindow.util.PointImmutable;
+import com.jogamp.nativewindow.util.PixelRectangle;
+import com.jogamp.nativewindow.util.PointImmutable;
import com.jogamp.common.util.locks.RecursiveLock;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/ProxySurface.java
index 7a69b9a40..7b36531dc 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/ProxySurface.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import jogamp.nativewindow.Debug;
@@ -65,6 +65,14 @@ public interface ProxySurface extends MutableSurface {
*/
public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8;
+ /**
+ * Implementation specific bitvalue stating the upstream's {@link NativeSurface}'s zero handle is valid.
+ * @see #addUpstreamOptionBits(int)
+ * @see #clearUpstreamOptionBits(int)
+ * @see #getUpstreamOptionBits()
+ */
+ public static final int OPT_UPSTREAM_SURFACELESS = 1 << 9;
+
/** Allow redefining the AbstractGraphicsConfiguration */
public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg);
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/ScalableSurface.java
index ffd5c224c..eea9e4bed 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/ScalableSurface.java
@@ -26,20 +26,21 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Adding mutable surface pixel scale property to implementing class, usually to a {@link NativeSurface} implementation,
- * see {@link #setSurfaceScale(int[])}.
+ * see {@link #setSurfaceScale(float[])}.
*/
public interface ScalableSurface {
/** Setting surface-pixel-scale of {@value}, results in same pixel- and window-units. */
- public static final int IDENTITY_PIXELSCALE = 1;
+ public static final float IDENTITY_PIXELSCALE = 1f;
/** Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale, i.e. pixel-units >> window-units where available. */
- public static final int AUTOMAX_PIXELSCALE = 0;
+ public static final float AUTOMAX_PIXELSCALE = 0f;
/**
- * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface}.
+ * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface},
+ * where {@code size_in_pixel_units = pixel_scale * size_in_window_units}.
* <p>
* Default pixel scale request for both directions is {@link #AUTOMAX_PIXELSCALE}.
* </p>
@@ -50,48 +51,57 @@ public interface ScalableSurface {
* <p>
* The <i>requested</i> pixel scale will be validated against platform limits before native scale-setup,
* i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or clipped to the platform maximum.
- * It can be queried via {@link #getRequestedSurfaceScale(int[])}.
+ * It can be queried via {@link #getRequestedSurfaceScale(float[])}.
* </p>
* <p>
* The actual <i>realized</i> pixel scale values of the {@link NativeSurface}
- * can be queried via {@link #getCurrentSurfaceScale(int[])} or
+ * can be queried via {@link #getCurrentSurfaceScale(float[])} or
* computed via <code>surface.{@link NativeSurface#convertToPixelUnits(int[]) convertToPixelUnits}(new int[] { 1, 1 })</code>
* </p>
- * @param pixelScale <i>requested</i> surface pixel scale int[2] values for x- and y-direction.
+ * @param pixelScale <i>requested</i> surface pixel scale float[2] values for x- and y-direction.
+ * @return {@code true} if the {@link #getCurrentSurfaceScale(float[]) current pixel scale} has changed, otherwise {@code false}.
+ * @see #getRequestedSurfaceScale(float[])
*/
- public void setSurfaceScale(final int[] pixelScale);
+ public boolean setSurfaceScale(final float[] pixelScale);
/**
- * Returns the requested pixel scale of the associated {@link NativeSurface}.
+ * Returns the {@link #setSurfaceScale(float[]) requested} pixel scale of the associated {@link NativeSurface}.
*
- * @param result int[2] storage for the result
- * @return the passed storage containing the requested pixelScale for chaining
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the current pixelScale for chaining
+ * @see #setSurfaceScale(float[])
*/
- int[] getRequestedSurfaceScale(final int[] result);
+ public float[] getRequestedSurfaceScale(final float[] result);
/**
* Returns the current pixel scale of the associated {@link NativeSurface}.
*
- * @param result int[2] storage for the result
+ * @param result float[2] storage for the result
* @return the passed storage containing the current pixelScale for chaining
*/
- public int[] getCurrentSurfaceScale(final int[] result);
+ public float[] getCurrentSurfaceScale(final float[] result);
+
+ /**
+ * Returns the minimum pixel scale of the associated {@link NativeSurface}.
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the minimum pixelScale for chaining
+ */
+ public float[] getMinimumSurfaceScale(final float[] result);
/**
- * Returns the native pixel scale of the associated {@link NativeSurface}
- * reflecting it's currently bound <i>monitor surface resolution in pixels</i>.
+ * Returns the maximum pixel scale of the associated {@link NativeSurface}.
* <p>
- * The native pixel scale maybe used to determine the proper <i>dpi</i>
- * value of this {@link NativeSurface}:
+ * The maximum pixel scale maybe used to determine the proper <i>dpi</i>
+ * value of the monitor displaying this {@link NativeSurface}.
* <pre>
* surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale,
* with PpMM == pixel per millimeter
* </pre>
* </p>
*
- * @param result int[2] storage for the result
- * @return the passed storage containing the native pixelScale for chaining
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the maximum pixelScale for chaining
*/
- public int[] getNativeSurfaceScale(final int[] result);
+ public float[] getMaximumSurfaceScale(final float[] result);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/com/jogamp/nativewindow/SurfaceUpdatedListener.java
index de65a3031..37e4bd0c9 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/SurfaceUpdatedListener.java
@@ -32,10 +32,10 @@
*
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
- * Clients may add their SurfaceUpdateListener implementation to a {@link javax.media.nativewindow.NativeSurface}
+ * Clients may add their SurfaceUpdateListener implementation to a {@link com.jogamp.nativewindow.NativeSurface}
* allowing to get notified after the surface has been updated, eg. after a swap buffer operation.
*/
public interface SurfaceUpdatedListener {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/com/jogamp/nativewindow/ToolkitLock.java
index 017b996d7..eef11adb7 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/ToolkitLock.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import jogamp.nativewindow.Debug;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHook.java
index 572649875..5e9b8d293 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHook.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Interface allowing upstream caller to pass lifecycle actions and size info
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java
index 45d12be5e..af75e8346 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java
@@ -1,8 +1,8 @@
package com.jogamp.nativewindow;
-import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.UpstreamSurfaceHook;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.ProxySurface;
+import com.jogamp.nativewindow.UpstreamSurfaceHook;
public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.MutableSize {
int pixWidth, pixHeight;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
index e337166d4..69bfe50f8 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
import java.util.Comparator;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/WindowClosingProtocol.java
index 8570b78da..f4f8a02e1 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/WindowClosingProtocol.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow;
+package com.jogamp.nativewindow;
/**
* Protocol for handling window closing events.
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java
index 3a62825a2..62fd49092 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -40,13 +40,13 @@
package com.jogamp.nativewindow.awt;
-import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.*;
import java.awt.Component;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.image.ColorModel;
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
import jogamp.nativewindow.Debug;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java
index 219f4bb92..54b26ae51 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java
@@ -40,10 +40,10 @@
package com.jogamp.nativewindow.awt;
-import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.*;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
/** A wrapper for an AWT GraphicsDevice allowing it to be
handled in a toolkit-independent manner. */
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java
index 6fc35f719..742a93dae 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java
@@ -42,7 +42,7 @@ package com.jogamp.nativewindow.awt;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.*;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java
index b0a7fbc76..d386d6a47 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java
@@ -37,10 +37,10 @@ import jogamp.nativewindow.awt.AWTMisc;
/**
* Interface describing print lifecycle to support AWT printing,
- * e.g. on AWT {@link javax.media.opengl.GLAutoDrawable GLAutoDrawable}s.
+ * e.g. on AWT {@link com.jogamp.opengl.GLAutoDrawable GLAutoDrawable}s.
* <a name="impl"><h5>Implementations</h5></a>
* <p>
- * Implementing {@link javax.media.opengl.GLAutoDrawable GLAutoDrawable} classes based on AWT
+ * Implementing {@link com.jogamp.opengl.GLAutoDrawable GLAutoDrawable} classes based on AWT
* supporting {@link Component#print(Graphics)} shall implement this interface.
* </p>
* <a name="usage"><h5>Usage</h5></a>
@@ -88,6 +88,7 @@ public interface AWTPrintLifecycle {
* @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
* @param tileWidth custom tile width for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
* @param tileHeight custom tile height for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
+ * FIXME: Add border size !
*/
void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight);
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
index 496e6e07b..fea23cb59 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
@@ -34,7 +34,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
-import javax.media.nativewindow.WindowClosingProtocol;
+import com.jogamp.nativewindow.WindowClosingProtocol;
import jogamp.nativewindow.awt.AWTMisc;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java
index c7055099f..0f103bfb3 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java
@@ -36,6 +36,7 @@ import java.awt.image.DirectColorModel;
import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
import java.awt.image.WritableRaster;
+import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Hashtable;
@@ -54,9 +55,12 @@ public final class DirectDataBufferInt extends DataBuffer {
public static class BufferedImageInt extends BufferedImage {
final int customImageType;
- public BufferedImageInt (final int customImageType, final ColorModel cm, final WritableRaster raster, final Hashtable<?,?> properties) {
+ final DirectDataBufferInt dataBuffer;
+ public BufferedImageInt (final int customImageType, final ColorModel cm,
+ final DirectDataBufferInt dataBuffer, final WritableRaster raster, final Hashtable<?,?> properties) {
super(cm, raster, false /* isRasterPremultiplied */, properties);
this.customImageType = customImageType;
+ this.dataBuffer = dataBuffer;
}
/**
@@ -68,6 +72,11 @@ public final class DirectDataBufferInt extends DataBuffer {
return customImageType;
}
+ /**
+ * Returns the underlying {@link DirectDataBufferInt} associated with this instance via {@link Raster} {@link #getRaster() instance}.
+ */
+ public DirectDataBufferInt getDataBuffer() { return dataBuffer; }
+
@Override
public String toString() {
return "BufferedImageInt@"+Integer.toHexString(hashCode())
@@ -163,14 +172,18 @@ public final class DirectDataBufferInt extends DataBuffer {
// final WritableRaster raster = new SunWritableRaster(sppsm, dataBuffer, location);
final WritableRaster raster = new DirectWritableRaster(sppsm, dataBuffer, location);
- return new BufferedImageInt(imageType, colorModel, raster, properties);
+ return new BufferedImageInt(imageType, colorModel, dataBuffer, raster, properties);
}
- /** Default data bank. */
- private final IntBuffer data;
+ /** Default NIO data bank storage, {@link ByteBuffer} representation. */
+ private final ByteBuffer dataBytes;
+ /** Default NIO data bank storage, {@link IntBuffer} representation. */
+ private final IntBuffer dataInts;
- /** All data banks */
- private final IntBuffer bankdata[];
+ /** All NIO data banks, {@link ByteBuffer} representation. */
+ private final ByteBuffer bankdataBytes[];
+ /** All NIO data banks, {@link IntBuffer} representation. */
+ private final IntBuffer bankdataInts[];
/**
* Constructs an nio integer-based {@link DataBuffer} with a single bank
@@ -180,9 +193,12 @@ public final class DirectDataBufferInt extends DataBuffer {
*/
public DirectDataBufferInt(final int size) {
super(TYPE_INT, size);
- data = Buffers.newDirectIntBuffer(size);
- bankdata = new IntBuffer[1];
- bankdata[0] = data;
+ dataBytes = Buffers.newDirectByteBuffer(size * Buffers.SIZEOF_INT);
+ dataInts = dataBytes.asIntBuffer();
+ bankdataBytes = new ByteBuffer[1];
+ bankdataInts = new IntBuffer[1];
+ bankdataBytes[0] = dataBytes;
+ bankdataInts[0] = dataInts;
}
/**
@@ -194,11 +210,14 @@ public final class DirectDataBufferInt extends DataBuffer {
*/
public DirectDataBufferInt(final int size, final int numBanks) {
super(TYPE_INT,size,numBanks);
- bankdata = new IntBuffer[numBanks];
+ bankdataBytes = new ByteBuffer[numBanks];
+ bankdataInts = new IntBuffer[numBanks];
for (int i= 0; i < numBanks; i++) {
- bankdata[i] = Buffers.newDirectIntBuffer(size);
+ bankdataBytes[i] = Buffers.newDirectByteBuffer(size * Buffers.SIZEOF_INT);
+ bankdataInts[i] = bankdataBytes[i].asIntBuffer();
}
- data = bankdata[0];
+ dataBytes = bankdataBytes[0];
+ dataInts = bankdataInts[0];
}
/**
@@ -210,33 +229,57 @@ public final class DirectDataBufferInt extends DataBuffer {
* hold <code>size</code> elements.
* </p>
*
- * @param dataArray The integer array for the {@link DataBuffer}.
+ * @param dataArray The NIO {@link ByteBuffer} array, holding the integer data for the {@link DataBuffer}.
* @param size The size of the {@link DataBuffer} bank.
*/
- public DirectDataBufferInt(final IntBuffer dataArray, final int size) {
+ public DirectDataBufferInt(final ByteBuffer dataArray, final int size) {
super(TYPE_INT,size);
- data = dataArray;
- bankdata = new IntBuffer[1];
- bankdata[0] = data;
+ dataBytes = Buffers.nativeOrder(dataArray);
+ dataInts = dataBytes.asIntBuffer();
+ bankdataBytes = new ByteBuffer[1];
+ bankdataInts = new IntBuffer[1];
+ bankdataBytes[0] = dataBytes;
+ bankdataInts[0] = dataInts;
}
/**
- * Returns the default (first) int data array in {@link DataBuffer}.
+ * Returns the default (first) int data array in {@link DataBuffer} as an {@link IntBuffer} representation.
*
* @return The first integer data array.
+ * @see #getDataBytes()
*/
public IntBuffer getData() {
- return data;
+ return dataInts;
+ }
+ /**
+ * Returns the default (first) int data array in {@link DataBuffer} as a {@link ByteBuffer} representation.
+ *
+ * @return The first integer data array.
+ * @see #getData()
+ */
+ public ByteBuffer getDataBytes() {
+ return dataBytes;
}
/**
- * Returns the data array for the specified bank.
+ * Returns the data array for the specified bank as an {@link IntBuffer} representation.
*
* @param bank The bank whose data array you want to get.
* @return The data array for the specified bank.
+ * @see #getDataBytes(int)
*/
public IntBuffer getData(final int bank) {
- return bankdata[bank];
+ return bankdataInts[bank];
+ }
+ /**
+ * Returns the data array for the specified bank as a {@link ByteBuffer} representation.
+ *
+ * @param bank The bank whose data array you want to get.
+ * @return The data array for the specified bank.
+ * @see #getData(int)
+ */
+ public ByteBuffer getDataBytes(final int bank) {
+ return bankdataBytes[bank];
}
/**
@@ -249,7 +292,7 @@ public final class DirectDataBufferInt extends DataBuffer {
*/
@Override
public int getElem(final int i) {
- return data.get(i+offset);
+ return dataInts.get(i+offset);
}
/**
@@ -263,7 +306,7 @@ public final class DirectDataBufferInt extends DataBuffer {
*/
@Override
public int getElem(final int bank, final int i) {
- return bankdata[bank].get(i+offsets[bank]);
+ return bankdataInts[bank].get(i+offsets[bank]);
}
/**
@@ -277,7 +320,7 @@ public final class DirectDataBufferInt extends DataBuffer {
*/
@Override
public void setElem(final int i, final int val) {
- data.put(i+offset, val);
+ dataInts.put(i+offset, val);
}
/**
@@ -291,7 +334,7 @@ public final class DirectDataBufferInt extends DataBuffer {
*/
@Override
public void setElem(final int bank, final int i, final int val) {
- bankdata[bank].put(i+offsets[bank], val);
+ bankdataInts[bank].put(i+offsets[bank], val);
}
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 6498ebd1e..f1442abee 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -37,6 +37,7 @@
package com.jogamp.nativewindow.awt;
+import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.awt.AWTEDTExecutor;
import com.jogamp.common.util.locks.LockFactory;
@@ -46,6 +47,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
+import java.awt.EventQueue;
+import java.awt.GraphicsConfiguration;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
@@ -53,23 +56,23 @@ import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.applet.Applet;
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.CapabilitiesImmutable;
-import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.NativeWindow;
-import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.OffscreenLayerOption;
-import javax.media.nativewindow.OffscreenLayerSurface;
-import javax.media.nativewindow.ScalableSurface;
-import javax.media.nativewindow.SurfaceUpdatedListener;
-import javax.media.nativewindow.util.Insets;
-import javax.media.nativewindow.util.InsetsImmutable;
-import javax.media.nativewindow.util.PixelRectangle;
-import javax.media.nativewindow.util.Point;
-import javax.media.nativewindow.util.PointImmutable;
-import javax.media.nativewindow.util.Rectangle;
-import javax.media.nativewindow.util.RectangleImmutable;
+import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.NativeWindow;
+import com.jogamp.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.OffscreenLayerOption;
+import com.jogamp.nativewindow.OffscreenLayerSurface;
+import com.jogamp.nativewindow.ScalableSurface;
+import com.jogamp.nativewindow.SurfaceUpdatedListener;
+import com.jogamp.nativewindow.util.Insets;
+import com.jogamp.nativewindow.util.InsetsImmutable;
+import com.jogamp.nativewindow.util.PixelRectangle;
+import com.jogamp.nativewindow.util.Point;
+import com.jogamp.nativewindow.util.PointImmutable;
+import com.jogamp.nativewindow.util.Rectangle;
+import com.jogamp.nativewindow.util.RectangleImmutable;
import jogamp.common.os.PlatformPropsImpl;
import jogamp.nativewindow.SurfaceScaleUtils;
@@ -102,10 +105,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected Insets insets;
private volatile long offscreenSurfaceLayer;
- private final int[] nativePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- private final int[] hasPixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- protected final int[] reqPixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
-
+ private final float[] minPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
+ private final float[] maxPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
+ private final float[] hasPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
+ private final float[] reqPixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
+ private volatile boolean hasPixelScaleChanged = false;
private long drawable_old;
/**
@@ -268,38 +272,41 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
insets = new Insets();
hasPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
hasPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
- nativePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- nativePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
+ minPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
+ minPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
+ maxPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
+ maxPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
+ hasPixelScaleChanged = false;
}
protected abstract void invalidateNative();
- /**
- * {@inheritDoc}
- * <p>
- * Per default impl. only works for not yet {@link #isRealized() realized} instances,
- * current exception OSX.
- * </p>
- */
@Override
- public void setSurfaceScale(final int[] pixelScale) {
- SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null);
+ public boolean setSurfaceScale(final float[] pixelScale) {
+ System.arraycopy(pixelScale, 0, reqPixelScale, 0, 2);
+ return false;
}
@Override
- public final int[] getRequestedSurfaceScale(final int[] result) {
+ public final float[] getRequestedSurfaceScale(final float[] result) {
System.arraycopy(reqPixelScale, 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) {
- System.arraycopy(nativePixelScale, 0, result, 0, 2);
+ public float[] getMinimumSurfaceScale(final float[] result) {
+ System.arraycopy(minPixelScale, 0, result, 0, 2);
+ return result;
+ }
+
+ @Override
+ public final float[] getMaximumSurfaceScale(final float[] result) {
+ System.arraycopy(maxPixelScale, 0, result, 0, 2);
return result;
}
@@ -322,31 +329,75 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom);
}
}
- {
- final int ps = JAWTUtil.getPixelScale(config.getAWTGraphicsConfiguration());
- nativePixelScale[0] = ps;
- nativePixelScale[1] = ps;
- }
- return updatePixelScale() || changedBounds;
+ updatePixelScale(false);
+ return hasPixelScaleChanged || changedBounds;
+ }
+
+ /**
+ * Updates the minimum and maximum pixel-scale values
+ * and returns {@code true} if they were updated.
+ * @param clearFlag if {@code true}, the {@code hasPixelScaleChanged} flag will be cleared
+ * @return {@code true} if values were updated, otherwise {@code false}.
+ * @see #hasPixelScaleChanged()
+ */
+ public final boolean updatePixelScale(final boolean clearFlag) {
+ // Using GraphicsConfiguration from component, which may change by moving to diff monitor
+ if( EventQueue.isDispatchThread() || Thread.holdsLock(component.getTreeLock()) ) {
+ if( JAWTUtil.getPixelScale(component.getGraphicsConfiguration(), minPixelScale, maxPixelScale) ) {
+ hasPixelScaleChanged = true;
+ if( DEBUG ) {
+ System.err.println("JAWTWindow.updatePixelScale: updated req["+
+ reqPixelScale[0]+", "+reqPixelScale[1]+"], min["+
+ minPixelScale[0]+", "+minPixelScale[1]+"], max["+
+ maxPixelScale[0]+", "+maxPixelScale[1]+"], has["+
+ hasPixelScale[0]+", "+hasPixelScale[1]+"]");
+ }
+ }
+ }
+ if( clearFlag ) {
+ final boolean r = hasPixelScaleChanged;
+ hasPixelScaleChanged = false;
+ return r;
+ } else {
+ return hasPixelScaleChanged;
+ }
+ }
+
+ /**
+ * Returns and clears the {@code hasPixelScaleChanged} flag, as set via {@link #lockSurface()}.
+ * <p>
+ * {@code hasPixelScaleChanged} is {@code true},
+ * if the {@link #getMinimumSurfaceScale(float[]) minimum} or {@link #getMaximumSurfaceScale(float[]) maximum}
+ * pixel scale has changed.
+ * User needs to {@link #setSurfaceScale(float[]) set the current pixel scale} in this case
+ * using the {@link #getRequestedSurfaceScale(float[]) requested pixel scale}
+ * to update the surface pixel scale.
+ * </p>
+ */
+ public final boolean hasPixelScaleChanged() {
+ final boolean v = hasPixelScaleChanged;
+ hasPixelScaleChanged = false;
+ return v;
}
/**
- * Update pixelScale
+ * set requested pixelScale
* @return true if pixelScale has changed, otherwise false
*/
- protected final boolean updatePixelScale() {
- return SurfaceScaleUtils.computePixelScale(hasPixelScale, hasPixelScale, reqPixelScale, nativePixelScale, DEBUG ? getClass().getSimpleName() : null);
+ protected final boolean setReqPixelScale() {
+ updatePixelScale(true);
+ 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 safe pixelScale value for x-direction, i.e. never negative or zero. Updated with lock. */
- protected final int getPixelScaleX() { return hasPixelScale[0]; }
+ 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 int getPixelScaleY() { return hasPixelScale[1]; }
+ protected final float getPixelScaleY() { return hasPixelScale[1]; }
@Override
public final InsetsImmutable getInsets() { return insets; }
@@ -558,7 +609,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
surfaceLock.unlock();
if(DEBUG) {
System.err.println("JAWTWindow: Can't lock surface, component peer n/a. Component displayable "+component.isDisplayable()+", "+component);
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
}
} else {
determineIfApplet();
@@ -670,26 +721,22 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
@Override
public final int getSurfaceWidth() {
- return getWidth() * getPixelScaleX();
+ return SurfaceScaleUtils.scale(getWidth(), getPixelScaleX());
}
@Override
public final int getSurfaceHeight() {
- return getHeight() * getPixelScaleY();
+ return SurfaceScaleUtils.scale(getHeight(), getPixelScaleY());
}
@Override
public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
- pixelUnitsAndResult[0] /= getPixelScaleX();
- pixelUnitsAndResult[1] /= getPixelScaleY();
- return pixelUnitsAndResult;
+ return SurfaceScaleUtils.scaleInv(pixelUnitsAndResult, pixelUnitsAndResult, hasPixelScale);
}
@Override
public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
- windowUnitsAndResult[0] *= getPixelScaleX();
- windowUnitsAndResult[1] *= getPixelScaleY();
- return windowUnitsAndResult;
+ return SurfaceScaleUtils.scale(windowUnitsAndResult, windowUnitsAndResult, hasPixelScale);
}
@Override
@@ -765,7 +812,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
// avoid deadlock ..
if(DEBUG) {
System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock: "+this);
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
}
if( null == storage ) {
storage = new Point();
@@ -788,7 +835,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
if(LOCK_SURFACE_NOT_READY == lockRes) {
if(DEBUG) {
System.err.println("Warning: JAWT Lock couldn't be acquired: "+this);
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
}
return null;
}
@@ -873,7 +920,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
", bounds "+bounds+", insets "+insets
);
sb.append(", window ["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+
- "], pixels[s "+getPixelScaleX()+"x"+getPixelScaleY()+" -> "+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"+
+ "], pixels[scale "+getPixelScaleX()+", "+getPixelScaleY()+" -> "+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"+
", visible "+component.isVisible());
sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
",\n\tconfig "+config+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java
index d21994ea5..04d304cd5 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java
@@ -32,13 +32,16 @@
package com.jogamp.nativewindow.egl;
-import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.*;
+
+import com.jogamp.common.util.VersionNumber;
/** Encapsulates a graphics device on EGL platforms.
*/
public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- final long[] nativeDisplayID = new long[1];
- /* final */ EGLDisplayLifecycleCallback eglLifecycleCallback;
+ private final long[] nativeDisplayID = new long[1];
+ private /* final */ EGLDisplayLifecycleCallback eglLifecycleCallback;
+ private VersionNumber eglVersion = VersionNumber.zeroVersion;
/**
* Hack to allow inject a EGL termination call.
@@ -52,9 +55,11 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
* Implementation should issue an <code>EGL.eglGetDisplay(nativeDisplayID)</code>
* inclusive <code>EGL.eglInitialize(eglDisplayHandle, ..)</code> call.
* @param nativeDisplayID in/out array of size 1, passing the requested nativeVisualID, may return a different revised nativeVisualID handle
+ * @param major out array for EGL major version
+ * @param minor out array for EGL minor version
* @return the initialized EGL display ID, or <code>0</code> if not successful
*/
- public long eglGetAndInitDisplay(long[] nativeDisplayID);
+ public long eglGetAndInitDisplay(final long[] nativeDisplayID, final int[] major, final int[] minor);
/**
* Implementation should issue an <code>EGL.eglTerminate(eglDisplayHandle)</code> call.
@@ -79,6 +84,9 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
this.eglLifecycleCallback = eglLifecycleCallback;
}
+ /** EGL server version as returned by {@code eglInitialize(..)}. Only valid after {@link #open()}. */
+ public VersionNumber getEGLVersion() { return eglVersion; }
+
public long getNativeDisplayID() { return nativeDisplayID[0]; }
@Override
@@ -98,11 +106,16 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
if(DEBUG) {
System.err.println(Thread.currentThread().getName() + " - EGLGraphicsDevice.open(): "+this);
}
- handle = eglLifecycleCallback.eglGetAndInitDisplay(nativeDisplayID);
+ final int[] major = { 0 };
+ final int[] minor = { 0 };
+ handle = eglLifecycleCallback.eglGetAndInitDisplay(nativeDisplayID, major, minor);
if(0 == handle) {
+ eglVersion = VersionNumber.zeroVersion;
throw new NativeWindowException("EGLGraphicsDevice.open() failed: "+this);
+ } else {
+ eglVersion = new VersionNumber(major[0], minor[0], 0);
+ return true;
}
- return true;
}
return false;
}
@@ -142,5 +155,10 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
eglLifecycleCallback = (EGLDisplayLifecycleCallback) newOwnership;
return oldOwnership;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+"[type "+getType()+", v"+eglVersion+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]";
+ }
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java
index ff149447e..ce7ea858c 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java
@@ -32,7 +32,7 @@
package com.jogamp.nativewindow.macosx;
-import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.*;
/** Encapsulates a graphics device on MacOSX platforms.
*/
diff --git a/src/nativewindow/classes/javax/media/nativewindow/package.html b/src/nativewindow/classes/com/jogamp/nativewindow/package.html
index 3fe42bab0..1fe52eea4 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/package.html
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/package.html
@@ -22,22 +22,22 @@
However, any other native windowing system may be added to the implementation,
using a generic string identifier and an optional specialisation of:
<ul>
- <li>{@link javax.media.nativewindow.AbstractGraphicsDevice AbstractGraphicsDevice},
- <p>Shall return the new string identifier with {@link javax.media.nativewindow.AbstractGraphicsDevice#getType() getType()}</p></li>
- <li>{@link javax.media.nativewindow.AbstractGraphicsScreen AbstractGraphicsScreen}</li>
- <li>{@link javax.media.nativewindow.AbstractGraphicsConfiguration AbstractGraphicsConfiguration}</li>
+ <li>{@link com.jogamp.nativewindow.AbstractGraphicsDevice AbstractGraphicsDevice},
+ <p>Shall return the new string identifier with {@link com.jogamp.nativewindow.AbstractGraphicsDevice#getType() getType()}</p></li>
+ <li>{@link com.jogamp.nativewindow.AbstractGraphicsScreen AbstractGraphicsScreen}</li>
+ <li>{@link com.jogamp.nativewindow.AbstractGraphicsConfiguration AbstractGraphicsConfiguration}</li>
</ul>
<p>The implementor has to provide the following:</p>
<ul>
- <li> The specialisation of the abstract class {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}
- <p>shall be registered with {@link javax.media.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.</p></li>
+ <li> The specialisation of the abstract class {@link com.jogamp.nativewindow.NativeWindowFactory NativeWindowFactory}
+ <p>shall be registered with {@link com.jogamp.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.</p></li>
- <li> The specialisation of the abstract class {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
- <p>shall be registered with {@link javax.media.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</p></li>
+ <li> The specialisation of the abstract class {@link com.jogamp.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
+ <p>shall be registered with {@link com.jogamp.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</p></li>
</ul>
<p>This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native surface to an implementation of
- and window to an implementation of {@link javax.media.nativewindow.NativeSurface NativeSurface}.</p>
- <p>{@link javax.media.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.</p>
+ and window to an implementation of {@link com.jogamp.nativewindow.NativeSurface NativeSurface}.</p>
+ <p>{@link com.jogamp.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.</p>
<p>However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.</p>
<h3>Dependencies</h3>
@@ -62,30 +62,30 @@
<h3>Package Structure</h3>
The packages defined by this specification include:
<ul>
- <li>The <b>javax.media.nativewindow</b> package
+ <li>The <b>com.jogamp.nativewindow</b> package
<p>This package contains Java bindings for a native windowing system.</p>
<p>Subsequent packages contain marker type classes, containing native characteristics of the windowing system.</p>
<ul>
- <li>The <b>javax.media.nativewindow.awt</b> package
+ <li>The <b>com.jogamp.nativewindow.awt</b> package
<p>This sub package contains classes to cover the native characteristics of the AWT windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.x11</b> package
+ <li>The <b>com.jogamp.nativewindow.x11</b> package
<p>This sub package contains classes to cover the native characteristics of the X11 windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.windows</b> package
+ <li>The <b>com.jogamp.nativewindow.windows</b> package
<p>This sub package contains classes to cover the native characteristics of the Windows windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.macosx</b> package
+ <li>The <b>com.jogamp.nativewindow.macosx</b> package
<p>This sub package contains classes to cover the native characteristics of the MacOSX windowing system.</p></li>
- <li>The <b>javax.media.nativewindow.egl</b> package
+ <li>The <b>com.jogamp.nativewindow.egl</b> package
<p>This sub package contains classes to cover the native characteristics of the EGL/OpenKODE windowing system.</p></li>
</ul></li>
</ul>
<h3>Factory Model</h3>
<p>Running on a platform with a supported windowing system, the factory model shall be used
-to instantiate a native window, see {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}.</p>
+to instantiate a native window, see {@link com.jogamp.nativewindow.NativeWindowFactory NativeWindowFactory}.</p>
<h3>Revision History</h3>
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
index d29e2abbc..b10b12128 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
@@ -37,11 +37,11 @@ import org.eclipse.swt.graphics.GCData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
-import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.VisualIDHolder;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
+import com.jogamp.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.NativeWindowFactory;
+import com.jogamp.nativewindow.VisualIDHolder;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionNumber;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Dimension.java
index 4c9672c26..28c5dd90e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Dimension.java
@@ -27,7 +27,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
public class Dimension implements Cloneable, DimensionImmutable {
int width;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/DimensionImmutable.java
index e6cacf4ff..6de77a716 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/DimensionImmutable.java
@@ -27,7 +27,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
import com.jogamp.common.type.WriteCloneable;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Insets.java
index 5ec4c758f..205e18346 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Insets.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
/**
* Mutable insets representing rectangular window decoration insets on all four edges
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/InsetsImmutable.java
index 0f8ba0158..e626a507e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/InsetsImmutable.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
import com.jogamp.common.type.WriteCloneable;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
new file mode 100644
index 000000000..8b1e91564
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
@@ -0,0 +1,739 @@
+/**
+ * Copyright (c) 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import java.util.Arrays;
+
+import com.jogamp.common.util.IntBitfield;
+
+/**
+ * Basic pixel formats
+ * <p>
+ * Notation follows OpenGL notation, i.e.
+ * name consist of all it's component names
+ * followed by their bit size.
+ * </p>
+ * <p>
+ * Order of component names is from lowest-bit to highest-bit.
+ * </p>
+ * <p>
+ * In case component-size is 1 byte (e.g. OpenGL data-type GL_UNSIGNED_BYTE),
+ * component names are ordered from lowest-byte to highest-byte.
+ * Note that OpenGL applies special interpretation if
+ * data-type is e.g. GL_UNSIGNED_8_8_8_8_REV or GL_UNSIGNED_8_8_8_8_REV.
+ * </p>
+ * <p>
+ * PixelFormat can be converted to OpenGL GLPixelAttributes
+ * via
+ * <pre>
+ * GLPixelAttributes glpa = GLPixelAttributes.convert(PixelFormat pixFmt, GLProfile glp);
+ * </pre>
+ * </p>
+ * <p>
+ * See OpenGL Specification 4.3 - February 14, 2013, Core Profile,
+ * Section 8.4.4 Transfer of Pixel Rectangles, p. 161-174.
+ * </ul>
+ *
+ * </p>
+ */
+public enum PixelFormat {
+ /**
+ * Stride is 8 bits, 8 bits per pixel, 1 component of 8 bits.
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_ALPHA (< GL3), GL_RED (>= GL3), data-type GL_UNSIGNED_BYTE</li>
+ * <li>AWT: <i>none</i></li>
+ * </ul>
+ * </p>
+ */
+ LUMINANCE(new CType[]{ CType.Y }, 1, 8, 8),
+
+ /**
+ * Stride is 16 bits, 16 bits per pixel, 3 {@link PackedComposition#isUniform() discrete} components.
+ * <p>
+ * The {@link PackedComposition#isUniform() discrete} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>R: 0x1F << 0</li>
+ * <li>G: 0x3F << 5</li>
+ * <li>B: 0x1F << 11</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGB, data-type GL_UNSIGNED_SHORT_5_6_5_REV</li>
+ * <li>AWT: <i>None</i></li>
+ * </ul>
+ * </p>
+ */
+ RGB565(new CType[]{ CType.R, CType.G, CType.B },
+ new int[]{ 0x1F, 0x3F, 0x1F },
+ new int[]{ 0, 5, 5+6 },
+ 16 ),
+
+ /**
+ * Stride is 16 bits, 16 bits per pixel, 3 {@link PackedComposition#isUniform() discrete} components.
+ * <p>
+ * The {@link PackedComposition#isUniform() discrete} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>B: 0x1F << 0</li>
+ * <li>G: 0x3F << 5</li>
+ * <li>R: 0x1F << 11</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGB, data-type GL_UNSIGNED_SHORT_5_6_5</li>
+ * <li>AWT: <i>None</i></li>
+ * </ul>
+ * </p>
+ */
+ BGR565(new CType[]{ CType.B, CType.G, CType.R},
+ new int[]{ 0x1F, 0x3F, 0x1F },
+ new int[]{ 0, 5, 5+6 },
+ 16 ),
+
+ /**
+ * Stride is 16 bits, 16 bits per pixel, 4 {@link PackedComposition#isUniform() discrete} components.
+ * <p>
+ * The {@link PackedComposition#isUniform() discrete} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>R: 0x1F << 0</li>
+ * <li>G: 0x1F << 5</li>
+ * <li>B: 0x1F << 10</li>
+ * <li>A: 0x01 << 15</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_SHORT_1_5_5_5_REV</li>
+ * <li>AWT: <i>None</i></li>
+ * </ul>
+ * </p>
+ */
+ RGBA5551(new CType[]{ CType.R, CType.G, CType.B, CType.A},
+ new int[]{ 0x1F, 0x1F, 0x1F, 0x01 },
+ new int[]{ 0, 5, 5+5, 5+5+5 },
+ 16 ),
+
+ /**
+ * Stride is 16 bits, 16 bits per pixel, 4 {@link PackedComposition#isUniform() discrete} components.
+ * <p>
+ * The {@link PackedComposition#isUniform() discrete} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>A: 0x01 << 0</li>
+ * <li>B: 0x1F << 1</li>
+ * <li>G: 0x1F << 6</li>
+ * <li>R: 0x1F << 11</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_SHORT_5_5_5_1</li>
+ * <li>AWT: <i>None</i></li>
+ * </ul>
+ * </p>
+ */
+ ABGR1555(new CType[]{ CType.A, CType.B, CType.G, CType.R },
+ new int[]{ 0x01, 0x1F, 0x1F, 0x1F },
+ new int[]{ 0, 1, 1+5, 1+5+5 },
+ 16 ),
+
+ /**
+ * Stride 24 bits, 24 bits per pixel, 3 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>R: 0xFF << 0</li>
+ * <li>G: 0xFF << 8</li>
+ * <li>B: 0xFF << 16</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGB, data-type GL_UNSIGNED_BYTE</li>
+ * <li>AWT: <i>None</i></li>
+ * </ul>
+ * </p>
+ */
+ RGB888(new CType[]{ CType.R, CType.G, CType.B }, 3, 8, 24),
+
+ /**
+ * Stride is 24 bits, 24 bits per pixel, 3 {@link PackedComposition#isUniform() uniform} components of of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>B: 0xFF << 0</li>
+ * <li>G: 0xFF << 8</li>
+ * <li>R: 0xFF << 16</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_BGR (>= GL2), data-type GL_UNSIGNED_BYTE</li>
+ * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_3BYTE_BGR TYPE_3BYTE_BGR}</li>
+ * </ul>
+ * </p>
+ */
+ BGR888(new CType[]{ CType.B, CType.G, CType.R }, 3, 8, 24),
+
+ /**
+ * Stride is 32 bits, 24 bits per pixel, 3 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>R: 0xFF << 0</li>
+ * <li>G: 0xFF << 8</li>
+ * <li>B: 0xFF << 16</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_BYTE, with alpha discarded!</li>
+ * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}</li>
+ * </ul>
+ * </p>
+ */
+ RGBx8888(new CType[]{ CType.R, CType.G, CType.B }, 3, 8, 32),
+
+ /**
+ * Stride is 32 bits, 24 bits per pixel, 3 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>B: 0xFF << 0</li>
+ * <li>G: 0xFF << 8</li>
+ * <li>R: 0xFF << 16</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_BGRA, data-type GL_UNSIGNED_BYTE - with alpha discarded!</li>
+ * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_INT_RGB TYPE_INT_RGB}</li>
+ * </ul>
+ * </p>
+ */
+ BGRx8888(new CType[]{ CType.B, CType.G, CType.R }, 3, 8, 32),
+
+ /**
+ * Stride is 32 bits, 32 bits per pixel, 4 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>R: 0xFF << 0</li>
+ * <li>G: 0xFF << 8</li>
+ * <li>B: 0xFF << 16</li>
+ * <li>A: 0xFF << 24</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_BYTE</li>
+ * <li>AWT: <i>None</i></li>
+ * <li>PointerIcon: OSX (NSBitmapImageRep)</li>
+ * <li>Window Icon: OSX (NSBitmapImageRep)</li>
+ * <li>PNGJ: Scanlines</li>
+ * </ul>
+ * </p>
+ */
+ RGBA8888(new CType[]{ CType.R, CType.G, CType.B, CType.A }, 4, 8, 32),
+
+ /**
+ * Stride is 32 bits, 32 bits per pixel, 4 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>A: 0xFF << 0</li>
+ * <li>B: 0xFF << 8</li>
+ * <li>G: 0xFF << 16</li>
+ * <li>R: 0xFF << 24</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_INT_8_8_8_8</li>
+ * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_4BYTE_ABGR TYPE_4BYTE_ABGR}</li>
+ * </ul>
+ * </p>
+ */
+ ABGR8888(new CType[]{ CType.A, CType.B, CType.G, CType.R }, 4, 8, 32),
+
+ /**
+ * Stride is 32 bits, 32 bits per pixel, 4 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>A: 0xFF << 0</li>
+ * <li>R: 0xFF << 8</li>
+ * <li>G: 0xFF << 16</li>
+ * <li>B: 0xFF << 24</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_BGRA, data-type GL_UNSIGNED_INT_8_8_8_8</li>
+ * <li>AWT: <i>None</i></li>
+ * </ul>
+ * </p>
+ */
+ ARGB8888(new CType[]{ CType.A, CType.R, CType.G, CType.B }, 4, 8, 32),
+
+ /**
+ * Stride is 32 bits, 32 bits per pixel, 4 {@link PackedComposition#isUniform() uniform} components of 8 bits.
+ * <p>
+ * The {@link PackedComposition#isUniform() uniform} {@link PixelFormat#composition components}
+ * are interleaved in the order Low to High:
+ * <ol>
+ * <li>B: 0xFF << 0</li>
+ * <li>G: 0xFF << 8</li>
+ * <li>R: 0xFF << 16</li>
+ * <li>A: 0xFF << 24</li>
+ * </ol>
+ * </p>
+ * <p>
+ * Compatible with:
+ * <ul>
+ * <li>OpenGL: data-format GL_BGRA, data-type GL_UNSIGNED_BYTE</li>
+ * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}</li>
+ * <li>PointerIcon: X11 (XCURSOR), Win32, AWT</li>
+ * <li>Window Icon: X11, Win32</li>
+ * </ul>
+ * </p>
+ */
+ BGRA8888(new CType[]{ CType.B, CType.G, CType.R, CType.A }, 4, 8, 32);
+
+ /** Unique {@link Composition Pixel Composition}, i.e. layout of its components. */
+ public final Composition comp;
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link Composition#componentBitMask()}.
+ * @param componentCount number of components
+ * @param bpc bits per component
+ * @param bitStride stride bits to next pixel
+ */
+ private PixelFormat(final CType[] componentOrder, final int componentCount, final int bpc, final int bitStride) {
+ this.comp = new PackedComposition(componentOrder, componentCount, bpc, bitStride);
+ }
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link Composition#componentBitMask()}.
+ * @param componentMask bit-mask of of all components, see {@link Composition##componentBitMask()}.
+ * @param componentBitShift bit-shift of all components, see {@link Composition##componentBitMask()}.
+ * @param bitStride stride bits to next pixel
+ */
+ private PixelFormat(final CType[] componentOrder, final int[] componentMask, final int[] componentBitShift, final int bitStride) {
+ this.comp = new PackedComposition(componentOrder, componentMask, componentBitShift, bitStride);
+ }
+
+ /**
+ * Returns the unique matching {@link PixelFormat} of the given {@link Composition}
+ * or {@code null} if none is available.
+ */
+ public static PixelFormat valueOf(final Composition comp) {
+ final PixelFormat[] all = PixelFormat.values();
+ for(int i=all.length-1; i>=0; i--) {
+ final PixelFormat pf = all[i];
+ if( comp.hashCode() == pf.comp.hashCode() && comp.equals(pf.comp) ) {
+ return pf;
+ }
+ }
+ return null;
+ }
+
+ /** Component types */
+ public static enum CType {
+ /** Red component */
+ R,
+ /** Green component */
+ G,
+ /** Blue component */
+ B,
+ /** Alpha component */
+ A,
+ /** Luminance component, e.g. grayscale or Y of YUV */
+ Y,
+ /** U component of YUV */
+ U,
+ /** V component of YUV */
+ V;
+ }
+
+ /**
+ * Pixel composition, i.e. layout of its components.
+ */
+ public static interface Composition {
+ /** {@value} */
+ public static final int UNDEF = -1;
+
+ /**
+ * Returns {@code true} if all components are of same bit-size, e.g. {@link PixelFormat#RGBA8888 RGBA8888},
+ * otherwise {@code false}, e.g. {@link PixelFormat#RGBA5551 RGBA5551}
+ */
+ boolean isUniform();
+
+ /**
+ * Returns {@code true} if all components are packed, i.e. interleaved, e.g. {@link PixelFormat#RGBA8888 RGBA8888},
+ * otherwise {@code false}.
+ */
+ boolean isInterleaved();
+
+ /** Number of components per pixel, e.g. 3 for {@link PixelFormat#RGBx8888 RGBx8888}. */
+ int componenCount();
+ /** Number of bits per pixel, e.g. 24 bits for {@link PixelFormat#RGBx8888 RGBx8888}. */
+ int bitsPerPixel();
+ /**
+ * Bit distance between pixels.
+ * <p>
+ * For packed pixels e.g. 32 bits for {@link PixelFormat#RGBx8888 RGBx8888}.
+ * </p>
+ */
+ int bitStride();
+ /** Number of bytes per pixel, i.e. packed {@link #bitStride()} in bytes, e.g. 4 for {@link PixelFormat#RGBx8888 RGBx8888}. */
+ int bytesPerPixel();
+ /**
+ * Returns the {@link CType Component type} order of all components, see {@link #componentBitMask()}.
+ */
+ CType[] componentOrder();
+ /**
+ * Returns the index of given {@link CType} within {@link #componentOrder()}, -1 if not exists.
+ */
+ int find(final PixelFormat.CType s);
+ /**
+ * Returns the un-shifted bit-mask of all components.
+ * <p>
+ * Components mask is returned in the order Low-Index to High-Index, e.g.:
+ * <ul>
+ * <li>{@link PixelFormat#RGB565 RGB565}: 0: R 0x1F, 1: G 0x3F, 2: B 0x1F</li>
+ * <li>{@link PixelFormat#RGBA5551 RGBA5551}: 0: R 0x1F, 1: G 0x1F, 2: B 0x1F, 3: A 0x01</li>
+ * <li>{@link PixelFormat#RGBA8888 RGBA8888}: 0: R 0xFF, 1: G 0xFF, 2: B 0xFF, 3: A 0xFF</li>
+ * </ul>
+ * </p>
+ * <p>
+ */
+ int[] componentBitMask();
+ /**
+ * Returns the number of bits of all components, see {@link #componentBitMask()}.
+ */
+ int[] componentBitCount();
+ /**
+ * Returns the bit-shift of all components, see {@link #componentBitMask()}.
+ */
+ int[] componentBitShift();
+
+ /**
+ * Decodes a component from the shifted pixel data with a {@link #bytesPerPixel()} of up to 32bit.
+ * @param shifted complete pixel encoded into on 32bit integer
+ * @param cIdx the desired component index
+ * @return the decoded component value
+ */
+ int decodeSingleI32(final int shifted, final int cIdx);
+ /**
+ * Decodes a component from the shifted pixel data with a {@link #bytesPerPixel()} of up to 64bit.
+ * @param shifted complete pixel encoded into on 64bit integer
+ * @param cIdx the desired component index
+ * @return the decoded component value
+ */
+ int decodeSingleI64(final long shifted, final int cIdx);
+
+ int encodeSingleI32(final int norm, final int cIdx);
+ long encodeSingleI64(final int norm, final int cIdx);
+
+ int encode3CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32);
+ int encode4CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32, final int c4NormI32);
+
+ int encodeSingleI8(final byte normalI8, final int cIdx);
+ int encode3CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8);
+ int encode4CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8, final byte c4NormI8);
+
+ float toFloat(final int i32, final int cIdx, final boolean i32Shifted);
+ int fromFloat(final float f, final int cIdx, final boolean shiftResult);
+
+ int defaultValue(final int cIdx, final boolean shiftResult);
+
+ /**
+ * Returns cached immutable hash value, see {@link Object#hashCode()}.
+ */
+ int hashCode();
+ /**
+ * Returns {@link Object#equals(Object)}
+ */
+ boolean equals(final Object o);
+
+ /**
+ * Returns {@link Object#toString()}.
+ */
+ String toString();
+ }
+
+ /**
+ * Packed pixel composition, see {@link Composition}.
+ * <p>
+ * Components are interleaved, i.e. packed.
+ * </p>
+ */
+ public static class PackedComposition implements Composition {
+ private final CType[] compOrder;
+ private final int[] compMask;
+ private final int[] compBitCount;
+ private final int[] compBitShift;
+ private final int bitsPerPixel;
+ private final int bitStride;
+ private final boolean uniform;
+ private final int hashCode;
+
+ public final String toString() {
+ return String.format("PackedComp[order %s, stride %d, bpp %d, uni %b, comp %d: %s]",
+ Arrays.toString(compOrder), bitStride, bitsPerPixel, uniform,
+ compMask.length, toHexString(compBitCount, compMask, compBitShift));
+ }
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link #componentBitMask()}.
+ * @param componentCount number of components
+ * @param bpc bits per component
+ * @param bitStride stride bits to next pixel
+ */
+ public PackedComposition(final CType[] componentOrder, final int componentCount, final int bpc, final int bitStride) {
+ this.compOrder = componentOrder;
+ this.compMask = new int[componentCount];
+ this.compBitShift = new int[componentCount];
+ this.compBitCount = new int[componentCount];
+ final int compMask = ( 1 << bpc ) - 1;
+ for(int i=0; i<componentCount; i++) {
+ this.compMask[i] = compMask;
+ this.compBitShift[i] = bpc * i;
+ this.compBitCount[i] = bpc;
+ }
+ this.uniform = true;
+ this.bitsPerPixel = bpc * componentCount;
+ this.bitStride = bitStride;
+ if( this.bitStride < this.bitsPerPixel ) {
+ throw new IllegalArgumentException(String.format("bit-stride %d < bitsPerPixel %d", this.bitStride, this.bitsPerPixel));
+ }
+ this.hashCode = hashCodeImpl();
+ }
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link #componentBitMask()}.
+ * @param componentMask bit-mask of of all components, see {@link #componentBitMask()}.
+ * @param componentBitShift bit-shift of all components, see {@link #componentBitMask()}.
+ * @param bitStride stride bits to next pixel
+ */
+ public PackedComposition(final CType[] componentOrder, final int[] componentMask, final int[] componentBitShift, final int bitStride) {
+ this.compOrder = componentOrder;
+ this.compMask = componentMask;
+ this.compBitShift = componentBitShift;
+ this.compBitCount = new int[componentMask.length];
+ int bpp = 0;
+ boolean uniform = true;
+ for(int i = componentMask.length-1; i>=0; i--) {
+ final int cmask = componentMask[i];
+ final int bitCount = IntBitfield.getBitCount(cmask);
+ bpp += bitCount;
+ this.compBitCount[i] = bitCount;
+ if( i > 0 && uniform ) {
+ uniform = componentMask[i-1] == cmask;
+ }
+ }
+ this.uniform = uniform;
+ this.bitsPerPixel = bpp;
+ this.bitStride = bitStride;
+ if( this.bitStride < this.bitsPerPixel ) {
+ throw new IllegalArgumentException(String.format("bit-stride %d < bitsPerPixel %d", this.bitStride, this.bitsPerPixel));
+ }
+ this.hashCode = hashCodeImpl();
+ }
+
+ @Override
+ public final boolean isUniform() { return uniform; }
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Instances of {@link PackedComposition} returns {@code true}.
+ * </p>
+ */
+ @Override
+ public final boolean isInterleaved() { return true; }
+ @Override
+ public final int componenCount() { return compMask.length; }
+ @Override
+ public final int bitsPerPixel() { return bitsPerPixel; }
+ @Override
+ public final int bitStride() { return bitStride; }
+ @Override
+ public final int bytesPerPixel() { return (7+bitStride)/8; }
+ @Override
+ public final CType[] componentOrder() { return compOrder; }
+ @Override
+ public final int find(final PixelFormat.CType s) { return PixelFormatUtil.find(s, compOrder, false /* mapRGB2Y */); }
+ @Override
+ public final int[] componentBitMask() { return compMask; }
+ @Override
+ public final int[] componentBitCount() { return compBitCount; }
+ @Override
+ public final int[] componentBitShift() { return compBitShift; }
+
+ @Override
+ public final int decodeSingleI32(final int shifted, final int cIdx) {
+ return ( shifted >>> compBitShift[cIdx] ) & compMask[cIdx];
+ }
+ @Override
+ public final int decodeSingleI64(final long shifted, final int cIdx) {
+ return ( (int)( 0xffffffffL & ( shifted >>> compBitShift[cIdx] ) ) ) & compMask[cIdx];
+ }
+ @Override
+ public final int encodeSingleI32(final int norm, final int cIdx) {
+ return ( norm & compMask[cIdx] ) << compBitShift[cIdx] ;
+ }
+ @Override
+ public final long encodeSingleI64(final int norm, final int cIdx) {
+ return ( 0xffffffffL & ( norm & compMask[cIdx] ) ) << compBitShift[cIdx] ;
+ }
+ @Override
+ public final int encode3CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32) {
+ return ( c1NormI32 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI32 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI32 & compMask[2] ) << compBitShift[2] ;
+ }
+ @Override
+ public final int encode4CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32, final int c4NormI32) {
+ return ( c1NormI32 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI32 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI32 & compMask[2] ) << compBitShift[2] |
+ ( c4NormI32 & compMask[3] ) << compBitShift[3] ;
+ }
+ @Override
+ public final int encodeSingleI8(final byte normI8, final int cIdx) {
+ return ( normI8 & compMask[cIdx] ) << compBitShift[cIdx] ;
+ }
+ @Override
+ public final int encode3CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8) {
+ return ( c1NormI8 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI8 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI8 & compMask[2] ) << compBitShift[2] ;
+ }
+ @Override
+ public final int encode4CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8, final byte c4NormI8) {
+ return ( c1NormI8 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI8 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI8 & compMask[2] ) << compBitShift[2] |
+ ( c4NormI8 & compMask[3] ) << compBitShift[3] ;
+ }
+
+ @Override
+ public final float toFloat(final int i32, final int cIdx, final boolean i32Shifted) {
+ if( i32Shifted ) {
+ return ( ( i32 >>> compBitShift[cIdx] ) & compMask[cIdx] ) / (float)( compMask[cIdx] ) ;
+ } else {
+ return ( i32 & compMask[cIdx] ) / (float)( compMask[cIdx] ) ;
+ }
+ }
+ @Override
+ public final int fromFloat(final float f, final int cIdx, final boolean shiftResult) {
+ final int v = (int)(f * compMask[cIdx] + 0.5f);
+ return shiftResult ? v << compBitShift[cIdx] : v;
+ }
+
+ @Override
+ public final int defaultValue(final int cIdx, final boolean shiftResult) {
+ final int v = ( CType.A == compOrder[cIdx] || CType.Y == compOrder[cIdx] )
+ ? compMask[cIdx] : 0;
+ return shiftResult ? v << compBitShift[cIdx] : v;
+ }
+
+ @Override
+ public final int hashCode() { return hashCode; }
+ private final int hashCodeImpl() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + bitStride;
+ hash = ((hash << 5) - hash) + bitsPerPixel;
+ hash = ((hash << 5) - hash) + compMask.length;
+ for(int i=compOrder.length-1; i>=0; i--) {
+ hash = ((hash << 5) - hash) + compOrder[i].ordinal();
+ }
+ for(int i=compMask.length-1; i>=0; i--) {
+ hash = ((hash << 5) - hash) + compMask[i];
+ }
+ for(int i=compBitShift.length-1; i>=0; i--) {
+ hash = ((hash << 5) - hash) + compBitShift[i];
+ }
+ return hash;
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if( obj instanceof PackedComposition ) {
+ final PackedComposition other = (PackedComposition) obj;
+ return bitStride == other.bitStride &&
+ bitsPerPixel == other.bitsPerPixel &&
+ Arrays.equals(compOrder, other.compOrder) &&
+ Arrays.equals(compMask, other.compMask) &&
+ Arrays.equals(compBitShift, other.compBitShift);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ private static String toHexString(final int[] bitCount, final int[] mask, final int[] shift) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("[");
+ final int l = mask.length;
+ for(int i=0; i < l; i++) {
+ if(i > 0) {
+ sb.append(", ");
+ }
+ sb.append(bitCount[i]).append(": ").
+ append("0x").append(Integer.toHexString(mask[i])).append(" << ").append(shift[i]);
+ }
+ return sb.append("]").toString();
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
new file mode 100644
index 000000000..180f02d72
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
@@ -0,0 +1,600 @@
+/**
+ * Copyright (c) 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.nativewindow.util;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.Bitstream;
+
+/**
+ * Pixel Rectangle Utilities.
+ * <p>
+ * All conversion methods are endian independent.
+ * </p>
+ */
+public class PixelFormatUtil {
+ private static boolean DEBUG = false;
+
+ public static class ComponentMap {
+ /**
+ * Contains the source index for each destination index,
+ * length is {@link Composition#componenCount()} of destination.
+ */
+ final int[] dst2src;
+ /**
+ * Contains the destination index for each source index,
+ * length is {@link Composition#componenCount()} of source.
+ */
+ final int[] src2dst;
+
+ /**
+ * Contains the source index of RGBA components.
+ */
+ final int[] srcRGBA;
+ final boolean hasSrcRGB;
+
+ public ComponentMap(final PixelFormat.Composition src, final PixelFormat.Composition dst) {
+ final int sCompCount = src.componenCount();
+ final int dCompCount = dst.componenCount();
+ final PixelFormat.CType[] sCompOrder = src.componentOrder();
+ final PixelFormat.CType[] dCompOrder = dst.componentOrder();
+
+ dst2src = new int[dCompCount];
+ for(int dIdx=0; dIdx<dCompCount; dIdx++) {
+ dst2src[dIdx] = PixelFormatUtil.find(dCompOrder[dIdx], sCompOrder, true);
+ }
+ src2dst = new int[sCompCount];
+ for(int sIdx=0; sIdx<sCompCount; sIdx++) {
+ src2dst[sIdx] = PixelFormatUtil.find(sCompOrder[sIdx], dCompOrder, true);
+ }
+ srcRGBA = new int[4];
+ srcRGBA[0] = PixelFormatUtil.find(PixelFormat.CType.R, sCompOrder, false);
+ srcRGBA[1] = PixelFormatUtil.find(PixelFormat.CType.G, sCompOrder, false);
+ srcRGBA[2] = PixelFormatUtil.find(PixelFormat.CType.B, sCompOrder, false);
+ srcRGBA[3] = PixelFormatUtil.find(PixelFormat.CType.A, sCompOrder, false);
+ hasSrcRGB = 0 <= srcRGBA[0] && 0 <= srcRGBA[1] && 0 <= srcRGBA[2];
+ }
+ }
+
+ public static final int find(final PixelFormat.CType s,
+ final PixelFormat.CType[] pool, final boolean mapRGB2Y) {
+ int i=pool.length-1;
+ while( i >= 0 && pool[i] != s) { i--; }
+
+ if( 0 > i && mapRGB2Y && 1 == pool.length && pool[0] == PixelFormat.CType.Y &&
+ ( PixelFormat.CType.R == s ||
+ PixelFormat.CType.G == s ||
+ PixelFormat.CType.B == s ) )
+ {
+ // Special case, fallback for RGB mapping -> LUMINANCE/Y
+ return 0;
+ } else {
+ return i;
+ }
+ }
+
+ /**
+ * Returns shifted bytes from the given {@code data} at given {@code offset}
+ * of maximal 4 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param offset byte offset of pixel {@code data} start
+ * @return the shifted 32bit integer value of the pixel
+ */
+ public static int getShiftedI32(final int bytesPerPixel, final byte[] data, final int offset) {
+ if( bytesPerPixel <= 4 ) {
+ int shiftedI32 = 0;
+ for(int i=0; i<bytesPerPixel; i++) {
+ shiftedI32 |= ( 0xff & data[offset+i] ) << 8*i;
+ }
+ return shiftedI32;
+ } else {
+ throw new UnsupportedOperationException(bytesPerPixel+" bytesPerPixel too big, i.e. > 4");
+ }
+ }
+ /**
+ * Returns shifted bytes from the given {@code data} at given {@code offset}
+ * of maximal 8 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param offset byte offset of pixel {@code data} start
+ * @return the shifted 64bit integer value of the pixel
+ */
+ public static long getShiftedI64(final int bytesPerPixel, final byte[] data, final int offset) {
+ if( bytesPerPixel <= 8 ) {
+ long shiftedI64 = 0;
+ for(int i=0; i<bytesPerPixel; i++) {
+ shiftedI64 |= ( 0xff & data[offset+i] ) << 8*i;
+ }
+ return shiftedI64;
+ } else {
+ throw new UnsupportedOperationException(bytesPerPixel+" bytesPerPixel too big, i.e. > 8");
+ }
+ }
+ /**
+ * Returns shifted bytes from the given {@code data} at current position
+ * of maximal 4 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param retainDataPos if true, absolute {@link ByteBuffer#get(int)} is used and the {@code data} position stays unchanged.
+ * Otherwise relative {@link ByteBuffer#get()} is used and the {@code data} position changes.
+ * @return the shifted 32bit integer value of the pixel
+ */
+ public static int getShiftedI32(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos) {
+ if( bytesPerPixel <= 4 ) {
+ int shiftedI32 = 0;
+ if( retainDataPos ) {
+ final int offset = data.position();
+ for(int i=0; i<bytesPerPixel; i++) {
+ shiftedI32 |= ( 0xff & data.get(offset+i) ) << 8*i;
+ }
+ } else {
+ for(int i=0; i<bytesPerPixel; i++) {
+ shiftedI32 |= ( 0xff & data.get() ) << 8*i;
+ }
+ }
+ return shiftedI32;
+ } else {
+ throw new UnsupportedOperationException(bytesPerPixel+" bytesPerPixel too big, i.e. > 4");
+ }
+ }
+ /**
+ * Returns shifted bytes from the given {@code data} at current position
+ * of maximal 8 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param retainDataPos if true, absolute {@link ByteBuffer#get(int)} is used and the {@code data} position stays unchanged.
+ * Otherwise relative {@link ByteBuffer#get()} is used and the {@code data} position changes.
+ * @return the shifted 64bit integer value of the pixel
+ */
+ public static long getShiftedI64(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos) {
+ if( bytesPerPixel <= 8 ) {
+ long shiftedI64 = 0;
+ if( retainDataPos ) {
+ final int offset = data.position();
+ for(int i=0; i<bytesPerPixel; i++) {
+ shiftedI64 |= ( 0xff & data.get(offset+i) ) << 8*i;
+ }
+ } else {
+ for(int i=0; i<bytesPerPixel; i++) {
+ shiftedI64 |= ( 0xff & data.get() ) << 8*i;
+ }
+ }
+ return shiftedI64;
+ } else {
+ throw new UnsupportedOperationException(bytesPerPixel+" bytesPerPixel too big, i.e. > 8");
+ }
+ }
+
+ /**
+ * Returns the {@link PixelFormat} with reversed components of <code>fmt</code>.
+ * If no reversed {@link PixelFormat} is available, returns <code>fmt</code>.
+ */
+ public static PixelFormat getReversed(final PixelFormat fmt) {
+ switch(fmt) {
+ case RGB565:
+ return PixelFormat.BGR565;
+ case BGR565:
+ return PixelFormat.RGB565;
+ case RGBA5551:
+ return PixelFormat.ABGR1555;
+ case ABGR1555:
+ return PixelFormat.RGBA5551;
+ case RGB888:
+ return PixelFormat.BGR888;
+ case BGR888:
+ return PixelFormat.RGB888;
+ case RGBA8888:
+ return PixelFormat.ABGR8888;
+ case ABGR8888:
+ return PixelFormat.RGBA8888;
+ case ARGB8888:
+ return PixelFormat.BGRA8888;
+ case BGRA8888:
+ return PixelFormat.ABGR8888;
+ default:
+ return fmt;
+ }
+ }
+
+ public static int convertToInt32(final PixelFormat dst_fmt, final byte r, final byte g, final byte b, final byte a) {
+ switch(dst_fmt) {
+ case LUMINANCE: {
+ final byte l = ( byte) ( ( ( ( 0xff & r ) + ( 0xff & g ) + ( 0xff & b ) ) / 3 ) * a );
+ return ( 0xff ) << 24 | ( 0xff & l ) << 16 | ( 0xff & l ) << 8 | ( 0xff & l );
+ }
+ case RGB888:
+ return ( 0xff ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
+ case BGR888:
+ return ( 0xff ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
+ case RGBA8888:
+ return ( 0xff & a ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
+ case ABGR8888:
+ return ( 0xff & r ) << 24 | ( 0xff & g ) << 16 | ( 0xff & b ) << 8 | ( 0xff & a );
+ case ARGB8888:
+ return ( 0xff & b ) << 24 | ( 0xff & g ) << 16 | ( 0xff & r ) << 8 | ( 0xff & a );
+ case BGRA8888:
+ return ( 0xff & a ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
+ default:
+ throw new InternalError("Unhandled format "+dst_fmt);
+ }
+ }
+
+ public static int convertToInt32(final PixelFormat dst_fmt, final PixelFormat src_fmt, final ByteBuffer src, int srcOff) {
+ final byte r, g, b, a;
+ switch(src_fmt) {
+ case LUMINANCE:
+ r = src.get(srcOff++); // R
+ g = r; // G
+ b = r; // B
+ a = (byte) 0xff; // A
+ break;
+ case RGB888:
+ r = src.get(srcOff++); // R
+ g = src.get(srcOff++); // G
+ b = src.get(srcOff++); // B
+ a = (byte) 0xff; // A
+ break;
+ case BGR888:
+ b = src.get(srcOff++); // B
+ g = src.get(srcOff++); // G
+ r = src.get(srcOff++); // R
+ a = (byte) 0xff; // A
+ break;
+ case RGBA8888:
+ r = src.get(srcOff++); // R
+ g = src.get(srcOff++); // G
+ b = src.get(srcOff++); // B
+ a = src.get(srcOff++); // A
+ break;
+ case ABGR8888:
+ a = src.get(srcOff++); // A
+ b = src.get(srcOff++); // B
+ g = src.get(srcOff++); // G
+ r = src.get(srcOff++); // R
+ break;
+ case ARGB8888:
+ a = src.get(srcOff++); // A
+ r = src.get(srcOff++); // R
+ g = src.get(srcOff++); // G
+ b = src.get(srcOff++); // B
+ break;
+ case BGRA8888:
+ b = src.get(srcOff++); // B
+ g = src.get(srcOff++); // G
+ r = src.get(srcOff++); // R
+ a = src.get(srcOff++); // A
+ break;
+ default:
+ throw new InternalError("Unhandled format "+src_fmt);
+ }
+ return convertToInt32(dst_fmt, r, g, b, a);
+ }
+
+ public static int convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final int src_pixel) {
+ final byte r, g, b, a;
+ switch(src_fmt) {
+ case LUMINANCE:
+ r = (byte) ( src_pixel ); // R
+ g = r; // G
+ b = r; // B
+ a = (byte) 0xff; // A
+ break;
+ case RGB888:
+ r = (byte) ( src_pixel ); // R
+ g = (byte) ( src_pixel >>> 8 ); // G
+ b = (byte) ( src_pixel >>> 16 ); // B
+ a = (byte) 0xff; // A
+ break;
+ case BGR888:
+ b = (byte) ( src_pixel ); // B
+ g = (byte) ( src_pixel >>> 8 ); // G
+ r = (byte) ( src_pixel >>> 16 ); // R
+ a = (byte) 0xff; // A
+ break;
+ case RGBA8888:
+ r = (byte) ( src_pixel ); // R
+ g = (byte) ( src_pixel >>> 8 ); // G
+ b = (byte) ( src_pixel >>> 16 ); // B
+ a = (byte) ( src_pixel >>> 24 ); // A
+ break;
+ case ABGR8888:
+ a = (byte) ( src_pixel ); // A
+ b = (byte) ( src_pixel >>> 8 ); // B
+ g = (byte) ( src_pixel >>> 16 ); // G
+ r = (byte) ( src_pixel >>> 24 ); // R
+ break;
+ case ARGB8888:
+ a = (byte) ( src_pixel ); // A
+ r = (byte) ( src_pixel >>> 8 ); // R
+ g = (byte) ( src_pixel >>> 16 ); // G
+ b = (byte) ( src_pixel >>> 24 ); // B
+ break;
+ case BGRA8888:
+ b = (byte) ( src_pixel ); // B
+ g = (byte) ( src_pixel >>> 8 ); // G
+ r = (byte) ( src_pixel >>> 16 ); // R
+ a = (byte) ( src_pixel >>> 24 ); // A
+ break;
+ default:
+ throw new InternalError("Unhandled format "+src_fmt);
+ }
+ return convertToInt32(dest_fmt, r, g, b, a);
+ }
+
+ public static PixelRectangle convert(final PixelRectangle src,
+ final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented,
+ final boolean destIsDirect) {
+ final int width = src.getSize().getWidth();
+ final int height = src.getSize().getHeight();
+ final int bpp = destFmt.comp.bytesPerPixel();
+ final int destStride;
+ if( 0 != ddestStride ) {
+ destStride = ddestStride;
+ } else {
+ destStride = bpp * width;
+ }
+ final int capacity = destStride*height;
+ final ByteBuffer destBB = destIsDirect ? Buffers.newDirectByteBuffer(capacity) : ByteBuffer.allocate(capacity).order(src.getPixels().order());
+ convert(src, destBB, destFmt, isGLOriented, destStride);
+ return new PixelRectangle.GenericPixelRect(destFmt, src.getSize(), destStride, isGLOriented, destBB);
+ }
+
+ /**
+ * @param src
+ * @param dst_bb {@link ByteBuffer} sink
+ * @param dst_fmt destination {@link PixelFormat}
+ * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, <i>origin at bottom left</i>,
+ * otherwise <i>origin at top left</i>.
+ * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line to the next.
+ * Must be >= {@link PixelFormat.Composition#bytesPerPixel() dst_fmt.comp.bytesPerPixel()} * width
+ * or {@code zero} for default stride.
+ *
+ * @throws IllegalStateException
+ * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid
+ */
+ public static void convert(final PixelRectangle src,
+ final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, final int dst_lineStride)
+ throws IllegalStateException
+ {
+ convert(src.getSize().getWidth(), src.getSize().getHeight(),
+ src.getPixels(), src.getPixelformat(), src.isGLOriented(), src.getStride(),
+ dst_bb, dst_fmt, dst_glOriented, dst_lineStride);
+ }
+
+
+ /**
+ * @param width width of the to be converted pixel rectangle
+ * @param height height of the to be converted pixel rectangle
+ * @param src_bb {@link ByteBuffer} source
+ * @param src_fmt source {@link PixelFormat}
+ * @param src_glOriented if true, the source memory is laid out in OpenGL's coordinate system, <i>origin at bottom left</i>,
+ * otherwise <i>origin at top left</i>.
+ * @param src_lineStride line stride in byte-size for source, i.e. byte count from one line to the next.
+ * Must be >= {@link PixelFormat.Composition#bytesPerPixel() src_fmt.comp.bytesPerPixel()} * width
+ * or {@code zero} for default stride.
+ * @param dst_bb {@link ByteBuffer} sink
+ * @param dst_fmt destination {@link PixelFormat}
+ * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, <i>origin at bottom left</i>,
+ * otherwise <i>origin at top left</i>.
+ * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line to the next.
+ * Must be >= {@link PixelFormat.Composition#bytesPerPixel() dst_fmt.comp.bytesPerPixel()} * width
+ * or {@code zero} for default stride.
+ *
+ * @throws IllegalStateException
+ * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid
+ */
+ public static void convert(final int width, final int height,
+ final ByteBuffer src_bb, final PixelFormat src_fmt, final boolean src_glOriented, int src_lineStride,
+ final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, int dst_lineStride
+ ) throws IllegalStateException, IllegalArgumentException {
+ final PixelFormat.Composition src_comp = src_fmt.comp;
+ final PixelFormat.Composition dst_comp = dst_fmt.comp;
+ final int src_bpp = src_comp.bytesPerPixel();
+ final int dst_bpp = dst_comp.bytesPerPixel();
+
+ if( 0 != src_lineStride ) {
+ if( src_lineStride < src_bpp * width ) {
+ throw new IllegalArgumentException(String.format("Invalid %s stride %d, must be greater than bytesPerPixel %d * width %d",
+ "source", src_lineStride, src_bpp, width));
+ }
+ } else {
+ src_lineStride = src_bpp * width;
+ }
+ if( 0 != dst_lineStride ) {
+ if( dst_lineStride < dst_bpp * width ) {
+ throw new IllegalArgumentException(String.format("Invalid %s stride %d, must be greater than bytesPerPixel %d * width %d",
+ "destination", dst_lineStride, dst_bpp, width));
+ }
+ } else {
+ dst_lineStride = dst_bpp * width;
+ }
+
+ // final int src_comp_bitStride = src_comp.bitStride();
+ final int dst_comp_bitStride = dst_comp.bitStride();
+ final boolean vert_flip = src_glOriented != dst_glOriented;
+ final boolean fast_copy = src_comp.equals(dst_comp) && 0 == dst_comp_bitStride%8;
+ if( DEBUG ) {
+ System.err.println("XXX: size "+width+"x"+height+", fast_copy "+fast_copy);
+ System.err.println("XXX: SRC fmt "+src_fmt+", "+src_comp+", stride "+src_lineStride+", isGLOrient "+src_glOriented);
+ System.err.println("XXX: DST fmt "+dst_fmt+", "+dst_comp+", stride "+dst_lineStride+", isGLOrient "+dst_glOriented);
+ }
+
+ if( fast_copy ) {
+ // Fast copy
+ for(int y=0; y<height; y++) {
+ int src_off = vert_flip ? ( height - 1 - y ) * src_lineStride : y * src_lineStride;
+ int dst_off = dst_lineStride*y;
+ for(int x=0; x<width; x++) {
+ dst_bb.put(dst_off+0, src_bb.get(src_off+0)); // 1
+ if( 2 <= dst_bpp ) {
+ dst_bb.put(dst_off+1, src_bb.get(src_off+1)); // 2
+ if( 3 <= dst_bpp ) {
+ dst_bb.put(dst_off+2, src_bb.get(src_off+2)); // 3
+ if( 4 <= dst_bpp ) {
+ dst_bb.put(dst_off+3, src_bb.get(src_off+3)); // 4
+ }
+ }
+ }
+ src_off += src_bpp;
+ dst_off += dst_bpp;
+ }
+ }
+ } else {
+ // Conversion
+ final ComponentMap cmap = new ComponentMap(src_fmt.comp, dst_fmt.comp);
+
+ final Bitstream.ByteBufferStream srcBBS = new Bitstream.ByteBufferStream(src_bb);
+ final Bitstream<ByteBuffer> srcBitStream = new Bitstream<ByteBuffer>(srcBBS, false /* outputMode */);
+ srcBitStream.setThrowIOExceptionOnEOF(true);
+
+ final Bitstream.ByteBufferStream dstBBS = new Bitstream.ByteBufferStream(dst_bb);
+ final Bitstream<ByteBuffer> dstBitStream = new Bitstream<ByteBuffer>(dstBBS, true /* outputMode */);
+ dstBitStream.setThrowIOExceptionOnEOF(true);
+
+ if( DEBUG ) {
+ System.err.println("XXX: cmap.dst2src "+Arrays.toString(cmap.dst2src));
+ System.err.println("XXX: cmap.src2dst "+Arrays.toString(cmap.src2dst));
+ System.err.println("XXX: cmap.srcRGBA "+Arrays.toString(cmap.srcRGBA));
+ System.err.println("XXX: srcBitStream "+srcBitStream);
+ System.err.println("XXX: dstBitStream "+dstBitStream);
+ }
+ try {
+ for(int y=0; y<height; y++) {
+ final int src_off = vert_flip ? ( height - 1 - y ) * src_lineStride * 8 : y * src_lineStride * 8;
+ // final int dst_off = dst_lineStride*8*y;
+ srcBitStream.position(src_off);
+ for(int x=0; x<width; x++) {
+ convert(cmap, dst_comp, dstBitStream, src_comp, srcBitStream);
+ }
+ // srcBitStream.skip(( src_lineStride * 8 ) - ( src_comp_bitStride * width ));
+ dstBitStream.skip(( dst_lineStride * 8 ) - ( dst_comp_bitStride * width ));
+ }
+ } catch(final IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ if( DEBUG ) {
+ System.err.println("XXX: srcBitStream "+srcBitStream);
+ System.err.println("XXX: dstBitStream "+dstBitStream);
+ }
+ }
+ }
+
+ public static void convert(final ComponentMap cmap,
+ final PixelFormat.Composition dstComp,
+ final Bitstream<ByteBuffer> dstBitStream,
+ final PixelFormat.Composition srcComp,
+ final Bitstream<ByteBuffer> srcBitStream) throws IllegalStateException, IOException {
+ final int sCompCount = srcComp.componenCount();
+ final int dCompCount = dstComp.componenCount();
+ final int[] sc = new int[sCompCount];
+ final int[] dcDef = new int[dCompCount];
+ final int[] srcCompBitCount = srcComp.componentBitCount();
+ final int[] srcCompBitMask = srcComp.componentBitMask();
+ final int[] dstCompBitCount = dstComp.componentBitCount();
+
+ // Fill w/ source values
+ for(int sIdx=0; sIdx<sCompCount; sIdx++) {
+ sc[sIdx] = srcBitStream.readBits31(srcCompBitCount[sIdx]) & srcCompBitMask[sIdx];
+ }
+ srcBitStream.skip(srcComp.bitStride() - srcComp.bitsPerPixel());
+
+ // Cache missing defaults
+ for(int i=0; i<dCompCount; i++) {
+ dcDef[i] = dstComp.defaultValue(i, false);
+ }
+
+ if( 1 == dCompCount &&
+ PixelFormat.CType.Y == dstComp.componentOrder()[0] &&
+ cmap.hasSrcRGB
+ )
+ {
+ // RGB[A] -> Y conversion
+ final int r = sc[cmap.srcRGBA[0]];
+ final int g = sc[cmap.srcRGBA[1]];
+ final int b = sc[cmap.srcRGBA[2]];
+ final float rF = srcComp.toFloat(r, cmap.srcRGBA[0], false);
+ final float gF = srcComp.toFloat(g, cmap.srcRGBA[1], false);
+ final float bF = srcComp.toFloat(b, cmap.srcRGBA[2], false);
+ final int a;
+ final float aF;
+ /** if( 0 <= cmap.srcRGBA[3] ) { // disable premultiplied-alpha
+ a = sc[cmap.srcRGBA[3]];
+ aF = srcComp.toFloat(a, false, cmap.srcRGBA[3]);
+ } else */ {
+ a = 1;
+ aF = 1f;
+ }
+ final float lF = ( rF + gF + bF ) * aF / 3f;
+ final int v = dstComp.fromFloat(lF, 0, false);
+
+ dstBitStream.writeBits31(dstCompBitCount[0], v);
+ dstBitStream.skip(dstComp.bitStride() - dstComp.bitsPerPixel());
+ if( DEBUG ) {
+ if( srcBitStream.position() <= 8*4 ) {
+ System.err.printf("convert: rgb[a] -> Y: rgb 0x%02X 0x%02X 0x%02X 0x%02X -> %f %f %f %f"+
+ " -> %f -> dstC 0 0x%08X (%d bits: %s)%n",
+ r, g, b, a,
+ rF, gF, bF, aF,
+ lF, v, dstCompBitCount[0], Bitstream.toBinString(true, v, dstCompBitCount[0])
+ );
+ }
+ }
+ return;
+ }
+
+ for(int dIdx=0; dIdx<dCompCount; dIdx++) {
+ int sIdx;
+ if( 0 <= ( sIdx = cmap.dst2src[dIdx] ) ) {
+ final float f = srcComp.toFloat(sc[sIdx], sIdx, false);
+ final int v = dstComp.fromFloat(f, dIdx, false);
+ dstBitStream.writeBits31(dstCompBitCount[dIdx], v);
+ if( DEBUG ) {
+ if( srcBitStream.position() <= 8*4 ) {
+ System.err.printf("convert: srcC %d: 0x%08X -> %f -> dstC %d 0x%08X (%d bits: %s)%n",
+ sIdx, sc[sIdx], f, dIdx, v, dstCompBitCount[dIdx], Bitstream.toBinString(true, v, dstCompBitCount[dIdx]));
+ }
+ }
+ } else {
+ dstBitStream.writeBits31(dstCompBitCount[dIdx], dcDef[dIdx]);
+ if( DEBUG ) {
+ if( srcBitStream.position() <= 8*4 ) {
+ System.err.printf("convert: srcC %d: undef -> dstC %d 0x%08X (%d bits: %s)%n",
+ sIdx, dIdx, dcDef[dIdx], dstCompBitCount[dIdx], Bitstream.toBinString(true, dcDef[dIdx], dstCompBitCount[dIdx]));
+ }
+ }
+ }
+ }
+ dstBitStream.skip(dstComp.bitStride() - dstComp.bitsPerPixel());
+ return;
+ }
+}
+
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelRectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelRectangle.java
index 96c1f7b33..f58ba0ce2 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelRectangle.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelRectangle.java
@@ -25,7 +25,7 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
import java.nio.ByteBuffer;
@@ -113,11 +113,11 @@ public interface PixelRectangle {
throws IllegalArgumentException, IndexOutOfBoundsException
{
if( 0 != strideInBytes ) {
- if( strideInBytes < pixelformat.bytesPerPixel() * size.getWidth()) {
- throw new IllegalArgumentException("Invalid stride "+strideInBytes+", must be greater than bytesPerPixel "+pixelformat.bytesPerPixel()+" * width "+size.getWidth());
+ if( strideInBytes < pixelformat.comp.bytesPerPixel() * size.getWidth()) {
+ throw new IllegalArgumentException("Invalid stride "+strideInBytes+", must be greater than bytesPerPixel "+pixelformat.comp.bytesPerPixel()+" * width "+size.getWidth());
}
} else {
- strideInBytes = pixelformat.bytesPerPixel() * size.getWidth();
+ strideInBytes = pixelformat.comp.bytesPerPixel() * size.getWidth();
}
final int reqBytes = strideInBytes * size.getHeight();
if( pixels.limit() < reqBytes ) {
@@ -148,7 +148,7 @@ public interface PixelRectangle {
synchronized (this) {
if( !hashCodeComputed ) {
// 31 * x == (x << 5) - x
- int hash = 31 + pixelformat.hashCode();
+ int hash = pixelformat.comp.hashCode();
hash = ((hash << 5) - hash) + size.hashCode();
hash = ((hash << 5) - hash) + strideInBytes;
hash = ((hash << 5) - hash) + ( isGLOriented ? 1 : 0);
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Point.java
index 3576a7dd0..fc5465bbf 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Point.java
@@ -27,7 +27,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
public class Point implements Cloneable, PointImmutable {
int x;
@@ -145,6 +145,22 @@ public class Point implements Cloneable, PointImmutable {
}
/**
+ * Scale this instance's x- and y-components,
+ * i.e. multiply them by the given scale factors.
+ * <p>
+ * The product is rounded back to integer.
+ * </p>
+ * @param sx scale factor for x
+ * @param sy scale factor for y
+ * @return this instance for scaling
+ */
+ public final Point scale(final float sx, final float sy) {
+ x = (int)(x * sx + 0.5f);
+ y = (int)(y * sy + 0.5f);
+ return this;
+ }
+
+ /**
* Inverse scale this instance's x- and y-components,
* i.e. divide them by the given scale factors.
* @param sx inverse scale factor for x
@@ -156,4 +172,19 @@ public class Point implements Cloneable, PointImmutable {
y /= sy ;
return this;
}
+ /**
+ * Inverse scale this instance's x- and y-components,
+ * i.e. divide them by the given scale factors.
+ * <p>
+ * The product is rounded back to integer.
+ * </p>
+ * @param sx inverse scale factor for x
+ * @param sy inverse scale factor for y
+ * @return this instance for scaling
+ */
+ public final Point scaleInv(final float sx, final float sy) {
+ x = (int)(x / sx + 0.5f);
+ y = (int)(y / sy + 0.5f);
+ return this;
+ }
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PointImmutable.java
index 08c628cc1..59372f67d 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PointImmutable.java
@@ -27,7 +27,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
import com.jogamp.common.type.WriteCloneable;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java
index c30968c4b..33a1955e8 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
import java.util.List;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/RectangleImmutable.java
index 7ca92ff53..ff2209598 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/RectangleImmutable.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
import com.jogamp.common.type.WriteCloneable;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/SurfaceSize.java
index 601e6dd71..b9e6ded95 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/SurfaceSize.java
@@ -27,12 +27,12 @@
* or implied, of JogAmp Community.
*/
-package javax.media.nativewindow.util;
+package com.jogamp.nativewindow.util;
/**
* Immutable SurfaceSize Class, consisting of it's read only components:<br>
* <ul>
- * <li>{@link javax.media.nativewindow.util.DimensionImmutable size in pixels}</li>
+ * <li>{@link com.jogamp.nativewindow.util.DimensionImmutable size in pixels}</li>
* <li><code>bits per pixel</code></li>
* </ul>
*/
@@ -105,7 +105,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> {
@Override
public final int hashCode() {
// 31 * x == (x << 5) - x
- int hash = 31 + getResolution().hashCode();
+ int hash = getResolution().hashCode();
hash = ((hash << 5) - hash) + getBitsPerPixel();
return hash;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java
index ef0cbddd7..549f4d21e 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java
@@ -32,7 +32,7 @@
package com.jogamp.nativewindow.windows;
-import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.*;
/**
* Encapsulates a graphics device on Windows platforms.<br>
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java
index 223cb5194..04619962d 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java
@@ -33,7 +33,7 @@
package com.jogamp.nativewindow.x11;
-import javax.media.nativewindow.CapabilitiesImmutable;
+import com.jogamp.nativewindow.CapabilitiesImmutable;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
@@ -41,7 +41,7 @@ import jogamp.nativewindow.x11.XVisualInfo;
/** Encapsulates a graphics configuration, or OpenGL pixel format, on
X11 platforms. Objects of this type are returned from {@link
- javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
+ com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
platforms when toolkits other than the AWT are being used. */
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
index fea4e7019..5e706884c 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
@@ -36,10 +36,10 @@ package com.jogamp.nativewindow.x11;
import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.X11Util;
-import javax.media.nativewindow.DefaultGraphicsDevice;
-import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.ToolkitLock;
+import com.jogamp.nativewindow.DefaultGraphicsDevice;
+import com.jogamp.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.NativeWindowFactory;
+import com.jogamp.nativewindow.ToolkitLock;
/** Encapsulates a graphics device on X11 platforms.
*/
@@ -49,7 +49,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
final boolean isXineramaEnabled;
/** Constructs a new X11GraphicsDevice corresponding to the given connection and default
- * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.<br>
+ * {@link com.jogamp.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.<br>
* Note that this is not an open connection, ie no native display handle exist.
* This constructor exist to setup a default device connection.
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int)
@@ -61,7 +61,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
}
/** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default
- * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}.
+ * {@link com.jogamp.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}.
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long)
*/
public X11GraphicsDevice(final long display, final int unitID, final boolean owner) {
@@ -70,7 +70,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
/**
* @param display the Display connection
- * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking w/ private connection
+ * @param locker custom {@link com.jogamp.nativewindow.ToolkitLock}, eg to force null locking w/ private connection
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long, ToolkitLock)
*/
public X11GraphicsDevice(final long display, final int unitID, final ToolkitLock locker, final boolean owner) {
@@ -88,7 +88,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
* The constructor opens the native connection and takes ownership.
* </p>
* @param displayConnection the semantic display connection name
- * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking w/ private connection
+ * @param locker custom {@link com.jogamp.nativewindow.ToolkitLock}, eg to force null locking w/ private connection
* @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long, ToolkitLock)
*/
public X11GraphicsDevice(final String displayConnection, final int unitID, final ToolkitLock locker) {
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java
index 8ebf3c379..82ae92288 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java
@@ -33,16 +33,16 @@
package com.jogamp.nativewindow.x11;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.DefaultGraphicsScreen;
-import javax.media.nativewindow.NativeWindowException;
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
+import com.jogamp.nativewindow.DefaultGraphicsScreen;
+import com.jogamp.nativewindow.NativeWindowException;
import jogamp.nativewindow.x11.X11Lib;
/** Encapsulates a screen index on X11
platforms. Objects of this type are passed to {@link
- javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
+ com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
platforms when toolkits other than the AWT are being used. */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java b/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
deleted file mode 100644
index e5901f584..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- * Copyright (c) 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package javax.media.nativewindow.util;
-
-/**
- * Basic pixel formats
- * <p>
- * Notation follows OpenGL notation, i.e.
- * name consist of all it's component names
- * followed by their bit size.
- * </p>
- * <p>
- * Order of component names is from lowest-bit to highest-bit.
- * </p>
- * <p>
- * In case component-size is 1 byte (e.g. OpenGL data-type GL_UNSIGNED_BYTE),
- * component names are ordered from lowest-byte to highest-byte.
- * Note that OpenGL applies special interpretation if
- * data-type is e.g. GL_UNSIGNED_8_8_8_8_REV or GL_UNSIGNED_8_8_8_8_REV.
- * </p>
- * <p>
- * PixelFormat can be converted to OpenGL GLPixelAttributes
- * via
- * <pre>
- * GLPixelAttributes glpa = GLPixelAttributes.convert(PixelFormat pixFmt, GLProfile glp);
- * </pre>
- * </p>
- * <p>
- * See OpenGL Specification 4.3 - February 14, 2013, Core Profile,
- * Section 8.4.4 Transfer of Pixel Rectangles, p. 161-174.
- * </ul>
- *
- * </p>
- */
-public enum PixelFormat {
- /**
- * Pixel size is 1 bytes (8 bits) with one component of size 1 byte (8 bits).
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_ALPHA (< GL3), GL_RED (>= GL3), data-type GL_UNSIGNED_BYTE</li>
- * <li>AWT: <i>none</i></li>
- * </ul>
- * </p>
- */
- LUMINANCE(1, 8),
-
- /**
- * Pixel size is 3 bytes (24 bits) with each component of size 1 byte (8 bits).
- * <p>
- * The components are interleaved in the order:
- * <ul>
- * <li>Low to High: R, G, B</li>
- * </ul>
- * </p>
- * <p>
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_RGB, data-type GL_UNSIGNED_BYTE</li>
- * <li>AWT: <i>None</i></li>
- * </ul>
- * </p>
- */
- RGB888(3, 24),
-
- /**
- * Pixel size is 3 bytes (24 bits) with each component of size 1 byte (8 bits).
- * <p>
- * The components are interleaved in the order:
- * <ul>
- * <li>Low to High: B, G, R</li>
- * </ul>
- * </p>
- * <p>
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_BGR (>= GL2), data-type GL_UNSIGNED_BYTE</li>
- * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_3BYTE_BGR TYPE_3BYTE_BGR}</li>
- * </ul>
- * </p>
- */
- BGR888(3, 24),
-
- /**
- * Pixel size is 4 bytes (32 bits) with each component of size 1 byte (8 bits).
- * <p>
- * The components are interleaved in the order:
- * <ul>
- * <li>Low to High: R, G, B, A</li>
- * </ul>
- * </p>
- * <p>
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_BYTE</li>
- * <li>AWT: <i>None</i></li>
- * <li>PointerIcon: OSX (NSBitmapImageRep)</li>
- * <li>Window Icon: OSX (NSBitmapImageRep)</li>
- * <li>PNGJ: Scanlines</li>
- * </ul>
- * </p>
- */
- RGBA8888(4, 32),
-
- /**
- * Pixel size is 4 bytes (32 bits) with each component of size 1 byte (8 bits).
- * <p>
- * The components are interleaved in the order:
- * <ul>
- * <li>Low to High: A, B, G, R</li>
- * </ul>
- * </p>
- * <p>
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_8_8_8_8</li>
- * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_4BYTE_ABGR TYPE_4BYTE_ABGR}</li>
- * </ul>
- * </p>
- */
- ABGR8888(4, 32),
-
- /**
- * Pixel size is 4 bytes (32 bits) with each component of size 1 byte (8 bits).
- * <p>
- * The components are interleaved in the order:
- * <ul>
- * <li>Low to High: A, R, G, B</li>
- * </ul>
- * </p>
- * <p>
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_BGRA, data-type GL_UNSIGNED_INT_8_8_8_8</li>
- * <li>AWT: <i>None</i></li>
- * </ul>
- * </p>
- */
- ARGB8888(4, 32),
-
- /**
- * Pixel size is 4 bytes (32 bits) with each component of size 1 byte (8 bits).
- * <p>
- * The components are interleaved in the order:
- * <ul>
- * <li>Low to High: B, G, R, A</li>
- * </ul>
- * </p>
- * <p>
- * Compatible with:
- * <ul>
- * <li>OpenGL: data-format GL_BGRA, data-type GL_UNSIGNED_BYTE</li>
- * <li>AWT: {@link java.awt.image.BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}</li>
- * <li>PointerIcon: X11 (XCURSOR), Win32, AWT</li>
- * <li>Window Icon: X11, Win32</li>
- * </ul>
- * </p>
- */
- BGRA8888(4, 32);
-
- /** Number of components per pixel, e.g. 4 for RGBA. */
- public final int componentCount;
- /** Number of bits per pixel, e.g. 32 for RGBA. */
- public final int bitsPerPixel;
- /** Number of bytes per pixel, e.g. 4 for RGBA. */
- public final int bytesPerPixel() { return (7+bitsPerPixel)/8; }
-
- private PixelFormat(final int componentCount, final int bpp) {
- this.componentCount = componentCount;
- this.bitsPerPixel = bpp;
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java b/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java
deleted file mode 100644
index 21bfa8a54..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/**
- * Copyright (c) 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package javax.media.nativewindow.util;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-import com.jogamp.common.nio.Buffers;
-
-/**
- * Pixel Rectangle Utilities.
- * <p>
- * All conversion methods are endian independent.
- * </p>
- */
-public class PixelFormatUtil {
- public static interface PixelSink {
- /** Return the sink's destination pixelformat. */
- PixelFormat getPixelformat();
-
- /**
- * Returns stride in byte-size, i.e. byte count from one line to the next.
- * <p>
- * Must be >= {@link #getPixelformat()}.{@link PixelFormat#bytesPerPixel() bytesPerPixel()} * {@link #getSize()}.{@link DimensionImmutable#getWidth() getWidth()}.
- * </p>
- */
- int getStride();
-
- /**
- * Returns <code>true</code> if the sink's memory is laid out in
- * OpenGL's coordinate system, <i>origin at bottom left</i>.
- * Otherwise returns <code>false</code>, i.e. <i>origin at top left</i>.
- */
- boolean isGLOriented();
- }
- /**
- * Pixel sink for up-to 32bit.
- */
- public static interface PixelSink32 extends PixelSink {
- /**
- * Will be invoked over all rows top-to down
- * and all columns left-to-right.
- * <p>
- * Shall consider dest pixelformat and only store as much components
- * as defined, up to 32bit.
- * </p>
- * <p>
- * Implementation may better write single bytes from low-to-high bits,
- * e.g. {@link ByteOrder#LITTLE_ENDIAN} order.
- * Otherwise a possible endian conversion must be taken into consideration.
- * </p>
- * @param x
- * @param y
- * @param pixel
- */
- void store(int x, int y, int pixel);
- }
-
- /**
- * Returns the {@link PixelFormat} with reversed components of <code>fmt</code>.
- * If no reversed {@link PixelFormat} is available, returns <code>fmt</code>.
- */
- public static PixelFormat getReversed(final PixelFormat fmt) {
- switch(fmt) {
- case LUMINANCE:
- return PixelFormat.LUMINANCE;
- case RGB888:
- return PixelFormat.BGR888;
- case BGR888:
- return PixelFormat.RGB888;
- case RGBA8888:
- return PixelFormat.ABGR8888;
- case ABGR8888:
- return PixelFormat.RGBA8888;
- case ARGB8888:
- return PixelFormat.BGRA8888;
- case BGRA8888:
- return PixelFormat.ABGR8888;
- default:
- throw new InternalError("Unhandled format "+fmt);
- }
- }
-
- public static int getValue32(final PixelFormat src_fmt, final ByteBuffer src, int srcOff) {
- switch(src_fmt) {
- case LUMINANCE: {
- final byte c1 = src.get(srcOff++);
- return ( 0xff ) << 24 | ( 0xff & c1 ) << 16 | ( 0xff & c1 ) << 8 | ( 0xff & c1 );
- }
- case RGB888:
- case BGR888: {
- final byte c1 = src.get(srcOff++);
- final byte c2 = src.get(srcOff++);
- final byte c3 = src.get(srcOff++);
- return ( 0xff ) << 24 | ( 0xff & c3 ) << 16 | ( 0xff & c2 ) << 8 | ( 0xff & c1 );
- }
- case RGBA8888:
- case ABGR8888:
- case ARGB8888:
- case BGRA8888: {
- final byte c1 = src.get(srcOff++);
- final byte c2 = src.get(srcOff++);
- final byte c3 = src.get(srcOff++);
- final byte c4 = src.get(srcOff++);
- return ( 0xff & c4 ) << 24 | ( 0xff & c3 ) << 16 | ( 0xff & c2 ) << 8 | ( 0xff & c1 );
- }
- default:
- throw new InternalError("Unhandled format "+src_fmt);
- }
- }
-
- public static int convertToInt32(final PixelFormat dest_fmt, final byte r, final byte g, final byte b, final byte a) {
- switch(dest_fmt) {
- case LUMINANCE: {
- final byte l = ( byte) ( ( ( ( 0xff & r ) + ( 0xff & g ) + ( 0xff & b ) ) / 3 ) );
- return ( 0xff ) << 24 | ( 0xff & l ) << 16 | ( 0xff & l ) << 8 | ( 0xff & l );
- }
- case RGB888:
- return ( 0xff ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
- case BGR888:
- return ( 0xff ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
- case RGBA8888:
- return ( 0xff & a ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
- case ABGR8888:
- return ( 0xff & r ) << 24 | ( 0xff & g ) << 16 | ( 0xff & b ) << 8 | ( 0xff & a );
- case ARGB8888:
- return ( 0xff & b ) << 24 | ( 0xff & g ) << 16 | ( 0xff & r ) << 8 | ( 0xff & a );
- case BGRA8888:
- return ( 0xff & a ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
- default:
- throw new InternalError("Unhandled format "+dest_fmt);
- }
- }
-
- public static int convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final ByteBuffer src, int srcOff) {
- final byte r, g, b, a;
- switch(src_fmt) {
- case LUMINANCE:
- r = src.get(srcOff++); // R
- g = r; // G
- b = r; // B
- a = (byte) 0xff; // A
- break;
- case RGB888:
- r = src.get(srcOff++); // R
- g = src.get(srcOff++); // G
- b = src.get(srcOff++); // B
- a = (byte) 0xff; // A
- break;
- case BGR888:
- b = src.get(srcOff++); // B
- g = src.get(srcOff++); // G
- r = src.get(srcOff++); // R
- a = (byte) 0xff; // A
- break;
- case RGBA8888:
- r = src.get(srcOff++); // R
- g = src.get(srcOff++); // G
- b = src.get(srcOff++); // B
- a = src.get(srcOff++); // A
- break;
- case ABGR8888:
- a = src.get(srcOff++); // A
- b = src.get(srcOff++); // B
- g = src.get(srcOff++); // G
- r = src.get(srcOff++); // R
- break;
- case ARGB8888:
- a = src.get(srcOff++); // A
- r = src.get(srcOff++); // R
- g = src.get(srcOff++); // G
- b = src.get(srcOff++); // B
- break;
- case BGRA8888:
- b = src.get(srcOff++); // B
- g = src.get(srcOff++); // G
- r = src.get(srcOff++); // R
- a = src.get(srcOff++); // A
- break;
- default:
- throw new InternalError("Unhandled format "+src_fmt);
- }
- return convertToInt32(dest_fmt, r, g, b, a);
- }
-
- public static int convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final int src_pixel) {
- final byte r, g, b, a;
- switch(src_fmt) {
- case LUMINANCE:
- r = (byte) ( src_pixel ); // R
- g = r; // G
- b = r; // B
- a = (byte) 0xff; // A
- break;
- case RGB888:
- r = (byte) ( src_pixel ); // R
- g = (byte) ( src_pixel >>> 8 ); // G
- b = (byte) ( src_pixel >>> 16 ); // B
- a = (byte) 0xff; // A
- break;
- case BGR888:
- b = (byte) ( src_pixel ); // B
- g = (byte) ( src_pixel >>> 8 ); // G
- r = (byte) ( src_pixel >>> 16 ); // R
- a = (byte) 0xff; // A
- break;
- case RGBA8888:
- r = (byte) ( src_pixel ); // R
- g = (byte) ( src_pixel >>> 8 ); // G
- b = (byte) ( src_pixel >>> 16 ); // B
- a = (byte) ( src_pixel >>> 24 ); // A
- break;
- case ABGR8888:
- a = (byte) ( src_pixel ); // A
- b = (byte) ( src_pixel >>> 8 ); // B
- g = (byte) ( src_pixel >>> 16 ); // G
- r = (byte) ( src_pixel >>> 24 ); // R
- break;
- case ARGB8888:
- a = (byte) ( src_pixel ); // A
- r = (byte) ( src_pixel >>> 8 ); // R
- g = (byte) ( src_pixel >>> 16 ); // G
- b = (byte) ( src_pixel >>> 24 ); // B
- break;
- case BGRA8888:
- b = (byte) ( src_pixel ); // B
- g = (byte) ( src_pixel >>> 8 ); // G
- r = (byte) ( src_pixel >>> 16 ); // R
- a = (byte) ( src_pixel >>> 24 ); // A
- break;
- default:
- throw new InternalError("Unhandled format "+src_fmt);
- }
- return convertToInt32(dest_fmt, r, g, b, a);
- }
-
- public static PixelRectangle convert32(final PixelRectangle src,
- final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented,
- final boolean destIsDirect) {
- final int width = src.getSize().getWidth();
- final int height = src.getSize().getHeight();
- final int bpp = destFmt.bytesPerPixel();
- final int destStride;
- if( 0 != ddestStride ) {
- destStride = ddestStride;
- if( destStride < bpp * width ) {
- throw new IllegalArgumentException("Invalid stride "+destStride+", must be greater than bytesPerPixel "+bpp+" * width "+width);
- }
- } else {
- destStride = bpp * width;
- }
- final int capacity = destStride*height;
- final ByteBuffer bb = destIsDirect ? Buffers.newDirectByteBuffer(capacity) : ByteBuffer.allocate(capacity).order(src.getPixels().order());
-
- // System.err.println("XXX: SOURCE "+src);
- // System.err.println("XXX: DEST fmt "+destFmt+", stride "+destStride+" ("+ddestStride+"), isGL "+isGLOriented+", "+width+"x"+height+", capacity "+capacity+", "+bb);
-
- final PixelFormatUtil.PixelSink32 imgSink = new PixelFormatUtil.PixelSink32() {
- public void store(final int x, final int y, final int pixel) {
- int o = destStride*y+x*bpp;
- bb.put(o++, (byte) ( pixel )); // 1
- if( 3 <= bpp ) {
- bb.put(o++, (byte) ( pixel >>> 8 )); // 2
- bb.put(o++, (byte) ( pixel >>> 16 )); // 3
- if( 4 <= bpp ) {
- bb.put(o++, (byte) ( pixel >>> 24 )); // 4
- }
- }
- }
- @Override
- public final PixelFormat getPixelformat() {
- return destFmt;
- }
- @Override
- public final int getStride() {
- return destStride;
- }
- @Override
- public final boolean isGLOriented() {
- return isGLOriented;
- }
- };
- convert32(imgSink, src);
- return new PixelRectangle.GenericPixelRect(destFmt, src.getSize(), destStride, isGLOriented, bb);
- }
-
- public static void convert32(final PixelSink32 destInt32, final PixelRectangle src) {
- convert32(destInt32,
- src.getPixels(), src.getPixelformat(),
- src.isGLOriented(),
- src.getSize().getWidth(), src.getSize().getHeight(),
- src.getStride());
- }
-
- /**
- *
- * @param dest32 32bit pixel sink
- * @param src_bb
- * @param src_fmt
- * @param src_glOriented if true, the source memory is laid out in OpenGL's coordinate system, <i>origin at bottom left</i>,
- * otherwise <i>origin at top left</i>.
- * @param width
- * @param height
- * @param strideInBytes stride in byte-size, i.e. byte count from one line to the next.
- * If zero, stride is set to <code>width * bytes-per-pixel</code>.
- * If not zero, value must be >= <code>width * bytes-per-pixel</code>.
- * @param stride_bytes stride in byte-size, i.e. byte count from one line to the next.
- * Must be >= {@link PixelFormat#bytesPerPixel() src_fmt.bytesPerPixel()} * width.
- * @throws IllegalArgumentException if <code>strideInBytes</code> is invalid
- */
- public static void convert32(final PixelSink32 dest32,
- final ByteBuffer src_bb, final PixelFormat src_fmt, final boolean src_glOriented, final int width, final int height, int stride_bytes) {
- final int src_bpp = src_fmt.bytesPerPixel();
- if( 0 != stride_bytes ) {
- if( stride_bytes < src_bpp * width ) {
- throw new IllegalArgumentException("Invalid stride "+stride_bytes+", must be greater than bytesPerPixel "+src_bpp+" * width "+width);
- }
- } else {
- stride_bytes = src_bpp * width;
- }
- final PixelFormat dest_fmt = dest32.getPixelformat();
- final boolean vert_flip = src_glOriented != dest32.isGLOriented();
- final boolean fast_copy = src_fmt == dest_fmt && dest_fmt.bytesPerPixel() == 4 ;
- // System.err.println("XXX: SRC fmt "+src_fmt+", stride "+stride_bytes+", isGL "+src_glOriented+", "+width+"x"+height);
- // System.err.println("XXX: DST fmt "+dest_fmt+", fast_copy "+fast_copy);
-
- if( fast_copy ) {
- // Fast copy
- for(int y=0; y<height; y++) {
- int o = vert_flip ? ( height - 1 - y ) * stride_bytes : y * stride_bytes;
- for(int x=0; x<width; x++) {
- dest32.store(x, y, getValue32(src_fmt, src_bb, o));
- o += src_bpp;
- }
- }
- } else {
- // Conversion
- for(int y=0; y<height; y++) {
- int o = vert_flip ? ( height - 1 - y ) * stride_bytes : y * stride_bytes;
- for(int x=0; x<width; x++) {
- dest32.store( x, y, convertToInt32( dest_fmt, src_fmt, src_bb, o));
- o += src_bpp;
- }
- }
- }
- }
-}
-
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} &gt; {@code maxPixelScale}</li>
+ * <li>{@code pixelScale} ~= {@code maxPixelScale}</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Method returns {@code minPixelScale} if
+ * <ul>
+ * <li>{@code pixelScale} &lt; {@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 &le; {@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;