Pick up changes to device-pixel-ratio in QRasterBackingStore

Regression from 2d2d9078, which assumed the code in QBackingStore::beginPaint
would apply to macOS as well, but QHighDpiScaling::isActive() is only active
when Qt does the high DPI scaling, so we never hit the resize() code-path.

Adds backingStore() accessor to go from QPlatformBackingStore to QBackingStore.

Change-Id: I5de2ade74e731df445ea22e0f49b2a121e678efe
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
bb10
Tor Arne Vestbø 2016-09-20 15:39:31 +02:00 committed by Tor Arne Vestbø
parent aaf16b2f43
commit 8a2557fbb7
4 changed files with 29 additions and 0 deletions

View File

@ -138,6 +138,7 @@ QBackingStore::QBackingStore(QWindow *window)
: d_ptr(new QBackingStorePrivate(window))
{
d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window);
d_ptr->platformBackingStore->setBackingStore(this);
}
/*!

View File

@ -77,6 +77,7 @@ class QPlatformBackingStorePrivate
public:
QPlatformBackingStorePrivate(QWindow *w)
: window(w)
, backingStore(0)
#ifndef QT_NO_OPENGL
, textureId(0)
, blitter(0)
@ -100,6 +101,7 @@ public:
#endif
}
QWindow *window;
QBackingStore *backingStore;
#ifndef QT_NO_OPENGL
mutable GLuint textureId;
mutable QSize textureSize;
@ -622,6 +624,23 @@ QWindow* QPlatformBackingStore::window() const
return d_ptr->window;
}
/*!
Sets the backing store associated with this surface.
*/
void QPlatformBackingStore::setBackingStore(QBackingStore *backingStore)
{
d_ptr->backingStore = backingStore;
}
/*!
Returns a pointer to the backing store associated with this
surface.
*/
QBackingStore *QPlatformBackingStore::backingStore() const
{
return d_ptr->backingStore;
}
/*!
This function is called before painting onto the surface begins,
with the \a region in which the painting will occur.

View File

@ -112,6 +112,7 @@ public:
virtual ~QPlatformBackingStore();
QWindow *window() const;
QBackingStore *backingStore() const;
virtual QPaintDevice *paintDevice() = 0;
@ -145,6 +146,9 @@ public:
private:
QPlatformBackingStorePrivate *d_ptr;
void setBackingStore(QBackingStore *);
friend class QBackingStore;
};
#ifndef QT_NO_OPENGL

View File

@ -39,6 +39,7 @@
#include "qrasterbackingstore_p.h"
#include <QtGui/qbackingstore.h>
#include <QtGui/qpainter.h>
QT_BEGIN_NAMESPACE
@ -104,6 +105,10 @@ bool QRasterBackingStore::scroll(const QRegion &region, int dx, int dy)
void QRasterBackingStore::beginPaint(const QRegion &region)
{
// Keep backing store device pixel ratio in sync with window
if (m_image.devicePixelRatio() != window()->devicePixelRatio())
resize(backingStore()->size(), backingStore()->staticContents());
if (!m_image.hasAlphaChannel())
return;