[vlc-commits] gl: rename opengl_shaders_api_t to opengl_vtable_t

Thomas Guillem git at videolan.org
Wed Aug 30 13:53:40 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Aug 25 13:14:58 2017 +0200| [bb0b174ed162dfc56b13226eccb6e0045fb29fdd] | committer: Thomas Guillem

gl: rename opengl_shaders_api_t to opengl_vtable_t

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

 modules/video_output/opengl/converter_android.c |  10 +-
 modules/video_output/opengl/converters.c        | 100 ++++++-------
 modules/video_output/opengl/internal.h          |   8 +-
 modules/video_output/opengl/vout_helper.c       | 184 ++++++++++++------------
 4 files changed, 150 insertions(+), 152 deletions(-)

diff --git a/modules/video_output/opengl/converter_android.c b/modules/video_output/opengl/converter_android.c
index 46bec5462a..7132d818a0 100644
--- a/modules/video_output/opengl/converter_android.c
+++ b/modules/video_output/opengl/converter_android.c
@@ -164,7 +164,7 @@ static int
 tc_anop_fetch_locations(opengl_tex_converter_t *tc, GLuint program)
 {
     struct priv *priv = tc->priv;
-    priv->uloc.uSTMatrix = tc->api->GetUniformLocation(program, "uSTMatrix");
+    priv->uloc.uSTMatrix = tc->vt->GetUniformLocation(program, "uSTMatrix");
     return priv->uloc.uSTMatrix != -1 ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
@@ -176,7 +176,7 @@ tc_anop_prepare_shader(const opengl_tex_converter_t *tc,
     (void) tex_width; (void) tex_height; (void) alpha;
     struct priv *priv = tc->priv;
     if (priv->transform_mtx != NULL)
-        tc->api->UniformMatrix4fv(priv->uloc.uSTMatrix, 1, GL_FALSE,
+        tc->vt->UniformMatrix4fv(priv->uloc.uSTMatrix, 1, GL_FALSE,
                                   priv->transform_mtx);
 }
 
@@ -261,9 +261,9 @@ opengl_tex_converter_anop_init(opengl_tex_converter_t *tc)
         "{ "
         "  gl_FragColor = texture2D(sTexture, (uSTMatrix * vec4(TexCoord0, 1, 1)).xy);"
         "}";
-    GLuint fragment_shader = tc->api->CreateShader(GL_FRAGMENT_SHADER);
-    tc->api->ShaderSource(fragment_shader, 1, &code, NULL);
-    tc->api->CompileShader(fragment_shader);
+    GLuint fragment_shader = tc->vt->CreateShader(GL_FRAGMENT_SHADER);
+    tc->vt->ShaderSource(fragment_shader, 1, &code, NULL);
+    tc->vt->CompileShader(fragment_shader);
     tc->fshader = fragment_shader;
 
     return VLC_SUCCESS;
diff --git a/modules/video_output/opengl/converters.c b/modules/video_output/opengl/converters.c
index bd71fbe73f..e3f768f1b3 100644
--- a/modules/video_output/opengl/converters.c
+++ b/modules/video_output/opengl/converters.c
@@ -302,7 +302,7 @@ tc_base_fetch_locations(opengl_tex_converter_t *tc, GLuint program)
 {
     if (tc->yuv_color)
     {
-        tc->uloc.Coefficients = tc->api->GetUniformLocation(program,
+        tc->uloc.Coefficients = tc->vt->GetUniformLocation(program,
                                                             "Coefficients");
         if (tc->uloc.Coefficients == -1)
             return VLC_EGENERIC;
@@ -312,21 +312,21 @@ tc_base_fetch_locations(opengl_tex_converter_t *tc, GLuint program)
     {
         char name[sizeof("TextureX")];
         snprintf(name, sizeof(name), "Texture%1u", i);
-        tc->uloc.Texture[i] = tc->api->GetUniformLocation(program, name);
+        tc->uloc.Texture[i] = tc->vt->GetUniformLocation(program, name);
         if (tc->uloc.Texture[i] == -1)
             return VLC_EGENERIC;
 #ifdef GL_TEXTURE_RECTANGLE
         if (tc->tex_target == GL_TEXTURE_RECTANGLE)
         {
             snprintf(name, sizeof(name), "TexSize%1u", i);
-            tc->uloc.TexSize[i] = tc->api->GetUniformLocation(program, name);
+            tc->uloc.TexSize[i] = tc->vt->GetUniformLocation(program, name);
             if (tc->uloc.TexSize[i] == -1)
                 return VLC_EGENERIC;
         }
 #endif
     }
 
-    tc->uloc.FillColor = tc->api->GetUniformLocation(program, "FillColor");
+    tc->uloc.FillColor = tc->vt->GetUniformLocation(program, "FillColor");
     if (tc->uloc.FillColor == -1)
         return VLC_EGENERIC;
     return VLC_SUCCESS;
@@ -340,18 +340,18 @@ tc_base_prepare_shader(const opengl_tex_converter_t *tc,
     (void) tex_width; (void) tex_height;
 
     if (tc->yuv_color)
-        tc->api->Uniform4fv(tc->uloc.Coefficients, 4, tc->yuv_coefficients);
+        tc->vt->Uniform4fv(tc->uloc.Coefficients, 4, tc->yuv_coefficients);
 
     for (unsigned i = 0; i < tc->tex_count; ++i)
-        tc->api->Uniform1i(tc->uloc.Texture[i], i);
+        tc->vt->Uniform1i(tc->uloc.Texture[i], i);
 
-    tc->api->Uniform4f(tc->uloc.FillColor, 1.0f, 1.0f, 1.0f, alpha);
+    tc->vt->Uniform4f(tc->uloc.FillColor, 1.0f, 1.0f, 1.0f, alpha);
 
 #ifdef GL_TEXTURE_RECTANGLE
     if (tc->tex_target == GL_TEXTURE_RECTANGLE)
     {
         for (unsigned i = 0; i < tc->tex_count; ++i)
-            tc->api->Uniform2f(tc->uloc.TexSize[i], tex_width[i],
+            tc->vt->Uniform2f(tc->uloc.TexSize[i], tex_width[i],
                                tex_height[i]);
     }
 #endif
@@ -489,15 +489,15 @@ opengl_fragment_shader_init(opengl_tex_converter_t *tc, GLenum tex_target,
     if (vlc_memstream_close(&ms) != 0)
         return 0;
 
-    GLuint fragment_shader = tc->api->CreateShader(GL_FRAGMENT_SHADER);
+    GLuint fragment_shader = tc->vt->CreateShader(GL_FRAGMENT_SHADER);
     if (fragment_shader == 0)
     {
         free(ms.ptr);
         return 0;
     }
     GLint length = ms.length;
-    tc->api->ShaderSource(fragment_shader, 1, (const char **)&ms.ptr, &length);
-    tc->api->CompileShader(fragment_shader);
+    tc->vt->ShaderSource(fragment_shader, 1, (const char **)&ms.ptr, &length);
+    tc->vt->CompileShader(fragment_shader);
     free(ms.ptr);
 
     tc->tex_target = tex_target;
@@ -562,18 +562,18 @@ pbo_data_alloc(const opengl_tex_converter_t *tc, picture_t *pic)
     picture_sys_t *picsys = pic->p_sys;
 
     glGetError();
-    tc->api->GenBuffers(pic->i_planes, picsys->buffers);
+    tc->vt->GenBuffers(pic->i_planes, picsys->buffers);
 
     for (int i = 0; i < pic->i_planes; ++i)
     {
-        tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
-        tc->api->BufferData(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i], NULL,
+        tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
+        tc->vt->BufferData(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i], NULL,
                             GL_DYNAMIC_DRAW);
 
         if (glGetError() != GL_NO_ERROR)
         {
             msg_Err(tc->gl, "could not alloc PBO buffers");
-            tc->api->DeleteBuffers(i, picsys->buffers);
+            tc->vt->DeleteBuffers(i, picsys->buffers);
             return VLC_EGENERIC;
         }
     }
@@ -587,7 +587,7 @@ picture_pbo_destroy_cb(picture_t *pic)
     const opengl_tex_converter_t *tc = picsys->tc;
 
     if (picsys->buffers[0] != 0)
-        tc->api->DeleteBuffers(pic->i_planes, picsys->buffers);
+        tc->vt->DeleteBuffers(pic->i_planes, picsys->buffers);
     free(picsys);
     free(pic);
 }
@@ -608,7 +608,7 @@ pbo_pics_alloc(const opengl_tex_converter_t *tc)
     }
 
     /* turn off pbo */
-    tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+    tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 
     return VLC_SUCCESS;
 error:
@@ -632,9 +632,9 @@ tc_pbo_update(const opengl_tex_converter_t *tc, GLuint *textures,
     {
         GLsizeiptr size = pic->p[i].i_lines * pic->p[i].i_pitch;
         const GLvoid *data = pic->p[i].p_pixels;
-        tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
+        tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
                             display_pic->p_sys->buffers[i]);
-        tc->api->BufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, size, data);
+        tc->vt->BufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, size, data);
 
         glActiveTexture(GL_TEXTURE0 + i);
         glClientActiveTexture(GL_TEXTURE0 + i);
@@ -648,7 +648,7 @@ tc_pbo_update(const opengl_tex_converter_t *tc, GLuint *textures,
     }
 
     /* turn off pbo */
-    tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+    tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 
     return VLC_SUCCESS;
 }
@@ -668,18 +668,18 @@ persistent_map(const opengl_tex_converter_t *tc, picture_t *pic)
 {
     picture_sys_t *picsys = pic->p_sys;
 
-    tc->api->GenBuffers(pic->i_planes, picsys->buffers);
+    tc->vt->GenBuffers(pic->i_planes, picsys->buffers);
 
     const GLbitfield access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT |
                               GL_MAP_PERSISTENT_BIT;
     for (int i = 0; i < pic->i_planes; ++i)
     {
-        tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
-        tc->api->BufferStorage(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i], NULL,
+        tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
+        tc->vt->BufferStorage(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i], NULL,
                                access | GL_CLIENT_STORAGE_BIT);
 
         pic->p[i].p_pixels =
-            tc->api->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, picsys->bytes[i],
+            tc->vt->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, picsys->bytes[i],
                                     access | GL_MAP_FLUSH_EXPLICIT_BIT);
 
         if (pic->p[i].p_pixels == NULL)
@@ -687,11 +687,11 @@ persistent_map(const opengl_tex_converter_t *tc, picture_t *pic)
             msg_Err(tc->gl, "could not map PBO buffers");
             for (i = i - 1; i >= 0; --i)
             {
-                tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
+                tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
                                     picsys->buffers[i]);
-                tc->api->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
+                tc->vt->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
             }
-            tc->api->DeleteBuffers(pic->i_planes, picsys->buffers);
+            tc->vt->DeleteBuffers(pic->i_planes, picsys->buffers);
             memset(picsys->buffers, 0, PICTURE_PLANE_MAX * sizeof(GLuint));
             return VLC_EGENERIC;
         }
@@ -723,11 +723,11 @@ persistent_release_gpupics(const opengl_tex_converter_t *tc, bool force)
 
         assert(picsys->fence != NULL);
         GLenum wait = force ? GL_ALREADY_SIGNALED
-                            : tc->api->ClientWaitSync(picsys->fence, 0, 0);
+                            : tc->vt->ClientWaitSync(picsys->fence, 0, 0);
 
         if (wait == GL_ALREADY_SIGNALED || wait == GL_CONDITION_SATISFIED)
         {
-            tc->api->DeleteSync(picsys->fence);
+            tc->vt->DeleteSync(picsys->fence);
             picsys->fence = NULL;
 
             priv->persistent.list &= ~(1ULL << (i - 1));
@@ -748,9 +748,9 @@ tc_persistent_update(const opengl_tex_converter_t *tc, GLuint *textures,
 
     for (int i = 0; i < pic->i_planes; i++)
     {
-        tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
+        tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
         if (picsys->fence == NULL)
-            tc->api->FlushMappedBufferRange(GL_PIXEL_UNPACK_BUFFER, 0,
+            tc->vt->FlushMappedBufferRange(GL_PIXEL_UNPACK_BUFFER, 0,
                                             picsys->bytes[i]);
         glActiveTexture(GL_TEXTURE0 + i);
         glClientActiveTexture(GL_TEXTURE0 + i);
@@ -770,10 +770,10 @@ tc_persistent_update(const opengl_tex_converter_t *tc, GLuint *textures,
     {
         /* The picture is already held */
         hold = false;
-        tc->api->DeleteSync(picsys->fence);
+        tc->vt->DeleteSync(picsys->fence);
     }
 
-    picsys->fence = tc->api->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+    picsys->fence = tc->vt->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
     if (pic->p_sys->fence == NULL)
     {
         /* Error (corner case): don't hold the picture */
@@ -794,7 +794,7 @@ tc_persistent_update(const opengl_tex_converter_t *tc, GLuint *textures,
     }
 
     /* turn off pbo */
-    tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+    tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 
     return VLC_SUCCESS;
 }
@@ -816,10 +816,10 @@ picture_persistent_destroy_cb(picture_t *pic)
     {
         for (int i = 0; i < pic->i_planes; ++i)
         {
-            tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
-            tc->api->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
+            tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
+            tc->vt->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
         }
-        tc->api->DeleteBuffers(pic->i_planes, picsys->buffers);
+        tc->vt->DeleteBuffers(pic->i_planes, picsys->buffers);
     }
     free(picsys);
     free(pic);
@@ -859,7 +859,7 @@ tc_persistent_get_pool(const opengl_tex_converter_t *tc, unsigned requested_coun
         goto error;
 
     /* turn off pbo */
-    tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+    tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 
     /* Wrap the pictures into a pool */
     picture_pool_t *pool = picture_pool_New(count, pictures);
@@ -984,7 +984,7 @@ tc_common_release(const opengl_tex_converter_t *tc)
 static int
 tc_xyz12_fetch_locations(opengl_tex_converter_t *tc, GLuint program)
 {
-    tc->uloc.Texture[0] = tc->api->GetUniformLocation(program, "Texture0");
+    tc->uloc.Texture[0] = tc->vt->GetUniformLocation(program, "Texture0");
     return tc->uloc.Texture[0] != -1 ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
@@ -994,7 +994,7 @@ tc_xyz12_prepare_shader(const opengl_tex_converter_t *tc,
                         float alpha)
 {
     (void) tex_width; (void) tex_height; (void) alpha;
-    tc->api->Uniform1i(tc->uloc.Texture[0], 0);
+    tc->vt->Uniform1i(tc->uloc.Texture[0], 0);
 }
 
 static GLuint
@@ -1041,11 +1041,11 @@ xyz12_shader_init(opengl_tex_converter_t *tc)
         " gl_FragColor = v_out;"
         "}";
 
-    GLuint fragment_shader = tc->api->CreateShader(GL_FRAGMENT_SHADER);
+    GLuint fragment_shader = tc->vt->CreateShader(GL_FRAGMENT_SHADER);
     if (fragment_shader == 0)
         return 0;
-    tc->api->ShaderSource(fragment_shader, 1, &code, NULL);
-    tc->api->CompileShader(fragment_shader);
+    tc->vt->ShaderSource(fragment_shader, 1, &code, NULL);
+    tc->vt->CompileShader(fragment_shader);
     return fragment_shader;
 }
 
@@ -1115,7 +1115,7 @@ generic_init(opengl_tex_converter_t *tc, bool allow_dr)
     struct priv *priv = tc->priv = calloc(1, sizeof(struct priv));
     if (unlikely(priv == NULL))
     {
-        tc->api->DeleteShader(fragment_shader);
+        tc->vt->DeleteShader(fragment_shader);
         return VLC_ENOMEM;
     }
 
@@ -1142,10 +1142,10 @@ generic_init(opengl_tex_converter_t *tc, bool allow_dr)
         const unsigned char *ogl_version = glGetString(GL_VERSION);
         const bool glver_ok = strverscmp((const char *)ogl_version, "3.0") >= 0;
 
-        supports_map_persistent = glver_ok && has_pbo && has_bs && tc->api->BufferStorage
-            && tc->api->MapBufferRange && tc->api->FlushMappedBufferRange
-            && tc->api->UnmapBuffer && tc->api->FenceSync && tc->api->DeleteSync
-            && tc->api->ClientWaitSync;
+        supports_map_persistent = glver_ok && has_pbo && has_bs && tc->vt->BufferStorage
+            && tc->vt->MapBufferRange && tc->vt->FlushMappedBufferRange
+            && tc->vt->UnmapBuffer && tc->vt->FenceSync && tc->vt->DeleteSync
+            && tc->vt->ClientWaitSync;
         if (supports_map_persistent)
         {
             tc->pf_get_pool = tc_persistent_get_pool;
@@ -1157,8 +1157,8 @@ generic_init(opengl_tex_converter_t *tc, bool allow_dr)
 #ifdef VLCGL_HAS_PBO
         if (!supports_map_persistent)
         {
-            const bool supports_pbo = has_pbo && tc->api->BufferData
-                && tc->api->BufferSubData;
+            const bool supports_pbo = has_pbo && tc->vt->BufferData
+                && tc->vt->BufferSubData;
             if (supports_pbo && pbo_pics_alloc(tc) == VLC_SUCCESS)
             {
                 tc->pf_update  = tc_pbo_update;
diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index 3c27d49028..b76edcddfa 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -145,11 +145,11 @@ typedef struct {
     PFNGLCLIENTACTIVETEXTUREPROC  ClientActiveTexture;
 #   undef glClientActiveTexture
 #   undef glActiveTexture
-#   define glActiveTexture tc->api->ActiveTexture
-#   define glClientActiveTexture tc->api->ClientActiveTexture
+#   define glActiveTexture tc->vt->ActiveTexture
+#   define glClientActiveTexture tc->vt->ClientActiveTexture
 #endif
 
-} opengl_shaders_api_t;
+} opengl_vtable_t;
 
 typedef struct opengl_tex_converter_t opengl_tex_converter_t;
 
@@ -174,7 +174,7 @@ struct opengl_tex_converter_t
     /* Pointer to object gl, set by the caller of the init cb */
     vlc_gl_t *gl;
     /* Function pointer to shaders commands, set by the caller of the init cb */
-    const opengl_shaders_api_t *api;
+    const opengl_vtable_t *vt;
     /* Available gl extensions (from GL_EXTENSIONS) */
     const char *glexts;
 
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 5c35ade2c1..4ea80058df 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -110,7 +110,7 @@ struct prgm
 struct vout_display_opengl_t {
 
     vlc_gl_t   *gl;
-    opengl_shaders_api_t api;
+    opengl_vtable_t vt;
 
     video_format_t fmt;
 
@@ -383,9 +383,9 @@ static GLuint BuildVertexShader(const opengl_tex_converter_t *tc,
                  coord1_code, coord2_code) < 0)
         return 0;
 
-    GLuint shader = tc->api->CreateShader(GL_VERTEX_SHADER);
-    tc->api->ShaderSource(shader, 1, (const char **) &code, NULL);
-    tc->api->CompileShader(shader);
+    GLuint shader = tc->vt->CreateShader(GL_VERTEX_SHADER);
+    tc->vt->ShaderSource(shader, 1, (const char **) &code, NULL);
+    tc->vt->CompileShader(shader);
     free(code);
     return shader;
 }
@@ -444,7 +444,7 @@ opengl_link_program(struct prgm *prgm)
     /* Check shaders messages */
     for (unsigned i = 0; i < 2; i++) {
         int infoLength;
-        tc->api->GetShaderiv(shaders[i], GL_INFO_LOG_LENGTH, &infoLength);
+        tc->vt->GetShaderiv(shaders[i], GL_INFO_LOG_LENGTH, &infoLength);
         if (infoLength <= 1)
             continue;
 
@@ -452,31 +452,31 @@ opengl_link_program(struct prgm *prgm)
         if (infolog != NULL)
         {
             int charsWritten;
-            tc->api->GetShaderInfoLog(shaders[i], infoLength, &charsWritten,
+            tc->vt->GetShaderInfoLog(shaders[i], infoLength, &charsWritten,
                                       infolog);
             msg_Err(tc->gl, "shader %d: %s", i, infolog);
             free(infolog);
         }
     }
 
-    prgm->id = tc->api->CreateProgram();
-    tc->api->AttachShader(prgm->id, tc->fshader);
-    tc->api->AttachShader(prgm->id, vertex_shader);
-    tc->api->LinkProgram(prgm->id);
+    prgm->id = tc->vt->CreateProgram();
+    tc->vt->AttachShader(prgm->id, tc->fshader);
+    tc->vt->AttachShader(prgm->id, vertex_shader);
+    tc->vt->LinkProgram(prgm->id);
 
-    tc->api->DeleteShader(vertex_shader);
-    tc->api->DeleteShader(tc->fshader);
+    tc->vt->DeleteShader(vertex_shader);
+    tc->vt->DeleteShader(tc->fshader);
 
     /* Check program messages */
     int infoLength = 0;
-    tc->api->GetProgramiv(prgm->id, GL_INFO_LOG_LENGTH, &infoLength);
+    tc->vt->GetProgramiv(prgm->id, GL_INFO_LOG_LENGTH, &infoLength);
     if (infoLength > 1)
     {
         char *infolog = malloc(infoLength);
         if (infolog != NULL)
         {
             int charsWritten;
-            tc->api->GetProgramInfoLog(prgm->id, infoLength, &charsWritten,
+            tc->vt->GetProgramInfoLog(prgm->id, infoLength, &charsWritten,
                                        infolog);
             msg_Err(tc->gl, "shader program: %s", infolog);
             free(infolog);
@@ -484,7 +484,7 @@ opengl_link_program(struct prgm *prgm)
 
         /* If there is some message, better to check linking is ok */
         GLint link_status = GL_TRUE;
-        tc->api->GetProgramiv(prgm->id, GL_LINK_STATUS, &link_status);
+        tc->vt->GetProgramiv(prgm->id, GL_LINK_STATUS, &link_status);
         if (link_status == GL_FALSE)
         {
             msg_Err(tc->gl, "Unable to use program");
@@ -494,7 +494,7 @@ opengl_link_program(struct prgm *prgm)
 
     /* Fetch UniformLocations and AttribLocations */
 #define GET_LOC(type, x, str) do { \
-    x = tc->api->Get##type##Location(prgm->id, str); \
+    x = tc->vt->Get##type##Location(prgm->id, str); \
     assert(x != -1); \
     if (x == -1) { \
         msg_Err(tc->gl, "Unable to Get"#type"Location(%s)\n", str); \
@@ -535,7 +535,7 @@ opengl_link_program(struct prgm *prgm)
     return VLC_SUCCESS;
 
 error:
-    tc->api->DeleteProgram(prgm->id);
+    tc->vt->DeleteProgram(prgm->id);
     prgm->id = 0;
     return VLC_EGENERIC;
 }
@@ -546,7 +546,7 @@ opengl_deinit_program(vout_display_opengl_t *vgl, struct prgm *prgm)
     if (prgm->tc.pf_release != NULL)
         prgm->tc.pf_release(&prgm->tc);
     if (prgm->id != 0)
-        vgl->api.DeleteProgram(prgm->id);
+        vgl->vt.DeleteProgram(prgm->id);
 }
 
 static int
@@ -556,7 +556,7 @@ opengl_init_program(vout_display_opengl_t *vgl, struct prgm *prgm,
     int ret;
     prgm->tc = (opengl_tex_converter_t) {
         .gl = vgl->gl,
-        .api = &vgl->api,
+        .vt = &vgl->vt,
         .glexts = glexts,
         .fmt = *fmt,
     };
@@ -661,14 +661,12 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
     }
 #endif
 
-    opengl_shaders_api_t *api = &vgl->api;
-
 #if defined(USE_OPENGL_ES2)
-#define GET_PROC_ADDR(name, critical) api->name = gl##name
+#define GET_PROC_ADDR(name, critical) vgl->vt.name = gl##name
 #else
 #define GET_PROC_ADDR(name, critical) do { \
-    api->name = vlc_gl_GetProcAddress(gl, "gl"#name); \
-    if (api->name == NULL && critical) { \
+    vgl->vt.name = vlc_gl_GetProcAddress(gl, "gl"#name); \
+    if (vgl->vt.name == NULL && critical) { \
         msg_Err(gl, "gl"#name" symbol not found, bailing out\n"); \
         free(vgl); \
         return NULL; \
@@ -725,8 +723,8 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
     GET_PROC_ADDR(ClientActiveTexture, true);
 #   undef glActiveTexture
 #   undef glClientActiveTexture
-#   define glActiveTexture vgl->api.ActiveTexture
-#   define glClientActiveTexture vgl->api.ClientActiveTexture
+#   define glActiveTexture vgl->vt.ActiveTexture
+#   define glClientActiveTexture vgl->vt.ClientActiveTexture
 #endif
 #undef GET_PROC_ADDR
 
@@ -813,9 +811,9 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
     glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
     glClear(GL_COLOR_BUFFER_BIT);
 
-    vgl->api.GenBuffers(1, &vgl->vertex_buffer_object);
-    vgl->api.GenBuffers(1, &vgl->index_buffer_object);
-    vgl->api.GenBuffers(vgl->prgm->tc.tex_count, vgl->texture_buffer_object);
+    vgl->vt.GenBuffers(1, &vgl->vertex_buffer_object);
+    vgl->vt.GenBuffers(1, &vgl->index_buffer_object);
+    vgl->vt.GenBuffers(vgl->prgm->tc.tex_count, vgl->texture_buffer_object);
 
     /* Initial number of allocated buffer objects for subpictures, will grow dynamically. */
     int subpicture_buffer_object_count = 8;
@@ -825,7 +823,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
         return NULL;
     }
     vgl->subpicture_buffer_object_count = subpicture_buffer_object_count;
-    vgl->api.GenBuffers(vgl->subpicture_buffer_object_count, vgl->subpicture_buffer_object);
+    vgl->vt.GenBuffers(vgl->subpicture_buffer_object_count, vgl->subpicture_buffer_object);
 
     /* */
     vgl->region_count = 0;
@@ -866,12 +864,12 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
     free(vgl->region);
     opengl_deinit_program(vgl, vgl->sub_prgm);
 
-    vgl->api.DeleteBuffers(1, &vgl->vertex_buffer_object);
-    vgl->api.DeleteBuffers(1, &vgl->index_buffer_object);
+    vgl->vt.DeleteBuffers(1, &vgl->vertex_buffer_object);
+    vgl->vt.DeleteBuffers(1, &vgl->index_buffer_object);
 
-    vgl->api.DeleteBuffers(vgl->prgm->tc.tex_count, vgl->texture_buffer_object);
+    vgl->vt.DeleteBuffers(vgl->prgm->tc.tex_count, vgl->texture_buffer_object);
     if (vgl->subpicture_buffer_object_count > 0)
-        vgl->api.DeleteBuffers(vgl->subpicture_buffer_object_count, vgl->subpicture_buffer_object);
+        vgl->vt.DeleteBuffers(vgl->subpicture_buffer_object_count, vgl->subpicture_buffer_object);
     free(vgl->subpicture_buffer_object);
 
     if (vgl->pool)
@@ -1387,18 +1385,18 @@ static int SetupCoords(vout_display_opengl_t *vgl,
 
     for (unsigned j = 0; j < vgl->prgm->tc.tex_count; j++)
     {
-        vgl->api.BindBuffer(GL_ARRAY_BUFFER, vgl->texture_buffer_object[j]);
-        vgl->api.BufferData(GL_ARRAY_BUFFER, nbVertices * 2 * sizeof(GLfloat),
-                        textureCoord + j * nbVertices * 2, GL_STATIC_DRAW);
+        vgl->vt.BindBuffer(GL_ARRAY_BUFFER, vgl->texture_buffer_object[j]);
+        vgl->vt.BufferData(GL_ARRAY_BUFFER, nbVertices * 2 * sizeof(GLfloat),
+                           textureCoord + j * nbVertices * 2, GL_STATIC_DRAW);
     }
 
-    vgl->api.BindBuffer(GL_ARRAY_BUFFER, vgl->vertex_buffer_object);
-    vgl->api.BufferData(GL_ARRAY_BUFFER, nbVertices * 3 * sizeof(GLfloat),
-                        vertexCoord, GL_STATIC_DRAW);
+    vgl->vt.BindBuffer(GL_ARRAY_BUFFER, vgl->vertex_buffer_object);
+    vgl->vt.BufferData(GL_ARRAY_BUFFER, nbVertices * 3 * sizeof(GLfloat),
+                       vertexCoord, GL_STATIC_DRAW);
 
-    vgl->api.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, vgl->index_buffer_object);
-    vgl->api.BufferData(GL_ELEMENT_ARRAY_BUFFER, nbIndices * sizeof(GLushort),
-                        indices, GL_STATIC_DRAW);
+    vgl->vt.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, vgl->index_buffer_object);
+    vgl->vt.BufferData(GL_ELEMENT_ARRAY_BUFFER, nbIndices * sizeof(GLushort),
+                       indices, GL_STATIC_DRAW);
 
     free(textureCoord);
     free(vertexCoord);
@@ -1420,31 +1418,31 @@ static void DrawWithShaders(vout_display_opengl_t *vgl, struct prgm *prgm)
         glClientActiveTexture(GL_TEXTURE0+j);
         glBindTexture(tc->tex_target, vgl->texture[j]);
 
-        vgl->api.BindBuffer(GL_ARRAY_BUFFER, vgl->texture_buffer_object[j]);
+        vgl->vt.BindBuffer(GL_ARRAY_BUFFER, vgl->texture_buffer_object[j]);
 
         assert(prgm->aloc.MultiTexCoord[j] != -1);
-        vgl->api.EnableVertexAttribArray(prgm->aloc.MultiTexCoord[j]);
-        vgl->api.VertexAttribPointer(prgm->aloc.MultiTexCoord[j], 2, GL_FLOAT,
+        vgl->vt.EnableVertexAttribArray(prgm->aloc.MultiTexCoord[j]);
+        vgl->vt.VertexAttribPointer(prgm->aloc.MultiTexCoord[j], 2, GL_FLOAT,
                                      0, 0, 0);
     }
 
-    vgl->api.BindBuffer(GL_ARRAY_BUFFER, vgl->vertex_buffer_object);
-    vgl->api.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, vgl->index_buffer_object);
-    vgl->api.EnableVertexAttribArray(prgm->aloc.VertexPosition);
-    vgl->api.VertexAttribPointer(prgm->aloc.VertexPosition, 3, GL_FLOAT, 0, 0, 0);
-
-    vgl->api.UniformMatrix4fv(prgm->uloc.OrientationMatrix, 1, GL_FALSE,
-                              prgm->var.OrientationMatrix);
-    vgl->api.UniformMatrix4fv(prgm->uloc.ProjectionMatrix, 1, GL_FALSE,
-                              prgm->var.ProjectionMatrix);
-    vgl->api.UniformMatrix4fv(prgm->uloc.ZRotMatrix, 1, GL_FALSE,
-                              prgm->var.ZRotMatrix);
-    vgl->api.UniformMatrix4fv(prgm->uloc.YRotMatrix, 1, GL_FALSE,
-                              prgm->var.YRotMatrix);
-    vgl->api.UniformMatrix4fv(prgm->uloc.XRotMatrix, 1, GL_FALSE,
-                              prgm->var.XRotMatrix);
-    vgl->api.UniformMatrix4fv(prgm->uloc.ZoomMatrix, 1, GL_FALSE,
-                              prgm->var.ZoomMatrix);
+    vgl->vt.BindBuffer(GL_ARRAY_BUFFER, vgl->vertex_buffer_object);
+    vgl->vt.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, vgl->index_buffer_object);
+    vgl->vt.EnableVertexAttribArray(prgm->aloc.VertexPosition);
+    vgl->vt.VertexAttribPointer(prgm->aloc.VertexPosition, 3, GL_FLOAT, 0, 0, 0);
+
+    vgl->vt.UniformMatrix4fv(prgm->uloc.OrientationMatrix, 1, GL_FALSE,
+                             prgm->var.OrientationMatrix);
+    vgl->vt.UniformMatrix4fv(prgm->uloc.ProjectionMatrix, 1, GL_FALSE,
+                             prgm->var.ProjectionMatrix);
+    vgl->vt.UniformMatrix4fv(prgm->uloc.ZRotMatrix, 1, GL_FALSE,
+                             prgm->var.ZRotMatrix);
+    vgl->vt.UniformMatrix4fv(prgm->uloc.YRotMatrix, 1, GL_FALSE,
+                             prgm->var.YRotMatrix);
+    vgl->vt.UniformMatrix4fv(prgm->uloc.XRotMatrix, 1, GL_FALSE,
+                             prgm->var.XRotMatrix);
+    vgl->vt.UniformMatrix4fv(prgm->uloc.ZoomMatrix, 1, GL_FALSE,
+                             prgm->var.ZoomMatrix);
 
     glDrawElements(GL_TRIANGLES, vgl->nb_indices, GL_UNSIGNED_SHORT, 0);
 }
@@ -1457,7 +1455,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
        Currently, the OS X provider uses it to get a smooth window resizing */
     glClear(GL_COLOR_BUFFER_BIT);
 
-    vgl->api.UseProgram(vgl->prgm->id);
+    vgl->vt.UseProgram(vgl->prgm->id);
 
     if (source->i_x_offset != vgl->last_source.i_x_offset
      || source->i_y_offset != vgl->last_source.i_y_offset
@@ -1509,7 +1507,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
     struct prgm *prgm = vgl->sub_prgm;
     GLuint program = prgm->id;
     opengl_tex_converter_t *tc = &prgm->tc;
-    vgl->api.UseProgram(program);
+    vgl->vt.UseProgram(program);
 
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1517,8 +1515,8 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
     /* We need two buffer objects for each region: for vertex and texture coordinates. */
     if (2 * vgl->region_count > vgl->subpicture_buffer_object_count) {
         if (vgl->subpicture_buffer_object_count > 0)
-            vgl->api.DeleteBuffers(vgl->subpicture_buffer_object_count,
-                                   vgl->subpicture_buffer_object);
+            vgl->vt.DeleteBuffers(vgl->subpicture_buffer_object_count,
+                                  vgl->subpicture_buffer_object);
         vgl->subpicture_buffer_object_count = 0;
 
         int new_count = 2 * vgl->region_count;
@@ -1527,8 +1525,8 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
             return VLC_ENOMEM;
 
         vgl->subpicture_buffer_object_count = new_count;
-        vgl->api.GenBuffers(vgl->subpicture_buffer_object_count,
-                            vgl->subpicture_buffer_object);
+        vgl->vt.GenBuffers(vgl->subpicture_buffer_object_count,
+                           vgl->subpicture_buffer_object);
     }
 
     glActiveTexture(GL_TEXTURE0 + 0);
@@ -1553,30 +1551,30 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
 
         tc->pf_prepare_shader(tc, &glr->width, &glr->height, glr->alpha);
 
-        vgl->api.BindBuffer(GL_ARRAY_BUFFER, vgl->subpicture_buffer_object[2 * i]);
-        vgl->api.BufferData(GL_ARRAY_BUFFER, sizeof(textureCoord), textureCoord, GL_STATIC_DRAW);
-        vgl->api.EnableVertexAttribArray(prgm->aloc.MultiTexCoord[0]);
-        vgl->api.VertexAttribPointer(prgm->aloc.MultiTexCoord[0], 2, GL_FLOAT,
-                                     0, 0, 0);
-
-        vgl->api.BindBuffer(GL_ARRAY_BUFFER, vgl->subpicture_buffer_object[2 * i + 1]);
-        vgl->api.BufferData(GL_ARRAY_BUFFER, sizeof(vertexCoord), vertexCoord, GL_STATIC_DRAW);
-        vgl->api.EnableVertexAttribArray(prgm->aloc.VertexPosition);
-        vgl->api.VertexAttribPointer(prgm->aloc.VertexPosition, 2, GL_FLOAT,
-                                     0, 0, 0);
-
-        vgl->api.UniformMatrix4fv(prgm->uloc.OrientationMatrix, 1, GL_FALSE,
-                                  prgm->var.OrientationMatrix);
-        vgl->api.UniformMatrix4fv(prgm->uloc.ProjectionMatrix, 1, GL_FALSE,
-                                  prgm->var.ProjectionMatrix);
-        vgl->api.UniformMatrix4fv(prgm->uloc.ZRotMatrix, 1, GL_FALSE,
-                                  prgm->var.ZRotMatrix);
-        vgl->api.UniformMatrix4fv(prgm->uloc.YRotMatrix, 1, GL_FALSE,
-                                  prgm->var.YRotMatrix);
-        vgl->api.UniformMatrix4fv(prgm->uloc.XRotMatrix, 1, GL_FALSE,
-                                  prgm->var.XRotMatrix);
-        vgl->api.UniformMatrix4fv(prgm->uloc.ZoomMatrix, 1, GL_FALSE,
-                                  prgm->var.ZoomMatrix);
+        vgl->vt.BindBuffer(GL_ARRAY_BUFFER, vgl->subpicture_buffer_object[2 * i]);
+        vgl->vt.BufferData(GL_ARRAY_BUFFER, sizeof(textureCoord), textureCoord, GL_STATIC_DRAW);
+        vgl->vt.EnableVertexAttribArray(prgm->aloc.MultiTexCoord[0]);
+        vgl->vt.VertexAttribPointer(prgm->aloc.MultiTexCoord[0], 2, GL_FLOAT,
+                                    0, 0, 0);
+
+        vgl->vt.BindBuffer(GL_ARRAY_BUFFER, vgl->subpicture_buffer_object[2 * i + 1]);
+        vgl->vt.BufferData(GL_ARRAY_BUFFER, sizeof(vertexCoord), vertexCoord, GL_STATIC_DRAW);
+        vgl->vt.EnableVertexAttribArray(prgm->aloc.VertexPosition);
+        vgl->vt.VertexAttribPointer(prgm->aloc.VertexPosition, 2, GL_FLOAT,
+                                    0, 0, 0);
+
+        vgl->vt.UniformMatrix4fv(prgm->uloc.OrientationMatrix, 1, GL_FALSE,
+                                 prgm->var.OrientationMatrix);
+        vgl->vt.UniformMatrix4fv(prgm->uloc.ProjectionMatrix, 1, GL_FALSE,
+                                 prgm->var.ProjectionMatrix);
+        vgl->vt.UniformMatrix4fv(prgm->uloc.ZRotMatrix, 1, GL_FALSE,
+                                 prgm->var.ZRotMatrix);
+        vgl->vt.UniformMatrix4fv(prgm->uloc.YRotMatrix, 1, GL_FALSE,
+                                 prgm->var.YRotMatrix);
+        vgl->vt.UniformMatrix4fv(prgm->uloc.XRotMatrix, 1, GL_FALSE,
+                                 prgm->var.XRotMatrix);
+        vgl->vt.UniformMatrix4fv(prgm->uloc.ZoomMatrix, 1, GL_FALSE,
+                                 prgm->var.ZoomMatrix);
 
         glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
     }



More information about the vlc-commits mailing list