From 22918e26ac717d661d45c764177780454f06c937 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Thu, 10 Jul 2014 16:50:16 +0200
Subject: Refine 'GLSharedContextSetter' test cases: Use
 'setSharedAutoDrawable(sharedAutoDrawable)' where possible; Fix/Refine API
 doc.

---
 .../classes/javax/media/opengl/GLSharedContextSetter.java  | 10 ++++++++--
 .../jogamp/opengl/test/android/MovieSimpleActivity1.java   |  2 +-
 .../test/junit/jogl/acore/TestSharedContextListNEWT.java   |  2 +-
 .../test/junit/jogl/acore/TestSharedContextListNEWT2.java  |  2 +-
 .../test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java |  2 +-
 .../junit/jogl/acore/TestSharedContextVBOES2NEWT0.java     | 11 ++++++-----
 .../junit/jogl/acore/TestSharedContextVBOES2NEWT1.java     |  2 +-
 .../junit/jogl/acore/TestSharedContextVBOES2NEWT2.java     | 14 ++++++--------
 8 files changed, 25 insertions(+), 20 deletions(-)

(limited to 'src')

diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
index 11ed648c2..679898dca 100644
--- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
+++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
@@ -110,6 +110,12 @@ public interface GLSharedContextSetter extends GLAutoDrawable {
      * as long it is not {@link GLContext#isCreated() created natively}.
      * </p>
      * <p>
+     * The <i>preferred method</i> of assigning a <i>shared context</i> is
+     * to {@link #setSharedAutoDrawable(GLAutoDrawable) set the shared GLAutoDrawable},
+     * since this method also takes the {@link GLEventListener}
+     * {@link GLAutoDrawable#areAllGLEventListenerInitialized() initialization into account}.
+     * </p>
+     * <p>
      * See <a href="#lifecycle">Lifecycle Considerations</a>.
      * </p>
      *
@@ -129,12 +135,12 @@ public interface GLSharedContextSetter extends GLAutoDrawable {
      * this method shall be called beforehand to have any effect.
      * </p>
      * <p>
-     * A set <i>sharedAutoDrawable</i> will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization},
+     * A set <i>sharedAutoDrawable</i> will block context creation, i.e. <a href="GLAutoDrawable.html#initialization">initialization</a>
      * as long it's
      * <ul>
      *   <li>{@link GLContext} is <code>null</code>, or</li>
      *   <li>{@link GLContext} has not been {@link GLContext#isCreated() created natively}, or</li>
-     *   <li>{@link GLEventListener} are <i>not</i> {@link GLSharedContextSetter#areAllGLEventListenerInitialized() completely initialized}</li>
+     *   <li>{@link GLEventListener} are <i>not</i> {@link GLAutoDrawable#areAllGLEventListenerInitialized() completely initialized}</li>
      * </ul>
      * </p>
      * <p>
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
index 1fc736ee7..7c99e2cf3 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
@@ -180,7 +180,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity {
                            windowBounds.setWidth( wh[0] );
                            windowBounds.setHeight( wh[1] );
                        }
-                       glWindowHUD.setSharedContext(glWindowMain.getContext());
+                       glWindowHUD.setSharedAutoDrawable(glWindowMain);
                        demoHUD = new MovieSimple(mPlayerShared);
                        mPlayerSub = mPlayerShared;
                     } else {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
index 0469092fb..6f8d6c626 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
@@ -92,7 +92,7 @@ public class TestSharedContextListNEWT extends UITestCase {
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
-            glWindow.setSharedContext(sharedDrawable.getContext());
+            glWindow.setSharedAutoDrawable(sharedDrawable);
         }
 
         glWindow.setSize(width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
index a11ddcdb0..16467771d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
@@ -93,7 +93,7 @@ public class TestSharedContextListNEWT2 extends UITestCase {
         Assert.assertNotNull(glWindow);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
-            glWindow.setSharedContext(sharedDrawable.getContext());
+            glWindow.setSharedAutoDrawable(sharedDrawable);
         }
 
         glWindow.setSize(width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
index a9e7c0cc1..8f84e293d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
@@ -120,7 +120,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
         glWindow.setPosition(x, y);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
-            glWindow.setSharedContext(sharedDrawable.getContext());
+            glWindow.setSharedAutoDrawable(sharedDrawable);
         }
 
         glWindow.setSize(width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
index 3efbabb20..d2d1384e4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
@@ -33,6 +33,7 @@ import java.util.List;
 import com.jogamp.newt.opengl.GLWindow;
 
 import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLAutoDrawable;
 import javax.media.opengl.GLCapabilities;
 import javax.media.opengl.GLContext;
 import javax.media.opengl.GLProfile;
@@ -76,14 +77,14 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
         }
     }
 
-    protected GLWindow runTestGL(final Animator animator, final int x, final int y, final GearsES2 gears, final GLContext sharedContext) throws InterruptedException {
-        final boolean useShared = null != sharedContext;
+    protected GLWindow runTestGL(final Animator animator, final int x, final int y, final GearsES2 gears, final GLAutoDrawable sharedDrawable) throws InterruptedException {
+        final boolean useShared = null != sharedDrawable;
         final GLWindow glWindow = GLWindow.create(caps);
         Assert.assertNotNull(glWindow);
         glWindow.setPosition(x, y);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
-            glWindow.setSharedContext(sharedContext);
+            glWindow.setSharedAutoDrawable(sharedDrawable);
         }
         glWindow.setSize(width, height);
         glWindow.addGLEventListener(gears);
@@ -130,7 +131,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
         final GearsES2 g2 = new GearsES2(0);
         g2.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
         final GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
-                                                f1.getY()+0, g2, f1.getContext());
+                                                f1.getY()+0, g2, f1);
         final GLContext ctx2 = f2.getContext();
         Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
         Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -153,7 +154,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
         final GearsES2 g3 = new GearsES2(0);
         g3.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
         final GLWindow f3 = runTestGL(animator, f1.getX()+0,
-                                                f1.getY()+height+insets.getTotalHeight(), g3, f1.getContext());
+                                                f1.getY()+height+insets.getTotalHeight(), g3, f1);
 
         final GLContext ctx3 = f3.getContext();
         Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
index 3a61f169e..fb15509d0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
@@ -135,7 +135,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
         glWindow.setPosition(x, y);
         glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared);
         if(useShared) {
-            glWindow.setSharedContext(sharedDrawable.getContext());
+            glWindow.setSharedAutoDrawable(sharedDrawable);
         }
 
         glWindow.setSize(width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
index 1921dca60..a101c05d0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
@@ -128,12 +128,11 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
         f1.invoke(false, new GLRunnable() {
             @Override
             public boolean run(final GLAutoDrawable drawable) {
-                final GLContext ctx1 = f1.getContext();
-                Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
-                f2.setSharedContext(ctx1);
+                Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
+                f2.setSharedAutoDrawable(f1);
                 f2.setVisible(true);
                 f2.display(); // kick off GLContext ..
-                f3.setSharedContext(ctx1);
+                f3.setSharedAutoDrawable(f1);
                 f3.setVisible(true);
                 f3.display(); // kick off GLContext ..
                 return true;
@@ -253,11 +252,10 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
         f1.invoke(false, new GLRunnable() {
             @Override
             public boolean run(final GLAutoDrawable drawable) {
-                final GLContext ctx1 = f1.getContext();
-                Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
-                f2.setSharedContext(ctx1);
+                Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
+                f2.setSharedAutoDrawable(f1);
                 f2.setVisible(true);
-                f3.setSharedContext(ctx1);
+                f3.setSharedAutoDrawable(f1);
                 f3.setVisible(true);
                 return true;
             }
-- 
cgit v1.2.3