14 std::vector<LayerVariant> layers_copy;
15 for (
size_t i = 0;
i < layer_count;
i++) {
18 layers_copy.push_back(PlatformViewLayer(layer));
20 std::vector<FlutterRect> rects;
22 if (present_info !=
nullptr && present_info->paint_region !=
nullptr) {
23 rects.reserve(present_info->paint_region->rects_count);
24 std::copy(present_info->paint_region->rects,
25 present_info->paint_region->rects + present_info->paint_region->rects_count,
26 std::back_inserter(rects));
28 layers_copy.push_back(BackingStoreLayer{rects});
38 : view_provider_(view_provider),
39 time_converter_(time_converter),
40 platform_view_controller_(platform_view_controller) {
41 FML_CHECK(view_provider !=
nullptr) <<
"view_provider cannot be nullptr";
45 dispatch_assert_queue(dispatch_get_main_queue());
46 presenters_.try_emplace(
view_id);
50 dispatch_assert_queue(dispatch_get_main_queue());
79 NSMutableArray* surfaces = [NSMutableArray array];
92 if (present_info !=
nullptr && present_info->
paint_region !=
nullptr) {
96 paint_region->rects, paint_region->rects + paint_region->rects_count);
98 [surfaces addObject:info];
103 CFTimeInterval presentation_time = 0;
111 auto layers_copy = std::make_shared<std::vector<LayerVariant>>(CopyLayers(
layers,
layers_count));
113 [
view.surfaceManager presentSurfaces:surfaces
114 atTime:presentation_time
123 dispatch_assert_queue(dispatch_get_main_queue());
124 auto found_presenter = presenters_.find(
view_id);
125 if (found_presenter != presenters_.end()) {
126 found_presenter->second.PresentPlatformViews(
127 view, *layers_copy, platform_view_controller_);
135 return presenters_.size();
138FlutterCompositor::ViewPresenter::ViewPresenter()
139 : mutator_views_([NSMapTable strongToStrongObjectsMapTable]) {}
141void FlutterCompositor::ViewPresenter::PresentPlatformViews(
143 const std::vector<LayerVariant>&
layers,
145 FML_DCHECK([[NSThread currentThread] isMainThread])
146 <<
"Must be on the main thread to present platform views";
149 NSMutableArray<FlutterMutatorView*>* present_mutators = [NSMutableArray array];
153 if (!std::holds_alternative<PlatformViewLayer>(layer)) {
156 const auto&
platform_view = std::get<PlatformViewLayer>(layer);
158 PresentPlatformView(default_base_view,
platform_view,
i, platform_view_controller);
159 [present_mutators addObject:mutator_view];
162 [mutator_view resetHitTestRegion];
164 const auto& overlay_layer =
layers[j];
165 if (!std::holds_alternative<BackingStoreLayer>(overlay_layer)) {
168 const auto& backing_store_layer = std::get<BackingStoreLayer>(overlay_layer);
169 for (
const auto& flutter_rect : backing_store_layer.paint_region) {
170 double scale = default_base_view.layer.contentsScale;
171 CGRect rect = CGRectMake(flutter_rect.left / scale, flutter_rect.top / scale,
172 (flutter_rect.right - flutter_rect.left) / scale,
173 (flutter_rect.bottom - flutter_rect.top) / scale);
174 CGRect intersection = CGRectIntersection(rect, mutator_view.frame);
175 if (!CGRectIsNull(intersection)) {
176 intersection.origin.x -= mutator_view.frame.origin.x;
177 intersection.origin.y -= mutator_view.frame.origin.y;
178 [mutator_view addHitTestIgnoreRegion:intersection];
184 NSMutableArray<FlutterMutatorView*>* obsolete_mutators =
185 [NSMutableArray arrayWithArray:[mutator_views_ objectEnumerator].allObjects];
186 [obsolete_mutators removeObjectsInArray:present_mutators];
189 [mutator_views_ removeObjectForKey:mutator.platformView];
190 [mutator removeFromSuperview];
193 [platform_view_controller disposePlatformViews];
198 const PlatformViewLayer& layer,
201 FML_DCHECK([[NSThread currentThread] isMainThread])
202 <<
"Must be on the main thread to present platform views";
204 int64_t platform_view_id = layer.identifier();
205 NSView*
platform_view = [platform_view_controller platformViewWithID:platform_view_id];
209 if (cursor_coordinator_ == nil) {
217 cursorCoordiator:cursor_coordinator_];
219 [default_base_view addSubview:container];
222 container.layer.zPosition = index;
223 [container applyFlutterLayer:&layer];
FlutterCompositor(id< FlutterViewProvider > view_provider, FlutterTimeConverter *time_converter, FlutterPlatformViewController *platform_views_controller)
bool CreateBackingStore(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
bool Present(FlutterViewIdentifier view_id, const FlutterLayer **layers, size_t layers_count)
void AddView(FlutterViewId view_id)
void RemoveView(FlutterViewId view_id)
@ kFlutterLayerContentTypePlatformView
Indicates that the contents of this layer are determined by the embedder.
@ kFlutterLayerContentTypeBackingStore
@ kFlutterBackingStoreTypeMetal
Specifies a Metal backing store. This is backed by a Metal texture.
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
G_BEGIN_DECLS FlutterViewId view_id
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
std::vector< FlutterRect > paintRegion
Converts between the time representation used by Flutter Engine and CAMediaTime.
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
FlutterSize size
The size of the render target the engine expects to render into.
FlutterMetalBackingStore metal
FlutterBackingStoreType type
Specifies the type of backing store.
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStore).
FlutterRegion * paint_region
FlutterLayerContentType type
const FlutterBackingStore * backing_store
FlutterBackingStorePresentInfo * backing_store_present_info
uint64_t presentation_time
FlutterSize size
The size of the layer (in physical pixels).