macOS: Don't update Metal layer's drawableSize automatically

Like our other rendering code paths, the Metal path should allow the user
to resize their surface when they see fit. This is the case today with
e.g QBackingStore::resize() and QOpenGLPaintDevice::setSize().

[ChangeLog][macOS] The drawableSize of Metal layers is no longer updated
automatically on window resize or screen change. Update the size manually
in response to resizeEvent(), or at the start of each frame, as needed.

Change-Id: I9ed6d4326d0e0a3f4e3c63984d3b193e8bb77cae
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-09-19 18:15:18 +02:00
parent 04dcc902eb
commit 0642ca3528

View File

@ -173,20 +173,6 @@
}
#endif
- (void)updateMetalLayerDrawableSize:(CAMetalLayer *)layer
{
CGSize drawableSize = layer.bounds.size;
drawableSize.width *= layer.contentsScale;
drawableSize.height *= layer.contentsScale;
layer.drawableSize = drawableSize;
}
- (void)layoutSublayersOfLayer:(CALayer *)layer
{
if ([layer isKindOfClass:CAMetalLayer.class])
[self updateMetalLayerDrawableSize:static_cast<CAMetalLayer* >(layer)];
}
- (void)displayLayer:(CALayer *)layer
{
if (!NSThread.isMainThread) {
@ -213,13 +199,8 @@
{
qCDebug(lcQpaDrawing) << "Backing properties changed for" << self;
if (CALayer *layer = self.layer) {
layer.contentsScale = self.window.backingScaleFactor;
// Metal layers must be manually updated on e.g. screen change
if ([layer isKindOfClass:CAMetalLayer.class])
[self updateMetalLayerDrawableSize:static_cast<CAMetalLayer* >(layer)];
}
if (self.layer)
self.layer.contentsScale = self.window.backingScaleFactor;
// Ideally we would plumb this situation through QPA in a way that lets
// clients invalidate their own caches, recreate QBackingStore, etc.