aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-22 23:24:18 +0200
committerMichael Bien <[email protected]>2010-04-22 23:24:18 +0200
commitca6818d87ee86b2cc9961e47ad9f899e1fd90f78 (patch)
tree0f664b7777d1a01364944c9864720bee0560ebc2 /src
parent26b0449cbc7db9961af92397f79e2b85f79ddb24 (diff)
reviewed X11Lib.XLock/UnlockDisplay() usage:
- added lock(); try{foo();}finally{unlock();} where missing - made sure lock is called outside the try block - fixed nesting in situations with two independent locks
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java27
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java270
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java103
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java33
6 files changed, 236 insertions, 207 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
index e3c1381f8..ec0eaf94f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
@@ -34,14 +34,12 @@ package com.jogamp.opengl.impl.x11.glx;
import javax.media.opengl.*;
-import com.jogamp.opengl.impl.*;
-import javax.media.nativewindow.NativeWindowFactory;
import com.jogamp.nativewindow.impl.x11.*;
public class GLXUtil {
public static boolean isMultisampleAvailable(long display) {
+ X11Lib.XLockDisplay(display);
try {
- X11Lib.XLockDisplay(display);
String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
if (exts != null) {
return (exts.indexOf("GLX_ARB_multisample") >= 0);
@@ -55,8 +53,8 @@ public class GLXUtil {
/** Workaround for apparent issue with ATI's proprietary drivers
where direct contexts still send GLX tokens for GL calls */
public static String getVendorName(long display) {
+ X11Lib.XLockDisplay(display);
try {
- X11Lib.XLockDisplay(display);
return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
} finally {
X11Lib.XUnlockDisplay(display);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index f331ad2a2..d8e5f7646 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -72,12 +72,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
X11Lib.XLockDisplay(sharedScreen.getDevice().getHandle());
- sharedDrawable = new X11DummyGLXDrawable(sharedScreen, this, null);
- X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
- ctx.makeCurrent();
- ctx.release();
- sharedContext = ctx;
- X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
+ try{
+ sharedDrawable = new X11DummyGLXDrawable(sharedScreen, this, null);
+ X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
+ ctx.makeCurrent();
+ ctx.release();
+ sharedContext = ctx;
+ }finally{
+ X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
+ }
if(null==sharedContext) {
throw new GLException("Couldn't init shared resources");
}
@@ -226,10 +229,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
validate();
+ NullWindow nw = null;
X11Lib.XLockDisplay(sharedScreen.getDevice().getHandle());
- NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
- X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
- nw.setSize(width, height);
+ try{
+ nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
+ }finally{
+ X11Lib.XUnlockDisplay(sharedScreen.getDevice().getHandle());
+ }
+ if(nw != null) {
+ nw.setSize(width, height);
+ }
return nw;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 477f2473c..e65fb5e90 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -190,108 +190,111 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
long display = absDevice.getHandle();
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- X11Lib.XLockDisplay(display);
try {
- int screen = x11Screen.getIndex();
- boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
- int[] count = { -1 };
-
- // determine the recommended FBConfig ..
- fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
- if (fbcfgsL == null || fbcfgsL.limit()<1) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
- }
- } else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
- }
- } else {
- recommendedFBConfig = fbcfgsL.get(0);
- }
-
- // get all, glXChooseFBConfig(.. attribs==null ..) == glXGetFBConfig(..)
- fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, null, 0, count, 0);
- if (fbcfgsL == null || fbcfgsL.limit()<1) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetFBConfig ("+x11Screen+"): "+fbcfgsL+", "+count[0]);
+ X11Lib.XLockDisplay(display);
+ try{
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
+ int[] count = { -1 };
+
+ // determine the recommended FBConfig ..
+ fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
+ if (fbcfgsL == null || fbcfgsL.limit()<1) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
+ }
+ } else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
+ }
+ } else {
+ recommendedFBConfig = fbcfgsL.get(0);
}
- return null;
- }
- // make GLCapabilities and seek the recommendedIndex
- caps = new GLCapabilities[fbcfgsL.limit()];
- for (int i = 0; i < fbcfgsL.limit(); i++) {
- if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
+ // get all, glXChooseFBConfig(.. attribs==null ..) == glXGetFBConfig(..)
+ fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, null, 0, count, 0);
+ if (fbcfgsL == null || fbcfgsL.limit()<1) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetFBConfig ("+x11Screen+"): "+fbcfgsL+", "+count[0]);
}
- } else {
- caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
- false, onscreen, usePBuffer, isMultisampleAvailable);
- if(caps[i]!=null && recommendedFBConfig==fbcfgsL.get(i)) {
- recommendedIndex=i;
- if (DEBUG) {
- System.err.println("!!! glXChooseFBConfig recommended "+i+", "+caps[i]);
+ return null;
+ }
+
+ // make GLCapabilities and seek the recommendedIndex
+ caps = new GLCapabilities[fbcfgsL.limit()];
+ for (int i = 0; i < fbcfgsL.limit(); i++) {
+ if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
+ }
+ } else {
+ caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
+ false, onscreen, usePBuffer, isMultisampleAvailable);
+ if(caps[i]!=null && recommendedFBConfig==fbcfgsL.get(i)) {
+ recommendedIndex=i;
+ if (DEBUG) {
+ System.err.println("!!! glXChooseFBConfig recommended "+i+", "+caps[i]);
+ }
}
}
}
- }
- if(null==chooser) {
- chosen = recommendedIndex; // may still be -1 in case nothing was recommended (-1)
- }
-
- if (chosen < 0) {
if(null==chooser) {
- // nothing recommended .. so use our default implementation
- chooser = new DefaultGLCapabilitiesChooser();
+ chosen = recommendedIndex; // may still be -1 in case nothing was recommended (-1)
}
- try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- } catch (NativeWindowException e) {
+
+ if (chosen < 0) {
+ if(null==chooser) {
+ // nothing recommended .. so use our default implementation
+ chooser = new DefaultGLCapabilitiesChooser();
+ }
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
+ }
+ }
+ if (chosen < 0) {
+ // keep on going ..
if(DEBUG) {
- e.printStackTrace();
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
}
- chosen = -1;
- }
- }
- if (chosen < 0) {
- // keep on going ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
- }
- // seek first available one ..
- for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
- if(chosen==caps.length) {
- // give up ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. nothing available, bail out");
- }
- return null;
- }
- } else if (chosen >= caps.length) {
- if(DEBUG) {
- System.err.println("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ", got "+chosen+")");
+ // seek first available one ..
+ for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
+ if(chosen==caps.length) {
+ // give up ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. nothing available, bail out");
+ }
+ return null;
+ }
+ } else if (chosen >= caps.length) {
+ if(DEBUG) {
+ System.err.println("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ", got "+chosen+")");
+ }
+ return null;
}
- return null;
- }
- retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen));
+ retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen));
- retXVisualInfo = GLX.glXGetVisualFromFBConfigCopied(display, fbcfgsL.get(chosen));
- if (retXVisualInfo==null) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
- }
- if(caps[chosen].isOnscreen()) {
- // Onscreen drawables shall have a XVisual ..
- return null;
+ retXVisualInfo = GLX.glXGetVisualFromFBConfigCopied(display, fbcfgsL.get(chosen));
+ if (retXVisualInfo==null) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
+ }
+ if(caps[chosen].isOnscreen()) {
+ // Onscreen drawables shall have a XVisual ..
+ return null;
+ }
}
+ }finally{
+ X11Lib.XUnlockDisplay(display);
}
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
@@ -320,60 +323,63 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
long display = absDevice.getHandle();
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- X11Lib.XLockDisplay(display);
try {
- int screen = x11Screen.getIndex();
- boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
- XVisualInfo[] infos = null;
-
- XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0);
- if (DEBUG) {
- System.err.print("!!! glXChooseVisual recommended ");
- if (recommendedVis == null) {
- System.err.println("null visual");
- } else {
- System.err.println("visual id " + toHexString(recommendedVis.getVisualid()));
+ X11Lib.XLockDisplay(display);
+ try{
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
+ XVisualInfo[] infos = null;
+
+ XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0);
+ if (DEBUG) {
+ System.err.print("!!! glXChooseVisual recommended ");
+ if (recommendedVis == null) {
+ System.err.println("null visual");
+ } else {
+ System.err.println("visual id " + toHexString(recommendedVis.getVisualid()));
+ }
}
- }
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.setScreen(screen);
- infos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, template, count, 0);
- if (infos == null || infos.length<1) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
- // Attempt to find the visual chosen by glXChooseVisual
- if (recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) {
- recommendedIndex = i;
+ int[] count = new int[1];
+ XVisualInfo template = XVisualInfo.create();
+ template.setScreen(screen);
+ infos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, template, count, 0);
+ if (infos == null || infos.length<1) {
+ throw new GLException("Error while enumerating available XVisualInfos");
}
+ caps = new GLCapabilities[infos.length];
+ for (int i = 0; i < infos.length; i++) {
+ caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
+ // Attempt to find the visual chosen by glXChooseVisual
+ if (recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) {
+ recommendedIndex = i;
+ }
+ }
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
+ }
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
+ }
+ chosen = 0; // default ..
+ } else if (chosen >= caps.length) {
+ throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
+ }
+ if (infos[chosen] == null) {
+ throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
+ }
+ retXVisualInfo = XVisualInfo.create(infos[chosen]);
+ }finally{
+ X11Lib.XUnlockDisplay(display);
}
- try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- } catch (NativeWindowException e) {
- if(DEBUG) {
- e.printStackTrace();
- }
- chosen = -1;
- }
- if (chosen < 0) {
- // keep on going ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
- }
- chosen = 0; // default ..
- } else if (chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- if (infos[chosen] == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
- }
- 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/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index 41f012122..14d07e74f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -41,7 +41,6 @@ package com.jogamp.opengl.impl.x11.glx;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
-import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.x11.*;
public class X11OffscreenGLXDrawable extends X11GLXDrawable {
@@ -75,27 +74,31 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
int screen = aScreen.getIndex();
getFactoryImpl().lockToolkit();
- X11Lib.XLockDisplay(dpy);
try {
- pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
- component.getWidth(), component.getHeight(), bitsPerPixel);
- if (pixmap == 0) {
- throw new GLException("XCreatePixmap failed");
- }
- long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
- if (drawable == 0) {
- X11Lib.XFreePixmap(dpy, pixmap);
- pixmap = 0;
- throw new GLException("glXCreateGLXPixmap failed");
- }
- ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
- if (DEBUG) {
- System.err.println("Created pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(dpy));
- }
+ X11Lib.XLockDisplay(dpy);
+ try{
+
+ pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
+ component.getWidth(), component.getHeight(), bitsPerPixel);
+ if (pixmap == 0) {
+ throw new GLException("XCreatePixmap failed");
+ }
+ long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
+ if (drawable == 0) {
+ X11Lib.XFreePixmap(dpy, pixmap);
+ pixmap = 0;
+ throw new GLException("glXCreateGLXPixmap failed");
+ }
+ ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
+ if (DEBUG) {
+ System.err.println("Created pixmap " + toHexString(pixmap) +
+ ", GLXPixmap " + toHexString(drawable) +
+ ", display " + toHexString(dpy));
+ }
+ }finally{
+ X11Lib.XUnlockDisplay(dpy);
+ }
} finally {
- X11Lib.XUnlockDisplay(dpy);
getFactoryImpl().unlockToolkit();
}
}
@@ -107,37 +110,41 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
long display = nw.getDisplayHandle();
getFactoryImpl().lockToolkit();
- X11Lib.XLockDisplay(display);
try {
- long drawable = nw.getSurfaceHandle();
- if (DEBUG) {
- System.err.println("Destroying pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(display));
- }
-
- // Must destroy pixmap and GLXPixmap
-
- if (DEBUG) {
- long cur = GLX.glXGetCurrentContext();
- if (cur != 0) {
- System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
+ X11Lib.XLockDisplay(display);
+ try{
+ long drawable = nw.getSurfaceHandle();
+ if (DEBUG) {
+ System.err.println("Destroying pixmap " + toHexString(pixmap) +
+ ", GLXPixmap " + toHexString(drawable) +
+ ", display " + toHexString(display));
+ }
+
+ // Must destroy pixmap and GLXPixmap
+
+ if (DEBUG) {
+ long cur = GLX.glXGetCurrentContext();
+ if (cur != 0) {
+ System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
+ }
+ }
+
+ // FIXME: workaround for crashes on NVidia hardware when
+ // destroying pixmap (no context is current at the point of the
+ // crash, at least from the point of view of
+ // glXGetCurrentContext)
+ GLX.glXMakeCurrent(display, 0, 0);
+
+ GLX.glXDestroyGLXPixmap(display, drawable);
+ X11Lib.XFreePixmap(display, pixmap);
+ drawable = 0;
+ pixmap = 0;
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
+
+ }finally{
+ X11Lib.XUnlockDisplay(display);
}
- }
-
- // FIXME: workaround for crashes on NVidia hardware when
- // destroying pixmap (no context is current at the point of the
- // crash, at least from the point of view of
- // glXGetCurrentContext)
- GLX.glXMakeCurrent(display, 0, 0);
-
- GLX.glXDestroyGLXPixmap(display, drawable);
- X11Lib.XFreePixmap(display, pixmap);
- drawable = 0;
- pixmap = 0;
- ((SurfaceChangeable)nw).setSurfaceHandle(0);
} finally {
- X11Lib.XUnlockDisplay(display);
getFactoryImpl().unlockToolkit();
display = 0;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
index 4ffda2fae..a6f52f3c0 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
@@ -58,8 +58,8 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
int num[] = { -1 };
long display = screen.getDevice().getHandle();
+ X11Lib.XLockDisplay(display);
try {
- X11Lib.XLockDisplay(display);
XVisualInfo[] xvis = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualIDMask|X11Lib.VisualScreenMask, xvi_temp, num, 0);
if(xvis==null || num[0]<1) {
@@ -90,8 +90,8 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
vinfo_template.setC_class(c_class);
long display = screen.getDevice().getHandle();
+ X11Lib.XLockDisplay(display);
try {
- X11Lib.XLockDisplay(display);
XVisualInfo[] vinfos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, vinfo_template, num, 0);
XVisualInfo best=null;
int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
index 69ace3c52..58b40efe0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
@@ -57,13 +57,16 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
/** Creates a new X11GraphicsScreen using a thread local display connection */
public static AbstractGraphicsScreen createDefault() {
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = X11Util.createThreadLocalDefaultDisplay();
try {
+ long display = X11Util.createThreadLocalDefaultDisplay();
X11Lib.XLockDisplay(display);
- int scrnIdx = X11Lib.DefaultScreen(display);
- return createScreenDevice(display, scrnIdx);
+ try{
+ int scrnIdx = X11Lib.DefaultScreen(display);
+ return createScreenDevice(display, scrnIdx);
+ }finally{
+ X11Lib.XUnlockDisplay(display);
+ }
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
}
@@ -71,13 +74,16 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
public long getDefaultVisualID() {
// It still could be an AWT hold handle ..
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = getDevice().getHandle();
try {
+ long display = getDevice().getHandle();
X11Lib.XLockDisplay(display);
- int scrnIdx = X11Lib.DefaultScreen(display);
- return X11Lib.DefaultVisualID(display, scrnIdx);
+ try{
+ int scrnIdx = X11Lib.DefaultScreen(display);
+ return X11Lib.DefaultVisualID(display, scrnIdx);
+ }finally{
+ X11Lib.XUnlockDisplay(display);
+ }
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
}
@@ -85,14 +91,17 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
private static int fetchScreen(X11GraphicsDevice device, int screen) {
// It still could be an AWT hold handle ..
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = device.getHandle();
try {
+ long display = device.getHandle();
X11Lib.XLockDisplay(display);
- if(X11Lib.XineramaEnabled(display)) {
- screen = 0; // Xinerama -> 1 screen
+ try{
+ if(X11Lib.XineramaEnabled(display)) {
+ screen = 0; // Xinerama -> 1 screen
+ }
+ }finally{
+ X11Lib.XUnlockDisplay(display);
}
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return screen;