mirror of
https://github.com/mpv-player/mpv
synced 2025-01-20 22:40:52 +00:00
vo_gpu/vo_gpu_next: set ctx->opts.want_alpha in specific functions
Currently this was being duplicated on init and on runtime updates between both VOs. Since the conditions for setting this will get more complicated in the future commits, it's better to just handle it in one place. We could combine the vo_gpu and vo_gpu_next handling into one single function but vo_gpu_next has an additional condition for determining alpha that vo_gpu_does not, so we'll leave these separate for simplicity. Also this technically fixes a memory leak where gl_opts weren't being freed.
This commit is contained in:
parent
bbbc0e248b
commit
b7fd232524
@ -113,7 +113,6 @@ struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts)
|
||||
ctx->log = vo->log;
|
||||
|
||||
struct ra_ctx_opts *ctx_opts = mp_get_config_group(ctx, vo->global, &ra_ctx_conf);
|
||||
ctx_opts->want_alpha = gl_opts->alpha_mode == ALPHA_YES;
|
||||
ctx->ra_ctx = ra_ctx_create(vo, *ctx_opts);
|
||||
if (!ctx->ra_ctx)
|
||||
goto err_out;
|
||||
|
@ -172,10 +172,9 @@ 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;
|
||||
talloc_free(gl_opts);
|
||||
}
|
||||
|
||||
static int control(struct vo *vo, uint32_t request, void *data)
|
||||
@ -285,16 +284,14 @@ static int preinit(struct vo *vo)
|
||||
p->log = vo->log;
|
||||
|
||||
struct ra_ctx_opts *ctx_opts = mp_get_config_group(vo, vo->global, &ra_ctx_conf);
|
||||
struct gl_video_opts *gl_opts = mp_get_config_group(vo, vo->global, &gl_video_conf);
|
||||
struct ra_ctx_opts opts = *ctx_opts;
|
||||
opts.want_alpha = gl_opts->alpha_mode == 1;
|
||||
p->ctx = ra_ctx_create(vo, opts);
|
||||
talloc_free(ctx_opts);
|
||||
talloc_free(gl_opts);
|
||||
if (!p->ctx)
|
||||
goto err_out;
|
||||
assert(p->ctx->ra);
|
||||
assert(p->ctx->swapchain);
|
||||
update_ra_ctx_options(vo);
|
||||
|
||||
p->renderer = gl_video_init(p->ctx->ra, vo->log, vo->global);
|
||||
gl_video_set_osd_source(p->renderer, vo->osd);
|
||||
|
@ -1454,6 +1454,13 @@ static inline void copy_frame_info_to_mp(struct frame_info *pl,
|
||||
}
|
||||
}
|
||||
|
||||
static void update_ra_ctx_options(struct vo *vo)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
struct gl_video_opts *gl_opts = p->opts_cache->opts;
|
||||
p->ra_ctx->opts.want_alpha = gl_opts->alpha_mode == ALPHA_YES;
|
||||
}
|
||||
|
||||
static int control(struct vo *vo, uint32_t request, void *data)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
@ -1469,8 +1476,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
|
||||
case VOCTRL_UPDATE_RENDER_OPTS: {
|
||||
m_config_cache_update(p->opts_cache);
|
||||
const struct gl_video_opts *opts = p->opts_cache->opts;
|
||||
p->ra_ctx->opts.want_alpha = opts->alpha_mode == ALPHA_YES;
|
||||
update_ra_ctx_options(vo);
|
||||
if (p->ra_ctx->fns->update_render_opts)
|
||||
p->ra_ctx->fns->update_render_opts(p->ra_ctx);
|
||||
update_render_options(vo);
|
||||
@ -1803,6 +1809,7 @@ static int preinit(struct vo *vo)
|
||||
.global = p->global,
|
||||
.ra_ctx = p->ra_ctx,
|
||||
};
|
||||
update_ra_ctx_options(vo);
|
||||
|
||||
vo->hwdec_devs = hwdec_devices_create();
|
||||
hwdec_devices_set_loader(vo->hwdec_devs, load_hwdec_api, vo);
|
||||
|
Loading…
Reference in New Issue
Block a user