Take into account scaling in blitFromFrameBuffer

Summary:
This method already translates to s_virtualScreenGeometry as the source
co-ordinates are in compostior space we should take scaling into account here too.

This method already supports resizing if source and target sizes do not match.
Calling funcitons can either double the size of the target if they want native resolution
or leave as-is if they want the result in standard DPI.

This implements scaling in the screenshot, magnifier and simple blur effect.

Test Plan:
Tested screenshot effect using spectacle.
I hit an (unrelated, was reproducible on master) crash whilst using this, so it is not fully tested

Ran magnifier effect manually

Reviewers: #plasma

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4951
This commit is contained in:
David Edmundson 2017-03-06 00:39:26 +00:00
parent 24c9194f4c
commit 71600d0a02

View file

@ -1240,8 +1240,10 @@ void GLRenderTarget::blitFromFramebuffer(const QRect &source, const QRect &desti
const QRect s = source.isNull() ? s_virtualScreenGeometry : source;
const QRect d = destination.isNull() ? QRect(0, 0, mTexture.width(), mTexture.height()) : destination;
glBlitFramebuffer(s.x() - s_virtualScreenGeometry.x(), s_virtualScreenGeometry.height() - s_virtualScreenGeometry.y() - s.y() - s.height(),
s.x() - s_virtualScreenGeometry.x() + s.width(), s_virtualScreenGeometry.height() - s_virtualScreenGeometry.y() - s.y(),
glBlitFramebuffer((s.x() - s_virtualScreenGeometry.x()) * s_virtualScreenScale,
(s_virtualScreenGeometry.height() - s_virtualScreenGeometry.y() - s.y() - s.height()) * s_virtualScreenScale,
(s.x() - s_virtualScreenGeometry.x() + s.width()) * s_virtualScreenScale,
(s_virtualScreenGeometry.height() - s_virtualScreenGeometry.y() - s.y()) * s_virtualScreenScale,
d.x(), mTexture.height() - d.y() - d.height(), d.x() + d.width(), mTexture.height() - d.y(),
GL_COLOR_BUFFER_BIT, filter);
GLRenderTarget::popRenderTarget();