5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_
10 #include <Metal/Metal.h>
12 #include "flutter/flow/surface.h"
13 #include "flutter/fml/memory/weak_ptr.h"
14 #include "flutter/fml/platform/darwin/scoped_nsobject.h"
15 #include "flutter/fml/trace_event.h"
33 - (instancetype)
initWithFrame:(CGRect)frame screenScale:(CGFloat)screenScale;
40 - (void)clipRect:(const SkRect&)clipSkRect matrix:(const SkMatrix&)matrix;
45 - (void)clipRRect:(const SkRRect&)clipSkRRect matrix:(const SkMatrix&)matrix;
50 - (void)clipPath:(const SkPath&)path matrix:(const SkMatrix&)matrix;
66 - (instancetype)initWithCapacity:(NSInteger)capacity;
84 @property(nonatomic, readonly) CGRect
frame;
113 blurRadius:(CGFloat)blurRadius
114 visualEffectView:(UIVisualEffectView*)visualEffectView NS_DESIGNATED_INITIALIZER;
146 const fml::scoped_nsobject<UIView>& overlay_view_wrapper,
147 std::unique_ptr<IOSSurface> ios_surface,
148 std::unique_ptr<Surface> surface);
175 std::shared_ptr<FlutterPlatformViewLayer> GetLayer(GrDirectContext* gr_context,
176 const std::shared_ptr<IOSContext>& ios_context,
177 MTLPixelFormat pixel_format);
181 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> GetUnusedLayers();
184 void RecycleLayers();
199 size_t available_layer_index_ = 0;
200 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> layers_;
211 fml::WeakPtr<flutter::FlutterPlatformViewsController> GetWeakPtr();
213 void SetFlutterView(UIView* flutter_view) __attribute__((cf_audited_transfer));
215 void SetFlutterViewController(UIViewController<FlutterViewResponder>* flutter_view_controller)
216 __attribute__((cf_audited_transfer));
218 UIViewController<FlutterViewResponder>* getFlutterViewController()
219 __attribute__((cf_audited_transfer));
221 void RegisterViewFactory(
222 NSObject<FlutterPlatformViewFactory>* factory,
225 __attribute__((cf_audited_transfer));
228 void BeginFrame(SkISize frame_size);
234 void PrerollCompositeEmbeddedView(int64_t view_id,
235 std::unique_ptr<flutter::EmbeddedViewParams> params);
237 size_t EmbeddedViewCount();
244 UIView* GetPlatformViewByID(int64_t view_id);
253 PostPrerollResult PostPrerollAction(
254 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger);
256 void EndFrame(
bool should_resubmit_frame,
257 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger);
259 DlCanvas* CompositeEmbeddedView(int64_t view_id);
263 SkRect GetPlatformViewRect(int64_t view_id);
268 bool SubmitFrame(GrDirectContext* gr_context,
269 const std::shared_ptr<IOSContext>& ios_context,
270 std::unique_ptr<SurfaceFrame>
frame);
273 __attribute__((cf_audited_transfer));
277 long FindFirstResponderPlatformViewId();
280 void PushFilterToVisitedPlatformViews(
const std::shared_ptr<const DlImageFilter>& filter,
281 const SkRect& filter_rect);
287 static const size_t kMaxLayerAllocations = 2;
289 using LayersMap = std::map<int64_t, std::vector<std::shared_ptr<FlutterPlatformViewLayer>>>;
293 __attribute__((cf_audited_transfer));
295 __attribute__((cf_audited_transfer));
297 __attribute__((cf_audited_transfer));
306 bool HasPlatformViewThisOrNextFrame();
309 int CountClips(
const MutatorsStack& mutators_stack);
311 void ClipViewSetMaskView(UIView* clipView) __attribute__((cf_audited_transfer));
322 void ApplyMutators(
const MutatorsStack& mutators_stack,
323 UIView* embedded_view,
324 const SkRect& bounding_rect) __attribute__((cf_audited_transfer));
326 void CompositeWithParams(int64_t view_id,
const EmbeddedViewParams& params);
330 std::shared_ptr<FlutterPlatformViewLayer> GetLayer(GrDirectContext* gr_context,
331 const std::shared_ptr<IOSContext>& ios_context,
332 EmbedderViewSlice* slice,
336 MTLPixelFormat pixel_format);
339 void RemoveUnusedLayers();
342 void BringLayersIntoView(LayersMap layer_map);
346 void BeginCATransaction();
349 void CommitCATransactionIfNeeded();
352 void ResetFrameState();
355 std::unique_ptr<FlutterPlatformViewLayerPool> layer_pool_;
361 std::map<int64_t, std::unique_ptr<EmbedderViewSlice>> slices_;
363 fml::scoped_nsobject<FlutterMethodChannel> channel_;
364 fml::scoped_nsobject<UIView> flutter_view_;
365 fml::scoped_nsobject<UIViewController<FlutterViewResponder>> flutter_view_controller_;
366 fml::scoped_nsobject<FlutterClippingMaskViewPool> mask_view_pool_;
367 std::map<std::string, fml::scoped_nsobject<NSObject<FlutterPlatformViewFactory>>> factories_;
368 std::map<int64_t, fml::scoped_nsobject<NSObject<FlutterPlatformView>>> views_;
369 std::map<int64_t, fml::scoped_nsobject<FlutterTouchInterceptingView>> touch_interceptors_;
375 std::map<int64_t, fml::scoped_nsobject<UIView>> root_views_;
377 std::map<int64_t, EmbeddedViewParams> current_composition_params_;
380 std::map<int64_t, int64_t> clip_count_;
388 static const int kDefaultMergedLeaseDuration = 10;
392 std::unordered_set<int64_t> views_to_dispose_;
396 std::vector<int64_t> composition_order_;
399 std::vector<int64_t> visited_platform_views_;
402 std::vector<int64_t> active_composition_order_;
405 std::unordered_set<int64_t> views_to_recomposite_;
408 std::map<std::string, FlutterPlatformViewGestureRecognizersBlockingPolicy>
409 gesture_recognizers_blocking_policies_;
411 bool catransaction_added_ =
false;
414 std::unique_ptr<fml::WeakPtrFactory<FlutterPlatformViewsController>> weak_factory_;
416 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
420 std::unordered_set<int64_t> non_zero_origin_views_;
434 - (instancetype)initWithEmbeddedView:(UIView*)embeddedView
435 platformViewsController:
436 (fml::WeakPtr<
flutter::FlutterPlatformViewsController>)platformViewsController
437 gestureRecognizersBlockingPolicy:
458 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_