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/Capabilities.java25
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java47
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java6
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java10
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java23
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java10
7 files changed, 93 insertions, 32 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index ff6e077ee..e844c4f3e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 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
@@ -43,7 +44,6 @@ package javax.media.nativewindow;
must support, such as color depth per channel. It currently
contains the minimal number of routines which allow configuration
on all supported window systems. */
-
public class Capabilities implements CapabilitiesImmutable, Cloneable {
private int redBits = 8;
private int greenBits = 8;
@@ -65,8 +65,8 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
*/
public Capabilities() {}
- public Capabilities cloneCapabilites() {
- return (Capabilities) clone();
+ public Object cloneMutable() {
+ return clone();
}
public Object clone() {
@@ -77,12 +77,27 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
}
}
+ public int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + this.redBits;
+ hash = ((hash << 5) - hash) + this.greenBits;
+ hash = ((hash << 5) - hash) + this.blueBits;
+ hash = ((hash << 5) - hash) + this.alphaBits;
+ hash = ((hash << 5) - hash) + ( this.backgroundOpaque ? 1 : 0 );
+ hash = ((hash << 5) - hash) + this.transparentValueRed;
+ hash = ((hash << 5) - hash) + this.transparentValueGreen;
+ hash = ((hash << 5) - hash) + this.transparentValueBlue;
+ hash = ((hash << 5) - hash) + this.transparentValueAlpha;
+ hash = ((hash << 5) - hash) + ( this.onscreen ? 1 : 0 );
+ return hash;
+ }
+
public boolean equals(Object obj) {
if(this == obj) { return true; }
- if(!(obj instanceof Capabilities)) {
+ if(!(obj instanceof CapabilitiesImmutable)) {
return false;
}
- Capabilities other = (Capabilities)obj;
+ CapabilitiesImmutable other = (CapabilitiesImmutable)obj;
boolean res = other.getRedBits()==redBits &&
other.getGreenBits()==greenBits &&
other.getBlueBits()==blueBits &&
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
index d61ebd4ef..94b0f68af 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
@@ -62,7 +62,7 @@ public interface CapabilitiesChooser {
invoked by users directly, unless it is desired to delegate the
choice to some other CapabilitiesChooser object.
*/
- public int chooseCapabilities(Capabilities desired,
- Capabilities[] available,
+ public int chooseCapabilities(CapabilitiesImmutable desired,
+ CapabilitiesImmutable[] available,
int windowSystemRecommendedChoice);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
index 9369221cb..72828b9f0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
@@ -1,12 +1,42 @@
+/**
+ * Copyright 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 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;
+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
*/
-public interface CapabilitiesImmutable extends Cloneable {
+public interface CapabilitiesImmutable extends WriteCloneable {
/**
* Returns the number of bits requested for the color buffer's red
@@ -71,11 +101,14 @@ public interface CapabilitiesImmutable extends Cloneable {
*/
int getTransparentAlphaValue();
- /**
- * Get a mutable clone of this instance.
- *
- * @see java.lang.Object#clone()
- */
- Capabilities cloneCapabilites();
+ Object cloneMutable();
+
+ /** Equality over the immutable attributes of both objects */
+ boolean equals(Object obj);
+
+ /** hash code over the immutable attributes of both objects */
+ int hashCode();
+ /** Returns a textual representation of this object. */
+ String toString();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
index cead0a4a8..856c29420 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
@@ -63,8 +63,8 @@ package javax.media.nativewindow;
public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
private static final boolean DEBUG = false; // FIXME: Debug.debug("DefaultCapabilitiesChooser");
- public int chooseCapabilities(Capabilities desired,
- Capabilities[] available,
+ public int chooseCapabilities(CapabilitiesImmutable desired,
+ CapabilitiesImmutable[] available,
int windowSystemRecommendedChoice) {
if (DEBUG) {
System.err.println("Desired: " + desired);
@@ -93,7 +93,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
}
// Compute score for each
for (int i = 0; i < scores.length; i++) {
- Capabilities cur = available[i];
+ CapabilitiesImmutable cur = available[i];
if (cur == null) {
continue;
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 3d06388c2..47110add9 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -41,9 +41,8 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
this.screen = screen;
- // Create "immutable" copies of capabilities.
- this.capabilitiesChosen = capsChosen.cloneCapabilites();
- this.capabilitiesRequested = capsRequested.cloneCapabilites();
+ this.capabilitiesChosen = capsChosen;
+ this.capabilitiesRequested = capsRequested;
}
public Object clone() {
@@ -76,13 +75,12 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
* The use case for setting the Capabilities at a later time is
* a change of the graphics device in a multi-screen environment.<br>
*
- * A copy of the passed object is being used.
+ * The objects reference is being used.
*
* @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
protected void setChosenCapabilities(CapabilitiesImmutable capsChosen) {
- // Create "immutable" copy of capabilities.
- capabilitiesChosen = (CapabilitiesImmutable) capsChosen.cloneCapabilites();
+ capabilitiesChosen = capsChosen;
}
/**
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index 1d3a7445f..c061f597f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008-2009 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
@@ -32,7 +33,6 @@
package javax.media.nativewindow;
-import java.lang.reflect.*;
import java.util.*;
import com.jogamp.common.util.*;
@@ -187,6 +187,12 @@ public abstract class GraphicsConfigurationFactory {
* javax.media.nativewindow.x11.X11GraphicsConfiguration
* X11GraphicsConfiguration} objects.</P>
*
+ * @param capsChosen the intermediate chosen capabilities to be refined by this implementation, may be equal to capsRequested
+ * @param capsRequested the original requested capabilities
+ * @param chooser the choosing implementation
+ * @param screen the referring Screen
+ * @return the complete GraphicsConfiguration
+ *
* @throws IllegalArgumentException if the data type of the passed
* AbstractGraphicsDevice is not supported by this
* NativeWindowFactory.
@@ -197,10 +203,16 @@ public abstract class GraphicsConfigurationFactory {
* @see javax.media.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
*/
public final AbstractGraphicsConfiguration
- chooseGraphicsConfiguration(Capabilities capabilities,
+ chooseGraphicsConfiguration(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
CapabilitiesChooser chooser,
AbstractGraphicsScreen screen)
throws IllegalArgumentException, NativeWindowException {
+ if(null==capsChosen) {
+ throw new NativeWindowException("Chosen Capabilities are null");
+ }
+ if(null==capsRequested) {
+ throw new NativeWindowException("Requested Capabilities are null");
+ }
if(null==screen) {
throw new NativeWindowException("Screen is null");
}
@@ -210,15 +222,14 @@ public abstract class GraphicsConfigurationFactory {
}
device.lock();
try {
- return chooseGraphicsConfigurationImpl(capabilities, chooser, screen);
+ return chooseGraphicsConfigurationImpl(capsChosen, capsRequested, chooser, screen);
} finally {
device.unlock();
}
}
protected abstract AbstractGraphicsConfiguration
- chooseGraphicsConfigurationImpl(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen screen)
+ chooseGraphicsConfigurationImpl(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen screen)
throws IllegalArgumentException, NativeWindowException;
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index bce9b248d..41051ab46 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.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
@@ -63,7 +64,8 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
this.encapsulated=encapsulated;
}
- public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, GraphicsConfiguration config) {
+ public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ GraphicsConfiguration config) {
super(screen, capsChosen, capsRequested);
this.config = config;
this.encapsulated=null;
@@ -97,7 +99,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
if(null==capsChosen) {
GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
- capsChosen = setupCapabilitiesRGBABits(capsRequested.cloneCapabilites(), gc);
+ capsChosen = setupCapabilitiesRGBABits(capsChosen, gc);
}
return new AWTGraphicsConfiguration(awtScreen, capsChosen, capsRequested, awtGfxConfig);
}
@@ -121,7 +123,9 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
* @param gc the GraphicsConfiguration from which to derive the RGBA bit depths
* @return the passed Capabilities
*/
- public static Capabilities setupCapabilitiesRGBABits(Capabilities capabilities, GraphicsConfiguration gc) {
+ public static CapabilitiesImmutable setupCapabilitiesRGBABits(CapabilitiesImmutable capabilitiesIn, GraphicsConfiguration gc) {
+ Capabilities capabilities = (Capabilities) capabilitiesIn.cloneMutable();
+
int cmTransparency = capabilities.isBackgroundOpaque()?Transparency.OPAQUE:Transparency.TRANSLUCENT;
ColorModel cm = gc.getColorModel(cmTransparency);
if(null==cm && !capabilities.isBackgroundOpaque()) {