diff options
author | wm4 <wm4@nowhere> | 2014-12-09 21:36:45 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-09 21:55:27 +0100 |
commit | 273565c525f92e62e3cf7e51257d8b5ea8085ba0 (patch) | |
tree | ca222f4324577cf0490b5531383bb88174428a83 /video | |
parent | 0125fb671478708b4e2a11931756f79e35d77e06 (diff) | |
download | mpv-273565c525f92e62e3cf7e51257d8b5ea8085ba0.tar.bz2 mpv-273565c525f92e62e3cf7e51257d8b5ea8085ba0.tar.xz |
vo_opengl_cb: simplify reconfigure, render transparent if unconfigured
I think that's expected; mpv shouldn't draw anything while no video is
active. This doesn't blend transparently, though.
Also document the vo_opengl_cb thing.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gl_video.c | 3 | ||||
-rw-r--r-- | video/out/vo_opengl_cb.c | 27 |
2 files changed, 15 insertions, 15 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 8ea895d22e..86d208b503 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -2387,7 +2387,8 @@ void gl_video_config(struct gl_video *p, struct mp_image_params *params) if (!mp_image_params_equal(&p->image_params, params)) { uninit_video(p); - init_video(p, params); + if (params->imgfmt) + init_video(p, params); } check_resize(p); diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index 09649c3b4b..44ad9e5484 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -55,7 +55,7 @@ struct mpv_opengl_cb_context { void *update_cb_ctx; struct mp_image *next_frame; struct mp_image_params img_params; - struct mp_image_params *new_params; + bool reconfigured; struct mp_rect wnd; bool flip; bool force_update; @@ -175,12 +175,7 @@ int mpv_opengl_cb_render(struct mpv_opengl_cb_context *ctx, int fbo, int vp[4]) struct vo *vo = ctx->active; - struct mp_image_params *new_params = ctx->new_params; - ctx->new_params = NULL; - if (new_params) { - ctx->img_params = *new_params; - ctx->force_update = true; - } + ctx->force_update |= ctx->reconfigured; int h = vp[3]; bool flip = h < 0 && h > INT_MIN; @@ -205,9 +200,12 @@ int mpv_opengl_cb_render(struct mpv_opengl_cb_context *ctx, int fbo, int vp[4]) gl_video_resize(ctx->renderer, &wnd, &src, &dst, &osd, !ctx->flip); } - if (new_params) { - gl_video_config(ctx->renderer, new_params); - talloc_free(new_params); + if (ctx->reconfigured) { + ctx->reconfigured = false; + gl_video_config(ctx->renderer, &ctx->img_params); + struct gl_video_opts opts = gl_video_opts_def; + opts.background.a = 0; // transparent + gl_video_set_options(ctx->renderer, &opts); } struct mp_image *mpi = ctx->next_frame; @@ -268,8 +266,8 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags) if (p->ctx) { pthread_mutex_lock(&p->ctx->lock); mp_image_unrefp(&p->ctx->next_frame); - talloc_free(p->ctx->new_params); - p->ctx->new_params = talloc_memdup(NULL, params, sizeof(*params)); + p->ctx->img_params = *params; + p->ctx->reconfigured = true; pthread_mutex_unlock(&p->ctx->lock); } else { return -1; @@ -293,6 +291,7 @@ static int control(struct vo *vo, uint32_t request, void *data) MP_FATAL(vo, "There is already a VO using the OpenGL context.\n"); } else { nctx->active = vo; + nctx->reconfigured = true; p->ctx = nctx; assert(vo->osd == p->ctx->osd); copy_vo_opts(vo); @@ -332,8 +331,8 @@ static void uninit(struct vo *vo) if (p->ctx) { pthread_mutex_lock(&p->ctx->lock); mp_image_unrefp(&p->ctx->next_frame); - talloc_free(p->ctx->new_params); - p->ctx->new_params = NULL; + p->ctx->img_params = (struct mp_image_params){0}; + p->ctx->reconfigured = true; p->ctx->active = NULL; pthread_mutex_unlock(&p->ctx->lock); } |