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;
142 const fml::scoped_nsobject<UIView>& overlay_view_wrapper,
143 std::unique_ptr<IOSSurface> ios_surface,
144 std::unique_ptr<Surface> surface);
171 std::shared_ptr<FlutterPlatformViewLayer> GetLayer(GrDirectContext* gr_context,
172 const std::shared_ptr<IOSContext>& ios_context,
173 MTLPixelFormat pixel_format);
177 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> GetUnusedLayers();
180 void RecycleLayers();
195 size_t available_layer_index_ = 0;
196 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> layers_;
207 fml::WeakPtr<flutter::FlutterPlatformViewsController> GetWeakPtr();
209 void SetFlutterView(UIView* flutter_view);
211 void SetFlutterViewController(UIViewController* flutter_view_controller);
213 UIViewController* getFlutterViewController();
215 void RegisterViewFactory(
216 NSObject<FlutterPlatformViewFactory>* factory,
221 void BeginFrame(SkISize frame_size);
227 void PrerollCompositeEmbeddedView(int64_t view_id,
228 std::unique_ptr<flutter::EmbeddedViewParams> params);
230 size_t EmbeddedViewCount();
237 UIView* GetPlatformViewByID(int64_t view_id);
246 PostPrerollResult PostPrerollAction(
247 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger);
249 void EndFrame(
bool should_resubmit_frame,
250 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger);
252 DlCanvas* CompositeEmbeddedView(int64_t view_id);
256 SkRect GetPlatformViewRect(int64_t view_id);
261 bool SubmitFrame(GrDirectContext* gr_context,
262 const std::shared_ptr<IOSContext>& ios_context,
263 std::unique_ptr<SurfaceFrame>
frame);
269 long FindFirstResponderPlatformViewId();
272 void PushFilterToVisitedPlatformViews(
const std::shared_ptr<const DlImageFilter>& filter,
273 const SkRect& filter_rect);
279 static const size_t kMaxLayerAllocations = 2;
281 using LayersMap = std::map<int64_t, std::vector<std::shared_ptr<FlutterPlatformViewLayer>>>;
295 bool HasPlatformViewThisOrNextFrame();
298 int CountClips(
const MutatorsStack& mutators_stack);
300 void ClipViewSetMaskView(UIView* clipView);
311 void ApplyMutators(
const MutatorsStack& mutators_stack,
312 UIView* embedded_view,
313 const SkRect& bounding_rect);
315 void CompositeWithParams(int64_t view_id,
const EmbeddedViewParams& params);
319 std::shared_ptr<FlutterPlatformViewLayer> GetLayer(GrDirectContext* gr_context,
320 const std::shared_ptr<IOSContext>& ios_context,
321 EmbedderViewSlice* slice,
325 MTLPixelFormat pixel_format);
328 void RemoveUnusedLayers();
331 void BringLayersIntoView(LayersMap layer_map);
335 void BeginCATransaction();
338 void CommitCATransactionIfNeeded();
341 void ResetFrameState();
344 std::unique_ptr<FlutterPlatformViewLayerPool> layer_pool_;
350 std::map<int64_t, std::unique_ptr<EmbedderViewSlice>> slices_;
352 fml::scoped_nsobject<FlutterMethodChannel> channel_;
353 fml::scoped_nsobject<UIView> flutter_view_;
354 fml::scoped_nsobject<UIViewController> flutter_view_controller_;
355 fml::scoped_nsobject<FlutterClippingMaskViewPool> mask_view_pool_;
356 std::map<std::string, fml::scoped_nsobject<NSObject<FlutterPlatformViewFactory>>> factories_;
357 std::map<int64_t, fml::scoped_nsobject<NSObject<FlutterPlatformView>>> views_;
358 std::map<int64_t, fml::scoped_nsobject<FlutterTouchInterceptingView>> touch_interceptors_;
364 std::map<int64_t, fml::scoped_nsobject<UIView>> root_views_;
366 std::map<int64_t, EmbeddedViewParams> current_composition_params_;
369 std::map<int64_t, int64_t> clip_count_;
377 static const int kDefaultMergedLeaseDuration = 10;
381 std::unordered_set<int64_t> views_to_dispose_;
385 std::vector<int64_t> composition_order_;
388 std::vector<int64_t> visited_platform_views_;
391 std::vector<int64_t> active_composition_order_;
394 std::unordered_set<int64_t> views_to_recomposite_;
397 std::map<std::string, FlutterPlatformViewGestureRecognizersBlockingPolicy>
398 gesture_recognizers_blocking_policies_;
400 bool catransaction_added_ =
false;
403 std::unique_ptr<fml::WeakPtrFactory<FlutterPlatformViewsController>> weak_factory_;
405 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
409 std::unordered_set<int64_t> non_zero_origin_views_;
423 - (instancetype)initWithEmbeddedView:(UIView*)embeddedView
424 platformViewsController:
425 (fml::WeakPtr<
flutter::FlutterPlatformViewsController>)platformViewsController
426 gestureRecognizersBlockingPolicy:
439 - (void)setFlutterAccessibilityContainer:(NSObject*)flutterAccessibilityContainer;
447 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_