summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-06 11:11:36 +0200
committerwm4 <wm4@nowhere>2016-09-06 11:11:36 +0200
commit9ab0f60d444984581e188b9987faed9b80eda7e2 (patch)
tree8317a840dfa7d50ac0d604ecefa115060d3202a2 /video/out/opengl/video.c
parente5cefa346da00feb01a2bb76be19a9d80e191a12 (diff)
downloadmpv-9ab0f60d444984581e188b9987faed9b80eda7e2.tar.bz2
mpv-9ab0f60d444984581e188b9987faed9b80eda7e2.tar.xz
vo_opengl: simplify option handling
Instead of copying the options around... just don't. video.c now has full control over when options are updated. (It still gets notified from outside, but it decides when the updated options are copied: when m_config_cache_update() is called.) So there's no need for tricky stuff, and it can be simplified a bit. Also change lcms.c. We could do it like video.c, and get the options from the global config store. But it seems simpler to just provide a pointer to an option struct, which is arbitrarily mutated from the outside (from the perspective of lcms.c).
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r--video/out/opengl/video.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index c3b5eb6f18..4bc733ae89 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -169,7 +169,6 @@ struct gl_video {
struct mpv_global *global;
struct mp_log *log;
struct gl_video_opts opts;
- struct gl_video_opts *opts_alloc;
struct m_config_cache *opts_cache;
struct gl_lcms *cms;
bool gl_debug;
@@ -513,7 +512,6 @@ static void check_gl_features(struct gl_video *p);
static bool init_format(struct gl_video *p, int fmt, bool test_only);
static void init_image_desc(struct gl_video *p, int fmt);
static bool gl_video_upload_image(struct gl_video *p, struct mp_image *mpi);
-static void set_options(struct gl_video *p, struct gl_video_opts *src);
static const char *handle_scaler_opt(const char *name, bool tscale);
static void reinit_from_options(struct gl_video *p);
static void get_scale_factors(struct gl_video *p, bool transpose_rot, double xy[2]);
@@ -3026,7 +3024,7 @@ static void check_gl_features(struct gl_video *p)
p->dumb_mode = true;
p->use_lut_3d = false;
// Most things don't work, so whitelist all options that still work.
- struct gl_video_opts new_opts = {
+ p->opts = (struct gl_video_opts){
.gamma = p->opts.gamma,
.gamma_auto = p->opts.gamma_auto,
.pbo = p->opts.pbo,
@@ -3040,8 +3038,7 @@ static void check_gl_features(struct gl_video *p)
.tone_mapping_param = p->opts.tone_mapping_param,
};
for (int n = 0; n < SCALER_COUNT; n++)
- new_opts.scaler[n] = gl_video_opts_def.scaler[n];
- set_options(p, &new_opts);
+ p->opts.scaler[n] = gl_video_opts_def.scaler[n];
return;
}
p->dumb_mode = false;
@@ -3062,7 +3059,7 @@ static void check_gl_features(struct gl_video *p)
if (reason) {
MP_WARN(p, "Disabling scaler #%d %s %s.\n", n,
p->opts.scaler[n].kernel.name, reason);
- // p->opts is a copy of p->opts_alloc => we can just mess with it.
+ // p->opts is a copy => we can just mess with it.
p->opts.scaler[n].kernel.name = "bilinear";
if (n == SCALER_TSCALE)
p->opts.interpolation = 0;
@@ -3414,13 +3411,13 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g)
.gl = gl,
.global = g,
.log = log,
- .cms = gl_lcms_init(p, log, g),
.texture_16bit_depth = 16,
.sc = gl_sc_create(gl, log),
.opts_cache = m_config_cache_alloc(p, g, &gl_video_conf),
};
- set_options(p, p->opts_cache->opts);
- gl_lcms_set_options(p->cms, p->opts.icc_opts);
+ struct gl_video_opts *opts = p->opts_cache->opts;
+ p->cms = gl_lcms_init(p, log, g, opts->icc_opts),
+ p->opts = *opts;
for (int n = 0; n < SCALER_COUNT; n++)
p->scaler[n] = (struct scaler){.index = n};
gl_video_set_debug(p, true);
@@ -3448,28 +3445,23 @@ static const char *handle_scaler_opt(const char *name, bool tscale)
return NULL;
}
-static void set_options(struct gl_video *p, struct gl_video_opts *src)
-{
- talloc_free(p->opts_alloc);
- p->opts_alloc = m_sub_options_copy(p, &gl_video_conf, src);
- p->opts = *p->opts_alloc;
-}
-
void gl_video_update_options(struct gl_video *p)
{
if (m_config_cache_update(p->opts_cache)) {
- set_options(p, p->opts_cache->opts);
+ gl_lcms_update_options(p->cms);
reinit_from_options(p);
}
}
static void reinit_from_options(struct gl_video *p)
{
- p->use_lut_3d = false;
-
- gl_lcms_set_options(p->cms, p->opts.icc_opts);
p->use_lut_3d = gl_lcms_has_profile(p->cms);
+ // Copy the option fields, so that check_gl_features() can mutate them.
+ // This works only for the fields themselves of course, not for any memory
+ // referenced by them.
+ p->opts = *(struct gl_video_opts *)p->opts_cache->opts;
+
check_gl_features(p);
uninit_rendering(p);
gl_video_setup_hooks(p);