From 43a473b2005d7f59a7f4f5b8bc7ca9ae88b4e894 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 16 Aug 2012 15:58:33 +0200 Subject: EGLDisplayUtil: Workaround (latest) PVR 540 EGL regression where 3nd EGLDisplay's eglInitialize(..) fails ; Fix EGLDrawableFactory.getEGLSurface() - EGLDisplayUtil: Workaround (latest) PVR 540 EGL regression where 3nd EGLDisplay's eglInitialize(..) fails In this case and if eglGetDisplay(..) fails w/ a non EGL_DEFAULT_DEVICE, fall back to EGL_DEFAULT_DEVICE - always. This workaround actually simplifies handling both cases. - Fix EGLDrawableFactory.getEGLSurface() Tests whether a given NativeSurface w/ EGLGraphicsDevice and EGLGraphicsConfiguration has a valid EGL Surface. Only if true, reuse the whole NativeSurface, otherwise construct the missing pieces (device, config and use a WrappedSurface for EGL). --- .../classes/jogamp/opengl/egl/EGLDrawable.java | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java') diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index 383b61f88..0dba4bb09 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -114,25 +114,30 @@ public abstract class EGLDrawable extends GLDrawableImpl { } } + protected static boolean isValidEGLSurface(EGLGraphicsDevice eglDevice, NativeSurface surface) { + final long eglDisplayHandle = eglDevice.getHandle(); + if (EGL.EGL_NO_DISPLAY == eglDisplayHandle) { + throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + } + boolean eglSurfaceValid = 0 != surface.getSurfaceHandle(); + if(eglSurfaceValid) { + int[] tmp = new int[1]; + eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0); + if(!eglSurfaceValid) { + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.isValidEGLSurface eglQuerySuface failed: "+toHexString(EGL.eglGetError())+", "+surface); + } + } + } + return eglSurfaceValid; + } + @Override protected final void setRealizedImpl() { final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); if (realized) { - final long eglDisplayHandle = eglDevice.getHandle(); - if (EGL.EGL_NO_DISPLAY == eglDisplayHandle) { - throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); - } - int[] tmp = new int[1]; - boolean eglSurfaceValid = 0 != surface.getSurfaceHandle(); - if(eglSurfaceValid) { - eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0); - if(!eglSurfaceValid) { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl eglQuerySuface failed: "+toHexString(EGL.eglGetError())+", "+surface); - } - } - } + final boolean eglSurfaceValid = isValidEGLSurface(eglDevice, surface); if(eglSurfaceValid) { // surface holds valid EGLSurface if(DEBUG) { -- cgit v1.2.3