[vlc-commits] opengl: move paddings computation to _Prepare()

Romain Vimont git at videolan.org
Mon Mar 23 11:37:39 CET 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Fri Jan 31 13:08:18 2020 +0100| [10b5929692e5b9883265b556a116e96320a6e1ad] | committer: Jean-Baptiste Kempf

opengl: move paddings computation to _Prepare()

Texture paddings were computed in _Display(), while the picture format
is known in _Prepare().

This will allow to remove the video_format_t parameter of _Display().

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=10b5929692e5b9883265b556a116e96320a6e1ad
---

 modules/video_output/opengl/renderer.c | 38 ++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index 88e0e3e3f8..41b9fee413 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -913,30 +913,13 @@ int
 vlc_gl_renderer_Prepare(struct vlc_gl_renderer *renderer, picture_t *picture)
 {
     const struct vlc_gl_interop *interop = renderer->interop;
-    /* Update the texture */
-    return interop->ops->update_textures(interop, renderer->textures,
-                                         renderer->tex_width,
-                                         renderer->tex_height, picture,
-                                         NULL);
-}
-
-int
-vlc_gl_renderer_Draw(struct vlc_gl_renderer *renderer,
-                     const video_format_t *source)
-{
-    const opengl_vtable_t *vt = renderer->vt;
-
-    vt->Clear(GL_COLOR_BUFFER_BIT);
-
-    vt->UseProgram(renderer->program_id);
+    const video_format_t *source = &picture->format;
 
     if (source->i_x_offset != renderer->last_source.i_x_offset
      || source->i_y_offset != renderer->last_source.i_y_offset
      || source->i_visible_width != renderer->last_source.i_visible_width
      || source->i_visible_height != renderer->last_source.i_visible_height)
     {
-        const struct vlc_gl_interop *interop = renderer->interop;
-
         memset(renderer->var.TexCoordsMap, 0,
                sizeof(renderer->var.TexCoordsMap));
         for (unsigned j = 0; j < interop->tex_count; j++)
@@ -1011,6 +994,25 @@ vlc_gl_renderer_Draw(struct vlc_gl_renderer *renderer,
         renderer->last_source.i_visible_width = source->i_visible_width;
         renderer->last_source.i_visible_height = source->i_visible_height;
     }
+
+    /* Update the texture */
+    return interop->ops->update_textures(interop, renderer->textures,
+                                         renderer->tex_width,
+                                         renderer->tex_height, picture,
+                                         NULL);
+}
+
+int
+vlc_gl_renderer_Draw(struct vlc_gl_renderer *renderer,
+                     const video_format_t *source)
+{
+    (void) source;
+    const opengl_vtable_t *vt = renderer->vt;
+
+    vt->Clear(GL_COLOR_BUFFER_BIT);
+
+    vt->UseProgram(renderer->program_id);
+
     DrawWithShaders(renderer);
 
     return VLC_SUCCESS;



More information about the vlc-commits mailing list