[vlc-devel] [PATCH 05/21] libvlc: pass the OpenGL rendering configuration update as a structure

Steve Lhomme robux4 at ycbcr.xyz
Wed Feb 5 16:13:13 CET 2020


For now the structure only includes the width/height of the rendering area.
---
 doc/libvlc/QtGL/qtvlcwidget.cpp   | 14 +++++++-------
 doc/libvlc/sdl_opengl_player.cpp  | 10 +++++-----
 include/vlc/libvlc_media_player.h | 11 ++++++++---
 modules/video_output/vgl.c        |  5 ++++-
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp b/doc/libvlc/QtGL/qtvlcwidget.cpp
index ee9c1b3effb..b1bf535e398 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.cpp
+++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
@@ -38,19 +38,19 @@ public:
     }
 
     /// this callback will create the surfaces and FBO used by VLC to perform its rendering
-    static void resizeRenderTextures(void* data, unsigned width, unsigned height,
+    static void resizeRenderTextures(void* data, const libvlc_video_render_cfg_t *cfg,
                                      libvlc_video_output_cfg_t *render_cfg)
     {
        VLCVideo* that = static_cast<VLCVideo*>(data);
-        if (width != that->m_width || height != that->m_height)
+        if (cfg->width != that->m_width || cfg->height != that->m_height)
             cleanup(data);
 
-        that->mBuffers[0] = new QOpenGLFramebufferObject(width, height);
-        that->mBuffers[1] = new QOpenGLFramebufferObject(width, height);
-        that->mBuffers[2] = new QOpenGLFramebufferObject(width, height);
+        that->mBuffers[0] = new QOpenGLFramebufferObject(cfg->width, cfg->height);
+        that->mBuffers[1] = new QOpenGLFramebufferObject(cfg->width, cfg->height);
+        that->mBuffers[2] = new QOpenGLFramebufferObject(cfg->width, cfg->height);
 
-        that->m_width = width;
-        that->m_height = height;
+        that->m_width = cfg->width;
+        that->m_height = cfg->height;
 
         that->mBuffers[that->m_idx_render]->bind();
 
diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index 6e44b451640..6b25f8d3f29 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -116,11 +116,11 @@ public:
     }
 
     /// this callback will create the surfaces and FBO used by VLC to perform its rendering
-    static void resize(void* data, unsigned width, unsigned height,
+    static void resize(void* data, const libvlc_video_render_cfg_t *cfg,
                        libvlc_video_output_cfg_t *render_cfg)
     {
         VLCVideo* that = static_cast<VLCVideo*>(data);
-        if (width != that->m_width || height != that->m_height)
+        if (cfg->width != that->m_width || cfg->height != that->m_height)
             cleanup(data);
 
         glGenTextures(3, that->m_tex);
@@ -128,7 +128,7 @@ public:
 
         for (int i = 0; i < 3; i++) {
             glBindTexture(GL_TEXTURE_2D, that->m_tex[i]);
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cfg->width, cfg->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -145,8 +145,8 @@ public:
             return;
         }
 
-        that->m_width = width;
-        that->m_height = height;
+        that->m_width = cfg->width;
+        that->m_height = cfg->height;
 
         glBindFramebuffer(GL_FRAMEBUFFER, that->m_fbo[that->m_idx_render]);
 
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 7b9f64bef4b..172cd963fd5 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -521,6 +521,12 @@ typedef bool (*libvlc_video_setup_cb)(void* opaque);
  */
 typedef void (*libvlc_video_cleanup_cb)(void* opaque);
 
+typedef struct
+{
+    unsigned width;                        /** rendering video width in pixel */
+    unsigned height;                      /** rendering video height in pixel */
+} libvlc_video_render_cfg_t;
+
 typedef struct
 {
     int surface_format;  /** the rendering DXGI_FORMAT for \ref libvlc_video_direct3d_engine_d3d11,
@@ -537,12 +543,11 @@ typedef struct
  * Callback prototype called on video size changes
  *
  * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
- * \param width video width in pixel [IN]
- * \param height video height in pixel [IN]
+ * \param cfg configuration of the video that will be rendered [IN]
  * \param output configuration describing with how the rendering is setup [OUT]
  * \version LibVLC 4.0.0 or later
  */
-typedef void (*libvlc_video_update_output_cb)(void* opaque, unsigned width, unsigned height,
+typedef void (*libvlc_video_update_output_cb)(void* opaque, const libvlc_video_render_cfg_t *cfg,
                                               libvlc_video_output_cfg_t *output );
 
 
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 7785a6b3444..3d2d08735a8 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -82,8 +82,11 @@ static void Resize(vlc_gl_t * gl, unsigned w, unsigned h)
         return;
 
     MakeCurrent(gl);
+    libvlc_video_render_cfg_t output_cfg = {
+        w, h,
+    };
     libvlc_video_output_cfg_t render_cfg;
-    sys->resizeCb(sys->opaque, h, w, &render_cfg);
+    sys->resizeCb(sys->opaque, &output_cfg, &render_cfg);
     ReleaseCurrent(gl);
     assert(render_cfg.surface_format == GL_RGBA);
     assert(render_cfg.full_range == true);
-- 
2.17.1



More information about the vlc-devel mailing list