13 const fml::scoped_nsobject<UIView>& overlay_view_wrapper,
14 std::unique_ptr<IOSSurface> ios_surface,
15 std::unique_ptr<Surface> surface)
16 : overlay_view(overlay_view),
17 overlay_view_wrapper(overlay_view_wrapper),
18 ios_surface(std::move(ios_surface)),
19 surface(std::move(surface)){};
26 auto screenScale = [UIScreen mainScreen].scale;
30 rect.width() / screenScale, rect.height() / screenScale);
33 [NSString stringWithFormat:
@"platform_view[%lld].overlay[%lld]", view_id, overlay_id];
41 [NSString stringWithFormat:
@"platform_view[%lld].overlay_view[%lld]", view_id, overlay_id];
48 std::shared_ptr<OverlayLayer> result;
49 if (available_layer_index_ < layers_.size()) {
50 result = layers_[available_layer_index_];
51 available_layer_index_++;
58 const std::shared_ptr<IOSContext>& ios_context,
59 MTLPixelFormat pixel_format) {
60 FML_DCHECK([[NSThread currentThread] isMainThread]);
61 std::shared_ptr<OverlayLayer> layer;
62 fml::scoped_nsobject<UIView> overlay_view;
63 fml::scoped_nsobject<UIView> overlay_view_wrapper;
65 bool impeller_enabled = !!ios_context->GetImpellerContext();
66 if (!gr_context && !impeller_enabled) {
70 auto ca_layer = fml::scoped_nsobject<CALayer>{[overlay_view.get() layer]};
72 std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface();
74 layer = std::make_shared<OverlayLayer>(std::move(overlay_view), std::move(overlay_view_wrapper),
75 std::move(ios_surface), std::move(surface));
77 CGFloat screenScale = [UIScreen mainScreen].scale;
79 pixelFormat:pixel_format]);
80 overlay_view_wrapper.reset([[
FlutterOverlayView alloc] initWithContentsScale:screenScale
81 pixelFormat:pixel_format]);
83 auto ca_layer = fml::scoped_nsobject<CALayer>{[overlay_view.get() layer]};
85 std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface(gr_context);
87 layer = std::make_shared<OverlayLayer>(std::move(overlay_view), std::move(overlay_view_wrapper),
88 std::move(ios_surface), std::move(surface));
89 layer->gr_context = gr_context;
105 layer->overlay_view_wrapper.get().clipsToBounds = YES;
106 [layer->overlay_view_wrapper.get() addSubview:layer->overlay_view];
108 layers_.push_back(layer);
112 available_layer_index_ = 0;
116 std::vector<std::shared_ptr<OverlayLayer>> results;
117 for (
size_t i = available_layer_index_; i < layers_.size(); i++) {
118 results.push_back(layers_[i]);
124 static constexpr
size_t kLeakLayerCount = 1;
125 size_t erase_offset = std::max(available_layer_index_, kLeakLayerCount);
126 if (erase_offset < layers_.size()) {
127 layers_.erase(layers_.begin() + erase_offset, layers_.end());
133 return layers_.size();