diff options
author | Filipe Azevedo <filipe.azevedo@kdab.com> | 2016-12-13 16:02:23 +0100 |
---|---|---|
committer | Filipe Azevedo <filipe.azevedo@kdab.com> | 2017-04-09 13:42:34 +0000 |
commit | 07bd5a90a3dccaa31940e3b1a78069f55e25405a (patch) | |
tree | 3a4183e199f65c4ec0377dd65b59a6970c126e7e | |
parent | 944bf6867f8360e7ec79f542f65b4ea556ecc4e5 (diff) |
Fix hidpi support for opengl window grabbing
Now set the QImage devicePixelRatio so the content is correct on all
screens.
Task-number: QTBUG-53795
Change-Id: Ic92eee98f691ebb1e0212498c1ae13ede74bca93
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r-- | src/gui/kernel/qopenglwindow.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/qopengl/tst_qopengl.cpp | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index e1bd3d11b2..5170c7ab63 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -528,7 +528,9 @@ QImage QOpenGLWindow::grabFramebuffer() return QImage(); makeCurrent(); - return qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false); + QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false); + img.setDevicePixelRatio(devicePixelRatio()); + return img; } /*! diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 44921f68aa..4cdd8202e9 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -381,6 +381,7 @@ static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const static void fuzzyCompareImages(const QImage &testImage, const QImage &referenceImage, const char* file, int line) { + QCOMPARE(testImage.devicePixelRatio(), referenceImage.devicePixelRatio()); QCOMPARE(testImage.width(), referenceImage.width()); QCOMPARE(testImage.height(), referenceImage.height()); |