aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/javax')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java11
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java71
3 files changed, 29 insertions, 55 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index 3f8746e2a..259644467 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -40,7 +40,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
/**
* Provides the mechanism by which the graphics configuration for a
* window can be chosen before the window is created. The graphics
@@ -81,10 +80,12 @@ public abstract class GraphicsConfigurationFactory {
} catch (Exception e) {
throw new RuntimeException(e);
}
- try {
- ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory",
- "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());
- } catch (Exception e) { /* n/a */ }
+ if(NativeWindowFactory.isAWTAvailable()) {
+ try {
+ ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory",
+ "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());
+ } catch (Exception e) { /* n/a */ }
+ }
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index d0b586f59..e255dc051 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -169,7 +169,7 @@ 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}.
+ * 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)
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index 012c952f1..45a3db838 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -47,6 +47,7 @@ import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.image.ColorModel;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
+
import jogamp.nativewindow.Debug;
/** A wrapper for an AWT GraphicsConfiguration allowing it to be
@@ -70,67 +71,39 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
this.config = config;
this.encapsulated=null;
}
-
+
/**
* @param capsChosen if null, <code>capsRequested</code> is copied and aligned
- * with the graphics capabilties of the AWT Component to produce the chosen Capabilties.
+ * with the graphics Capabilities of the AWT Component to produce the chosen Capabilities.
* Otherwise the <code>capsChosen</code> is used.
*/
- public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested)
- {
- AWTGraphicsScreen awtScreen = null;
- AWTGraphicsDevice awtDevice = null;
- GraphicsDevice awtGraphicsDevice = null;
- GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
- if(null!=awtGfxConfig) {
- awtGraphicsDevice = awtGfxConfig.getDevice();
- if(null!=awtGraphicsDevice) {
- // Create Device/Screen
- awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
- awtScreen = new AWTGraphicsScreen(awtDevice);
- }
+ public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
+ final GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
+ if(null==awtGfxConfig) {
+ throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp);
}
- if(null==awtScreen) {
- // use defaults since no native peer is available yet
- awtScreen = (AWTGraphicsScreen) AWTGraphicsScreen.createScreenDevice(-1, AbstractGraphicsDevice.DEFAULT_UNIT);
- awtDevice = (AWTGraphicsDevice) awtScreen.getDevice();
- awtGraphicsDevice = awtDevice.getGraphicsDevice();
+ final GraphicsDevice awtGraphicsDevice = awtGfxConfig.getDevice();
+ if(null==awtGraphicsDevice) {
+ throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsDevice @ "+awtGfxConfig);
}
+ // Create Device/Screen
+ final AWTGraphicsDevice awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
+ final AWTGraphicsScreen awtScreen = new AWTGraphicsScreen(awtDevice);
+
if(null==capsChosen) {
GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
- capsChosen = setupCapabilitiesRGBABits(capsRequested, gc);
+ capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsRequested, gc);
+ }
+ final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(awtDevice);
+ final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, null, awtScreen);
+ if(config instanceof AWTGraphicsConfiguration) {
+ return (AWTGraphicsConfiguration) config;
}
+ // System.err.println("Info: AWTGraphicsConfiguration.create: Expected AWTGraphicsConfiguration got: "+config.getClass()+" w/ factory "+factory.getClass()+" - Unable to encapsulate native GraphicsConfiguration.");
return new AWTGraphicsConfiguration(awtScreen, capsChosen, capsRequested, awtGfxConfig);
- // FIXME: use encapsulated X11 as used in X11AWTGLXGraphicsConfigurationFactory
}
- public void updateGraphicsConfiguration(Component awtComp)
- {
- AWTGraphicsScreen awtScreen = null;
- AWTGraphicsDevice awtDevice = null;
- GraphicsDevice awtGraphicsDevice = null;
- GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
- if(null!=awtGfxConfig) {
- awtGraphicsDevice = awtGfxConfig.getDevice();
- if(null!=awtGraphicsDevice) {
- // Create Device/Screen
- awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
- awtScreen = new AWTGraphicsScreen(awtDevice);
- }
- }
- if(null==awtScreen) {
- throw new NativeWindowException("native peer n/a: "+awtComp);
- }
- config = awtGfxConfig;
- setScreen(awtScreen);
-
- CapabilitiesImmutable caps = ( null != getChosenCapabilities() ) ? getChosenCapabilities() : getRequestedCapabilities();
- GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
- setChosenCapabilities(setupCapabilitiesRGBABits(caps, gc));
- // FIXME: use encapsulated X11 as used in X11AWTGLXGraphicsConfigurationFactory
- }
-
// open access to superclass method
public void setChosenCapabilities(CapabilitiesImmutable capsChosen) {
super.setChosenCapabilities(capsChosen);
@@ -190,7 +163,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return capabilities;
}
- @Override
+ @Override
public String toString() {
return getClass().getSimpleName()+"[" + getScreen() +
",\n\tchosen " + capabilitiesChosen+