diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2013-08-26 10:49:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-14 18:23:25 +0100 |
commit | d9c34e9cdd24937a3c487d0f525a8b8b38ee1ad5 (patch) | |
tree | 84172b9043b140fe4a3a69a1806eb7b9ebb4da8a /src/plugins/platforms/cocoa/qcocoabackingstore.mm | |
parent | 6d858a0fdb896d2c4f9f6411f691f0648c084cd7 (diff) |
Repaint widgets on screen change.
Add a screenChanged handler slot to QWidgetWindow,
which calls markDirty() on the backing store with
the BufferInvalid and UpdateNow flags set.
Update CocoaBackingStore to create a new buffer on
window devicePixelRatio change. Use the
QCocoaWindow::devicePixelRatio() implementation instead
of a duplicate implementation in the backing store.
The plan is to replace this implementation with one
based on QUpdateWindowRequestEvent for Qt 5.4
Change-Id: I8e521c53df4ac90815613e730fe821996334721f
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoabackingstore.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoabackingstore.mm | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 3ca611b537..2222b51a42 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -59,25 +59,20 @@ QCocoaBackingStore::~QCocoaBackingStore() QPaintDevice *QCocoaBackingStore::paintDevice() { - if (m_qImage.size() / m_qImage.devicePixelRatio() != m_requestedSize) { + QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()); + int windowDevicePixelRatio = int(cocoaWindow->devicePixelRatio()); + + // Receate the backing store buffer if the effective buffer size has changed, + // either due to a window resize or devicePixelRatio change. + QSize effectiveBufferSize = m_requestedSize * windowDevicePixelRatio; + if (m_qImage.size() != effectiveBufferSize) { CGImageRelease(m_cgImage); m_cgImage = 0; - int scaleFactor = 1; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { - QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()); - if (cocoaWindow && cocoaWindow->m_contentView && [cocoaWindow->m_contentView window]) { - scaleFactor = int([[cocoaWindow->m_contentView window] backingScaleFactor]); - } - } -#endif - - QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()); QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; - m_qImage = QImage(m_requestedSize * scaleFactor, format); - m_qImage.setDevicePixelRatio(scaleFactor); + m_qImage = QImage(effectiveBufferSize, format); + m_qImage.setDevicePixelRatio(windowDevicePixelRatio); if (format == QImage::Format_ARGB32_Premultiplied) m_qImage.fill(Qt::transparent); } |