Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[ios] Set contentsScale before we commit CATransaction #8218

Merged
merged 5 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;

- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithContentsScale:(CGFloat)contentsScale;
- (std::unique_ptr<shell::IOSSurface>)createSoftwareSurface;
- (std::unique_ptr<shell::IOSSurfaceGL>)createGLSurfaceWithContext:
(std::shared_ptr<shell::IOSGLContext>)gl_context;
Expand Down
15 changes: 8 additions & 7 deletions shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -43,16 +43,17 @@ - (instancetype)init {
return self;
}

- (void)layoutSubviews {
- (instancetype)initWithContentsScale:(CGFloat)contentsScale {
self = [self init];

if ([self.layer isKindOfClass:[CAEAGLLayer class]]) {
CAEAGLLayer* layer = reinterpret_cast<CAEAGLLayer*>(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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
[flutter_view addSubview:overlays_[view_id]->overlay_view.get()];
active_composition_order_.push_back(view_id);
}

composition_order_.clear();
return did_submit;
}
Expand Down Expand Up @@ -277,7 +276,9 @@
}
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);
Expand All @@ -286,6 +287,7 @@
std::unique_ptr<Surface> surface = ios_surface->CreateSecondaryGPUSurface(gr_context);
overlays_[overlay_id] = std::make_unique<FlutterPlatformViewLayer>(
fml::scoped_nsobject<UIView>(overlay_view), std::move(ios_surface), std::move(surface));
overlays_gr_context_ = gr_context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mention this in the PR description

}

} // namespace shell
Expand Down