aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out/gl_video.c
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-05-01 18:44:45 +0200
committerGravatar wm4 <wm4@nowhere>2015-05-01 18:44:45 +0200
commit0a7abbda6b555fb7746f737b52d0f00fb3e614db (patch)
treef97223c385573718609738b5b8ffda09a7ecfa86 /video/out/gl_video.c
parente23e4c7c603fc1cd911621d0f833031be4a6f7c7 (diff)
vo_opengl: refactor wayland frame skipping
Currently, the wayland backend needs extra work to avoid drawing more often than the wayland frame callback allows. (This is not ideal, but will be fixed at a later time.) Unify this with the start_frame callback added for cocoa. Some details change for the better. For example, if a frame is dropped, and a redraw is done afterwards, the actually correct frame is redrawn, instead whatever was in the textures from before the dropped frame.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r--video/out/gl_video.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 9b4b46ad16..b1976d6521 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -107,6 +107,7 @@ struct texplane {
struct video_image {
struct texplane planes[4];
bool image_flipped;
+ bool needs_upload;
struct mp_image *mpi; // original input image
};
@@ -469,6 +470,7 @@ static void uninit_rendering(struct gl_video *p);
static void uninit_scaler(struct gl_video *p, struct scaler *scaler);
static void check_gl_features(struct gl_video *p);
static bool init_format(int fmt, struct gl_video *init);
+static void gl_video_upload_image(struct gl_video *p);
#define GLSL(x) gl_sc_add(p->sc, #x "\n");
#define GLSLF(...) gl_sc_addf(p->sc, __VA_ARGS__)
@@ -2048,6 +2050,8 @@ void gl_video_render_frame(struct gl_video *p, int fbo, struct frame_timing *t)
}
if (vimg->mpi) {
+ gl_video_upload_image(p);
+
gl_sc_set_vao(p->sc, &p->vao);
if (p->opts.interpolation) {
@@ -2124,27 +2128,30 @@ static bool get_image(struct gl_video *p, struct mp_image *mpi)
return true;
}
-void gl_video_skip_image(struct gl_video *p, struct mp_image *mpi)
+void gl_video_set_image(struct gl_video *p, struct mp_image *mpi)
{
+ assert(mpi);
+
struct video_image *vimg = &p->image;
talloc_free(vimg->mpi);
vimg->mpi = mpi;
+ vimg->needs_upload = true;
+
+ p->osd_pts = mpi->pts;
}
-void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi)
+static void gl_video_upload_image(struct gl_video *p)
{
GL *gl = p->gl;
struct video_image *vimg = &p->image;
+ struct mp_image *mpi = vimg->mpi;
- p->osd_pts = mpi->pts;
-
- talloc_free(vimg->mpi);
- vimg->mpi = mpi;
-
- if (p->hwdec_active)
+ if (p->hwdec_active || !mpi || !vimg->needs_upload)
return;
+ vimg->needs_upload = false;
+
assert(mpi->num_planes == p->plane_count);
mp_image_t mpi2 = *mpi;