vlc | branch: master | Romain Vimont <[email protected]> | Tue Jul 7 12:33:45 2020 +0200| [a54ffc55fe78a3012f606cea2079317779fecc26] | committer: Alexandre Janniaux
opengl: add filter private part Create a private part not exposed to filter modules. Co-authored-by: Alexandre Janniaux <[email protected]> Signed-off-by: Alexandre Janniaux <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a54ffc55fe78a3012f606cea2079317779fecc26 --- modules/video_output/opengl/Makefile.am | 2 ++ modules/video_output/opengl/filter.c | 47 +++++++++++++++++++++++++++++++ modules/video_output/opengl/filter_priv.h | 42 +++++++++++++++++++++++++++ modules/video_output/opengl/renderer.c | 16 +++++++++-- modules/video_output/opengl/renderer.h | 2 +- modules/video_output/opengl/vout_helper.c | 2 +- 6 files changed, 106 insertions(+), 5 deletions(-) diff --git a/modules/video_output/opengl/Makefile.am b/modules/video_output/opengl/Makefile.am index 3774737129..6f4141fb58 100644 --- a/modules/video_output/opengl/Makefile.am +++ b/modules/video_output/opengl/Makefile.am @@ -1,5 +1,7 @@ OPENGL_COMMONSOURCES = video_output/opengl/vout_helper.c \ + video_output/opengl/filter.c \ video_output/opengl/filter.h \ + video_output/opengl/filter_priv.h \ video_output/opengl/gl_api.c \ video_output/opengl/gl_api.h \ video_output/opengl/gl_common.h \ diff --git a/modules/video_output/opengl/filter.c b/modules/video_output/opengl/filter.c new file mode 100644 index 0000000000..c889768479 --- /dev/null +++ b/modules/video_output/opengl/filter.c @@ -0,0 +1,47 @@ +/***************************************************************************** + * filter.c + ***************************************************************************** + * Copyright (C) 2020 VLC authors and VideoLAN + * Copyright (C) 2020 Videolabs + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "filter_priv.h" + +struct vlc_gl_filter * +vlc_gl_filter_New(void) +{ + struct vlc_gl_filter_priv *priv = malloc(sizeof(*priv)); + if (!priv) + return NULL; + + struct vlc_gl_filter *filter = &priv->filter; + filter->ops = NULL; + filter->sys = NULL; + + return filter; +} + +void +vlc_gl_filter_Delete(struct vlc_gl_filter *filter) +{ + struct vlc_gl_filter_priv *priv = vlc_gl_filter_PRIV(filter); + free(priv); +} diff --git a/modules/video_output/opengl/filter_priv.h b/modules/video_output/opengl/filter_priv.h new file mode 100644 index 0000000000..ffc54e0ca8 --- /dev/null +++ b/modules/video_output/opengl/filter_priv.h @@ -0,0 +1,42 @@ +/***************************************************************************** + * filter_priv.h + ***************************************************************************** + * Copyright (C) 2020 VLC authors and VideoLAN + * Copyright (C) 2020 Videolabs + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_GL_FILTER_PRIV_H +#define VLC_GL_FILTER_PRIV_H + +#include <vlc_common.h> + +#include "filter.h" + +struct vlc_gl_filter_priv { + struct vlc_gl_filter filter; +}; + +#define vlc_gl_filter_PRIV(filter) \ + container_of(filter, struct vlc_gl_filter_priv, filter) + +struct vlc_gl_filter * +vlc_gl_filter_New(void); + +void +vlc_gl_filter_Delete(struct vlc_gl_filter *filter); + +#endif diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c index e08d754f41..3db6f4c599 100644 --- a/modules/video_output/opengl/renderer.c +++ b/modules/video_output/opengl/renderer.c @@ -37,7 +37,7 @@ #include <vlc_es.h> #include <vlc_picture.h> -#include "filter.h" +#include "filter_priv.h" #include "gl_util.h" #include "internal.h" #include "vout_helper.h" @@ -310,6 +310,8 @@ vlc_gl_renderer_Delete(struct vlc_gl_renderer *renderer) { const opengl_vtable_t *vt = renderer->vt; + vlc_gl_filter_Delete(renderer->filter); + vt->DeleteBuffers(1, &renderer->vertex_buffer_object); vt->DeleteBuffers(1, &renderer->index_buffer_object); vt->DeleteBuffers(1, &renderer->texture_buffer_object); @@ -336,12 +338,20 @@ vlc_gl_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api, if (!renderer) return NULL; + struct vlc_gl_filter *filter = vlc_gl_filter_New(); + if (!filter) + { + free(renderer); + return NULL; + } + static const struct vlc_gl_filter_ops filter_ops = { .draw = Draw, }; - renderer->filter.ops = &filter_ops; - renderer->filter.sys = renderer; + filter->ops = &filter_ops; + filter->sys = renderer; + renderer->filter = filter; renderer->sampler = sampler; renderer->gl = gl; diff --git a/modules/video_output/opengl/renderer.h b/modules/video_output/opengl/renderer.h index 9aec83d2e2..76f12b6070 100644 --- a/modules/video_output/opengl/renderer.h +++ b/modules/video_output/opengl/renderer.h @@ -49,7 +49,7 @@ struct vlc_gl_renderer const opengl_vtable_t *vt; /* for convenience, same as &api->vt */ /* vlc_gl_renderer "extends" vlc_gl_filter */ - struct vlc_gl_filter filter; + struct vlc_gl_filter *filter; /* True to dump shaders */ bool dump_shaders; diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c index ee51abf83f..1aa0a93abe 100644 --- a/modules/video_output/opengl/vout_helper.c +++ b/modules/video_output/opengl/vout_helper.c @@ -268,7 +268,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl) Currently, the OS X provider uses it to get a smooth window resizing */ /* Retrieve the "super-class" (renderer "extends" filter) */ - struct vlc_gl_filter *renderer_filter = &vgl->renderer->filter; + struct vlc_gl_filter *renderer_filter = vgl->renderer->filter; int ret = renderer_filter->ops->draw(renderer_filter); if (ret != VLC_SUCCESS) return ret; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
