kwin/libkwineffects
Alex Nemeth 8342cdd3b6 [libkwineffects/kwinglutils] Calculate correct srcY0 and srcY1 in GLRenderTarget::blitFromFramebuffer
Summary:
There are several spaces that have to be considered in `GLRenderTarget::blitFromFramebuffer`:
* KWin logical space: the origin is located at the global top-left corner
* display space: the origin is located at the top-left corner of monitor/display
* OpenGL screen space: the origin is located at the bottom-left corner of monitor/display

Given `s`, which is in the KWin logical space, we have to transform it to the display space, then to the OpenGL screen space:

* KWin logical space -> display space: `y' = s.y() - s_virtualScreenGeometry.y()`
* display space -> OpenGL screen space: `y'' = s_virtualScreenGeometry.height() - y'`

Overall, `srcY0` and `srcY1` should be written as follows:

```
srcY0 = s_virtualScreenGeometry.height() - (s.y() - s_virtualScreenGeometry.y() + s.height())
srcY1 = s_virtualScreenGeometry.height() - (s.y() - s_virtualScreenGeometry.y())
```

Test Plan:
Tweak background contrast effect to use GLRenderTarget::blitFromFramebuffer

```
diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp
index f920fcd88..5247d83b8 100644
--- a/effects/backgroundcontrast/contrast.cpp
+++ b/effects/backgroundcontrast/contrast.cpp
@@ -447,11 +447,10 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRe
     GLTexture scratch(GL_RGBA8, r.width() * scale, r.height() * scale);
     scratch.setFilter(GL_LINEAR);
     scratch.setWrapMode(GL_CLAMP_TO_EDGE);
-    scratch.bind();

-    const QRect sg = GLRenderTarget::virtualScreenGeometry();
-    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (r.x() - sg.x()) * scale, (sg.height() - sg.y() - r.y() - r.height()) * scale,
-                        scratch.width(), scratch.height());
+    GLRenderTarget scratchTarget(scratch);
+    scratchTarget.blitFromFramebuffer(r);
+    scratch.bind();

     // Draw the texture on the offscreen framebuffer object, while blurring it horizontally

```

GLRenderTarget::blitFromFramebuffer without this change:
{F5817883, layout=center, size=full}

Reviewers: #kwin, fredrik, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kpiwowarski, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12452
2018-05-29 15:27:02 +02:00
..
anidata.cpp
anidata_p.h
CMakeLists.txt [effects] Use arg="true" in the kcfg files 2017-04-15 10:03:34 +02:00
kwinanimationeffect.cpp
kwinanimationeffect.h
kwinconfig.h.cmake Move linking to DL_LIBRARY to x11standalone platform 2016-11-22 14:22:06 +01:00
kwineffects.cpp Sanity check WindowQuad before trying to create a grid out of it 2018-03-05 19:31:51 +01:00
kwineffects.h Fix build with a KWindowSystem framework that doesn't pull QWidget 2017-11-17 17:30:58 +01:00
kwinglobals.h Deprecate global KWin::displayWidth and KWin::displayHeight 2017-09-01 21:37:42 +02:00
kwinglplatform.cpp Fix the build on armhf/aarch64 2018-03-06 09:25:33 +05:30
kwinglplatform.h
kwingltexture.cpp don't override m_canUseMipmaps 2018-03-14 04:37:44 +02:00
kwingltexture.h
kwingltexture_p.h [libkwineffects] Try fixing compile error with clang 2017-10-01 09:54:12 +02:00
kwinglutils.cpp [libkwineffects/kwinglutils] Calculate correct srcY0 and srcY1 in GLRenderTarget::blitFromFramebuffer 2018-05-29 15:27:02 +02:00
kwinglutils.h Updated the blur method to use the more efficient dual kawase blur algorithm. 2018-01-26 02:31:45 +09:00
kwinglutils_funcs.cpp
kwinglutils_funcs.h Remove epoxy/egl.h from kwinglutils_func.h 2016-11-22 14:21:40 +01:00
kwinxrenderutils.cpp
kwinxrenderutils.h
logging.cpp
logging_p.h
Mainpage.dox
Messages.sh