diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2014-03-31 17:45:37 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-31 17:45:37 +0200 |
commit | bd822bedfea5126b12c32523a68c3a1ac7a8931d (patch) | |
tree | 0fafd5ac037e3b62ad45e8808989ec89155618b4 /src/plugins/platforms/cocoa/qcocoabackingstore.mm | |
parent | 84c10500b1730e8d947732728d190fde612fc840 (diff) | |
parent | 3b5c0bc0780f1749fed7c07bd8b691400a0282b7 (diff) |
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoabackingstore.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoabackingstore.mm | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 3ca611b537..d76645c668 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); } @@ -101,6 +96,11 @@ void QCocoaBackingStore::flush(QWindow *win, const QRegion ®ion, const QPoint } } +QImage QCocoaBackingStore::toImage() const +{ + return m_qImage; +} + void QCocoaBackingStore::resize(const QSize &size, const QRegion &) { m_requestedSize = size; |