diff options
author | Sven Gothel <[email protected]> | 2019-11-22 17:13:50 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-11-22 17:13:50 +0100 |
commit | 4b9754d210b22f32e5f083d3524da8f3d886bfb7 (patch) | |
tree | f238fbe9ae3f8cb7498baf10e4827c3e4d345c8a /src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java | |
parent | 29ec5eeccbe683e79106a44646c4ad99326609fa (diff) |
Bug 1156: EGL-GBM: [Re]use EGL Platform type for eglCreatePlatformWindowSurface as well (like eglGetPlatformDisplay)
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index a2903e713..d5ab61e20 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -188,46 +188,65 @@ public class EGLDisplayUtil { /* pp */ static synchronized void setSingletonEGLDisplayOnly(final boolean v) { useSingletonEGLDisplay = v; } - private static synchronized long eglGetDisplay(final long nativeDisplay_id) { - if( useSingletonEGLDisplay && null != singletonEGLDisplay ) { - if(DEBUG) { - System.err.println("EGLDisplayUtil.eglGetDisplay.s: eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+ - EGLContext.toHexString(singletonEGLDisplay.eglDisplay)+ - ", "+((EGL.EGL_NO_DISPLAY != singletonEGLDisplay.eglDisplay)?"OK":"Failed")+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); - } - return singletonEGLDisplay.eglDisplay; - } + /** + * @param useCustom see {@link NativeWindowFactory#getNativeWindowType(boolean)} + * @return the EGL platform type, e.g. {@link EGLExt#EGL_PLATFORM_X11_KHR} or {@link EGLExt#EGL_PLATFORM_GBM_KHR} + * @see NativeWindowFactory#getNativeWindowType(boolean) + * @see #getEGLPlatformType(String) + */ + public static int getEGLPlatformType(final boolean useCustom) { + return getEGLPlatformType( NativeWindowFactory.getNativeWindowType(useCustom) ); + } - final String nativeWindowType = NativeWindowFactory.getNativeWindowType(false); - final int platform; - final long eglDisplay; + /** + * @param nativeWindowType return value of {@link NativeWindowFactory#getNativeWindowType(boolean)} + * @return the EGL platform type, e.g. {@link EGLExt#EGL_PLATFORM_X11_KHR} or {@link EGLExt#EGL_PLATFORM_GBM_KHR} + * @see NativeWindowFactory#getNativeWindowType(boolean) + * @see #getEGLPlatformType(boolean) + */ + public static int getEGLPlatformType(final String nativeWindowType) { + final int eglPlatform; switch( nativeWindowType ) { case NativeWindowFactory.TYPE_X11: - platform = EGLExt.EGL_PLATFORM_X11_KHR; + eglPlatform = EGLExt.EGL_PLATFORM_X11_KHR; break; case NativeWindowFactory.TYPE_ANDROID: - platform = EGLExt.EGL_PLATFORM_ANDROID_KHR; + eglPlatform = EGLExt.EGL_PLATFORM_ANDROID_KHR; break; case NativeWindowFactory.TYPE_EGL_GBM: - platform = EGLExt.EGL_PLATFORM_GBM_KHR; // same EGLExt.EGL_PLATFORM_GBM_MESA; + eglPlatform = EGLExt.EGL_PLATFORM_GBM_KHR; // same EGLExt.EGL_PLATFORM_GBM_MESA; break; case NativeWindowFactory.TYPE_WAYLAND: // TODO - platform = EGLExt.EGL_PLATFORM_WAYLAND_KHR; + eglPlatform = EGLExt.EGL_PLATFORM_WAYLAND_KHR; break; default: - platform = 0; + eglPlatform = 0; } - if( 0 != platform ) { - eglDisplay = EGL.eglGetPlatformDisplay(platform, nativeDisplay_id, null); + return eglPlatform; + } + + private static synchronized long eglGetDisplay(final long nativeDisplay_id) { + if( useSingletonEGLDisplay && null != singletonEGLDisplay ) { + if(DEBUG) { + System.err.println("EGLDisplayUtil.eglGetDisplay.s: eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+ + EGLContext.toHexString(singletonEGLDisplay.eglDisplay)+ + ", "+((EGL.EGL_NO_DISPLAY != singletonEGLDisplay.eglDisplay)?"OK":"Failed")+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); + } + return singletonEGLDisplay.eglDisplay; } - else{ - eglDisplay = EGL.eglGetDisplay(nativeDisplay_id); + + final int eglPlatform = getEGLPlatformType(true); + final long eglDisplay; + if( 0 != eglPlatform ) { + eglDisplay = EGL.eglGetPlatformDisplay(eglPlatform, nativeDisplay_id, null); + } else { + eglDisplay = EGL.eglGetDisplay(nativeDisplay_id); } if(DEBUG) { System.err.println("EGLDisplayUtil.eglGetDisplay.X: eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+") @ "+ - platform+"/"+nativeWindowType+": "+ + eglPlatform+"/"+NativeWindowFactory.getNativeWindowType(true)+": "+ EGLContext.toHexString(eglDisplay)+ ", "+((EGL.EGL_NO_DISPLAY != eglDisplay)?"OK":"Failed")+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); } |