Fix viewport restore in GLRenderTarget::popRenderTarget
ClosedPublic

Authored by graesslin on Oct 18 2016, 2:11 PM.

Details

Summary

The viewport needs adjustment in the per-output rendering case. This
change ensures the viewport is setup like in the platforms which do per
output rendering. For the X11 case (multiple outputs in one render pass)
the values are the same as previously.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin updated this revision to Diff 7509.Oct 18 2016, 2:11 PM
graesslin retitled this revision from to Fix viewport restore in GLRenderTarget::popRenderTarget.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
graesslin added reviewers: KWin, Plasma on Wayland.
Restricted Application added projects: Plasma on Wayland, KWin. · View Herald TranscriptOct 18 2016, 2:11 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
mart accepted this revision.Oct 19 2016, 9:41 AM
mart added a reviewer: mart.
This revision is now accepted and ready to land.Oct 19 2016, 9:41 AM
broulik added inline comments.
libkwineffects/kwinglutils.cpp
1181–1182

I don't understand the maths, why is the "x" the negative virtualScreenGeometry and "y" some formula?

graesslin added inline comments.Oct 19 2016, 10:41 AM
libkwineffects/kwinglutils.cpp
1181–1182

OpenGL has a different coordinate system. The 0/0 is on the bottom left corner unlike our own coordinate system which has 0/0 as the top left.

The virtualScreenGeometry contains the geometry of the output we are currently rendering to in our coordinate system. E.g. two screens:

  • 0,0x1920,1080
  • 1280,0x1280,1024

Now we need to map that into the coordinate system of OpenGL which has for the first screen a window of size 1920,1080 and for the second screen a window of 1280,1024 - both windows have the coordinate system start at 0/0 at the bottom left.

What we try to do here is to map the rendering to the OpenGL window. Everything of the first screen needs to end up on the first OpenGL window, everything on the second screen needs to end up on the second OpenGL window. In both cases we need to adjust so that it becomes 0/0 from bottom left corner.

Thus for x we need to take the negative. For the left most screen nothing changes, 0 is 0. For the right screen we need to ensure that 1920 gets mapped to 0. So negative x it is.

Height is similarly adjusted, but is a little bit more complex as it also swaps the coordinate system. Always a mess.

This revision was automatically updated to reflect the committed changes.