Metal rhi: Cast layer bounds to int before multiplying by scale factor
In qrhimetal, we were setting the current pixel size by multiplying the width/height of the CAMetal layer bounds, which are floats, with the scale factor, and then rounded these to the nearest integers by converting from QSizeF to QSize. This caused problems, namely a crash when trying to resize a modal view controller on iOS, because Metal expected the height of the render pass to be equal to (int)height * scaleFactor. So looks like we were relying on the truncated rather than rounded value of the height for this. To fix, cast the layer width/height to int before multiplying with the scale factor, to be consistent. Change-Id: I02f4f48db3dcc3802dd56aa816988847fc5d4603 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit f0e98e35a1a0eb842548d008c1524a1e436bc934) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
db51321ce6
commit
b8833ccc31
@ -5483,10 +5483,11 @@ QSize QMetalSwapChain::surfacePixelSize()
|
|||||||
if (!layer)
|
if (!layer)
|
||||||
layer = layerForWindow(m_window);
|
layer = layerForWindow(m_window);
|
||||||
|
|
||||||
CGSize layerSize = layer.bounds.size;
|
int height = (int)layer.bounds.size.height;
|
||||||
layerSize.width *= layer.contentsScale;
|
int width = (int)layer.bounds.size.width;
|
||||||
layerSize.height *= layer.contentsScale;
|
width *= layer.contentsScale;
|
||||||
return QSizeF::fromCGSize(layerSize).toSize();
|
height *= layer.contentsScale;
|
||||||
|
return QSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QMetalSwapChain::isFormatSupported(Format f)
|
bool QMetalSwapChain::isFormatSupported(Format f)
|
||||||
@ -5592,7 +5593,9 @@ bool QMetalSwapChain::createOrResize()
|
|||||||
// Now set the layer's drawableSize which will stay set to the same value
|
// Now set the layer's drawableSize which will stay set to the same value
|
||||||
// until the next createOrResize(), thus ensuring atomicity with regards to
|
// until the next createOrResize(), thus ensuring atomicity with regards to
|
||||||
// the drawable size in frames.
|
// the drawable size in frames.
|
||||||
CGSize layerSize = d->layer.bounds.size;
|
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.width *= d->layer.contentsScale;
|
||||||
layerSize.height *= d->layer.contentsScale;
|
layerSize.height *= d->layer.contentsScale;
|
||||||
d->layer.drawableSize = layerSize;
|
d->layer.drawableSize = layerSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user