From 3bd5876c89c13a22666fdd0b05fb38969eaa5f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 16 Aug 2016 14:52:14 +0200 Subject: Cocoa: Add drawBackingStoreUsingCoreGraphics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drawRect is a general “repaint now” function, which we should handle also for OpenGL content. Make that clearer by moving the implementation details of drawing the raster backing store using CoreGraphics to a separate function. Behavior change: Call invalidateWindowShadowIfNeeded also for the OpenGL case. Change-Id: I158ebef548e063f826db2dc708c14ab1d784b095 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 02ae64a58e..963b29ebbb 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -101,6 +101,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)setMaskRegion:(const QRegion *)region; - (void)invalidateWindowShadowIfNeeded; - (void)drawRect:(NSRect)dirtyRect; +- (void)drawBackingStoreUsingCoreGraphics:(NSRect)dirtyRect; - (void)updateGeometry; - (void)notifyWindowStateChanged:(Qt::WindowState)newState; - (void)windowNotification : (NSNotification *) windowNotification; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 22a32c7ceb..72ac3431de 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -569,6 +569,18 @@ static bool _q_dontOverrideCtrlLMB = false; if (m_platformWindow->m_drawContentBorderGradient) NSDrawWindowBackground(dirtyRect); + if (m_backingStore) + [self drawBackingStoreUsingCoreGraphics:dirtyRect]; + + [self invalidateWindowShadowIfNeeded]; +} + +// Draws the backing store content to the QNSView using Core Graphics. +// This function assumes that the QNSView is in a configuration that +// supports Core Graphics, such as "classic" mode or layer mode with +// the default layer. +- (void)drawBackingStoreUsingCoreGraphics:(NSRect)dirtyRect +{ if (!m_backingStore) return; @@ -623,8 +635,6 @@ static bool _q_dontOverrideCtrlLMB = false; CGImageRelease(cleanImg); CGImageRelease(subMask); CGImageRelease(bsCGImage); - - [self invalidateWindowShadowIfNeeded]; } - (BOOL) isFlipped -- cgit v1.2.3