[vlc-devel] [PATCH v2 15/17] opengl: expose functions to call sampler callbacks

Romain Vimont rom1v at videolabs.io
Thu May 14 15:38:13 CEST 2020


The fact that the sampler use internal function pointers (instead of
if-blocks for example) is an internal detail.
---
 modules/video_output/opengl/renderer.c |  5 +++--
 modules/video_output/opengl/sampler.h  | 12 ++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index 6dd2684683a..51e3763aec0 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -361,7 +361,7 @@ opengl_link_program(struct vlc_gl_renderer *renderer)
 #undef GET_ULOC
 #undef GET_ALOC
 
-    int ret = sampler->pf_fetch_locations(sampler, program_id);
+    int ret = vlc_gl_sampler_FetchLocations(sampler, program_id);
     assert(ret == VLC_SUCCESS);
     if (ret != VLC_SUCCESS)
     {
@@ -831,7 +831,8 @@ static void DrawWithShaders(struct vlc_gl_renderer *renderer)
 {
     struct vlc_gl_sampler *sampler = renderer->sampler;
     const opengl_vtable_t *vt = renderer->vt;
-    sampler->pf_prepare_shader(sampler);
+
+    vlc_gl_sampler_PrepareShader(sampler);
 
     vt->BindBuffer(GL_ARRAY_BUFFER, renderer->texture_buffer_object);
     assert(renderer->aloc.PicCoordsIn != -1);
diff --git a/modules/video_output/opengl/sampler.h b/modules/video_output/opengl/sampler.h
index 7ef2d950c3a..b5b296872b6 100644
--- a/modules/video_output/opengl/sampler.h
+++ b/modules/video_output/opengl/sampler.h
@@ -129,4 +129,16 @@ vlc_gl_sampler_New(struct vlc_gl_interop *interop);
 void
 vlc_gl_sampler_Delete(struct vlc_gl_sampler *sampler);
 
+static inline int
+vlc_gl_sampler_FetchLocations(struct vlc_gl_sampler *sampler, GLuint program)
+{
+    return sampler->pf_fetch_locations(sampler, program);
+}
+
+static inline void
+vlc_gl_sampler_PrepareShader(const struct vlc_gl_sampler *sampler)
+{
+    sampler->pf_prepare_shader(sampler);
+}
+
 #endif
-- 
2.26.2



More information about the vlc-devel mailing list