Update metal layer drawable size on relayout. (#11224)

This makes it so that the texture obtained by the next frame has the same dimensions as the frame being renderered.

Fixes https://github.com/flutter/flutter/issues/38754
This commit is contained in:
Chinmay Garde 2019-08-19 13:01:11 -07:00 committed by GitHub
parent 1c8c639073
commit 84bd736656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,9 +66,15 @@ id<FlutterViewEngineDelegate> _delegate;
#if FLUTTER_SHELL_ENABLE_METAL
if ([self.layer isKindOfClass:[CAMetalLayer class]]) {
CGFloat screenScale = [UIScreen mainScreen].scale;
self.layer.contentsScale = screenScale;
self.layer.rasterizationScale = screenScale;
const CGFloat screenScale = [UIScreen mainScreen].scale;
auto metal_layer = reinterpret_cast<CAMetalLayer*>(self.layer);
metal_layer.contentsScale = screenScale;
metal_layer.rasterizationScale = screenScale;
const auto layer_size = self.bounds.size;
metal_layer.drawableSize =
CGSizeMake(layer_size.width * screenScale, layer_size.height * screenScale);
}
#endif // FLUTTER_SHELL_ENABLE_METAL