From da16dfd39cc17687808308c386d64f6206027c00 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sat, 30 Aug 2014 12:03:03 +0200
Subject: Bug 1054: Revert dfb9ed47ac6d8e85f6ae5fe166e7a6e28ca8ff83: Cannot
 change protected field name w/o breaking backward compatibility

---
 src/jogl/classes/jogamp/opengl/GLContextImpl.java | 66 +++++++++++------------
 1 file changed, 33 insertions(+), 33 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')

diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 9280d9830..a528c60be 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -206,11 +206,11 @@ public abstract class GLContextImpl extends GLContext {
           throw new GLException("Setting read drawable feature not available");
       }
       final Thread currentThread = Thread.currentThread();
-      if( contextLock.isLockedByOtherThread() ) {
-          throw new GLException("GLContext current by other thread "+contextLock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
+      if( lock.isLockedByOtherThread() ) {
+          throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
       }
-      final boolean lockHeld = contextLock.isOwner(currentThread);
-      if( lockHeld && contextLock.getHoldCount() > 1 ) {
+      final boolean lockHeld = lock.isOwner(currentThread);
+      if( lockHeld && lock.getHoldCount() > 1 ) {
           // would need to makeCurrent * holdCount
           throw new GLException("GLContext is recursively locked - unsupported for setGLDrawable(..)");
       }
@@ -234,11 +234,11 @@ public abstract class GLContextImpl extends GLContext {
   public final GLDrawable setGLDrawable(final GLDrawable readWrite, final boolean setWriteOnly) {
       // Validate constraints first!
       final Thread currentThread = Thread.currentThread();
-      if( contextLock.isLockedByOtherThread() ) {
-          throw new GLException("GLContext current by other thread "+contextLock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
+      if( lock.isLockedByOtherThread() ) {
+          throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
       }
-      final boolean lockHeld = contextLock.isOwner(currentThread);
-      if( lockHeld && contextLock.getHoldCount() > 1 ) {
+      final boolean lockHeld = lock.isOwner(currentThread);
+      if( lockHeld && lock.getHoldCount() > 1 ) {
           // would need to makeCurrent * holdCount
           throw new GLException("GLContext is recursively locked - unsupported for setGLDrawable(..)");
       }
@@ -339,11 +339,11 @@ public abstract class GLContextImpl extends GLContext {
   private void release(final boolean inDestruction) throws GLException {
       if( TRACE_SWITCH ) {
           final long drawH = null != drawable ? drawable.getHandle() : 0;
-          System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+(null!=drawable)+" "+toHexString(drawH)+", inDestruction: "+inDestruction+", "+contextLock);
+          System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+(null!=drawable)+" "+toHexString(drawH)+", inDestruction: "+inDestruction+", "+lock);
       }
-      if ( !contextLock.isOwner(Thread.currentThread()) ) {
+      if ( !lock.isOwner(Thread.currentThread()) ) {
           final long drawH = null != drawable ? drawable.getHandle() : 0;
-          final String msg = getThreadName() +": Context not current on thread, obj " + toHexString(hashCode())+", ctx "+toHexString(contextHandle)+", surf "+(null!=drawable)+" "+toHexString(drawH)+", inDestruction: "+inDestruction+", "+contextLock;
+          final String msg = getThreadName() +": Context not current on thread, obj " + toHexString(hashCode())+", ctx "+toHexString(contextHandle)+", surf "+(null!=drawable)+" "+toHexString(drawH)+", inDestruction: "+inDestruction+", "+lock;
           if( DEBUG_TRACE_SWITCH ) {
               System.err.println(msg);
               if( null != lastCtxReleaseStack ) {
@@ -357,7 +357,7 @@ public abstract class GLContextImpl extends GLContext {
       }
 
       Throwable drawableContextMadeCurrentException = null;
-      final boolean actualRelease = ( inDestruction || contextLock.getHoldCount() == 1 ) && 0 != contextHandle;
+      final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle;
       try {
           if( actualRelease ) {
               if( !inDestruction ) {
@@ -374,10 +374,10 @@ public abstract class GLContextImpl extends GLContext {
           if( actualRelease ) {
               setCurrent(null);
           }
-          contextLock.unlock();
+          lock.unlock();
           drawable.unlockSurface();
           if( DEBUG_TRACE_SWITCH ) {
-              final String msg = getThreadName() +": GLContext.ContextSwitch[release.X]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep  ")+" - "+contextLock;
+              final String msg = getThreadName() +": GLContext.ContextSwitch[release.X]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep  ")+" - "+lock;
               lastCtxReleaseStack = new Throwable(msg);
               if( TRACE_SWITCH ) {
                   System.err.println(msg);
@@ -397,7 +397,7 @@ public abstract class GLContextImpl extends GLContext {
       if ( DEBUG_TRACE_SWITCH ) {
           final long drawH = null != drawable ? drawable.getHandle() : 0;
           System.err.println(getThreadName() + ": GLContextImpl.destroy.0: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) +
-                  ", surf "+(null!=drawable)+" "+toHexString(drawH)+", isShared "+GLContextShareSet.isShared(this)+" - "+contextLock);
+                  ", surf "+(null!=drawable)+" "+toHexString(drawH)+", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
       }
       if ( 0 != contextHandle ) { // isCreated() ?
           if ( null == drawable ) {
@@ -415,17 +415,17 @@ public abstract class GLContextImpl extends GLContext {
               }
               // Must hold the lock around the destroy operation to make sure we
               // don't destroy the context while another thread renders to it.
-              contextLock.lock(); // holdCount++ -> 1 - n (1: not locked, 2-n: destroy while rendering)
+              lock.lock(); // holdCount++ -> 1 - n (1: not locked, 2-n: destroy while rendering)
               if ( DEBUG_TRACE_SWITCH ) {
-                  if ( contextLock.getHoldCount() > 2 ) {
+                  if ( lock.getHoldCount() > 2 ) {
                       final String msg = getThreadName() + ": GLContextImpl.destroy: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle);
-                      System.err.println(msg+" - Lock was hold more than once - makeCurrent/release imbalance: "+contextLock);
+                      System.err.println(msg+" - Lock was hold more than once - makeCurrent/release imbalance: "+lock);
                       Thread.dumpStack();
                   }
               }
               try {
                   // if not current, makeCurrent(), to call associateDrawable(..) and to disable debug handler
-                  if ( contextLock.getHoldCount() == 1 ) {
+                  if ( lock.getHoldCount() == 1 ) {
                       if ( GLContext.CONTEXT_NOT_CURRENT == makeCurrent() ) {
                           throw new GLException("GLContext.makeCurrent() failed: "+toString());
                       }
@@ -443,7 +443,7 @@ public abstract class GLContextImpl extends GLContext {
                       defaultVAO = 0;
                   }
                   glDebugHandler.enable(false);
-                  if(contextLock.getHoldCount() > 1) {
+                  if(lock.getHoldCount() > 1) {
                       // pending release() after makeCurrent()
                       release(true);
                   }
@@ -456,10 +456,10 @@ public abstract class GLContextImpl extends GLContext {
                   }
                   resetStates(false);
               } finally {
-                  contextLock.unlock();
+                  lock.unlock();
                   if ( DEBUG_TRACE_SWITCH ) {
                       System.err.println(getThreadName() + ": GLContextImpl.destroy.X: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) +
-                              ", isShared "+GLContextShareSet.isShared(this)+" - "+contextLock);
+                              ", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
                   }
               }
           } finally {
@@ -545,11 +545,11 @@ public abstract class GLContextImpl extends GLContext {
     final boolean hasDrawable = null != drawable;
     if( TRACE_SWITCH ) {
         final long drawH = null != drawable ? drawable.getHandle() : 0;
-        System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+hasDrawable+" "+toHexString(drawH)+" - "+contextLock);
+        System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+hasDrawable+" "+toHexString(drawH)+" - "+lock);
     }
     if( !hasDrawable ) {
         if( DEBUG_TRACE_SWITCH ) {
-            System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - NULL Drawable - CONTEXT_NOT_CURRENT - "+contextLock);
+            System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - NULL Drawable - CONTEXT_NOT_CURRENT - "+lock);
         }
         return CONTEXT_NOT_CURRENT;
     }
@@ -558,7 +558,7 @@ public abstract class GLContextImpl extends GLContext {
     final int lockRes = drawable.lockSurface();
     if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
         if( DEBUG_TRACE_SWITCH ) {
-            System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+contextLock);
+            System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock);
         }
         return CONTEXT_NOT_CURRENT;
     }
@@ -570,7 +570,7 @@ public abstract class GLContextImpl extends GLContext {
             if ( 0 == drawable.getHandle() ) {
                 throw new GLException("drawable has invalid handle: "+drawable);
             }
-            contextLock.lock();
+            lock.lock();
             try {
                 // One context can only be current by one thread,
                 // and one thread can only have one context current!
@@ -582,7 +582,7 @@ public abstract class GLContextImpl extends GLContext {
                         drawableUpdatedNotify();
                         unlockResources = false; // success
                         if( TRACE_SWITCH ) {
-                            System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep   - CONTEXT_CURRENT - "+contextLock);
+                            System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep   - CONTEXT_CURRENT - "+lock);
                         }
                         return CONTEXT_CURRENT;
                     } else {
@@ -605,9 +605,9 @@ public abstract class GLContextImpl extends GLContext {
             } finally {
               if (unlockResources) {
                 if( DEBUG_TRACE_SWITCH ) {
-                  System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.1]: Context lock.unlock() due to error, res "+makeCurrentResultToString(res)+", "+contextLock);
+                  System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.1]: Context lock.unlock() due to error, res "+makeCurrentResultToString(res)+", "+lock);
                 }
-                contextLock.unlock();
+                lock.unlock();
               }
             }
         } /* if ( drawable.isRealized() ) */
@@ -658,7 +658,7 @@ public abstract class GLContextImpl extends GLContext {
       */
     }
     if( TRACE_SWITCH ) {
-        System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - stateTracker.on "+glStateTracker.isEnabled()+" - "+contextLock);
+        System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - stateTracker.on "+glStateTracker.isEnabled()+" - "+lock);
     }
     return res;
   }
@@ -2223,7 +2223,7 @@ public abstract class GLContextImpl extends GLContext {
    * </p>
    */
   public final boolean isOwner(final Thread thread) {
-      return contextLock.isOwner(thread);
+      return lock.isOwner(thread);
   }
 
   /**
@@ -2233,7 +2233,7 @@ public abstract class GLContextImpl extends GLContext {
    * </p>
    */
   public final boolean hasWaiters() {
-    return contextLock.getQueueLength()>0;
+    return lock.getQueueLength()>0;
   }
 
   /**
@@ -2243,7 +2243,7 @@ public abstract class GLContextImpl extends GLContext {
    * </p>
    */
   public final int getLockCount() {
-      return contextLock.getHoldCount();
+      return lock.getHoldCount();
   }
 
   //---------------------------------------------------------------------------
-- 
cgit v1.2.3