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/Capabilities.java43
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java6
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java7
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java20
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java15
5 files changed, 85 insertions, 6 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java b/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
index fa172b201..ea9ca7fc4 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
@@ -1,6 +1,6 @@
/*
+ * Copyright (c) 2010-2023 JogAmp Community. All rights reserved.
* 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
@@ -121,6 +121,22 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
return hash;
}
+ private static boolean checkSameSuppSameValue(final VIDType type, final VisualIDHolder a, final VisualIDHolder b) {
+ final boolean has_a = a.isVisualIDSupported(type);
+ if( has_a != b.isVisualIDSupported(type) ) {
+ // both should either support or not support the extra X11_FBCONFIG
+ return false;
+ }
+ return !has_a || a.getVisualID(type) == b.getVisualID(type);
+ }
+ private static boolean checkSameValueIfBothSupp(final VIDType type, final VisualIDHolder a, final VisualIDHolder b) {
+ final boolean has_a = a.isVisualIDSupported(type);
+ if( has_a && has_a == b.isVisualIDSupported(type) ) {
+ return a.getVisualID(type) == b.getVisualID(type);
+ }
+ return true;
+ }
+
@Override
public boolean equals(final Object obj) {
if(this == obj) { return true; }
@@ -128,6 +144,20 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
return false;
}
final CapabilitiesImmutable other = (CapabilitiesImmutable)obj;
+ {
+ // first check whether the VID is compatible
+ final int id_t = this.getVisualID(VIDType.NATIVE);
+ final int id_o = other.getVisualID(VIDType.NATIVE);
+ if( id_t != id_o ) {
+ return false;
+ }
+ if( !checkSameSuppSameValue(VIDType.X11_FBCONFIG, this, other) ) {
+ return false;
+ }
+ if( !checkSameValueIfBothSupp(VIDType.EGL_CONFIG, this, other) ) {
+ return false;
+ }
+ }
boolean res = other.getRedBits()==redBits &&
other.getGreenBits()==greenBits &&
other.getBlueBits()==blueBits &&
@@ -182,6 +212,17 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
}
@Override
+ public boolean isVisualIDSupported(final VIDType type) {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
public final int getRedBits() {
return redBits;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
index 780d537b8..526d184a1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2010-2023 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:
@@ -122,11 +122,11 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C
*/
int getTransparentAlphaValue();
- /** Equality over the immutable attributes of both objects */
+ /** Equality over the immutable attributes of both objects. */
@Override
boolean equals(Object obj);
- /** hash code over the immutable attributes of both objects */
+ /** Hash code over the immutable attributes. */
@Override
int hashCode();
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
index d20a6824d..220f0555b 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
@@ -32,6 +32,8 @@
package com.jogamp.nativewindow;
+import com.jogamp.nativewindow.VisualIDHolder.VIDType;
+
import jogamp.nativewindow.Debug;
public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration {
@@ -91,6 +93,11 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
return capabilitiesChosen.getVisualID(type);
}
+ @Override
+ final public boolean isVisualIDSupported(final VIDType type) {
+ return capabilitiesChosen.isVisualIDSupported(type);
+ }
+
/**
* Set the capabilities to a new value.
*
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
index 62b73d230..627fc4f3b 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2012 JogAmp Community. All rights reserved.
+ * Copyright 2012-2023 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:
@@ -90,6 +90,10 @@ public interface VisualIDHolder {
* </ul></li>
* </ul>
* </p>
+ * <p>
+ * One may use {@link #isVisualIDSupported(VIDType)} to test upfront whether a {@link VIDType} is supported,
+ * e.g. to avoid an exception or query or compare all available.
+ * </p>
* Note: <code>INTRINSIC</code> and <code>NATIVE</code> are always handled,
* but may result in {@link #VID_UNDEFINED}. The latter is true if
* the native value are actually undefined or the corresponding object is not
@@ -98,10 +102,24 @@ public interface VisualIDHolder {
* @throws NativeWindowException if <code>type</code> is neither
* <code>INTRINSIC</code> nor <code>NATIVE</code>
* and does not match the native implementation.
+ *
+ * @see #isVisualIDSupported(VIDType)
*/
int getVisualID(VIDType type) throws NativeWindowException ;
/**
+ * Returns true if the given {@link VIDType} is supported, otherwise false.
+ * <p>
+ * Note: <code>INTRINSIC</code> and <code>NATIVE</code> are always handled,
+ * but may result in {@link #VID_UNDEFINED}. The latter is true if
+ * the native value are actually undefined or the corresponding object is not
+ * mapped to a native visual object.
+ * </p>
+ * @see #getVisualID(VIDType)
+ */
+ boolean isVisualIDSupported(VIDType type);
+
+ /**
* {@link #getVisualID(VIDType)} result indicating an undefined value,
* which could be cause by an unsupported query.
* <p>
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java
index 99cfca97b..71bd033b0 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2012 JogAmp Community. All rights reserved.
+ * Copyright 2012-2023 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:
@@ -74,6 +74,19 @@ public class X11Capabilities extends Capabilities {
}
@Override
+ final public boolean isVisualIDSupported(final VIDType type) {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ case X11_XVISUAL:
+ case X11_FBCONFIG:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
public StringBuilder toString(StringBuilder sink) {
if(null == sink) {
sink = new StringBuilder();