From c225285e09f0a29fca418601bf1aa07cafb54339 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 13 Mar 2013 06:35:30 +0100
Subject: Bug 665: Allow re-association of GLContext/GLEventListener to a
GLDrawable (Part 4)
Note:
- GLEventListenerState preservs the GLAutoDrawable state,
i.e. GLContext, all GLEventListener and the GLAnimatorControl association.
- GLEventListenerState may be utilized to move the state from a dying GLAutoDrawable,
to be moved to a new created GLAutoDrawable at a later time.
- GLEventListenerState will be made public soon.
+++
Exessive unit tests cover the new feature, tested manually on GNU/Linux/X11 and OSX(Java6/Java7).
+++
- GLAutoDrawable
- Change 'setContext(..)' to allow the destruction of the unbound old context:
'setContext(GLContext newCtx)' -> 'setContext(GLContext newCtx, boolean destroyPrevCtx)'
- Implementations: Properly implement 'setRealized(..)' incl. obeying threading constraints if exists.
Method is being utilized at least for GLEventListenerState.moveTo(..)
to unrealize and realize the drawable resources.
+++
Fix propagation of GLContext/GLDrawable association change (Bottom -> Top):
GLDrawableImpl.associateContext
GLContextImpl.associateDrawable
GLContextImpl.makeCurrent
GLContextImpl.destroy
GLContext.setGLDrawable
...
GLDrawableHelper.switchContext
GLAutoDrawble.setContext
associateDrawable(..)/associateContext(..) unifies and hence:
- GLContextImpl.contextRealized() (removed)
- GLDrawableImpl.contextRealized() (removed)
- GLDrawableImpl.associateContext(..) (merged)
- MacOSXCGLContext.drawableChangedNotify(..) (removed)
+++
- EGLUpstreamSurfaceHook.evalUpstreamSurface() validates the surface's device for reusage,
which is valid in case of GLEventListenerState.moveTo(..)
- MacOSXCGLContext.NSOpenGLImpl: pixelFormat replaces NSOpenGLLayerPfmt and has simplified lifecycle [create..destroy],
while native NSOpenGLLayer code only holds the reference until released.
---
src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 40 +++++++++++-----------
1 file changed, 20 insertions(+), 20 deletions(-)
(limited to 'src/jogl/classes/jogamp/opengl/GLDrawableImpl.java')
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index c0c28a5f2..d0c1461a9 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -164,13 +164,14 @@ public abstract class GLDrawableImpl implements GLDrawable {
@Override
public final void setRealized(boolean realizedArg) {
if ( realized != realizedArg ) { // volatile: OK (locked below)
+ final boolean isProxySurface = surface instanceof ProxySurface;
if(DEBUG) {
- System.err.println(getThreadName() + ": setRealized: "+getClass().getSimpleName()+" "+realized+" -> "+realizedArg);
+ System.err.println(getThreadName() + ": setRealized: drawable "+getClass().getSimpleName()+", surface "+surface.getClass().getSimpleName()+", isProxySurface "+isProxySurface+": "+realized+" -> "+realizedArg);
Thread.dumpStack();
}
AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice();
if(realizedArg) {
- if(surface instanceof ProxySurface) {
+ if(isProxySurface) {
((ProxySurface)surface).createNotify();
}
if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) {
@@ -195,7 +196,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
unlockSurface();
} else {
aDevice.unlock();
- if(surface instanceof ProxySurface) {
+ if(isProxySurface) {
((ProxySurface)surface).destroyNotify();
}
}
@@ -210,18 +211,26 @@ public abstract class GLDrawableImpl implements GLDrawable {
*/
protected abstract void setRealizedImpl();
- /**
- * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: construct
, destroy
.
+ /**
+ * Callback for special implementations, allowing
+ *
+ * - to associate bound context to this drawable (bound == true)
+ * or to remove such association (bound == false).
+ * - to trigger GLContext/GLDrawable related lifecycle:
construct
, destroy
.
+ *
*
- * If realized
is true
, the context has just been created and made current.
+ * If bound
is true
, the context is current and being newly associated w/ this drawable.
*
*
- * If realized
is false
, the context is still current and will be released and destroyed after this method returns.
+ * If bound
is false
, the context is still current and will be unbound (released and destroyed, or simply disassociated).
*
*
- * @see #contextMadeCurrent(GLContext, boolean)
+ * Being called by {@link GLContextImpl#associateDrawable(boolean)}.
+ *
+ * @param ctx the just bounded or unbounded context
+ * @param bound if true
create an association, otherwise remove it
*/
- protected void contextRealized(GLContext glc, boolean realized) {}
+ protected void associateContext(GLContext ctx, boolean bound) { }
/**
* Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent
, release
.
@@ -232,21 +241,12 @@ public abstract class GLDrawableImpl implements GLDrawable {
* If current
is false
, the context is still current and will be release after this method returns.
*
*
- * Note: Will also be called after {@link #contextRealized(GLContext, boolean) contextRealized(ctx, true)}
- * but not at context destruction, i.e. {@link #contextRealized(GLContext, boolean) contextRealized(ctx, false)}.
+ * Being called by {@link GLContextImpl#contextMadeCurrent(boolean)}.
*
- * @see #contextRealized(GLContext, boolean)
+ * @see #associateContext(GLContext, boolean)
*/
protected void contextMadeCurrent(GLContext glc, boolean current) { }
- /**
- * Callback for special implementations, allowing to associate bound context to this drawable (bound == true)
- * or to remove such association (bound == false).
- * @param ctx the just bounded or unbounded context
- * @param bound if true
create an association, otherwise remove it
- */
- protected void associateContext(GLContext ctx, boolean bound) { }
-
/** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/
protected int getDefaultDrawFramebuffer() { return 0; }
/** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */
--
cgit v1.2.3