rhi: metal: Use scale from the layer we already have

...so that we do not need to call devicePixelRatio() again, which means
one less UI Thread Checker warning in Xcode.

Pick-to: 6.5
Task-number: QTBUG-97518
Change-Id: I01d54ea113788cd0b141e124a47940f5cd3efabb
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
bb10
Laszlo Agocs 2022-12-12 17:48:27 +01:00
parent 0657b0734e
commit 8e5806b680
1 changed files with 6 additions and 4 deletions

View File

@ -5633,8 +5633,9 @@ bool QMetalSwapChain::createOrResize()
int width = (int)d->layer.bounds.size.width;
int height = (int)d->layer.bounds.size.height;
CGSize layerSize = CGSizeMake(width, height);
layerSize.width *= d->layer.contentsScale;
layerSize.height *= d->layer.contentsScale;
const float scaleFactor = d->layer.contentsScale;
layerSize.width *= scaleFactor;
layerSize.height *= scaleFactor;
d->layer.drawableSize = layerSize;
m_currentPixelSize = QSizeF::fromCGSize(layerSize).toSize();
@ -5673,12 +5674,13 @@ bool QMetalSwapChain::createOrResize()
rtWrapper.setRenderPassDescriptor(m_renderPassDesc); // for the public getter in QRhiRenderTarget
rtWrapper.d->pixelSize = pixelSize;
rtWrapper.d->dpr = float(window->devicePixelRatio());
rtWrapper.d->dpr = scaleFactor;
rtWrapper.d->sampleCount = samples;
rtWrapper.d->colorAttCount = 1;
rtWrapper.d->dsAttCount = ds ? 1 : 0;
qCDebug(QRHI_LOG_INFO, "got CAMetalLayer, size %dx%d", pixelSize.width(), pixelSize.height());
qCDebug(QRHI_LOG_INFO, "got CAMetalLayer, pixel size %dx%d (scale %.2f)",
pixelSize.width(), pixelSize.height(), scaleFactor);
if (samples > 1) {
MTLTextureDescriptor *desc = [[MTLTextureDescriptor alloc] init];