Updates drawable size of metal view after it is attached to display hierarchy. (#3903)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Stephan Partzsch
2025-10-23 02:06:50 +02:00
committed by GitHub
parent 270789e57b
commit ee2d7e0dc4

View File

@@ -157,7 +157,7 @@ void MLNMapViewMetalImpl::createView() {
}
id<MTLDevice> device = (__bridge id<MTLDevice>)resource.getBackend().getDevice().get();
const auto scaleFactor = MLNEffectiveScaleFactorForView(resource.mtlView);
const auto scaleFactor = MLNEffectiveScaleFactorForView(mapView);
resource.mtlView = [[MTKView alloc] initWithFrame:mapView.bounds device:device];
resource.mtlView.delegate = resource.delegate;
@@ -217,9 +217,15 @@ UIImage* MLNMapViewMetalImpl::snapshot() {
void MLNMapViewMetalImpl::layoutChanged() {
const auto scaleFactor = MLNEffectiveScaleFactorForView(mapView);
const auto screenSize = mapView.window.screen.nativeBounds.size;
size = { static_cast<uint32_t>(screenSize.width * scaleFactor),
static_cast<uint32_t>(screenSize.height * scaleFactor) };
const auto screenSize = mapView.bounds.size;
auto& resource = getResource<MLNMapViewMetalRenderableResource>();
resource.mtlView.contentScaleFactor = scaleFactor;
resource.mtlView.drawableSize = CGSizeMake(screenSize.width * scaleFactor, screenSize.height * scaleFactor);
size = { static_cast<uint32_t>(resource.mtlView.drawableSize.width),
static_cast<uint32_t>(resource.mtlView.drawableSize.height) };
}
MLNBackendResource* MLNMapViewMetalImpl::getObject() {