summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java22
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java82
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java22
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java12
4 files changed, 90 insertions, 48 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
index 8f21fef42..418d31503 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
@@ -40,17 +40,27 @@ import com.sun.nativewindow.impl.x11.*;
public class GLXUtil {
public static boolean isMultisampleAvailable(long display) {
- String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- return (exts.indexOf("GLX_ARB_multisample") >= 0);
+ try {
+ X11Lib.XLockDisplay(display);
+ String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
+ if (exts != null) {
+ return (exts.indexOf("GLX_ARB_multisample") >= 0);
+ }
+ return false;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- return false;
}
/** Workaround for apparent issue with ATI's proprietary drivers
where direct contexts still send GLX tokens for GL calls */
public static boolean isVendorATI(long display) {
- String vendor = GLX.glXGetClientString(display, GLX.GLX_VENDOR);
- return vendor != null && vendor.startsWith("ATI") ;
+ try {
+ X11Lib.XLockDisplay(display);
+ String vendor = GLX.glXGetClientString(display, GLX.GLX_VENDOR);
+ return vendor != null && vendor.startsWith("ATI") ;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index ebf650ae4..09bea723f 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -181,17 +181,22 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return gammaRampLength;
}
- int[] size = new int[1];
long display = X11Util.getThreadLocalDefaultDisplay();
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
- if (!res) {
- return 0;
+ try {
+ X11Lib.XLockDisplay(display);
+ int[] size = new int[1];
+ boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+ X11Lib.DefaultScreen(display),
+ size, 0);
+ if (!res) {
+ return 0;
+ }
+ gotGammaRampLength = true;
+ gammaRampLength = size[0];
+ return gammaRampLength;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- gotGammaRampLength = true;
- gammaRampLength = size[0];
- return gammaRampLength;
}
protected boolean setGammaRamp(float[] ramp) {
@@ -202,13 +207,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
long display = X11Util.getThreadLocalDefaultDisplay();
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- return res;
+ try {
+ X11Lib.XLockDisplay(display);
+ boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ rampData.length,
+ rampData, 0,
+ rampData, 0,
+ rampData, 0);
+ return res;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
protected Buffer getGammaRamp() {
@@ -224,16 +234,21 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = X11Util.getThreadLocalDefaultDisplay();
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- if (!res) {
- return null;
+ try {
+ X11Lib.XLockDisplay(display);
+ boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ if (!res) {
+ return null;
+ }
+ return rampData;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- return rampData;
}
protected void resetGammaRamp(Buffer originalGammaRamp) {
@@ -255,11 +270,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = X11Util.getThreadLocalDefaultDisplay();
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
+ try {
+ X11Lib.XLockDisplay(display);
+ X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 0d19d2063..908d12aa1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -79,9 +79,10 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
// Utilizing FBConfig
//
GLCapabilities capsFB = null;
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ long display = x11Screen.getDevice().getHandle();
try {
- long display = x11Screen.getDevice().getHandle();
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ X11Lib.XLockDisplay(display);
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
@@ -106,6 +107,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
} catch (Throwable t) {
} finally {
+ X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
@@ -183,11 +185,12 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
// Utilizing FBConfig
//
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+ long display = absDevice.getHandle();
try {
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ X11Lib.XLockDisplay(display);
int screen = x11Screen.getIndex();
- AbstractGraphicsDevice absDevice = x11Screen.getDevice();
- long display = absDevice.getHandle();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
@@ -247,6 +250,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
}
} finally {
+ X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
@@ -271,11 +275,12 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
XVisualInfo retXVisualInfo = null;
int chosen=-1;
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+ long display = absDevice.getHandle();
try {
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ X11Lib.XLockDisplay(display);
int screen = x11Screen.getIndex();
- AbstractGraphicsDevice absDevice = x11Screen.getDevice();
- long display = absDevice.getHandle();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
XVisualInfo[] infos = null;
@@ -326,6 +331,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
retXVisualInfo = XVisualInfo.create(infos[chosen]);
} finally {
+ X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, 0, -1);
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index c8b8851f8..e02df3cc6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -76,6 +76,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
getFactoryImpl().lockToolkit();
try {
+ X11Lib.XLockDisplay(dpy);
pixmap = X11Lib.XCreatePixmap(dpy, (int) X11Lib.RootWindow(dpy, screen),
component.getWidth(), component.getHeight(), bitsPerPixel);
if (pixmap == 0) {
@@ -94,15 +95,20 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
", display " + toHexString(dpy));
}
} finally {
+ X11Lib.XUnlockDisplay(dpy);
getFactoryImpl().unlockToolkit();
}
}
public void destroy() {
if (pixmap == 0) return;
+
+ NativeWindow nw = getNativeWindow();
+ long display = nw.getDisplayHandle();
try {
- NativeWindow nw = getNativeWindow();
- long display = nw.getDisplayHandle();
+ getFactoryImpl().lockToolkit();
+ X11Lib.XLockDisplay(display);
+
long drawable = nw.getSurfaceHandle();
if (DEBUG) {
System.err.println("Destroying pixmap " + toHexString(pixmap) +
@@ -111,7 +117,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
}
// Must destroy pixmap and GLXPixmap
- getFactoryImpl().lockToolkit();
if (DEBUG) {
long cur = GLX.glXGetCurrentContext();
@@ -133,6 +138,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
display = 0;
((SurfaceChangeable)nw).setSurfaceHandle(0);
} finally {
+ X11Lib.XUnlockDisplay(display);
getFactoryImpl().unlockToolkit();
}
}