diff options
author | wm4 <wm4@nowhere> | 2017-08-07 16:44:15 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-08-07 16:44:15 +0200 |
commit | 346ac1e09f89bfbaac6329c89435e3c1faff6e8e (patch) | |
tree | 6288a19c964e27937043399b93c2fc94a5873628 /video/out/opengl/utils.c | |
parent | 46f7a4352e18b306d6cff7965c53150c5abcf20c (diff) | |
download | mpv-346ac1e09f89bfbaac6329c89435e3c1faff6e8e.tar.bz2 mpv-346ac1e09f89bfbaac6329c89435e3c1faff6e8e.tar.xz |
vo_opengl: simplify mirroring and fix it if glBlitFramebuffer is used
The vp_w/vp_h variables and parameters were not really used anymore
(they were redundant with ra_tex w/h) - but vp_h was still used to
identify whether rendering should be done mirrored.
Simplify this by adding a fbodst struct (some bad naming), which
contains the render target texture, and some parameters how it should be
rendered to (for now only flipping). It would not be appropriate to make
this a member of ra_tex, so it's a separate struct.
Introduces a weird regression for the first frame rendered after
interpolation is toggled at runtime, but seems to work otherwise. This
is possibly due to the change that blit() now mirrors, instead of just
copying. (This is also why ra_fns.blit is changed.)
Fixes #4719.
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r-- | video/out/opengl/utils.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index ffc2fb3fce..a0174e8063 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -33,6 +33,12 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x) gl_transform_vec(t, &x->t[0], &x->t[1]); } +void gl_transform_ortho_fbodst(struct gl_transform *t, struct fbodst fbo) +{ + int y_dir = fbo.flip ? -1 : 1; + gl_transform_ortho(t, 0, fbo.tex->params.w, 0, fbo.tex->params.h * y_dir); +} + // Create a texture and a FBO using the texture as color attachments. // fmt: texture internal format // If the parameters are the same as the previous call, do not touch it. @@ -41,6 +47,8 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x) bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, int w, int h, const struct ra_format *fmt, int flags) { + int lw = w, lh = h; + if (fbo->tex) { int cw = w, ch = h; int rw = fbo->tex->params.w, rh = fbo->tex->params.h; @@ -50,15 +58,10 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, if ((flags & FBOTEX_FUZZY_H) && ch < rh) ch = rh; - if (rw == cw && rh == ch && fbo->tex->params.format == fmt) { - fbo->lw = w; - fbo->lh = h; - return true; - } + if (rw == cw && rh == ch && fbo->tex->params.format == fmt) + goto done; } - int lw = w, lh = h; - if (flags & FBOTEX_FUZZY_W) w = MP_ALIGN_UP(w, 256); if (flags & FBOTEX_FUZZY_H) @@ -75,10 +78,6 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, *fbo = (struct fbotex) { .ra = ra, - .rw = w, - .rh = h, - .lw = lw, - .lh = lh, }; struct ra_tex_params params = { @@ -100,6 +99,15 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, return false; } +done: + + fbo->lw = lw; + fbo->lh = lh; + + fbo->fbo = (struct fbodst){ + .tex = fbo->tex, + }; + return true; } |