macOS: Do layer updates via the CALayerDelegate protocol

The updateLayer function is only called when the layer is a
_NSViewBackingLayer instance, which is what the default
implementation of [NSView makeBackingLayer] returns.

Once we move to optionally returning a CAMetalLayer, we need
to use the more generic displayLayer: API, so we do that now
as a first step.

This matches the way we draw and send expose events on iOS.

Change-Id: I49721ff005ca9dfddebff645705f96b5ab46abb4
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
bb10
Tor Arne Vestbø 2018-03-19 16:59:24 +01:00
parent 9b604a151a
commit 941aea658f
2 changed files with 4 additions and 7 deletions

View File

@ -74,7 +74,7 @@
- (BOOL)isTransparentForUserInput;
@end
@interface QT_MANGLE_NAMESPACE(QNSView) (Drawing)
@interface QT_MANGLE_NAMESPACE(QNSView) (Drawing) <CALayerDelegate>
@end
@interface QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) : NSObject

View File

@ -137,17 +137,14 @@
}
}
- (BOOL)wantsUpdateLayer
- (void)displayLayer:(CALayer *)layer
{
return YES;
}
Q_ASSERT(layer == self.layer);
- (void)updateLayer
{
if (!m_platformWindow)
return;
qCDebug(lcQpaDrawing) << "[QNSView updateLayer]" << m_platformWindow->window();
qCDebug(lcQpaDrawing) << "[QNSView displayLayer]" << m_platformWindow->window();
// FIXME: Find out if there's a way to resolve the dirty rect like in drawRect:
[self updateRegion:QRectF::fromCGRect(self.bounds).toRect()];