summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-05-02 17:09:16 +0200
committerwm4 <wm4@nowhere>2017-05-02 17:10:26 +0200
commit2eaa43e5daccfef4bb3eab72b46f2764530ed21e (patch)
tree44a08aebf08ffe1e729fb85a9d11e6b0317211de /video/out/opengl/video.c
parent985e5b1d8a9fb446fc2941c15c2dd4fa1294c550 (diff)
downloadmpv-2eaa43e5daccfef4bb3eab72b46f2764530ed21e.tar.bz2
mpv-2eaa43e5daccfef4bb3eab72b46f2764530ed21e.tar.xz
vo_opengl: another attempt at removing the overlay correctly
This reverts commit 142b2f23d4293, and replaces it with another try. The previous attempt removed the overlay on every rendering, because the normal rendering path actually unrefs the mp_image. Consequently, unmap_current_image() was completely inappropriate for removing the overlay.
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r--video/out/opengl/video.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 2cce989bdd..0bfba10ae1 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -840,11 +840,8 @@ static void unmap_current_image(struct gl_video *p)
p->hwdec->driver->unmap(p->hwdec);
memset(vimg->planes, 0, sizeof(vimg->planes));
vimg->hwdec_mapped = false;
- vimg->id = 0; // needs to be mapped again
+ vimg->id = 0; // needs to be mapped again
}
-
- if (p->hwdec_active && p->hwdec->driver->overlay_frame)
- p->hwdec->driver->overlay_frame(p->hwdec, NULL);
}
static void unref_current_image(struct gl_video *p)
@@ -854,6 +851,15 @@ static void unref_current_image(struct gl_video *p)
p->image.id = 0;
}
+// If overlay mode is used, make sure to remove the overlay.
+// Be careful with this. Removing the overlay and adding another one will
+// lead to flickering artifacts.
+static void unmap_overlay(struct gl_video *p)
+{
+ if (p->hwdec_active && p->hwdec->driver->overlay_frame)
+ p->hwdec->driver->overlay_frame(p->hwdec, NULL);
+}
+
static void uninit_video(struct gl_video *p)
{
GL *gl = p->gl;
@@ -862,6 +868,7 @@ static void uninit_video(struct gl_video *p)
struct video_image *vimg = &p->image;
+ unmap_overlay(p);
unref_current_image(p);
for (int n = 0; n < p->plane_count; n++) {
@@ -3281,6 +3288,7 @@ bool gl_video_check_format(struct gl_video *p, int mp_format)
void gl_video_config(struct gl_video *p, struct mp_image_params *params)
{
+ unmap_overlay(p);
unref_current_image(p);
if (!mp_image_params_equal(&p->real_image_params, params)) {