diff options
author | Sven Gothel <[email protected]> | 2013-03-13 06:35:30 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-03-13 06:35:30 +0100 |
commit | c225285e09f0a29fca418601bf1aa07cafb54339 (patch) | |
tree | 5cf619ad3b51db76511c3809d32ef29156eb71dd /src/jogl/classes/jogamp/opengl/egl | |
parent | 8457bf35fee253d9af29ff1150a9671f6896fc17 (diff) |
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.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index 342c4c417..77e9dc173 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -47,7 +47,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { public final void create(ProxySurface surface) { final String dbgPrefix; if(DEBUG) { - dbgPrefix = getThreadName() + ": EGLUpstreamSurfaceHook.create("+surface.getClass().getSimpleName()+"): "; + dbgPrefix = getThreadName() + ": EGLUpstreamSurfaceHook.create( up "+upstreamSurface.getClass().getSimpleName()+" -> this "+surface.getClass().getSimpleName()+" ): "; System.err.println(dbgPrefix+this); } else { dbgPrefix = null; @@ -76,24 +76,51 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { boolean isEGLSurfaceValid = true; // assume yes - final AbstractGraphicsConfiguration aConfig = upstreamSurface.getGraphicsConfiguration(); - final AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); - final EGLGraphicsDevice eglDevice; - if( aDevice instanceof EGLGraphicsDevice ) { - eglDevice = (EGLGraphicsDevice) aDevice; + final AbstractGraphicsConfiguration aConfig; + { + final AbstractGraphicsConfiguration surfaceConfig = surface.getGraphicsConfiguration(); + final AbstractGraphicsDevice surfaceDevice = null != surfaceConfig ? surfaceConfig.getScreen().getDevice() : null; + if(DEBUG) { + System.err.println(dbgPrefix+"SurfaceDevice: "+surfaceDevice.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(surfaceDevice.hashCode())+", "+surfaceDevice); + System.err.println(dbgPrefix+"SurfaceConfig: "+surfaceConfig.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(surfaceConfig.hashCode())+", "+surfaceConfig); + } + + final AbstractGraphicsConfiguration upstreamConfig = upstreamSurface.getGraphicsConfiguration(); + final AbstractGraphicsDevice upstreamDevice = upstreamConfig.getScreen().getDevice(); if(DEBUG) { - System.err.println(dbgPrefix+"Reusing eglDevice: "+eglDevice); + System.err.println(dbgPrefix+"UpstreamDevice: "+upstreamDevice.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(upstreamDevice.hashCode())+", "+upstreamDevice); + System.err.println(dbgPrefix+"UpstreamConfig: "+upstreamConfig.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(upstreamConfig.hashCode())+", "+upstreamConfig); } - if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { - eglDevice.open(); + + if( surfaceDevice instanceof EGLGraphicsDevice ) { + eglDevice = (EGLGraphicsDevice) surfaceDevice; + aConfig = surfaceConfig; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing this eglDevice: "+eglDevice+", using this config "+aConfig.getClass().getSimpleName()+" "+aConfig); + } + if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { + eglDevice.open(); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } else if( upstreamDevice instanceof EGLGraphicsDevice ) { + eglDevice = (EGLGraphicsDevice) upstreamDevice; + aConfig = upstreamConfig; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing upstream eglDevice: "+eglDevice+", using upstream config "+aConfig.getClass().getSimpleName()+" "+aConfig); + } + if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { + eglDevice.open(); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } else { + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); + aConfig = upstreamConfig; isEGLSurfaceValid = false; surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } - } else { - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); - isEGLSurfaceValid = false; - surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); |