diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2017-03-28 12:23:44 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2017-04-04 11:14:38 +0000 |
commit | 5b78fcd03b63241fa0382aa196afe789740fd5b6 (patch) | |
tree | 035d07b7578e21d1ee8c011a1200b1e4289c6e35 /src | |
parent | 6a83f9aa98760d0ed1ab4c216a28a10862e86f00 (diff) |
QRasterBackingStore: Correct high-dpi image size
Fix QT_SCALE_FACTOR usage on macOS. Follow-up to
2d2d9078
QRasterBackingStore should account for native scaling
only. Any Qt scaling will have already been factored
into the size argument.
Change-Id: I26a67addfcbec3d45f4ed87f03b8dd79fd99cb62
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/platformsupport/graphics/qrasterbackingstore.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/platformsupport/graphics/qrasterbackingstore.cpp b/src/platformsupport/graphics/qrasterbackingstore.cpp index ef26edc494..2f7074403c 100644 --- a/src/platformsupport/graphics/qrasterbackingstore.cpp +++ b/src/platformsupport/graphics/qrasterbackingstore.cpp @@ -42,6 +42,9 @@ #include <QtGui/qbackingstore.h> #include <QtGui/qpainter.h> +#include <private/qhighdpiscaling_p.h> +#include <qpa/qplatformwindow.h> + QT_BEGIN_NAMESPACE QRasterBackingStore::QRasterBackingStore(QWindow *window) @@ -57,14 +60,14 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent { Q_UNUSED(staticContents); - int windowDevicePixelRatio = window()->devicePixelRatio(); - QSize effectiveBufferSize = size * windowDevicePixelRatio; + qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio(); + QSize effectiveBufferSize = size * nativeWindowDevicePixelRatio; if (m_image.size() == effectiveBufferSize) return; m_image = QImage(effectiveBufferSize, format()); - m_image.setDevicePixelRatio(windowDevicePixelRatio); + m_image.setDevicePixelRatio(nativeWindowDevicePixelRatio); if (m_image.format() == QImage::Format_ARGB32_Premultiplied) m_image.fill(Qt::transparent); } @@ -106,8 +109,11 @@ bool QRasterBackingStore::scroll(const QRegion ®ion, int dx, int dy) void QRasterBackingStore::beginPaint(const QRegion ®ion) { // Keep backing store device pixel ratio in sync with window - if (m_image.devicePixelRatio() != window()->devicePixelRatio()) - resize(backingStore()->size(), backingStore()->staticContents()); + qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio(); + if (m_image.devicePixelRatio() != nativeWindowDevicePixelRatio) { + const QSize nativeSize = QHighDpi::toNativePixels(backingStore()->size(), window()); + resize(nativeSize, backingStore()->staticContents()); + } if (!m_image.hasAlphaChannel()) return; |