[vlc-commits] opengl: set textures non const

Thomas Guillem git at videolan.org
Thu Jan 26 12:47:45 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jan 24 11:01:47 2017 +0100| [26ace33de5f28d742d3d9ef815e59dd4db8d3274] | committer: Thomas Guillem

opengl: set textures non const

This allow tex converters to generate textures from the pf_update callback.

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

 modules/video_output/opengl/converter_android.c | 9 ++++++---
 modules/video_output/opengl/converters.c        | 9 +++++----
 modules/video_output/opengl/internal.h          | 6 +++---
 modules/video_output/opengl/vout_helper.c       | 3 ++-
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/modules/video_output/opengl/converter_android.c b/modules/video_output/opengl/converter_android.c
index db887db..9e1f274 100644
--- a/modules/video_output/opengl/converter_android.c
+++ b/modules/video_output/opengl/converter_android.c
@@ -58,10 +58,11 @@ tc_anop_gen_textures(const opengl_tex_converter_t *tc,
 }
 
 static void
-tc_anop_del_textures(const opengl_tex_converter_t *tc, const GLuint *textures)
+tc_anop_del_textures(const opengl_tex_converter_t *tc, GLuint *textures)
 {
     (void) tc;
     glDeleteTextures(1, textures);
+    textures[0] = 0;
 }
 
 static int
@@ -86,9 +87,10 @@ pool_unlock_pic(picture_t *p_pic)
 
 static picture_pool_t *
 tc_anop_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt,
-                 unsigned requested_count, const GLuint *textures)
+                 unsigned requested_count, GLuint *textures)
 {
     struct priv *priv = tc->priv;
+    assert(textures[0] != 0);
     priv->stex = SurfaceTexture_create(tc->parent, textures[0]);
     if (priv->stex == NULL)
     {
@@ -145,11 +147,12 @@ error:
 }
 
 static int
-tc_anop_update(const opengl_tex_converter_t *tc, const GLuint *textures,
+tc_anop_update(const opengl_tex_converter_t *tc, GLuint *textures,
                unsigned width, unsigned height,
                picture_t *pic, const size_t *plane_offset)
 {
     (void) width; (void) height; (void) plane_offset;
+    assert(textures[0] != 0);
 
     if (plane_offset != NULL)
         return VLC_EGENERIC;
diff --git a/modules/video_output/opengl/converters.c b/modules/video_output/opengl/converters.c
index bcbc5a1..71863f1 100644
--- a/modules/video_output/opengl/converters.c
+++ b/modules/video_output/opengl/converters.c
@@ -233,7 +233,7 @@ picture_destroy_cb(picture_t *pic)
 
 static picture_pool_t *
 tc_common_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt,
-                   unsigned requested_count, const GLuint *textures)
+                   unsigned requested_count, GLuint *textures)
 {
     struct priv *priv = tc->priv;
     picture_t *pictures[VLCGL_PICTURE_MAX];
@@ -343,10 +343,10 @@ tc_common_gen_textures(const opengl_tex_converter_t *tc,
 }
 
 static void
-tc_common_del_textures(const opengl_tex_converter_t *tc,
-                       const GLuint *textures)
+tc_common_del_textures(const opengl_tex_converter_t *tc, GLuint *textures)
 {
     glDeleteTextures(tc->desc->plane_count, textures);
+    memset(textures, 0, tc->desc->plane_count * sizeof(GLuint));
 }
 
 static int
@@ -410,7 +410,7 @@ upload_plane(const opengl_tex_converter_t *tc,
 }
 
 static int
-tc_common_update(const opengl_tex_converter_t *tc, const GLuint *textures,
+tc_common_update(const opengl_tex_converter_t *tc, GLuint *textures,
                  unsigned width, unsigned height,
                  picture_t *pic, const size_t *plane_offset)
 {
@@ -422,6 +422,7 @@ tc_common_update(const opengl_tex_converter_t *tc, const GLuint *textures,
     int ret = VLC_SUCCESS;
     for (unsigned i = 0; i < tc->desc->plane_count && ret == VLC_SUCCESS; i++)
     {
+        assert(textures[i] != 0);
         glActiveTexture(GL_TEXTURE0 + i);
         glClientActiveTexture(GL_TEXTURE0 + i);
         glBindTexture(tc->tex_target, textures[i]);
diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index ae0c1e4..e1be75d 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -204,7 +204,7 @@ struct opengl_tex_converter_t
      * \param textures array of textures to delete (one per plane)
      */
     void (*pf_del_textures)(const opengl_tex_converter_t *fc,
-                            const GLuint *textures);
+                            GLuint *textures);
 
     /*
      * Callback to allocate a picture pool
@@ -221,7 +221,7 @@ struct opengl_tex_converter_t
     picture_pool_t *(*pf_get_pool)(const opengl_tex_converter_t *fc,
                                    const video_format_t *fmt,
                                    unsigned requested_count,
-                                   const GLuint *textures);
+                                   GLuint *textures);
 
     /*
      * Callback to update a picture
@@ -238,7 +238,7 @@ struct opengl_tex_converter_t
      * (one per plane, can be NULL)
      * \return VLC_SUCCESS or a VLC error
      */
-    int (*pf_update)(const opengl_tex_converter_t *fc, const GLuint *textures,
+    int (*pf_update)(const opengl_tex_converter_t *fc, GLuint *textures,
                      unsigned width, unsigned height,
                      picture_t *pic, const size_t *plane_offset);
 
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index e3430bd..3ad38b3 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -611,7 +611,6 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned
 
 error:
     tc->pf_del_textures(tc, vgl->texture);
-    memset(vgl->texture, 0, PICTURE_PLANE_MAX * sizeof(GLuint));
     return NULL;
 }
 
@@ -1201,6 +1200,7 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
     }
 
     for (unsigned j = 0; j < vgl->chroma->plane_count; j++) {
+        assert(vgl->texture[j] != 0);
         glActiveTexture(GL_TEXTURE0+j);
         glClientActiveTexture(GL_TEXTURE0+j);
         glBindTexture(tc->tex_target, vgl->texture[j]);
@@ -1329,6 +1329,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
             glr->tex_width, glr->tex_height,
         };
 
+        assert(glr->texture != 0);
         glBindTexture(sub_tc->tex_target, glr->texture);
         sub_tc->pf_prepare_shader(sub_tc, sub_program, glr->alpha);
 



More information about the vlc-commits mailing list