From 6b66ec1550a1f022db2dda2db3fe473cbebfec85 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Wed, 8 Mar 2006 17:14:04 +0000 Subject: 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 --- .../com/sun/opengl/impl/GLContextShareSet.java | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/classes/com/sun/opengl/impl/GLContextShareSet.java') diff --git a/src/classes/com/sun/opengl/impl/GLContextShareSet.java b/src/classes/com/sun/opengl/impl/GLContextShareSet.java index 20a9364fb..293402899 100644 --- a/src/classes/com/sun/opengl/impl/GLContextShareSet.java +++ b/src/classes/com/sun/opengl/impl/GLContextShareSet.java @@ -52,6 +52,7 @@ import javax.media.opengl.*; public class GLContextShareSet { private static boolean forceTracking = Debug.isPropertyDefined("jogl.glcontext.forcetracking"); + private static final boolean DEBUG = Debug.debug("GLContextShareSet"); // This class is implemented with a WeakHashMap that goes from the // contexts as keys to a complex data structure as value that tracks @@ -157,7 +158,8 @@ public class GLContextShareSet { before any server-side OpenGL objects have been created in that context. */ public static synchronized void registerForObjectTracking(GLContext olderContextOrNull, - GLContext newContext) { + GLContext newContext, + GLContext realShareContext) { if (isObjectTrackingEnabled() || isObjectTrackingDebuggingEnabled()) { if (olderContextOrNull != null && newContext != null) { @@ -170,6 +172,36 @@ public class GLContextShareSet { GLContextImpl impl1 = (GLContextImpl) olderContextOrNull; GLContextImpl impl2 = (GLContextImpl) newContext; GLObjectTracker tracker = null; + + GLObjectTracker deletedObjectTracker = null; + GLContextImpl shareImpl = (GLContextImpl) realShareContext; + // Before we zap the "user-level" object trackers, make sure + // that all contexts in the share set share the destroyed object + // tracker + if (shareImpl != null) { + deletedObjectTracker = shareImpl.getDeletedObjectTracker(); + } + if (deletedObjectTracker == null) { + // Must create one and possibly set it up in the older context + deletedObjectTracker = new GLObjectTracker(); + if (DEBUG) { + System.err.println("Created deletedObjectTracker " + deletedObjectTracker + " because " + + ((shareImpl == null) ? "shareImpl was null" : "shareImpl's (" + shareImpl + ") deletedObjectTracker was null")); + } + + if (shareImpl != null) { + // FIXME: think should really assert in this case + shareImpl.setDeletedObjectTracker(deletedObjectTracker); + if (DEBUG) { + System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in shareImpl context " + shareImpl); + } + } + } + impl2.setDeletedObjectTracker(deletedObjectTracker); + if (DEBUG) { + System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in impl2 context " + impl2); + } + // Don't share object trackers with the primordial share context from Java2D if (Java2D.isOGLPipelineActive()) { // FIXME: probably need to do something different here -- cgit v1.2.3