summaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/GLContextShareSet.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-02-05 18:09:25 +0000
committerKenneth Russel <[email protected]>2006-02-05 18:09:25 +0000
commitced30725fdaa23c108605104d0d364055e629a63 (patch)
tree05b00a2e9e623854b2e1262d038811d56282f45b /src/classes/com/sun/opengl/impl/GLContextShareSet.java
parente3699308d1478ec35b2cc3fdcef2046a8b1b695f (diff)
Intermediate checkin for FBO support in Java2D/JOGL bridge. Needed to
keep track of server-side OpenGL objects, like textures and display lists, created by the end user to preserve the illusion of independent contexts even though they will all share textures and display lists with the Java2D OpenGL context in order to access its FBO. Added GLObjectTracker class to track creation and destruction of these objects and to support cleanup when the last referring context has been destroyed. Modified GLContextShareSet to create and install GLObjectTrackers when necessary and GLContext to ref and unref tracker appropriately. Changed GlueGen's JavaPrologue and JavaEpilogue directives (and their documentation) to perform argument name substitution. Wrote documentation section on argument name substitution and specified behavior for primitive arrays (converts to string "array_name, array_name_offset" in substitution). Rephrased GlueGen's RangeCheck directives in terms of JavaPrologue directives and deleted old specialized code. Fixed bug in handling of VBO support in GLConfiguration when JavaPrologue was present for affected functions. Added JavaPrologue and JavaEpilogue directives to all existing OpenGL routines creating server-side objects (though it's possible some were missed) to call GLObjectTracker when necessary. Added RangeCheck directives for these routines as well. Worked around bug in JOGL demos where shutdownDemo() was being called more than once. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@584 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/GLContextShareSet.java')
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextShareSet.java55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextShareSet.java b/src/classes/com/sun/opengl/impl/GLContextShareSet.java
index a797ae69c..b0d1b1da4 100644
--- a/src/classes/com/sun/opengl/impl/GLContextShareSet.java
+++ b/src/classes/com/sun/opengl/impl/GLContextShareSet.java
@@ -48,11 +48,13 @@ import javax.media.opengl.*;
context creation as is inherent in the AWT and Swing. */
public class GLContextShareSet {
+ private static boolean forceTracking = Debug.isPropertyDefined("jogl.glcontext.forcetracking");
+
// This class is implemented with a WeakHashMap that goes from the
// contexts as keys to a complex data structure as value that tracks
// context creation and deletion.
- private static Map/*<GLContext, WeakReference<ShareSet>>*/ shareMap = new WeakHashMap();
+ private static Map/*<GLContext, ShareSet>*/ shareMap = new WeakHashMap();
private static Object dummyValue = new Object();
private static class ShareSet {
@@ -60,6 +62,17 @@ public class GLContextShareSet {
private Map createdShares = new WeakHashMap();
private Map destroyedShares = new WeakHashMap();
+ // When the Java2D/OpenGL pipeline is active and using FBOs to
+ // render, we need to track the creation and destruction of
+ // server-side OpenGL objects among contexts sharing these objects
+ private GLObjectTracker tracker;
+
+ public ShareSet() {
+ if (isObjectTrackingEnabled()) {
+ tracker = new GLObjectTracker();
+ }
+ }
+
public void add(GLContext ctx) {
if (allShares.put(ctx, dummyValue) == null) {
// FIXME: downcast to GLContextImpl undesirable
@@ -98,23 +111,57 @@ public class GLContextShareSet {
assert res == null : "State of ShareSet corrupted; thought context " +
ctx + " shouldn't have been in destroyed set but was";
}
+
+ public GLObjectTracker getObjectTracker() {
+ return tracker;
+ }
+ }
+
+ private static boolean isObjectTrackingEnabled() {
+ return (Java2D.isOGLPipelineActive() && Java2D.isFBOEnabled());
}
+ /** Indicates to callers whether sharing must be registered even for
+ contexts which don't share textures and display lists with any
+ others. */
+ public static boolean isObjectTrackingDebuggingEnabled() {
+ return forceTracking;
+ }
/** Indicate that contexts <code>share1</code> and
<code>share2</code> will share textures and display lists. */
public static synchronized void registerSharing(GLContext share1, GLContext share2) {
ShareSet share = entryFor(share1);
- if (share == null) {
+ if (share == null && (share2 != null)) {
share = entryFor(share2);
}
if (share == null) {
share = new ShareSet();
}
share.add(share1);
- share.add(share2);
+ if (share2 != null) {
+ share.add(share2);
+ }
addEntry(share1, share);
- addEntry(share2, share);
+ if (share2 != null) {
+ addEntry(share2, share);
+ }
+ GLObjectTracker tracker = share.getObjectTracker();
+ if (tracker != null) {
+ // FIXME: downcast to GLContextImpl undesirable
+ GLContextImpl impl1 = (GLContextImpl) share1;
+ GLContextImpl impl2 = (GLContextImpl) share2;
+ if (impl1.getObjectTracker() == null) {
+ impl1.setObjectTracker(tracker);
+ }
+ if ((impl2 != null) && (impl2.getObjectTracker() == null)) {
+ impl2.setObjectTracker(tracker);
+ }
+ assert impl1.getObjectTracker() == tracker : "State of ShareSet corrupted; " +
+ "got different-than-expected GLObjectTracker for context 1";
+ assert (impl2 == null) || (impl2.getObjectTracker() == tracker) : "State of ShareSet corrupted; " +
+ "got different-than-expected GLObjectTracker for context 2";
+ }
}
public static synchronized GLContext getShareContext(GLContext contextToCreate) {