[vlc-commits] [Git][videolan/vlc][master] 4 commits: opengl: expose the activate function

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Mar 5 15:13:28 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
2c1b88a8 by Thomas Guillem at 2023-03-05T14:48:33+00:00
opengl: expose the activate function

- - - - -
09d8638e by Thomas Guillem at 2023-03-05T14:48:33+00:00
opengl: ensure the activate cb use the correct type

- - - - -
9155b089 by Thomas Guillem at 2023-03-05T14:48:33+00:00
opengl: add an alpha config to the activate cb

- - - - -
a780676a by Thomas Guillem at 2023-03-05T14:48:33+00:00
egl: implement gl_cfg->need_alpha

- - - - -


19 changed files:

- include/vlc_opengl.h
- modules/video_filter/egl_pbuffer.c
- modules/video_filter/egl_surfacetexture.c
- modules/video_filter/opengl.c
- modules/video_output/android/display.c
- modules/video_output/apple/VLCCVOpenGLProvider.m
- modules/video_output/apple/VLCOpenGLES2VideoView.m
- modules/video_output/glx.c
- modules/video_output/libplacebo/instance_opengl.c
- modules/video_output/opengl/display.c
- modules/video_output/opengl/egl.c
- modules/video_output/vgl.c
- modules/video_output/win32/glwin32.c
- modules/video_output/win32/wgl.c
- modules/visualization/glspectrum.c
- modules/visualization/projectm.cpp
- modules/visualization/vsxu.cpp
- src/video_output/opengl.c
- test/src/video_output/opengl.c


Changes:

=====================================
include/vlc_opengl.h
=====================================
@@ -49,6 +49,37 @@ enum vlc_gl_api_type {
     VLC_OPENGL_ES2,
 };
 
+struct vlc_gl_cfg
+{
+    bool need_alpha; /* False by default */
+};
+
+typedef int (*vlc_gl_activate)(vlc_gl_t *, unsigned width, unsigned height,
+                               const struct vlc_gl_cfg *cfg);
+
+#define set_callback_opengl_common(activate) \
+    { \
+        vlc_gl_activate activate__ = activate; \
+        (void) activate__; \
+        set_callback(activate) \
+    } \
+
+#define set_callback_opengl(activate, priority) \
+    set_callback_opengl_common(activate) \
+    set_capability("opengl", priority)
+
+#define set_callback_opengl_offscreen(activate, priority) \
+    set_callback_opengl_common(activate) \
+    set_capability("opengl offscreen", priority)
+
+#define set_callback_opengl_es2(activate, priority) \
+    set_callback_opengl_common(activate) \
+    set_capability("opengl es2", priority)
+
+#define set_callback_opengl_es2_offscreen(activate, priority) \
+    set_callback_opengl_common(activate) \
+    set_capability("opengl es2 offscreen", priority)
+
 struct vlc_gl_operations
 {
     union {
@@ -97,14 +128,17 @@ struct vlc_gl_t
  * @param cfg initial configuration (including window to use as OpenGL surface)
  * @param flags OpenGL context type
  * @param name module name (or NULL for auto)
+ * @param gl_cfg OpenGL configuration (or NULL for default)
  * @return a new context, or NULL on failure
  */
 VLC_API vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *cfg,
-                                unsigned flags, const char *name) VLC_USED;
+                                unsigned flags, const char *name,
+                                const struct vlc_gl_cfg *gl_cfg) VLC_USED;
 VLC_API vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
                                          struct vlc_decoder_device *device,
                                          unsigned width, unsigned height,
-                                         unsigned flags, const char *name);
+                                         unsigned flags, const char *name,
+                                         const struct vlc_gl_cfg *gl_cfg);
 
 VLC_API void vlc_gl_Delete(vlc_gl_t *);
 
@@ -159,7 +193,9 @@ static inline void *vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
 
 VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
                                         const struct vlc_window_cfg *,
-                                        struct vlc_window **) VLC_USED;
+                                        struct vlc_window **,
+                                        const struct vlc_gl_cfg *) VLC_USED;
+
 VLC_API bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
 VLC_API void vlc_gl_surface_Destroy(vlc_gl_t *);
 


=====================================
modules/video_filter/egl_pbuffer.c
=====================================
@@ -385,8 +385,15 @@ static void Close( vlc_gl_t *gl )
     vlc_egl_display_Delete(sys->vlc_display);
 }
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     struct vlc_gl_pbuffer *sys = vlc_obj_malloc(&gl->obj, sizeof *sys);
     if (sys == NULL)
         return VLC_ENOMEM;
@@ -482,11 +489,9 @@ vlc_module_begin()
     set_shortname( N_("egl_pbuffer") )
     set_description( N_("EGL PBuffer offscreen opengl provider") )
 #ifdef USE_OPENGL_ES2
-    set_capability( "opengl es2 offscreen", 1)
+    set_callback_opengl_es2_offscreen( Open, 1 )
 #else
-    set_capability( "opengl offscreen", 1 )
+    set_callback_opengl_offscreen( Open, 1 )
 #endif
-
     add_shortcut( "egl_pbuffer" )
-    set_callback( Open )
 vlc_module_end()


=====================================
modules/video_filter/egl_surfacetexture.c
=====================================
@@ -327,8 +327,15 @@ error:
     return VLC_EGENERIC;
 }
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     if (gl->device == NULL || gl->device->type != VLC_DECODER_DEVICE_AWINDOW)
     {
         msg_Err(gl, "Wrong decoder device");
@@ -434,8 +441,7 @@ error1:
 vlc_module_begin()
     set_shortname( N_("egl_surfacetexture") )
     set_description( N_("EGL Android SurfaceTexture offscreen opengl provider") )
-    set_capability( "opengl es2 offscreen", 100)
+    set_callback_opengl_es2_offscreen(Open, 100)
 
     add_shortcut( "egl_surfacetexture" )
-    set_callback( Open )
 vlc_module_end()


=====================================
modules/video_filter/opengl.c
=====================================
@@ -183,7 +183,7 @@ static int Open( vlc_object_t *obj )
 
     struct vlc_decoder_device *device = filter_HoldDecoderDevice(filter);
     sys->gl = vlc_gl_CreateOffscreen(obj, device, width, height, VLCGLAPI,
-                                     NULL);
+                                     NULL, NULL);
 
     /* The vlc_gl_t instance must have hold the device if it needs it. */
     if (device)


=====================================
modules/video_output/android/display.c
=====================================
@@ -606,7 +606,7 @@ static void ClearSurface(vout_display_t *vd)
     {
         /* Clear the surface to black with OpenGL ES 2 */
         char *modlist = var_InheritString(sys->embed, "gles2");
-        vlc_gl_t *gl = vlc_gl_Create(vd->cfg, VLC_OPENGL_ES2, modlist);
+        vlc_gl_t *gl = vlc_gl_Create(vd->cfg, VLC_OPENGL_ES2, modlist, NULL);
         free(modlist);
         if (gl == NULL)
             return;


=====================================
modules/video_output/apple/VLCCVOpenGLProvider.m
=====================================
@@ -506,8 +506,15 @@ static void FreeCVBuffer(picture_t *picture)
 
 @end
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     VLCCVOpenGLProvider *sys = [[VLCCVOpenGLProvider alloc] initWithGL:gl width:width height:height];
     if (sys == nil)
         return VLC_EGENERIC;;
@@ -521,10 +528,9 @@ vlc_module_begin()
     set_shortname( N_("cvpx_gl") )
     set_description( N_("OpenGL backed by CVPixelBuffer") )
 #if TARGET_OS_IPHONE
-    set_capability( "opengl es2 offscreen", 100 )
+    set_callback_opengl_es2_offscreen( Open, 100 )
 #else
-    set_capability( "opengl offscreen", 100 )
+    set_callback_opengl_offscreen( Open, 100 )
 #endif
     add_shortcut( "cvpx_gl" )
-    set_callback( Open)
 vlc_module_end()


=====================================
modules/video_output/apple/VLCOpenGLES2VideoView.m
=====================================
@@ -490,10 +490,17 @@ static void Close(vlc_gl_t *gl)
 
 
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
     vlc_window_t *wnd = gl->surface;
 
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     /* We only support UIView container window. */
     if (wnd->type != VLC_WINDOW_TYPE_NSOBJECT)
         return VLC_EGENERIC;
@@ -521,7 +528,6 @@ vlc_module_begin ()
     set_shortname (N_("CAEAGL"))
     set_description (N_("CAEAGL provider for OpenGL"))
     set_subcategory (SUBCAT_VIDEO_VOUT)
-    set_capability ("opengl es2", 50)
-    set_callback(Open)
+    set_callback_opengl_es2 (Open, 50)
     add_shortcut ("caeagl")
 vlc_module_end ()


=====================================
modules/video_output/glx.c
=====================================
@@ -152,10 +152,17 @@ static void Close(vlc_gl_t *gl)
     free(sys);
 }
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
     vlc_object_t *obj = VLC_OBJECT(gl);
 
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     if (gl->surface->type != VLC_WINDOW_TYPE_XID || !vlc_xlib_init (obj))
         return VLC_EGENERIC;
 
@@ -317,6 +324,5 @@ vlc_module_begin ()
     set_shortname (N_("GLX"))
     set_description (N_("GLX extension for OpenGL"))
     set_subcategory (SUBCAT_VIDEO_VOUT)
-    set_capability ("opengl", 20)
-    set_callback(Open)
+    set_callback_opengl(Open, 20)
 vlc_module_end ()


=====================================
modules/video_output/libplacebo/instance_opengl.c
=====================================
@@ -105,7 +105,7 @@ static int InitInstance(vlc_placebo_t *pl, const vout_display_cfg_t *cfg)
     bool current = false;
 
     char *name = var_InheritString(pl, MODULE_VARNAME);
-    sys->gl = vlc_gl_Create(cfg, API, name);
+    sys->gl = vlc_gl_Create(cfg, API, name, NULL);
     free(name);
     if (!sys->gl || vlc_gl_MakeCurrent(sys->gl) != VLC_SUCCESS)
         goto error;


=====================================
modules/video_output/opengl/display.c
=====================================
@@ -186,7 +186,7 @@ static int Open(vout_display_t *vd,
     }
 #endif
 
-    sys->gl = vlc_gl_Create(vd->cfg, API, gl_name);
+    sys->gl = vlc_gl_Create(vd->cfg, API, gl_name, NULL);
     free(gl_name);
     if (sys->gl == NULL)
         goto error;


=====================================
modules/video_output/opengl/egl.c
=====================================
@@ -597,7 +597,8 @@ static void InitEGL(void)
  * Probe EGL display availability
  */
 static int Open(vlc_gl_t *gl, const struct gl_api *api,
-                unsigned width, unsigned height)
+                unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
     InitEGL();
 
@@ -644,6 +645,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
         EGL_RED_SIZE, 5,
         EGL_GREEN_SIZE, 5,
         EGL_BLUE_SIZE, 5,
+        EGL_ALPHA_SIZE, gl_cfg->need_alpha ? 5 : 0,
         EGL_RENDERABLE_TYPE, api->render_bit,
         EGL_NONE
     };
@@ -699,22 +701,24 @@ error:
     return ret;
 }
 
-static int OpenGLES2(vlc_gl_t *gl, unsigned width, unsigned height)
+static int OpenGLES2(vlc_gl_t *gl, unsigned width, unsigned height,
+                     const struct vlc_gl_cfg *gl_cfg)
 {
     static const struct gl_api api = {
         "OpenGL_ES", EGL_OPENGL_ES_API, 4, EGL_OPENGL_ES2_BIT,
         { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE },
     };
-    return Open(gl, &api, width, height);
+    return Open(gl, &api, width, height, gl_cfg);
 }
 
-static int OpenGL(vlc_gl_t *gl, unsigned width, unsigned height)
+static int OpenGL(vlc_gl_t *gl, unsigned width, unsigned height,
+                  const struct vlc_gl_cfg *gl_cfg)
 {
     static const struct gl_api api = {
         "OpenGL", EGL_OPENGL_API, 4, EGL_OPENGL_BIT,
         { EGL_NONE },
     };
-    return Open(gl, &api, width, height);
+    return Open(gl, &api, width, height, gl_cfg);
 }
 
 #ifdef USE_PLATFORM_XCB
@@ -728,13 +732,11 @@ vlc_module_begin ()
     set_shortname (N_("EGL"))
     set_description (N_("EGL extension for OpenGL"))
     set_subcategory (SUBCAT_VIDEO_VOUT)
-    set_capability("opengl", VLC_PRIORITY)
-    set_callback(OpenGL)
+    set_callback_opengl(OpenGL, VLC_PRIORITY)
     add_shortcut ("egl")
 
     add_submodule ()
-    set_capability("opengl es2", VLC_PRIORITY)
-    set_callback(OpenGLES2)
+    set_callback_opengl_es2(OpenGLES2, VLC_PRIORITY)
     add_shortcut ("egl")
 
 vlc_module_end ()


=====================================
modules/video_output/vgl.c
=====================================
@@ -122,7 +122,8 @@ static void Close(vlc_gl_t *gl)
         }                                                          \
     } while( 0 )
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
     vout_display_sys_t * sys;
 
@@ -131,6 +132,12 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
          engineType != libvlc_video_engine_gles2 )
         return VLC_ENOTSUP;
 
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     /* Allocate structure */
     gl->sys = sys = vlc_obj_calloc(VLC_OBJECT(gl), 1, sizeof(*sys));
     if( !sys )
@@ -181,12 +188,11 @@ vlc_module_begin()
     set_description("GL texture output")
     set_subcategory(SUBCAT_VIDEO_VOUT)
 
-    set_capability("opengl", 0)
-    set_callback(Open)
+    set_callback_opengl(Open, 0)
+
     add_shortcut("vglmem")
 
     add_submodule()
-    set_capability("opengl es2", 0)
-    set_callback(Open)
+    set_callback_opengl_es2(Open, 0)
     add_shortcut("vglmem")
 vlc_module_end()


=====================================
modules/video_output/win32/glwin32.c
=====================================
@@ -148,7 +148,7 @@ static int Open(vout_display_t *vd,
         goto error;
 
     char *modlist = var_InheritString(embed_cfg.window, "gl");
-    sys->gl = vlc_gl_Create(&embed_cfg, VLC_OPENGL, modlist);
+    sys->gl = vlc_gl_Create(&embed_cfg, VLC_OPENGL, modlist, NULL);
     free(modlist);
     if (!sys->gl)
     {


=====================================
modules/video_output/win32/wgl.c
=====================================
@@ -35,7 +35,8 @@
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-static int Open(vlc_gl_t *, unsigned width, unsigned height);
+static int Open(vlc_gl_t *, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg);
 static void Close(vlc_gl_t *);
 
 #define HW_GPU_AFFINITY_TEXT N_("GPU affinity")
@@ -47,8 +48,7 @@ vlc_module_begin()
 
     add_integer("gpu-affinity", -1, HW_GPU_AFFINITY_TEXT, NULL)
 
-    set_capability("opengl", 50)
-    set_callback(Open)
+    set_callback_opengl(Open, 50)
     add_shortcut("wgl")
 vlc_module_end()
 
@@ -149,10 +149,17 @@ static void DestroyGPUAffinityDC(vlc_gl_t *gl) {
     fncDeleteDCNV(sys->affinityHDC);
 }
 
-static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
+static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
+                const struct vlc_gl_cfg *gl_cfg)
 {
     vout_display_sys_t *sys;
 
+    if (gl_cfg->need_alpha)
+    {
+        msg_Err(gl, "Cannot support alpha yet");
+        return VLC_ENOTSUP;
+    }
+
     /* Allocate structure */
     gl->sys = sys = calloc(1, sizeof(*sys));
     if (!sys)


=====================================
modules/visualization/glspectrum.c
=====================================
@@ -199,7 +199,7 @@ static int Open(vlc_object_t * p_this)
         .height = var_InheritInteger(p_filter, "glspectrum-height"),
     };
 
-    p_sys->gl = vlc_gl_surface_Create(p_this, &cfg, NULL);
+    p_sys->gl = vlc_gl_surface_Create(p_this, &cfg, NULL, NULL);
     if (p_sys->gl == NULL)
         return VLC_EGENERIC;
 


=====================================
modules/visualization/projectm.cpp
=====================================
@@ -190,7 +190,7 @@ static int Open( vlc_object_t * p_this )
     cfg.width = var_CreateGetInteger( p_filter, "projectm-width" );
     cfg.height = var_CreateGetInteger( p_filter, "projectm-height" );
 
-    p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL );
+    p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL, NULL );
     if( p_sys->gl == NULL )
         goto error;
 


=====================================
modules/visualization/vsxu.cpp
=====================================
@@ -134,7 +134,7 @@ static int Open( vlc_object_t * p_this )
     cfg.width = var_InheritInteger( p_filter, "vsxu-width" );
     cfg.height = var_InheritInteger( p_filter, "vsxu-height" );
 
-    p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL );
+    p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL, NULL);
     if( p_sys->gl == NULL )
         goto error;
 


=====================================
src/video_output/opengl.c
=====================================
@@ -33,6 +33,10 @@
 #include "libvlc.h"
 #include <vlc_modules.h>
 
+static const struct vlc_gl_cfg gl_cfg_default = {
+    .need_alpha = false
+};
+
 struct vlc_gl_priv_t
 {
     vlc_gl_t gl;
@@ -40,12 +44,13 @@ struct vlc_gl_priv_t
 
 static int vlc_gl_start(void *func, bool forced, va_list ap)
 {
-    int (*activate)(vlc_gl_t *, unsigned, unsigned) = func;
+    vlc_gl_activate activate = func;
     vlc_gl_t *gl = va_arg(ap, vlc_gl_t *);
     unsigned width = va_arg(ap, unsigned);
     unsigned height = va_arg(ap, unsigned);
+    const struct vlc_gl_cfg *gl_cfg = va_arg(ap, const struct vlc_gl_cfg *);
 
-    int ret = activate(gl, width, height);
+    int ret = activate(gl, width, height, gl_cfg);
     if (ret)
         vlc_objres_clear(VLC_OBJECT(gl));
     (void) forced;
@@ -53,11 +58,14 @@ static int vlc_gl_start(void *func, bool forced, va_list ap)
 }
 
 vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
-                        unsigned flags, const char *name)
+                        unsigned flags, const char *name,
+                        const struct vlc_gl_cfg * gl_cfg)
 {
     vlc_window_t *wnd = cfg->window;
     struct vlc_gl_priv_t *glpriv;
     const char *type;
+    if (gl_cfg == NULL)
+        gl_cfg = &gl_cfg_default;
 
     enum vlc_gl_api_type api_type;
 
@@ -85,7 +93,8 @@ vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
     gl->device = NULL;
 
     gl->module = vlc_module_load(gl, type, name, true, vlc_gl_start, gl,
-                                 cfg->display.width, cfg->display.height);
+                                 cfg->display.width, cfg->display.height,
+                                 gl_cfg);
     if (gl->module == NULL)
     {
         vlc_object_delete(gl);
@@ -104,12 +113,15 @@ vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
 vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
                                  struct vlc_decoder_device *device,
                                  unsigned width, unsigned height,
-                                 unsigned flags, const char *name)
+                                 unsigned flags, const char *name,
+                                 const struct vlc_gl_cfg *gl_cfg)
 {
     struct vlc_gl_priv_t *glpriv;
     const char *type;
 
     enum vlc_gl_api_type api_type;
+    if (gl_cfg == NULL)
+        gl_cfg = &gl_cfg_default;
 
     switch (flags /*& VLC_OPENGL_API_MASK*/)
     {
@@ -140,7 +152,7 @@ vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
     gl->surface = NULL;
     gl->device = device ? vlc_decoder_device_Hold(device) : NULL;
     gl->module = vlc_module_load(gl, type, name, true, vlc_gl_start, gl, width,
-                                 height);
+                                 height, gl_cfg);
     if (gl->module == NULL)
     {
         vlc_object_delete(gl);
@@ -199,7 +211,8 @@ static void vlc_gl_surface_ResizeNotify(vlc_window_t *surface,
 
 vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
                                 const vlc_window_cfg_t *cfg,
-                                struct vlc_window **restrict wp)
+                                struct vlc_window **restrict wp,
+                                const struct vlc_gl_cfg *gl_cfg)
 {
     vlc_gl_surface_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
@@ -244,7 +257,7 @@ vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
     }
     vlc_mutex_unlock(&sys->lock);
 
-    vlc_gl_t *gl = vlc_gl_Create(&dcfg, VLC_OPENGL, NULL);
+    vlc_gl_t *gl = vlc_gl_Create(&dcfg, VLC_OPENGL, NULL, gl_cfg);
     if (gl == NULL) {
         vlc_window_Disable(surface);
         vlc_window_Delete(surface);


=====================================
test/src/video_output/opengl.c
=====================================
@@ -122,9 +122,10 @@ static void OpenGLClose(vlc_gl_t *gl)
 static int
 OpenOpenGLCommon(
         vlc_gl_t *gl, unsigned width, unsigned height,
-        bool offscreen, enum vlc_gl_api_type api_type)
+        bool offscreen, enum vlc_gl_api_type api_type,
+        const struct vlc_gl_cfg *cfg)
 {
-    (void)width; (void)height;
+    (void)width; (void)height; (void) cfg;
     assert(gl->api_type == api_type);
 
     static const struct vlc_gl_operations onscreen_ops =
@@ -152,20 +153,24 @@ OpenOpenGLCommon(
 }
 
 static int
-OpenOpenGL(vlc_gl_t *gl, unsigned width, unsigned height)
-    { return OpenOpenGLCommon(gl, width, height, false, VLC_OPENGL); };
+OpenOpenGL(vlc_gl_t *gl, unsigned width, unsigned height,
+           const struct vlc_gl_cfg *cfg)
+    { return OpenOpenGLCommon(gl, width, height, false, VLC_OPENGL, cfg); };
 
 static int
-OpenOpenGLES(vlc_gl_t *gl, unsigned width, unsigned height)
-    { return OpenOpenGLCommon(gl, width, height, false, VLC_OPENGL_ES2); };
+OpenOpenGLES(vlc_gl_t *gl, unsigned width, unsigned height,
+             const struct vlc_gl_cfg *cfg)
+    { return OpenOpenGLCommon(gl, width, height, false, VLC_OPENGL_ES2, cfg); };
 
 static int
-OpenOpenGLOffscreen(vlc_gl_t *gl, unsigned width, unsigned height)
-    { return OpenOpenGLCommon(gl, width, height, true, VLC_OPENGL); };
+OpenOpenGLOffscreen(vlc_gl_t *gl, unsigned width, unsigned height,
+                    const struct vlc_gl_cfg *cfg)
+    { return OpenOpenGLCommon(gl, width, height, true, VLC_OPENGL, cfg); };
 
 static int
-OpenOpenGLESOffscreen(vlc_gl_t *gl, unsigned width, unsigned height)
-    { return OpenOpenGLCommon(gl, width, height, true, VLC_OPENGL_ES2); };
+OpenOpenGLESOffscreen(vlc_gl_t *gl, unsigned width, unsigned height,
+                      const struct vlc_gl_cfg *cfg)
+    { return OpenOpenGLCommon(gl, width, height, true, VLC_OPENGL_ES2, cfg); };
 
 /**
  * Inject the mocked modules as a static plugin:
@@ -182,20 +187,16 @@ vlc_module_begin()
         set_capability("vout window", 1)
 
     add_submodule()
-        set_callback(OpenOpenGL)
-        set_capability("opengl", 1)
+        set_callback_opengl(OpenOpenGL, 1)
 
     add_submodule()
-        set_callback(OpenOpenGLES)
-        set_capability("opengl es2", 1)
+        set_callback_opengl_es2(OpenOpenGLES, 1)
 
     add_submodule()
-        set_callback(OpenOpenGLOffscreen)
-        set_capability("opengl offscreen", 1)
+        set_callback_opengl_offscreen(OpenOpenGLOffscreen, 1)
 
     add_submodule()
-        set_callback(OpenOpenGLESOffscreen)
-        set_capability("opengl es2 offscreen", 1)
+        set_callback_opengl_es2_offscreen(OpenOpenGLESOffscreen, 1)
 vlc_module_end()
 
 VLC_EXPORT vlc_plugin_cb vlc_static_modules[] = {
@@ -210,7 +211,7 @@ static void test_opengl_offscreen(vlc_object_t *root, enum vlc_gl_api_type api_t
     assert(device != NULL);
 
     vlc_gl_t *gl = vlc_gl_CreateOffscreen(
-            root, device, 800, 600, api_type, MODULE_STRING);
+            root, device, 800, 600, api_type, MODULE_STRING, NULL);
     assert(gl != NULL);
     vlc_decoder_device_Release(device);
 
@@ -237,7 +238,7 @@ static void test_opengl(vlc_object_t *root, enum vlc_gl_api_type api_type)
         .display.width = wnd_cfg.width,
         .display.height = wnd_cfg.height,
     };
-    vlc_gl_t *gl = vlc_gl_Create(&cfg, api_type, MODULE_STRING);
+    vlc_gl_t *gl = vlc_gl_Create(&cfg, api_type, MODULE_STRING, NULL);
     assert(gl != NULL);
 
     assert(vlc_gl_MakeCurrent(gl) == VLC_SUCCESS);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/527a08ec49ff28beef6afa44a694001d698731d8...a780676a08c7e77df90741326242cce90c7a5d9f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/527a08ec49ff28beef6afa44a694001d698731d8...a780676a08c7e77df90741326242cce90c7a5d9f
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