aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextImpl.java15
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableHelper.java7
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java23
3 files changed, 43 insertions, 2 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java
index 8963b2f5e..d363cfe80 100644
--- a/src/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -50,6 +50,7 @@ public abstract class GLContextImpl extends GLContext {
protected static final boolean DEBUG = Debug.debug("GLContextImpl");
protected static final boolean VERBOSE = Debug.verbose();
protected static final boolean NO_FREE = Debug.isPropertyDefined("jogl.GLContext.nofree");
+ protected boolean optimizationEnabled = !Debug.isPropertyDefined("jogl.GLContext.noopt");
// Cache of the functions that are available to be called at the current
// moment in time
@@ -351,6 +352,11 @@ public abstract class GLContextImpl extends GLContext {
return "0x" + Long.toHexString(hex);
}
+ //---------------------------------------------------------------------------
+ // Helpers for integration with Java2D/OpenGL pipeline when FBOs are
+ // being used
+ //
+
public void setObjectTracker(GLObjectTracker tracker) {
this.tracker = tracker;
}
@@ -367,6 +373,15 @@ public abstract class GLContextImpl extends GLContext {
return deletedObjectTracker;
}
+ //---------------------------------------------------------------------------
+ // Helpers for context optimization where the last context is left
+ // current on the OpenGL worker thread
+ //
+
+ public boolean isOptimizable() {
+ return optimizationEnabled;
+ }
+
public boolean hasWaiters() {
return lock.hasWaiters();
}
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
index 920fac624..2a96e2958 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
@@ -105,8 +105,13 @@ public class GLDrawableHelper {
GLContext context,
Runnable runnable,
Runnable initAction) {
+ // FIXME: downcast to GLContextImpl undesirable
+ boolean isOptimizable = ((context instanceof GLContextImpl) &&
+ ((GLContextImpl) context).isOptimizable());
+
if (GLWorkerThread.isStarted() &&
- GLWorkerThread.isWorkerThread()) {
+ GLWorkerThread.isWorkerThread() &&
+ isOptimizable) {
// We're going to allow a context to be left current on the
// GLWorkerThread for optimization purposes
GLContext lastContext = GLContext.getCurrent();
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java
index e666fc152..f4f4c7094 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java
+++ b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java
@@ -46,6 +46,10 @@ import com.sun.opengl.impl.*;
public class X11OnscreenGLContext extends X11GLContext {
protected X11OnscreenGLDrawable drawable;
+ // This indicates whether the context we have created is indirect
+ // and therefore requires the toolkit to be locked around all GL
+ // calls rather than just all GLX calls
+ protected boolean isIndirect;
public X11OnscreenGLContext(X11OnscreenGLDrawable drawable,
GLContext shareWith) {
@@ -64,13 +68,30 @@ public class X11OnscreenGLContext extends X11GLContext {
}
return super.makeCurrentImpl();
} finally {
- if (lockRes != X11OnscreenGLDrawable.LOCK_SURFACE_NOT_READY) {
+ if (optimizationEnabled) {
+ if (lockRes != X11OnscreenGLDrawable.LOCK_SURFACE_NOT_READY) {
+ drawable.unlockSurface();
+ }
+ }
+ }
+ }
+
+ protected void releaseImpl() throws GLException {
+ if (!optimizationEnabled) {
+ try {
+ super.releaseImpl();
+ } finally {
drawable.unlockSurface();
}
}
}
+ public boolean isOptimizable() {
+ return super.isOptimizable() && !isIndirect;
+ }
+
protected void create() {
createContext(true);
+ isIndirect = !GLX.glXIsDirect(drawable.getDisplay(), context);
}
}