diff options
author | 2015-07-26 20:13:53 +0200 | |
---|---|---|
committer | 2015-07-26 21:44:57 +0200 | |
commit | 68d5e7a9862b6c0140b64d6ca151f0e20d12d3c3 (patch) | |
tree | fc6a1e99ee05547d343ac6c18fbbcfb0b5fd26f3 /video/out/gl_video.c | |
parent | a3a453b69b4e1d9230e3f7a291a606afc59f9708 (diff) |
vo_opengl: minor cleanup to hwdec texture setting code
Instead of special-casing hwdec in the place where the video textures
are used, just set the textures in the image upload function. The
renderer code doesn't need to know whether hwdec interop is used at all.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r-- | video/out/gl_video.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 610a8fdb25..cf9703de3c 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -641,7 +641,6 @@ static void pass_load_fbotex(struct gl_video *p, struct fbotex *src_fbo, int id, static void pass_set_image_textures(struct gl_video *p, struct video_image *vimg, struct gl_transform *chroma) { - GLuint imgtex[4] = {0}; *chroma = (struct gl_transform){{{0}}}; assert(vimg->mpi); @@ -669,20 +668,10 @@ static void pass_set_image_textures(struct gl_video *p, struct video_image *vimg chroma->m[1][1] = ls_h * (float)vimg->planes[0].tex_h / vimg->planes[1].tex_h; - if (p->hwdec_active) { - if (p->hwdec->driver->map_image(p->hwdec, vimg->mpi, imgtex) < 0) { - for (int n = 0; n < p->plane_count; n++) - imgtex[n] = -1; - } - } else { - for (int n = 0; n < p->plane_count; n++) - imgtex[n] = vimg->planes[n].gl_texture; - } - for (int n = 0; n < p->plane_count; n++) { struct texplane *t = &vimg->planes[n]; p->pass_tex[n] = (struct src_tex){ - .gl_tex = imgtex[n], + .gl_tex = vimg->planes[n].gl_texture, .gl_target = t->gl_target, .tex_w = t->tex_w, .tex_h = t->tex_h, @@ -772,7 +761,8 @@ static void uninit_video(struct gl_video *p) for (int n = 0; n < p->plane_count; n++) { struct texplane *plane = &vimg->planes[n]; - gl->DeleteTextures(1, &plane->gl_texture); + if (!p->hwdec_active) + gl->DeleteTextures(1, &plane->gl_texture); plane->gl_texture = 0; gl->DeleteBuffers(1, &plane->gl_buffer); plane->gl_buffer = 0; @@ -2343,8 +2333,13 @@ static void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi) p->osd_pts = mpi->pts; p->frames_uploaded++; - if (p->hwdec_active) + if (p->hwdec_active) { + GLuint imgtex[4] = {0}; + bool ok = p->hwdec->driver->map_image(p->hwdec, vimg->mpi, imgtex) >= 0; + for (int n = 0; n < p->plane_count; n++) + vimg->planes[n].gl_texture = ok ? imgtex[n] : -1; return; + } assert(mpi->num_planes == p->plane_count); |