1
mirror of https://github.com/mpv-player/mpv synced 2024-11-18 21:16:10 +01:00

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.
This commit is contained in:
wm4 2015-07-26 20:13:53 +02:00
parent a3a453b69b
commit 68d5e7a986

View File

@ -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);