iOS: Keep size and device pixel ratio of QIOSBackingStore in sync with window
We were only doing this for the size, which caused problems when moving a window from one screen to another where the two screens had different device pixel ratios. Change-Id: If56df34677417369639ee8e4df05820fddd9198d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>bb10
parent
5abba00bef
commit
f568e511b7
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOpenGLPaintDevice;
|
||||
|
||||
class QIOSBackingStore : public QPlatformBackingStore
|
||||
{
|
||||
public:
|
||||
|
|
@ -53,7 +55,7 @@ public:
|
|||
|
||||
private:
|
||||
QOpenGLContext *m_context;
|
||||
QPaintDevice *m_device;
|
||||
QOpenGLPaintDevice *m_device;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -73,19 +73,17 @@ QIOSBackingStore::~QIOSBackingStore()
|
|||
void QIOSBackingStore::beginPaint(const QRegion &)
|
||||
{
|
||||
m_context->makeCurrent(window());
|
||||
|
||||
QIOSWindow *iosWindow = static_cast<QIOSWindow *>(window()->handle());
|
||||
static_cast<QOpenGLPaintDevice *>(paintDevice())->setSize(window()->size() * iosWindow->devicePixelRatio());
|
||||
}
|
||||
|
||||
QPaintDevice *QIOSBackingStore::paintDevice()
|
||||
{
|
||||
if (!m_device) {
|
||||
QIOSWindow *iosWindow = static_cast<QIOSWindow *>(window()->handle());
|
||||
QOpenGLPaintDevice *openGLDevice = new QOpenGLPaintDevice(window()->size() * iosWindow->devicePixelRatio());
|
||||
openGLDevice->setDevicePixelRatio(iosWindow->devicePixelRatio());
|
||||
m_device = openGLDevice;
|
||||
}
|
||||
if (!m_device)
|
||||
m_device = new QOpenGLPaintDevice;
|
||||
|
||||
// Keep paint device size and device pixel ratio in sync with window
|
||||
qreal devicePixelRatio = window()->devicePixelRatio();
|
||||
m_device->setSize(window()->size() * devicePixelRatio);
|
||||
m_device->setDevicePixelRatio(devicePixelRatio);
|
||||
|
||||
return m_device;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue