summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qopenglwindow.cpp17
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp18
2 files changed, 19 insertions, 16 deletions
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp
index 2b6692c461..158fb248dc 100644
--- a/src/gui/kernel/qopenglwindow.cpp
+++ b/src/gui/kernel/qopenglwindow.cpp
@@ -211,8 +211,11 @@ public:
context->makeCurrent(q);
}
+ const int deviceWidth = q->width() * q->devicePixelRatio();
+ const int deviceHeight = q->height() * q->devicePixelRatio();
+ const QSize deviceSize(deviceWidth, deviceHeight);
if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
- if (!fbo || fbo->size() != q->size() * q->devicePixelRatio()) {
+ if (!fbo || fbo->size() != deviceSize) {
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
if (q->requestedFormat().samples() > 0) {
@@ -221,15 +224,13 @@ public:
else
qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling");
}
- fbo.reset(new QOpenGLFramebufferObject(q->size() * q->devicePixelRatio(), fboFormat));
+ fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat));
markWindowAsDirty();
}
} else {
markWindowAsDirty();
}
- const int deviceWidth = q->width() * q->devicePixelRatio();
- const int deviceHeight = q->height() * q->devicePixelRatio();
paintDevice->setSize(QSize(deviceWidth, deviceHeight));
paintDevice->setDevicePixelRatio(q->devicePixelRatio());
context->functions()->glViewport(0, 0, deviceWidth, deviceHeight);
@@ -252,11 +253,13 @@ public:
context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject());
if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) {
+ const int deviceWidth = q->width() * q->devicePixelRatio();
+ const int deviceHeight = q->height() * q->devicePixelRatio();
QOpenGLExtensions extensions(context.data());
extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle());
extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject());
- extensions.glBlitFramebuffer(0, 0, q->width(), q->height(),
- 0, 0, q->width(), q->height(),
+ extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight,
+ 0, 0, deviceWidth, deviceHeight,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
} else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) {
@@ -591,7 +594,7 @@ int QOpenGLWindow::metric(PaintDeviceMetric metric) const
break;
case PdmDevicePixelRatio:
if (d->paintDevice)
- return d->paintDevice->devicePixelRatio();
+ return devicePixelRatio();
break;
default:
break;
diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
index 7f571fba89..02e00afe50 100644
--- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
+++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
@@ -116,8 +116,8 @@ void tst_QOpenGLWindow::basic()
QVERIFY(w.paintCount >= 1);
// Check that something has been drawn;
- QCOMPARE(w.img.size(), w.size());
- QVERIFY(w.img.pixel(5, 5) == qRgb(255, 0, 0));
+ QCOMPARE(w.img.size(), w.size() * w.devicePixelRatio());
+ QVERIFY(w.img.pixel(QPoint(5, 5) * w.devicePixelRatio()) == qRgb(255, 0, 0));
// Check that the viewport was properly set.
w.makeCurrent();
@@ -168,9 +168,9 @@ void tst_QOpenGLWindow::painter()
w.show();
QTest::qWaitForWindowExposed(&w);
- QCOMPARE(w.img.size(), w.size());
- QVERIFY(w.img.pixel(5, 5) == qRgb(0, 0, 255));
- QVERIFY(w.img.pixel(200, 5) == qRgb(255, 0, 0));
+ QCOMPARE(w.img.size(), w.size() * w.devicePixelRatio());
+ QVERIFY(w.img.pixel(QPoint(5, 5) * w.devicePixelRatio()) == qRgb(0, 0, 255));
+ QVERIFY(w.img.pixel(QPoint(200, 5) * w.devicePixelRatio()) == qRgb(255, 0, 0));
}
class PartialPainterWindow : public QOpenGLWindow
@@ -222,10 +222,10 @@ void tst_QOpenGLWindow::partial()
// Now since the painting went to an extra framebuffer, all the rects should
// be present since everything is preserved between the frames.
QImage img = w.grabFramebuffer();
- QCOMPARE(img.size(), w.size());
- QCOMPARE(img.pixel(5, 5), qRgb(0, 0, 255));
- QCOMPARE(img.pixel(15, 5), qRgb(0, 255, 0));
- QCOMPARE(img.pixel(25, 5), qRgb(0, 0, 255));
+ QCOMPARE(img.size(), w.size() * w.devicePixelRatio());
+ QCOMPARE(img.pixel(QPoint(5, 5) * w.devicePixelRatio()), qRgb(0, 0, 255));
+ QCOMPARE(img.pixel(QPoint(15, 5) * w.devicePixelRatio()), qRgb(0, 255, 0));
+ QCOMPARE(img.pixel(QPoint(25, 5) * w.devicePixelRatio()), qRgb(0, 0, 255));
}
class PaintUnderOverWindow : public QOpenGLWindow