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>
This commit is contained in:
parent
6a83f9aa98
commit
5b78fcd03b
@ -42,6 +42,9 @@
|
|||||||
#include <QtGui/qbackingstore.h>
|
#include <QtGui/qbackingstore.h>
|
||||||
#include <QtGui/qpainter.h>
|
#include <QtGui/qpainter.h>
|
||||||
|
|
||||||
|
#include <private/qhighdpiscaling_p.h>
|
||||||
|
#include <qpa/qplatformwindow.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QRasterBackingStore::QRasterBackingStore(QWindow *window)
|
QRasterBackingStore::QRasterBackingStore(QWindow *window)
|
||||||
@ -57,14 +60,14 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent
|
|||||||
{
|
{
|
||||||
Q_UNUSED(staticContents);
|
Q_UNUSED(staticContents);
|
||||||
|
|
||||||
int windowDevicePixelRatio = window()->devicePixelRatio();
|
qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio();
|
||||||
QSize effectiveBufferSize = size * windowDevicePixelRatio;
|
QSize effectiveBufferSize = size * nativeWindowDevicePixelRatio;
|
||||||
|
|
||||||
if (m_image.size() == effectiveBufferSize)
|
if (m_image.size() == effectiveBufferSize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_image = QImage(effectiveBufferSize, format());
|
m_image = QImage(effectiveBufferSize, format());
|
||||||
m_image.setDevicePixelRatio(windowDevicePixelRatio);
|
m_image.setDevicePixelRatio(nativeWindowDevicePixelRatio);
|
||||||
if (m_image.format() == QImage::Format_ARGB32_Premultiplied)
|
if (m_image.format() == QImage::Format_ARGB32_Premultiplied)
|
||||||
m_image.fill(Qt::transparent);
|
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)
|
void QRasterBackingStore::beginPaint(const QRegion ®ion)
|
||||||
{
|
{
|
||||||
// Keep backing store device pixel ratio in sync with window
|
// Keep backing store device pixel ratio in sync with window
|
||||||
if (m_image.devicePixelRatio() != window()->devicePixelRatio())
|
qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio();
|
||||||
resize(backingStore()->size(), backingStore()->staticContents());
|
if (m_image.devicePixelRatio() != nativeWindowDevicePixelRatio) {
|
||||||
|
const QSize nativeSize = QHighDpi::toNativePixels(backingStore()->size(), window());
|
||||||
|
resize(nativeSize, backingStore()->staticContents());
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_image.hasAlphaChannel())
|
if (!m_image.hasAlphaChannel())
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user