[vlc-commits] [Git][videolan/vlc][master] 2 commits: xcb/egl: add EGL OpenGL provider with XCB platform

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Thu Apr 14 11:13:10 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
dfa7a2e3 by Rémi Denis-Courmont at 2022-04-14T09:56:27+00:00
xcb/egl: add EGL OpenGL provider with XCB platform

- - - - -
a4f0a74f by Rémi Denis-Courmont at 2022-04-14T09:56:27+00:00
xcb/egl: bump priority above XLib

- - - - -


2 changed files:

- modules/video_output/opengl/egl.c
- modules/video_output/xcb/Makefile.am


Changes:

=====================================
modules/video_output/opengl/egl.c
=====================================
@@ -36,6 +36,10 @@
 #ifdef USE_PLATFORM_X11
 # include <vlc_xlib.h>
 #endif
+#ifdef USE_PLATFORM_XCB
+# include <xcb/xcb.h>
+# include "../xcb/events.h"
+#endif
 #ifdef USE_PLATFORM_WAYLAND
 # include <wayland-egl.h>
 #endif
@@ -52,6 +56,10 @@ typedef struct vlc_gl_sys_t
     Display *x11;
     bool restore_forget_gravity;
 #endif
+#if defined (USE_PLATFORM_XCB)
+    xcb_connection_t *conn;
+    bool restore_forget_gravity;
+#endif
 #if defined (USE_PLATFORM_WAYLAND)
     struct wl_egl_window *window;
 #endif
@@ -75,6 +83,20 @@ static void ReleaseCurrent (vlc_gl_t *gl)
                     EGL_NO_CONTEXT);
 }
 
+#ifdef USE_PLATFORM_XCB
+static int GetScreenNum(xcb_connection_t *conn, const xcb_screen_t *scr)
+{
+    xcb_screen_iterator_t i = xcb_setup_roots_iterator(xcb_get_setup(conn));
+    int n = 0;
+
+    while (scr != i.data) {
+         xcb_screen_next(&i);
+         n++;
+    }
+    return n;
+}
+#endif
+
 #ifdef USE_PLATFORM_WAYLAND
 static void Resize (vlc_gl_t *gl, unsigned width, unsigned height)
 {
@@ -174,6 +196,16 @@ static void Close(vlc_gl_t *gl)
         }
         XCloseDisplay(sys->x11);
     }
+#elif defined (USE_PLATFORM_XCB)
+    if (sys->conn != NULL) {
+        if (sys->restore_forget_gravity) {
+            const uint32_t values[] = { XCB_GRAVITY_BIT_FORGET };
+
+            xcb_change_window_attributes(sys->conn, gl->surface->handle.xid,
+                                         XCB_CW_BIT_GRAVITY, values);
+        }
+        xcb_disconnect(sys->conn);
+    }
 #endif
 #ifdef USE_PLATFORM_WAYLAND
     if (sys->window != NULL)
@@ -192,6 +224,7 @@ static void Close(vlc_gl_t *gl)
 static int Open(vlc_gl_t *gl, const struct gl_api *api,
                 unsigned width, unsigned height)
 {
+    int ret = VLC_EGENERIC;
     vlc_object_t *obj = VLC_OBJECT(gl);
     vlc_gl_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
@@ -264,6 +297,53 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
     }
     (void) width; (void) height;
 
+#elif defined (USE_PLATFORM_XCB)
+    xcb_connection_t *conn;
+    const xcb_screen_t *scr;
+
+    sys->conn = NULL;
+    sys->restore_forget_gravity = false;
+
+    if (wnd->type != VOUT_WINDOW_TYPE_XID)
+        goto error;
+
+# ifdef EGL_EXT_platform_xcb
+    if (!CheckClientExt("EGL_EXT_platform_xcb"))
+        goto error;
+
+    ret = vlc_xcb_parent_Create(gl->obj.logger, wnd, &conn, &scr);
+    if (ret == VLC_SUCCESS)
+    {
+        xcb_get_window_attributes_reply_t *r =
+            xcb_get_window_attributes_reply(conn,
+                xcb_get_window_attributes(conn, wnd->handle.xid), NULL);
+
+        if (r != NULL && r->bit_gravity == XCB_GRAVITY_BIT_FORGET) {
+            const uint32_t values[] = { XCB_GRAVITY_NORTH_WEST };
+
+            xcb_change_window_attributes(sys->conn, gl->surface->handle.xid,
+                                         XCB_CW_BIT_GRAVITY, values);
+            sys->restore_forget_gravity = true;
+        }
+        free(r);
+    }
+    else
+        goto error;
+
+    sys->conn = conn;
+    window = &wnd->handle.xid;
+
+    {
+        const EGLint attrs[] = {
+            EGL_PLATFORM_XCB_SCREEN_EXT, GetScreenNum(sys->conn, scr),
+            EGL_NONE
+        };
+        sys->display = GetDisplayEXT(EGL_PLATFORM_XCB_EXT, sys->conn, attrs);
+        createSurface = CreateWindowSurfaceEXT;
+    }
+# endif
+    (void) width; (void) height;
+
 #elif defined (USE_PLATFORM_WAYLAND)
     sys->window = NULL;
 
@@ -388,7 +468,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
 
 error:
     Close(gl);
-    return VLC_EGENERIC;
+    return ret;
 }
 
 static int OpenGLES2(vlc_gl_t *gl, unsigned width, unsigned height)
@@ -409,16 +489,23 @@ static int OpenGL(vlc_gl_t *gl, unsigned width, unsigned height)
     return Open(gl, &api, width, height);
 }
 
+#ifdef USE_PLATFORM_XCB
+# define VLC_PRIORITY 60
+#endif
+#ifndef VLC_PRIORITY
+# define VLC_PRIORITY 50
+#endif
+
 vlc_module_begin ()
     set_shortname (N_("EGL"))
     set_description (N_("EGL extension for OpenGL"))
     set_subcategory (SUBCAT_VIDEO_VOUT)
-    set_capability ("opengl", 50)
+    set_capability("opengl", VLC_PRIORITY)
     set_callback(OpenGL)
     add_shortcut ("egl")
 
     add_submodule ()
-    set_capability ("opengl es2", 50)
+    set_capability("opengl es2", VLC_PRIORITY)
     set_callback(OpenGLES2)
     add_shortcut ("egl")
 


=====================================
modules/video_output/xcb/Makefile.am
=====================================
@@ -32,6 +32,11 @@ libxcb_window_plugin_la_CFLAGS = $(AM_CFLAGS) \
 libxcb_window_plugin_la_LIBADD = $(XPROTO_LIBS) $(XCB_LIBS) \
 	$(XCB_XKB_LIBS) $(XKBCOMMON_X11_LIBS)
 
+libxcb_egl_plugin_la_SOURCES = video_output/opengl/egl.c
+libxcb_egl_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PLATFORM_XCB=1
+libxcb_egl_plugin_la_CFLAGS = $(AM_CFLAGS) $(EGL_CFLAGS) $(XCB_CFLAGS)
+libxcb_egl_plugin_la_LIBADD = libvlc_xcb_events.la $(EGL_LIBS) $(XCB_LIBS)
+
 libvk_x11_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) \
 	video_output/vulkan/platform_xcb.c
 libvk_x11_plugin_la_CFLAGS = $(AM_CFLAGS) \
@@ -64,7 +69,7 @@ if HAVE_VULKAN
 vout_LTLIBRARIES += libvk_x11_plugin.la
 endif
 if HAVE_EGL
-vout_LTLIBRARIES += libegl_x11_plugin.la
+vout_LTLIBRARIES += libxcb_egl_plugin.la libegl_x11_plugin.la
 endif
 if HAVE_GL
 vout_LTLIBRARIES += libglx_plugin.la



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e4b58707be272b76abc7aff51f673fd017a4e083...a4f0a74f11cfb01182e5a42d005f045e2f6c2650

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e4b58707be272b76abc7aff51f673fd017a4e083...a4f0a74f11cfb01182e5a42d005f045e2f6c2650
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list