vlc | branch: master | Romain Vimont <ro...@videolabs.io> | Mon Mar 22 16:06:24 2021 +0100| [90a6084eaa9611fdf44c91e6b48a24f2a4c46cd9] | committer: Alexandre Janniaux
egl_display: improve support detection A module egl_display must only provide EGL displays where eglTerminate() can be called, even if other modules are using EGL (typically because it is internally refcounted). This is always the case on Android, so egl_display was initially only enabled on Android: https://android.googlesource.com/platform/frameworks/native/+/master/opengl/libs/EGL/egl_display.cpp But this may also be the case on other platforms which support EGL_KHR_display_reference: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_display_reference.txt Co-authored-by: Alexandre Janniaux <aja...@videolabs.io> Signed-off-by: Alexandre Janniaux <aja...@videolabs.io> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=90a6084eaa9611fdf44c91e6b48a24f2a4c46cd9 --- modules/video_output/opengl/Makefile.am | 2 +- modules/video_output/opengl/egl_display_generic.c | 38 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/video_output/opengl/Makefile.am b/modules/video_output/opengl/Makefile.am index 3bee347ef0..c7cbdedfb6 100644 --- a/modules/video_output/opengl/Makefile.am +++ b/modules/video_output/opengl/Makefile.am @@ -92,7 +92,7 @@ endif # HAVE_GL libegl_display_generic_plugin_la_SOURCES = video_output/opengl/egl_display_generic.c libegl_display_generic_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(EGL_FLAGS) libegl_display_generic_plugin_la_LIBADD = $(EGL_LIBS) -if HAVE_ANDROID +if HAVE_EGL vout_LTLIBRARIES += libegl_display_generic_plugin.la endif diff --git a/modules/video_output/opengl/egl_display_generic.c b/modules/video_output/opengl/egl_display_generic.c index dfa68125c4..dfb841feef 100644 --- a/modules/video_output/opengl/egl_display_generic.c +++ b/modules/video_output/opengl/egl_display_generic.c @@ -31,11 +31,49 @@ #include "egl_display.h" +#ifndef __ANDROID__ +static EGLenum GetPlatform(const char *extensions) +{ +#ifdef EGL_KHR_platform_x11 + if (vlc_gl_StrHasToken(extensions, "EGL_EXT_platform_x11")) + return EGL_PLATFORM_X11_KHR; +#endif + +#ifdef EGL_KHR_platform_wayland + if (vlc_gl_StrHasToken(extensions, "EGL_EXT_platform_wayland")) + return EGL_PLATFORM_WAYLAND_KHR; +#endif + + return 0; +} +#endif + static vlc_egl_display_open_fn Open; static int Open(struct vlc_egl_display *display) { +#ifdef __ANDROID__ + /* The default display is refcounted on Android */ display->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); +#elif defined(EGL_KHR_display_reference) + const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + + if (!vlc_gl_StrHasToken(extensions, "EGL_KHR_display_reference")) + return VLC_EGENERIC; + + EGLenum platform = GetPlatform(extensions); + if (!platform) + return VLC_EGENERIC; + + const EGLAttrib attribs[] = { + EGL_TRACK_REFERENCES_KHR, EGL_TRUE, + EGL_NONE, + }; + + display->display = + eglGetPlatformDisplay(platform, EGL_DEFAULT_DISPLAY, attribs); +#endif + if (display->display == EGL_NO_DISPLAY) return VLC_EGENERIC; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits