summaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-23 07:44:42 +0100
committerSven Gothel <[email protected]>2011-11-23 07:44:42 +0100
commitbafd9b99816f55c105230a59211caf13f0315910 (patch)
treec805b6385938e2014f504d8d0d025ac799b79c44 /src/nativewindow
parent645a863ee5a8efa915dd43abd608248e8cbc13cd (diff)
NativeSurface's getGraphicsConfiguration() returns the native (delegated) AbstractGraphicsConfiguration, if delegation is used.
This change restricts the usage of AbstractGraphicsConfiguration's getNativeGraphicsConfiguration() to NativeSurface implementations and hence reduces complexity. NativeSurface implementations are adapted and access to it's AbstractGraphicsConfiguration is controlled via get/set method avoiding flawed usage (read/write), since read access shall return the delegated AbstractGraphicsConfiguration, if used.
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java13
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java5
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java18
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java5
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java18
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java4
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java5
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java2
11 files changed, 46 insertions, 30 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
index 784343c5a..1930bdda3 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 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
@@ -50,7 +51,7 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
/**
* Return the capabilities reflecting this graphics configuration,
- * which may differ from the capabilites used to choose this configuration.
+ * which may differ from the capabilities used to choose this configuration.
*
* @return An immutable instance of the Capabilities to avoid mutation by
* the user.
@@ -61,7 +62,7 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
* Return the capabilities used to choose this graphics configuration.
*
* These may be used to reconfigure the NativeWindow in case
- * the device changes in a multi screen environment.
+ * the device changes in a multiple screen environment.
*
* @return An immutable instance of the Capabilities to avoid mutation by
* the user.
@@ -69,10 +70,10 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
public CapabilitiesImmutable getRequestedCapabilities();
/**
- * In case this instance already reflects a native configuration,
- * return this one.
- * Otherwise return the encapsuled native configuration,
- * as it shall be included e.g. in the AWT case.
+ * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
+ * this method shall return the native {@link AbstractGraphicsConfiguration},
+ * otherwise this instance.
+ * @see NativeSurface#getGraphicsConfiguration()
*/
public AbstractGraphicsConfiguration getNativeGraphicsConfiguration();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index b2a2bc4ee..d0b586f59 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -167,6 +167,11 @@ public interface NativeSurface extends SurfaceUpdatedListener {
/**
* Returns the graphics configuration corresponding to this window.
+ * <p>
+ * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
+ * this method shall return the native {@link AbstractGraphicsConfiguration}.
+ * </p>
+ * @see AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()
* @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
public AbstractGraphicsConfiguration getGraphicsConfiguration();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index 7380d19b6..9100beac2 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -34,18 +34,18 @@ import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
public abstract class ProxySurface implements NativeSurface {
+ private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
+ private AbstractGraphicsConfiguration config; // control access due to delegation
protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
- protected AbstractGraphicsConfiguration config;
protected long displayHandle;
protected int height;
protected int scrnIndex;
protected int width;
- private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
public ProxySurface(AbstractGraphicsConfiguration cfg) {
invalidate();
config = cfg;
- displayHandle=cfg.getScreen().getDevice().getHandle();
+ displayHandle=cfg.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle();
}
void invalidate() {
@@ -58,12 +58,16 @@ public abstract class ProxySurface implements NativeSurface {
return displayHandle;
}
- public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() {
return config;
}
+
+ public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config.getNativeGraphicsConfiguration();
+ }
public final int getScreenIndex() {
- return config.getScreen().getIndex();
+ return getGraphicsConfiguration().getScreen().getIndex();
}
public abstract long getSurfaceHandle();
@@ -107,7 +111,7 @@ public abstract class ProxySurface implements NativeSurface {
if ( LOCK_SURFACE_NOT_READY == res ) {
try {
- final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+ final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
adevice.lock();
try {
res = lockSurfaceImpl();
@@ -129,7 +133,7 @@ public abstract class ProxySurface implements NativeSurface {
surfaceLock.validateLocked();
if (surfaceLock.getHoldCount() == 1) {
- final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+ final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
try {
unlockSurfaceImpl();
} finally {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index f60fc3312..012c952f1 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -141,11 +141,12 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return super.clone();
}
- public GraphicsConfiguration getGraphicsConfiguration() {
+ /** Return the AWT {@link GraphicsConfiguration}. */
+ public GraphicsConfiguration getAWTGraphicsConfiguration() {
return config;
}
- @Override
+ @Override
public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() {
return (null!=encapsulated)?encapsulated:this;
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
index 65ecc48fe..59aa73b6e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
@@ -65,6 +65,6 @@ public class WrappedSurface extends ProxySurface implements SurfaceChangeable {
}
public String toString() {
- return "WrappedSurface[config " + config + ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + "]";
+ return "WrappedSurface[config " + getPrivateGraphicsConfiguration() + ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + "]";
}
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index 0f97b0b9f..2d695b84d 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -67,7 +67,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface
// lifetime: forever
protected Component component;
- protected AWTGraphicsConfiguration config;
+ private AWTGraphicsConfiguration config; // control access due to delegation
private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
// lifetime: valid after lock but may change with each 1st lock, purges after invalidate
@@ -273,7 +273,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface
if ( LOCK_SURFACE_NOT_READY == res ) {
determineIfApplet();
try {
- final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+ final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
adevice.lock();
try {
jawt = fetchJAWTImpl();
@@ -299,7 +299,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface
surfaceLock.validateLocked();
if (surfaceLock.getHoldCount() == 1) {
- final AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+ final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
try {
unlockSurfaceImpl();
} finally {
@@ -329,16 +329,20 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface
return drawable;
}
- public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration() {
return config;
}
+
+ public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config.getNativeGraphicsConfiguration();
+ }
public final long getDisplayHandle() {
- return config.getScreen().getDevice().getHandle();
+ return getGraphicsConfiguration().getScreen().getDevice().getHandle();
}
public final int getScreenIndex() {
- return config.getScreen().getIndex();
+ return getGraphicsConfiguration().getScreen().getIndex();
}
public int getWidth() {
@@ -472,7 +476,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface
sb.append(", component NULL");
}
sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+
- ",\n\tconfig "+config+
+ ",\n\tconfig "+getPrivateGraphicsConfiguration()+
",\n\tawtComponent "+getAWTComponent()+"]");
return sb.toString();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 70fc1d62f..dfd81d411 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -196,9 +196,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
throw new NativeWindowException("Unable to created dummy NSWindow (layered case)");
}
// fix caps reflecting offscreen!
- Capabilities caps = (Capabilities) config.getChosenCapabilities().cloneMutable();
+ Capabilities caps = (Capabilities) getPrivateGraphicsConfiguration().getChosenCapabilities().cloneMutable();
caps.setOnscreen(false);
- config.setChosenCapabilities(caps);
+ getPrivateGraphicsConfiguration().setChosenCapabilities(caps);
}
if(0 == rootSurfaceLayerHandle) {
rootSurfaceLayerHandle = OSXUtil.CreateCALayer();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java
index 5ad22807f..bf5c18eaf 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java
@@ -95,7 +95,7 @@ public class Win32SunJDKReflection {
public static int graphicsConfigurationGetPixelFormatID(AbstractGraphicsConfiguration config) {
try {
if (config instanceof AWTGraphicsConfiguration) {
- return graphicsConfigurationGetPixelFormatID(((AWTGraphicsConfiguration) config).getGraphicsConfiguration());
+ return graphicsConfigurationGetPixelFormatID(((AWTGraphicsConfiguration) config).getAWTGraphicsConfiguration());
}
return 0;
} catch (Exception e) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
index 236d380d8..965dc7990 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
@@ -61,7 +61,8 @@ public class X11JAWTWindow extends JAWTWindow {
}
protected void validateNative() throws NativeWindowException {
- final AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) config.getScreen().getDevice();
+ // FIXME: REMOVE !!!!!!!!
+ final AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) getPrivateGraphicsConfiguration().getScreen().getDevice();
if(awtDevice.getHandle() != 0) {
// subtype and handle set already, done
@@ -71,7 +72,7 @@ public class X11JAWTWindow extends JAWTWindow {
long displayHandle = 0;
// first try a pre-existing attached native configuration, ie native X11GraphicsDevice
- AbstractGraphicsConfiguration aconfig = (null!=config) ? config.getNativeGraphicsConfiguration() : null;
+ AbstractGraphicsConfiguration aconfig = getGraphicsConfiguration();
AbstractGraphicsScreen ascreen = (null!=aconfig) ? aconfig.getScreen() : null;
AbstractGraphicsDevice adevice = (null!=ascreen) ? ascreen.getDevice() : null; // X11GraphicsDevice
if(null!=adevice) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java
index 6dbf36612..08d471448 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java
@@ -96,7 +96,7 @@ public class X11SunJDKReflection {
public static int graphicsConfigurationGetVisualID(AbstractGraphicsConfiguration config) {
try {
if (config instanceof AWTGraphicsConfiguration) {
- return graphicsConfigurationGetVisualID(((AWTGraphicsConfiguration) config).getGraphicsConfiguration());
+ return graphicsConfigurationGetVisualID(((AWTGraphicsConfiguration) config).getAWTGraphicsConfiguration());
}
return 0;
} catch (Exception e) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
index 68cf8af45..cbc30afa7 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java
@@ -77,7 +77,7 @@ public class GDISurface extends ProxySurface {
}
public String toString() {
- return "GDISurface[config "+config+
+ return "GDISurface[config "+getPrivateGraphicsConfiguration()+
", displayHandle 0x"+Long.toHexString(getDisplayHandle())+
", windowHandle 0x"+Long.toHexString(windowHandle)+
", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+