diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h index a344179057..7332e46115 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h @@ -23,6 +23,7 @@ - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; - (instancetype)init NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithContentsScale:(CGFloat)contentsScale; - (std::unique_ptr)createSoftwareSurface; - (std::unique_ptr)createGLSurfaceWithContext: (std::shared_ptr)gl_context; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm index 83f59d24e0..394ae89550 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm @@ -21,13 +21,13 @@ @implementation FlutterOverlayView - (instancetype)initWithFrame:(CGRect)frame { - @throw([NSException exceptionWithName:@"FlutterOverlayView must initWithDelegate" + @throw([NSException exceptionWithName:@"FlutterOverlayView must init or initWithContentsScale" reason:nil userInfo:nil]); } - (instancetype)initWithCoder:(NSCoder*)aDecoder { - @throw([NSException exceptionWithName:@"FlutterOverlayView must initWithDelegate" + @throw([NSException exceptionWithName:@"FlutterOverlayView must init or initWithContentsScale" reason:nil userInfo:nil]); } @@ -43,16 +43,17 @@ return self; } -- (void)layoutSubviews { +- (instancetype)initWithContentsScale:(CGFloat)contentsScale { + self = [self init]; + if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { CAEAGLLayer* layer = reinterpret_cast(self.layer); layer.allowsGroupOpacity = NO; - CGFloat screenScale = [UIScreen mainScreen].scale; - layer.contentsScale = screenScale; - layer.rasterizationScale = screenScale; + layer.contentsScale = contentsScale; + layer.rasterizationScale = contentsScale; } - [super layoutSubviews]; + return self; } + (Class)layerClass { diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 82659b4fe2..4eb773532a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -245,7 +245,6 @@ bool FlutterPlatformViewsController::SubmitFrame(bool gl_rendering, active_composition_order_.push_back(view_id); } - composition_order_.clear(); return did_submit; } @@ -294,7 +293,9 @@ void FlutterPlatformViewsController::EnsureGLOverlayInitialized( } return; } - FlutterOverlayView* overlay_view = [[FlutterOverlayView alloc] init]; + auto contentsScale = flutter_view_.get().layer.contentsScale; + FlutterOverlayView* overlay_view = + [[FlutterOverlayView alloc] initWithContentsScale:contentsScale]; overlay_view.frame = flutter_view_.get().bounds; overlay_view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); @@ -303,6 +304,7 @@ void FlutterPlatformViewsController::EnsureGLOverlayInitialized( std::unique_ptr surface = ios_surface->CreateSecondaryGPUSurface(gr_context); overlays_[overlay_id] = std::make_unique( fml::scoped_nsobject(overlay_view), std::move(ios_surface), std::move(surface)); + overlays_gr_context_ = gr_context; } } // namespace shell