summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-06-21 09:03:22 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-06-22 21:17:46 +0000
commitdfce0a8feceeb7156eba6ac5d8d3521e3009a583 (patch)
tree76a8ab4fdb484e4c4b6eb8e7b7e360baae3e200e
parent8635fb9e0ca9a8a2bb5d42785c53ac4b4eb363b1 (diff)
Support non-integer pixel-ratio in QQuickWidget
Non-integer pixel-ratios always resulted in blurry rendering when QQuickWidget was used, but not with QQuickWindow. Fixed by reading qreal accessor of devicePixelRatio instead. Change-Id: I49f5efcf2da2efc090c00017e68c99c857cd84ef Task-number: QTBUG-61502 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/quickwidgets/qquickwidget.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 2e8623f508..2c3c72d5f1 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -913,9 +913,9 @@ void QQuickWidget::createFramebufferObject()
d->offscreenWindow->setGeometry(globalPos.x(), globalPos.y(), width(), height());
if (d->useSoftwareRenderer) {
- const QSize imageSize = size() * devicePixelRatio();
+ const QSize imageSize = size() * devicePixelRatioF();
d->softwareImage = QImage(imageSize, QImage::Format_ARGB32_Premultiplied);
- d->softwareImage.setDevicePixelRatio(devicePixelRatio());
+ d->softwareImage.setDevicePixelRatio(devicePixelRatioF());
return;
}
@@ -960,7 +960,7 @@ void QQuickWidget::createFramebufferObject()
format.setInternalTextureFormat(GL_SRGB8_ALPHA8_EXT);
#endif
- const QSize fboSize = size() * devicePixelRatio();
+ const QSize fboSize = size() * devicePixelRatioF();
// Could be a simple hide - show, in which case the previous fbo is just fine.
if (!d->fbo || d->fbo->size() != fboSize) {
@@ -1181,7 +1181,7 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
// Software Renderer
if (d->useSoftwareRenderer) {
needsSync = true;
- if (d->softwareImage.size() != size() * devicePixelRatio()) {
+ if (d->softwareImage.size() != size() * devicePixelRatioF()) {
createFramebufferObject();
}
} else {
@@ -1191,7 +1191,7 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
// during hide - resize - show sequences and also during application exit.
if (!d->fbo && !d->offscreenWindow->openglContext())
return;
- if (!d->fbo || d->fbo->size() != size() * devicePixelRatio()) {
+ if (!d->fbo || d->fbo->size() != size() * devicePixelRatioF()) {
needsSync = true;
createFramebufferObject();
}
@@ -1607,10 +1607,12 @@ void QQuickWidget::paintEvent(QPaintEvent *event)
//Paint everything
painter.drawImage(rect(), d->softwareImage);
} else {
+ QTransform transform;
+ transform.scale(devicePixelRatioF(), devicePixelRatioF());
//Paint only the updated areas
const auto rects = d->updateRegion.rects();
for (auto targetRect : rects) {
- auto sourceRect = QRect(targetRect.topLeft() * devicePixelRatio(), targetRect.size() * devicePixelRatio());
+ auto sourceRect = transform.mapRect(QRectF(targetRect));
painter.drawImage(targetRect, d->softwareImage, sourceRect);
}
d->updateRegion = QRegion();