5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_PLATFORM_VIEWS_CONTROLLER_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_PLATFORM_VIEWS_CONTROLLER_H_
8 #include <Metal/Metal.h>
10 #include "flutter/flow/surface.h"
11 #include "flutter/fml/memory/weak_ptr.h"
12 #include "flutter/fml/platform/darwin/scoped_nsobject.h"
13 #include "flutter/fml/task_runner.h"
14 #include "flutter/fml/trace_event.h"
15 #include "impeller/base/thread_safety.h"
16 #include "third_party/skia/include/core/SkRect.h"
38 fml::WeakPtr<flutter::PlatformViewsController>
GetWeakPtr();
41 void SetTaskRunner(
const fml::RefPtr<fml::TaskRunner>& platform_task_runner);
44 void SetFlutterView(UIView* flutter_view) __attribute__((cf_audited_transfer));
48 __attribute__((cf_audited_transfer));
52 __attribute__((cf_audited_transfer));
56 NSObject<FlutterPlatformViewFactory>* factory,
59 __attribute__((cf_audited_transfer));
75 std::unique_ptr<flutter::EmbeddedViewParams> params);
87 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger,
88 bool impeller_enabled);
94 void EndFrame(
bool should_resubmit_frame,
95 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger,
96 bool impeller_enabled);
113 const std::shared_ptr<IOSContext>& ios_context,
114 std::unique_ptr<SurfaceFrame> frame);
118 __attribute__((cf_audited_transfer));
128 const SkRect& filter_rect);
152 return current_composition_params_.find(view_id)->second;
163 std::shared_ptr<OverlayLayer> layer;
166 using LayersMap = std::unordered_map<int64_t, LayerData>;
171 void PerformSubmit(
const LayersMap& platform_view_layers,
172 std::unordered_map<int64_t, EmbeddedViewParams>& current_composition_params,
173 const std::unordered_set<int64_t>& views_to_recomposite,
174 const std::vector<int64_t>& composition_order,
175 const std::vector<std::shared_ptr<OverlayLayer>>& unused_layers,
176 const std::vector<std::unique_ptr<SurfaceFrame>>& surface_frames);
181 void CreateMissingOverlays(GrDirectContext* gr_context,
182 const std::shared_ptr<IOSContext>& ios_context,
183 size_t required_overlay_layers);
188 __attribute__((cf_audited_transfer));
191 __attribute__((cf_audited_transfer));
194 __attribute__((cf_audited_transfer));
197 std::vector<UIView*> GetViewsToDispose();
199 void ClipViewSetMaskView(UIView* clipView) __attribute__((cf_audited_transfer));
210 void ApplyMutators(
const MutatorsStack& mutators_stack,
211 UIView* embedded_view,
212 const SkRect& bounding_rect) __attribute__((cf_audited_transfer));
214 std::shared_ptr<OverlayLayer> GetExistingLayer();
217 void CreateLayer(GrDirectContext* gr_context,
218 const std::shared_ptr<IOSContext>& ios_context,
219 MTLPixelFormat pixel_format);
223 void RemoveUnusedLayers(
const std::vector<std::shared_ptr<OverlayLayer>>& unused_layers,
224 const std::vector<int64_t>& composition_order);
228 void BringLayersIntoView(
const LayersMap& layer_map,
229 const std::vector<int64_t>& composition_order);
232 void ResetFrameState();
235 std::unique_ptr<OverlayLayerPool> layer_pool_;
241 std::unordered_map<int64_t, std::unique_ptr<EmbedderViewSlice>> slices_;
243 fml::scoped_nsobject<FlutterMethodChannel> channel_;
244 fml::scoped_nsobject<UIView> flutter_view_;
245 fml::scoped_nsobject<UIViewController<FlutterViewResponder>> flutter_view_controller_;
246 fml::scoped_nsobject<FlutterClippingMaskViewPool> mask_view_pool_;
247 std::unordered_map<std::string, fml::scoped_nsobject<NSObject<FlutterPlatformViewFactory>>>
251 std::unordered_map<std::string, FlutterPlatformViewGestureRecognizersBlockingPolicy>
252 gesture_recognizers_blocking_policies_;
258 fml::RefPtr<fml::TaskRunner> platform_task_runner_;
264 struct PlatformViewData {
265 fml::scoped_nsobject<NSObject<FlutterPlatformView>> view;
266 fml::scoped_nsobject<FlutterTouchInterceptingView> touch_interceptor;
267 fml::scoped_nsobject<UIView> root_view;
271 std::unordered_map<int64_t, PlatformViewData> platform_views_;
276 std::unordered_map<int64_t, EmbeddedViewParams> current_composition_params_;
282 std::unordered_set<int64_t> views_to_dispose_;
287 std::vector<int64_t> composition_order_;
292 std::vector<int64_t> visited_platform_views_;
297 std::unordered_set<int64_t> views_to_recomposite_;
299 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
303 std::unordered_set<int64_t> non_zero_origin_views_;
309 std::vector<int64_t> previous_composition_order_;
318 bool had_platform_views_ =
false;
321 std::unique_ptr<fml::WeakPtrFactory<PlatformViewsController>> weak_factory_;
326 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_PLATFORM_VIEWS_CONTROLLER_H_