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:
parent
04dcc902eb
commit
0642ca3528
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user