5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_
8 #include <Metal/Metal.h>
9 #include "flutter/flow/embedded_views.h"
10 #include "flutter/fml/platform/darwin/scoped_nsobject.h"
11 #include "flutter/shell/common/shell.h"
31 - (instancetype)
initWithFrame:(CGRect)frame screenScale:(CGFloat)screenScale;
38 - (void)clipRect:(const SkRect&)clipSkRect matrix:(const SkMatrix&)matrix;
43 - (void)clipRRect:(const SkRRect&)clipSkRRect matrix:(const SkMatrix&)matrix;
48 - (void)clipPath:(const SkPath&)path matrix:(const SkMatrix&)matrix;
64 - (instancetype)initWithCapacity:(NSInteger)capacity;
82 @property(assign, nonatomic, readonly) CGRect
frame;
87 @property(assign, nonatomic, readonly) CGFloat
blurRadius;
111 blurRadius:(CGFloat)blurRadius
112 visualEffectView:(UIVisualEffectView*)visualEffectView NS_DESIGNATED_INITIALIZER;
144 const fml::scoped_nsobject<UIView>& overlay_view_wrapper,
145 std::unique_ptr<IOSSurface> ios_surface,
146 std::unique_ptr<Surface> surface);
173 std::shared_ptr<FlutterPlatformViewLayer> GetLayer(GrDirectContext* gr_context,
174 const std::shared_ptr<IOSContext>& ios_context,
175 MTLPixelFormat pixel_format);
179 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> GetUnusedLayers();
182 void RecycleLayers();
197 size_t available_layer_index_ = 0;
198 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> layers_;
209 fml::WeakPtr<flutter::FlutterPlatformViewsController> GetWeakPtr();
211 void SetFlutterView(UIView* flutter_view);
213 void SetFlutterViewController(UIViewController* flutter_view_controller);
215 UIViewController* getFlutterViewController();
217 void RegisterViewFactory(
218 NSObject<FlutterPlatformViewFactory>* factory,
223 void BeginFrame(SkISize frame_size);
229 void PrerollCompositeEmbeddedView(int64_t view_id,
230 std::unique_ptr<flutter::EmbeddedViewParams> params);
232 size_t EmbeddedViewCount();
239 UIView* GetPlatformViewByID(int64_t view_id);
248 PostPrerollResult PostPrerollAction(
249 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger);
251 void EndFrame(
bool should_resubmit_frame,
252 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger);
254 DlCanvas* CompositeEmbeddedView(int64_t view_id);
258 SkRect GetPlatformViewRect(int64_t view_id);
263 bool SubmitFrame(GrDirectContext* gr_context,
264 const std::shared_ptr<IOSContext>& ios_context,
265 std::unique_ptr<SurfaceFrame>
frame);
271 long FindFirstResponderPlatformViewId();
274 void PushFilterToVisitedPlatformViews(
const std::shared_ptr<const DlImageFilter>& filter,
275 const SkRect& filter_rect);
281 static const size_t kMaxLayerAllocations = 2;
283 using LayersMap = std::map<int64_t, std::vector<std::shared_ptr<FlutterPlatformViewLayer>>>;
297 bool HasPlatformViewThisOrNextFrame();
300 int CountClips(
const MutatorsStack& mutators_stack);
302 void ClipViewSetMaskView(UIView* clipView);
313 void ApplyMutators(
const MutatorsStack& mutators_stack,
314 UIView* embedded_view,
315 const SkRect& bounding_rect);
317 void CompositeWithParams(int64_t view_id,
const EmbeddedViewParams& params);
321 std::shared_ptr<FlutterPlatformViewLayer> GetLayer(GrDirectContext* gr_context,
322 const std::shared_ptr<IOSContext>& ios_context,
323 EmbedderViewSlice* slice,
327 MTLPixelFormat pixel_format);
330 void RemoveUnusedLayers();
333 void BringLayersIntoView(LayersMap layer_map);
337 void BeginCATransaction();
340 void CommitCATransactionIfNeeded();
343 void ResetFrameState();
346 std::unique_ptr<FlutterPlatformViewLayerPool> layer_pool_;
352 std::map<int64_t, std::unique_ptr<EmbedderViewSlice>> slices_;
354 fml::scoped_nsobject<FlutterMethodChannel> channel_;
355 fml::scoped_nsobject<UIView> flutter_view_;
356 fml::scoped_nsobject<UIViewController> flutter_view_controller_;
357 fml::scoped_nsobject<FlutterClippingMaskViewPool> mask_view_pool_;
358 std::map<std::string, fml::scoped_nsobject<NSObject<FlutterPlatformViewFactory>>> factories_;
359 std::map<int64_t, fml::scoped_nsobject<NSObject<FlutterPlatformView>>> views_;
360 std::map<int64_t, fml::scoped_nsobject<FlutterTouchInterceptingView>> touch_interceptors_;
366 std::map<int64_t, fml::scoped_nsobject<UIView>> root_views_;
368 std::map<int64_t, EmbeddedViewParams> current_composition_params_;
371 std::map<int64_t, int64_t> clip_count_;
379 static const int kDefaultMergedLeaseDuration = 10;
383 std::unordered_set<int64_t> views_to_dispose_;
387 std::vector<int64_t> composition_order_;
390 std::vector<int64_t> visited_platform_views_;
393 std::vector<int64_t> active_composition_order_;
396 std::unordered_set<int64_t> views_to_recomposite_;
399 std::map<std::string, FlutterPlatformViewGestureRecognizersBlockingPolicy>
400 gesture_recognizers_blocking_policies_;
402 bool catransaction_added_ =
false;
405 std::unique_ptr<fml::WeakPtrFactory<FlutterPlatformViewsController>> weak_factory_;
407 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
411 std::unordered_set<int64_t> non_zero_origin_views_;
425 - (instancetype)initWithEmbeddedView:(UIView*)embeddedView
426 platformViewsController:
427 (fml::WeakPtr<
flutter::FlutterPlatformViewsController>)platformViewsController
428 gestureRecognizersBlockingPolicy:
441 - (void)setFlutterAccessibilityContainer:(NSObject*)flutterAccessibilityContainer;
449 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_