From ab6f6aa61e491f214bc486ad512bfdadc5932fcf Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 8 Sep 2015 22:46:36 +0200 Subject: vo_opengl: move gl_video_opts copying code to separate function Sigh... Hopefully this code will be completely unnecessary one day, as it's only needed due to the sub-option parser craziness. Move dumb_mode to the top of the struct, so the C universal initializer doesn't cause warnings with all those broken compilers. --- video/out/gl_video.c | 35 +++++++++++++++++++++-------------- video/out/gl_video.h | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 36e4366d5a..38f2e546e3 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -486,6 +486,7 @@ static void uninit_scaler(struct gl_video *p, struct scaler *scaler); static void check_gl_features(struct gl_video *p); static bool init_format(int fmt, struct gl_video *init); static void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi); +static void assign_options(struct gl_video_opts *dst, struct gl_video_opts *src); #define GLSL(x) gl_sc_add(p->sc, #x "\n"); #define GLSLF(...) gl_sc_addf(p->sc, __VA_ARGS__) @@ -2518,6 +2519,7 @@ void gl_video_uninit(struct gl_video *p) gl_set_debug_logger(gl, NULL); + assign_options(&p->opts, &(struct gl_video_opts){0}); talloc_free(p); } @@ -2780,26 +2782,31 @@ static char **dup_str_array(void *parent, char **src) return res; } -// Set the options, and possibly update the filter chain too. -// Note: assumes all options are valid and verified by the option parser. -void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts) +static void assign_options(struct gl_video_opts *dst, struct gl_video_opts *src) { - talloc_free(p->opts.source_shader); - talloc_free(p->opts.scale_shader); - talloc_free(p->opts.pre_shaders); - talloc_free(p->opts.post_shaders); + talloc_free(dst->source_shader); + talloc_free(dst->scale_shader); + talloc_free(dst->pre_shaders); + talloc_free(dst->post_shaders); - p->opts = *opts; + *dst = *src; for (int n = 0; n < 4; n++) { - p->opts.scaler[n].kernel.name = - (char *)handle_scaler_opt(p->opts.scaler[n].kernel.name, n==3); + dst->scaler[n].kernel.name = + (char *)handle_scaler_opt(dst->scaler[n].kernel.name, n == 3); } - p->opts.source_shader = talloc_strdup(p, p->opts.source_shader); - p->opts.scale_shader = talloc_strdup(p, p->opts.scale_shader); - p->opts.pre_shaders = dup_str_array(p, p->opts.pre_shaders); - p->opts.post_shaders = dup_str_array(p, p->opts.post_shaders); + dst->source_shader = talloc_strdup(NULL, dst->source_shader); + dst->scale_shader = talloc_strdup(NULL, dst->scale_shader); + dst->pre_shaders = dup_str_array(NULL, dst->pre_shaders); + dst->post_shaders = dup_str_array(NULL, dst->post_shaders); +} + +// Set the options, and possibly update the filter chain too. +// Note: assumes all options are valid and verified by the option parser. +void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts) +{ + assign_options(&p->opts, opts); check_gl_features(p); uninit_rendering(p); diff --git a/video/out/gl_video.h b/video/out/gl_video.h index e8f8ffa030..443cb76787 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -43,6 +43,7 @@ struct scaler_config { }; struct gl_video_opts { + int dumb_mode; struct scaler_config scaler[4]; float gamma; int gamma_auto; @@ -71,7 +72,6 @@ struct gl_video_opts { char *scale_shader; char **pre_shaders; char **post_shaders; - int dumb_mode; }; extern const struct m_sub_options gl_video_conf; -- cgit v1.2.3