aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/GLContextImpl.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-03-08 17:14:04 +0000
committerKenneth Russel <[email protected]>2006-03-08 17:14:04 +0000
commit6b66ec1550a1f022db2dda2db3fe473cbebfec85 (patch)
tree72dca2fe3e14e7b1410f60f0d01305206285c202 /src/classes/com/sun/opengl/impl/GLContextImpl.java
parentec11d8b213d18fc9dbcc2add3d86265044f629c9 (diff)
Restructured how GLObjectTracker destroys tracked objects during
context destruction. Now, in addition to tracking sharing between contexts requested by the user, also tracks the behind-the-scenes sharing going on with e.g. Java2D. Makes determination of whether objects can be immediately destroyed by checking current context and seeing whether it shares the same deleted object pool as the one being destroyed. If objects can not be destroyed immediately, their destruction is deferred until the next makeCurrent of a context sharing objects with the one currently being destroyed (if one exists -- the case of this being the last context actually referencing the objects is handled by the OpenGL drivers). This fixes the resizing problems seen when -Dsun.java2d.opengl.fobject=true is specified along with -Dsun.java2d.opengl=true in Mustang. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@654 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/GLContextImpl.java')
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextImpl.java45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java
index 4a6885f45..8e38ec276 100644
--- a/src/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -61,6 +61,9 @@ public abstract class GLContextImpl extends GLContext {
// Tracks creation and deletion of server-side OpenGL objects when
// the Java2D/OpenGL pipeline is active and using FBOs to render
private GLObjectTracker tracker;
+ // Supports deletion of these objects when no other context is
+ // current which can support immediate deletion of them
+ private GLObjectTracker deletedObjectTracker;
protected GL gl;
public GLContextImpl(GLContext shareWith) {
@@ -77,7 +80,11 @@ public abstract class GLContextImpl extends GLContext {
if (shareContext != null) {
GLContextShareSet.registerSharing(this, shareContext);
}
- GLContextShareSet.registerForObjectTracking(shareWith, this);
+ // Always indicate real behind-the-scenes sharing to track deleted objects
+ if (shareContext == null) {
+ shareContext = Java2D.filterShareContext(shareWith);
+ }
+ GLContextShareSet.registerForObjectTracking(shareWith, this, shareContext);
}
public int makeCurrent() throws GLException {
@@ -119,6 +126,12 @@ public abstract class GLContextImpl extends GLContext {
lock.unlock();
} else {
setCurrent(this);
+
+ // Try cleaning up any stale server-side OpenGL objects
+ // FIXME: not sure what to do here if this throws
+ if (deletedObjectTracker != null) {
+ deletedObjectTracker.clean(getGL());
+ }
}
return res;
}
@@ -151,23 +164,11 @@ public abstract class GLContextImpl extends GLContext {
// If we are tracking creation and destruction of server-side
// OpenGL objects, we must decrement the reference count of the
// GLObjectTracker upon context destruction.
- try {
- int res = makeCurrent();
- if (res != CONTEXT_CURRENT) {
- // FIXME: we really need to behave better than this
- throw new GLException("Unable to make context current to destroy tracked server-side OpenGL objects");
- }
- try {
- tracker.unref(getGL());
- } finally {
- release();
- }
- } catch (GLException e) {
- // FIXME: should probably do something more intelligent here
- if (DEBUG) {
- e.printStackTrace();
- }
- }
+ //
+ // Note that we can only eagerly delete these server-side
+ // objects if there is another context currrent right now
+ // which shares textures and display lists with this one.
+ tracker.unref(deletedObjectTracker);
}
}
@@ -352,6 +353,14 @@ public abstract class GLContextImpl extends GLContext {
return tracker;
}
+ public void setDeletedObjectTracker(GLObjectTracker deletedObjectTracker) {
+ this.deletedObjectTracker = deletedObjectTracker;
+ }
+
+ public GLObjectTracker getDeletedObjectTracker() {
+ return deletedObjectTracker;
+ }
+
public boolean hasWaiters() {
return lock.hasWaiters();
}