Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterPlatformViewsController.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWSCONTROLLER_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWSCONTROLLER_H_
7
8#include <Metal/Metal.h>
9#include <memory>
10#include <unordered_map>
11#include <unordered_set>
12
17
25
27
30
31@interface FlutterPlatformViewsController : NSObject
32
33- (instancetype)init NS_DESIGNATED_INITIALIZER;
34
35/// The task runner used to post rendering tasks to the platform thread.
36@property(nonatomic, strong) FlutterFMLTaskRunner* taskRunner;
37
38/// The flutter view.
39@property(nonatomic, weak) UIView* _Nullable flutterView;
40
41/// @brief The flutter view controller.
42@property(nonatomic, weak) UIViewController<FlutterViewResponder>* _Nullable flutterViewController;
43
44/// @brief set the factory used to construct embedded UI Views.
45- (void)registerViewFactory:(NSObject<FlutterPlatformViewFactory>*)factory
46 withId:(NSString*)factoryId
47 gestureRecognizersBlockingPolicy:
48 (FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizerBlockingPolicy;
49
50/// @brief Mark the beginning of a frame and record the size of the onscreen.
51- (void)beginFrameWithSize:(flutter::DlISize)frameSize;
52
53/// @brief Cancel the current frame, indicating that no platform views are composited.
54///
55/// Additionally, reverts the composition order to its original state at the beginning of the
56/// frame.
57- (void)cancelFrame;
58
59/// @brief Record a platform view in the layer tree to be rendered, along with the positioning and
60/// mutator parameters.
61///
62/// Called from the raster thread.
63- (void)prerollCompositeEmbeddedView:(int64_t)viewId
64 withParams:(std::unique_ptr<flutter::EmbeddedViewParams>)params;
65
66/// @brief Returns the`FlutterTouchInterceptingView` with the provided view_id.
67///
68/// Returns nil if there is no platform view with the provided id. Called
69/// from the platform thread.
70- (FlutterTouchInterceptingView*)flutterTouchInterceptingViewForId:(int64_t)viewId;
71
72/// @brief Determine if thread merging is required after prerolling platform views.
73///
74/// Called from the raster thread.
75- (flutter::PostPrerollResult)postPrerollActionWithThreadMerger:
76 (const fml::RefPtr<fml::RasterThreadMerger>&)rasterThreadMerger;
77
78/// @brief Mark the end of a compositor frame.
79///
80/// May determine changes are required to the thread merging state.
81/// Called from the raster thread.
82- (void)endFrameWithResubmit:(BOOL)shouldResubmitFrame
83 threadMerger:(const fml::RefPtr<fml::RasterThreadMerger>&)rasterThreadMerger;
84
85/// @brief Returns the Canvas for the overlay slice for the given platform view.
86///
87/// Called from the raster thread.
88- (flutter::DlCanvas*)compositeEmbeddedViewWithId:(int64_t)viewId;
89
90/// @brief Discards all platform views instances and auxiliary resources.
91///
92/// Called from the raster thread.
93- (void)reset;
94
95/// @brief Encode rendering for the Flutter overlay views and queue up perform platform view
96/// mutations.
97///
98/// Called from the raster thread.
99- (BOOL)submitFrame:(std::unique_ptr<flutter::SurfaceFrame>)frame
100 withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext;
101
102/// @brief Handler for platform view message channels.
103- (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
104
105/// @brief Returns the platform view id if the platform view (or any of its descendant view) is
106/// the first responder.
107///
108/// Returns -1 if no such platform view is found.
110
111/// @brief Pushes backdrop filter mutation to the mutator stack of each visited platform view.
112- (void)pushFilterToVisitedPlatformViews:(const std::shared_ptr<flutter::DlImageFilter>&)filter
113 withRect:(const flutter::DlRect&)filterRect;
114
115/// @brief Pushes the view id of a visted platform view to the list of visied platform views.
116- (void)pushVisitedPlatformViewId:(int64_t)viewId;
117
118/// @brief Pushes the outstanding rectangular clips to the mutator stack of each visited platform
119/// view
120- (void)pushClipRectToVisitedPlatformViews:(const flutter::DlRect&)clipRect;
121
122/// @brief Pushes the outstanding rounded rectangular clips to the mutator stack of each visited
123/// platform view
124- (void)pushClipRRectToVisitedPlatformViews:(const flutter::DlRoundRect&)clipRRect;
125
126/// @brief Pushes the outstanding round super elliptical clips to the mutator stack of each visited
127/// platform view
128- (void)pushClipRSuperellipseToVisitedPlatformViews:(const flutter::DlRoundSuperellipse&)clipRse;
129
130/// @brief Pushes the outstanding path clips to the mutator stack of each visited platform
131/// view
132- (void)pushClipPathToVisitedPlatformViews:(const flutter::DlPath&)clipPath;
133
134@end
135
136@interface FlutterPlatformViewsController (Testing)
137
138- (size_t)embeddedViewCount;
139
140// Returns the `FlutterPlatformView`'s `view` object associated with the view_id.
141//
142// If the `PlatformViewsController` does not contain any `FlutterPlatformView` object or
143// a `FlutterPlatformView` object associated with the view_id cannot be found, the method
144// returns nil.
145- (UIView* _Nullable)platformViewForId:(int64_t)viewId;
146
147// Composite the PlatformView with `viewId`.
148//
149// Every frame, during the paint traversal of the layer tree, this method is called for all
150// the PlatformViews in `_viewsToRecomposite`.
151//
152// Note that `_viewsToRecomposite` does not represent all the views in the view hierarchy,
153// if a PlatformView does not change its composition parameter from last frame, it is not
154// included in the `views_to_recomposite_`.
155- (void)compositeView:(int64_t)viewId withParams:(const flutter::EmbeddedViewParams&)params;
156
157- (const flutter::EmbeddedViewParams&)compositionParamsForView:(int64_t)viewId;
158
159/// @brief The composition order from the previous frame.
160///
161/// Only accessed from the platform thread.
162- (NSArray<NSNumber*>*)previousCompositionOrder;
163
164@end
165
167
168#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWSCONTROLLER_H_
void(^ FlutterResult)(id _Nullable result)
#define NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_END
FlutterPlatformViewGestureRecognizersBlockingPolicy
NSArray< NSNumber * > * previousCompositionOrder()
The composition order from the previous frame.
HWND(* FlutterPlatformViewFactory)(const FlutterPlatformViewCreationParameters *)
void reset()
Discards all platform views instances and auxiliary resources.
long firstResponderPlatformViewId()
Returns the platform view id if the platform view (or any of its descendant view) is the first respon...
FlutterFMLTaskRunner * taskRunner
The task runner used to post rendering tasks to the platform thread.
instancetype NS_DESIGNATED_INITIALIZER()
UIViewController< FlutterViewResponder > *_Nullable flutterViewController
The flutter view controller.
void cancelFrame()
Cancel the current frame, indicating that no platform views are composited.
UIView *_Nullable flutterView
The flutter view.
Definition ref_ptr.h:261
int BOOL