summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-05-21 13:52:53 +0200
committerMorten Johan Sørvig <morten.sorvig@digia.com>2015-03-26 11:00:14 +0100
commit70f565b6e43b6ab93b01112286a40869155207c8 (patch)
treeed4c7fee3fdc5a25bce1041e9aa4616155b8eabd /src/gui/painting
parent3cede847c39269374c52dcf156dc982d7a51f29c (diff)
WIP: Add platform independent high-dpi support to QtGui
Add coordinate scaling support to the QWindow/ QWindowSystemInterface layer. The scale factor can be set with the QT_HIGHDPI_SCALE_FACTOR environment variable. Setting a scale factor different than the default (1) now has the following effects: QWindow::devicePixelRatio is set accordingly, enabling the high-dpi code paths. QWindow and related classes now return geometry in device independent pixels. This includes screen, desktop and window geometry as well as event coordinates. The platform plugins continue to operate in device pixels, unaware of the scaling. Task-number: QTBUG-38858 Change-Id: I85b0d1bc682b25196f6db286e672a64f8da0ae5c
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qbackingstore.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 19074e4c47..88e9aaac2c 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -42,6 +42,8 @@
#include <private/qguiapplication_p.h>
#include <private/qwindow_p.h>
+#include <private/qhighdpiscaling_p.h>
+
QT_BEGIN_NAMESPACE
class QBackingStorePrivate
@@ -102,7 +104,7 @@ void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &off
}
#endif
- d_ptr->platformBackingStore->flush(win, region, offset);
+ d_ptr->platformBackingStore->flush(win, qHighDpiToDevicePixels(region), offset);
}
/*!
@@ -112,7 +114,17 @@ void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &off
*/
QPaintDevice *QBackingStore::paintDevice()
{
- return d_ptr->platformBackingStore->paintDevice();
+ QPaintDevice *device = d_ptr->platformBackingStore->paintDevice();
+ // When QtGui is applying a high-dpi scale factor we are asking
+ // the platform backing store to create a "large" backing store
+ // image. This image needs to be converted into a high-dpi image by
+ // setting the scale factor on the image:
+ if (QHighDpiScaling::isActive() && device->devType() == QInternal::Image) {
+ QImage *image = reinterpret_cast<QImage *>(device);
+ image->setDevicePixelRatio(d_ptr->window->devicePixelRatio());
+ }
+
+ return device;
}
/*!
@@ -150,7 +162,7 @@ QWindow* QBackingStore::window() const
void QBackingStore::beginPaint(const QRegion &region)
{
- d_ptr->platformBackingStore->beginPaint(region);
+ d_ptr->platformBackingStore->beginPaint(qHighDpiToDevicePixels(region));
}
/*!
@@ -170,8 +182,8 @@ void QBackingStore::endPaint()
*/
void QBackingStore::resize(const QSize &size)
{
- d_ptr->size = size;
- d_ptr->platformBackingStore->resize(size, d_ptr->staticContents);
+ d_ptr->size = size; // QBackingStore stores size in point, QPlatformBackingStore gets it in pixel.
+ d_ptr->platformBackingStore->resize(size * QHighDpiScaling::factor(), d_ptr->staticContents);
}
/*!
@@ -194,7 +206,7 @@ bool QBackingStore::scroll(const QRegion &area, int dx, int dy)
Q_UNUSED(dx);
Q_UNUSED(dy);
- return d_ptr->platformBackingStore->scroll(area, dx, dy);
+ return d_ptr->platformBackingStore->scroll(qHighDpiToDevicePixels(area), qHighDpiToDevicePixels(dx), qHighDpiToDevicePixels(dy));
}
void QBackingStore::setStaticContents(const QRegion &region)