summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-10-05 10:27:44 -0500
committerDudemanguy <random342@airmail.cc>2020-10-15 13:43:45 +0000
commitaacefa4ae5c6112ee7e98535e377c3806bcec85a (patch)
tree34977407c82247e0266baec38fed1e2e2d00d145
parentdeaea70630647e261d60fa7eb9447d386efd38d2 (diff)
downloadmpv-aacefa4ae5c6112ee7e98535e377c3806bcec85a.tar.bz2
mpv-aacefa4ae5c6112ee7e98535e377c3806bcec85a.tar.xz
vo_gpu: update render options on runtime
vo_gpu has a small set of options for ra_ctx that can be set. In practice, runtime toggling doesn't matter for most of these as they have no effect while a video is playing. However, changing the alpha option during runtime can actually work depending on the backend used. mpv already detected when one of these options changed, but it made no attempt to update the options in the ra_ctx accordingly (likely because nothing made any use of this information). Another related change is to add an update_render_opts to the fns and allow invidiual backends to (optionally) use it.
-rw-r--r--video/out/gpu/context.h1
-rw-r--r--video/out/vo_gpu.c17
2 files changed, 14 insertions, 4 deletions
diff --git a/video/out/gpu/context.h b/video/out/gpu/context.h
index 4cf2af9e3e..8c35eb0fc0 100644
--- a/video/out/gpu/context.h
+++ b/video/out/gpu/context.h
@@ -44,6 +44,7 @@ struct ra_ctx_fns {
// optional.
void (*wakeup)(struct ra_ctx *ctx);
void (*wait_events)(struct ra_ctx *ctx, int64_t until_time_us);
+ void (*update_render_opts)(struct ra_ctx *ctx);
// Initialize/destroy the 'struct ra' and possibly the underlying VO backend.
// Not normally called by the user of the ra_ctx.
diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c
index f765e79d34..f7c29ceacb 100644
--- a/video/out/vo_gpu.c
+++ b/video/out/vo_gpu.c
@@ -173,6 +173,15 @@ static void get_and_update_ambient_lighting(struct gpu_priv *p)
}
}
+static void update_ra_ctx_options(struct vo *vo)
+{
+ struct gpu_priv *p = vo->priv;
+
+ /* Only the alpha option has any runtime toggle ability. */
+ struct gl_video_opts *gl_opts = mp_get_config_group(p->ctx, vo->global, &gl_video_conf);
+ p->ctx->opts.want_alpha = gl_opts->alpha_mode == 1;
+}
+
static int control(struct vo *vo, uint32_t request, void *data)
{
struct gpu_priv *p = vo->priv;
@@ -195,8 +204,10 @@ static int control(struct vo *vo, uint32_t request, void *data)
request_hwdec_api(vo);
return true;
case VOCTRL_UPDATE_RENDER_OPTS: {
+ update_ra_ctx_options(vo);
gl_video_configure_queue(p->renderer, vo);
get_and_update_icc_profile(p);
+ p->ctx->fns->update_render_opts(p->ctx);
vo->want_redraw = true;
return true;
}
@@ -279,11 +290,9 @@ static int preinit(struct vo *vo)
struct gpu_priv *p = vo->priv;
p->log = vo->log;
- int alpha_mode;
- mp_read_option_raw(vo->global, "alpha", &m_option_type_choice, &alpha_mode);
-
struct ra_ctx_opts opts = p->opts;
- opts.want_alpha = alpha_mode == 1;
+ struct gl_video_opts *gl_opts = mp_get_config_group(p->ctx, vo->global, &gl_video_conf);
+ opts.want_alpha = gl_opts->alpha_mode == 1;
p->ctx = ra_ctx_create(vo, p->context_type, p->context_name, opts);
if (!p->ctx)