vlc | branch: master | Romain Vimont <[email protected]> | Thu Jun 4 11:52:14 2020 +0200| [cd36d84418416aa2453d2675a854c8a04feb969e] | committer: Alexandre Janniaux
opengl: group sampler callbacks into struct ops This makes explicit that these functions are set by the sampler implementation and must be called by the user of sampler. Signed-off-by: Alexandre Janniaux <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cd36d84418416aa2453d2675a854c8a04feb969e --- modules/video_output/opengl/renderer.c | 5 +++-- modules/video_output/opengl/sampler.c | 14 ++++++++++---- modules/video_output/opengl/sampler.h | 14 ++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c index 0f6a7ba73f..aa10d1f8bb 100644 --- a/modules/video_output/opengl/renderer.c +++ b/modules/video_output/opengl/renderer.c @@ -247,8 +247,9 @@ opengl_link_program(struct vlc_gl_renderer *renderer) return VLC_EGENERIC; } - assert(sampler->pf_fetch_locations != NULL && - sampler->pf_prepare_shader != NULL); + assert(sampler->ops && + sampler->ops->fetch_locations && + sampler->ops->prepare_shader); GLuint program_id = vlc_gl_BuildProgram(VLC_OBJECT(renderer->gl), vt, diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c index e7e4d0b49e..6a7f75fcb6 100644 --- a/modules/video_output/opengl/sampler.c +++ b/modules/video_output/opengl/sampler.c @@ -434,8 +434,11 @@ sampler_xyz12_prepare_shader(const struct vlc_gl_sampler *sampler) static int xyz12_shader_init(struct vlc_gl_sampler *sampler) { - sampler->pf_fetch_locations = sampler_xyz12_fetch_locations; - sampler->pf_prepare_shader = sampler_xyz12_prepare_shader; + static const struct vlc_gl_sampler_ops ops = { + .fetch_locations = sampler_xyz12_fetch_locations, + .prepare_shader = sampler_xyz12_prepare_shader, + }; + sampler->ops = &ops; /* Shader for XYZ to RGB correction * 3 steps : @@ -833,8 +836,11 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target, } sampler->shader.body = ms.ptr; - sampler->pf_fetch_locations = sampler_base_fetch_locations; - sampler->pf_prepare_shader = sampler_base_prepare_shader; + static const struct vlc_gl_sampler_ops ops = { + .fetch_locations = sampler_base_fetch_locations, + .prepare_shader = sampler_base_prepare_shader, + }; + sampler->ops = &ops; return VLC_SUCCESS; } diff --git a/modules/video_output/opengl/sampler.h b/modules/video_output/opengl/sampler.h index f26820bfab..9eec401490 100644 --- a/modules/video_output/opengl/sampler.h +++ b/modules/video_output/opengl/sampler.h @@ -77,6 +77,10 @@ struct vlc_gl_sampler { char *body; } shader; + const struct vlc_gl_sampler_ops *ops; +}; + +struct vlc_gl_sampler_ops { /** * Callback to fetch locations of uniform or attributes variables * @@ -86,7 +90,8 @@ struct vlc_gl_sampler { * \param sampler the sampler * \param program linked program that will be used by this sampler */ - void (*pf_fetch_locations)(struct vlc_gl_sampler *sampler, GLuint program); + void + (*fetch_locations)(struct vlc_gl_sampler *sampler, GLuint program); /** * Callback to prepare the fragment shader @@ -96,19 +101,20 @@ struct vlc_gl_sampler { * * \param sampler the sampler */ - void (*pf_prepare_shader)(const struct vlc_gl_sampler *sampler); + void + (*prepare_shader)(const struct vlc_gl_sampler *sampler); }; static inline void vlc_gl_sampler_FetchLocations(struct vlc_gl_sampler *sampler, GLuint program) { - sampler->pf_fetch_locations(sampler, program); + sampler->ops->fetch_locations(sampler, program); } static inline void vlc_gl_sampler_PrepareShader(const struct vlc_gl_sampler *sampler) { - sampler->pf_prepare_shader(sampler); + sampler->ops->prepare_shader(sampler); } #endif _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
