Flutter Engine
 
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
24
26
29
30@interface FlutterPlatformViewsController : NSObject
31
32- (instancetype)init NS_DESIGNATED_INITIALIZER;
33
34/// The task runner used to post rendering tasks to the platform thread.
35@property(nonatomic, assign) const fml::RefPtr<fml::TaskRunner>& taskRunner;
36
37/// The flutter view.
38@property(nonatomic, weak) UIView* _Nullable flutterView;
39
40/// @brief The flutter view controller.
41@property(nonatomic, weak) UIViewController<FlutterViewResponder>* _Nullable flutterViewController;
42
43/// @brief set the factory used to construct embedded UI Views.
44- (void)registerViewFactory:(NSObject<FlutterPlatformViewFactory>*)factory
45 withId:(NSString*)factoryId
46 gestureRecognizersBlockingPolicy:
47 (FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizerBlockingPolicy;
48
49/// @brief Mark the beginning of a frame and record the size of the onscreen.
50- (void)beginFrameWithSize:(flutter::DlISize)frameSize;
51
52/// @brief Cancel the current frame, indicating that no platform views are composited.
53///
54/// Additionally, reverts the composition order to its original state at the beginning of the
55/// frame.
56- (void)cancelFrame;
57
58/// @brief Record a platform view in the layer tree to be rendered, along with the positioning and
59/// mutator parameters.
60///
61/// Called from the raster thread.
62- (void)prerollCompositeEmbeddedView:(int64_t)viewId
63 withParams:(std::unique_ptr<flutter::EmbeddedViewParams>)params;
64
65/// @brief Returns the`FlutterTouchInterceptingView` with the provided view_id.
66///
67/// Returns nil if there is no platform view with the provided id. Called
68/// from the platform thread.
69- (FlutterTouchInterceptingView*)flutterTouchInterceptingViewForId:(int64_t)viewId;
70
71/// @brief Determine if thread merging is required after prerolling platform views.
72///
73/// Called from the raster thread.
74- (flutter::PostPrerollResult)postPrerollActionWithThreadMerger:
75 (const fml::RefPtr<fml::RasterThreadMerger>&)rasterThreadMerger;
76
77/// @brief Mark the end of a compositor frame.
78///
79/// May determine changes are required to the thread merging state.
80/// Called from the raster thread.
81- (void)endFrameWithResubmit:(BOOL)shouldResubmitFrame
82 threadMerger:(const fml::RefPtr<fml::RasterThreadMerger>&)rasterThreadMerger;
83
84/// @brief Returns the Canvas for the overlay slice for the given platform view.
85///
86/// Called from the raster thread.
87- (flutter::DlCanvas*)compositeEmbeddedViewWithId:(int64_t)viewId;
88
89/// @brief Discards all platform views instances and auxiliary resources.
90///
91/// Called from the raster thread.
92- (void)reset;
93
94/// @brief Encode rendering for the Flutter overlay views and queue up perform platform view
95/// mutations.
96///
97/// Called from the raster thread.
98- (BOOL)submitFrame:(std::unique_ptr<flutter::SurfaceFrame>)frame
99 withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext;
100
101/// @brief Handler for platform view message channels.
102- (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
103
104/// @brief Returns the platform view id if the platform view (or any of its descendant view) is
105/// the first responder.
106///
107/// Returns -1 if no such platform view is found.
109
110/// @brief Pushes backdrop filter mutation to the mutator stack of each visited platform view.
111- (void)pushFilterToVisitedPlatformViews:(const std::shared_ptr<flutter::DlImageFilter>&)filter
112 withRect:(const flutter::DlRect&)filterRect;
113
114/// @brief Pushes the view id of a visted platform view to the list of visied platform views.
115- (void)pushVisitedPlatformViewId:(int64_t)viewId;
116
117@end
118
119@interface FlutterPlatformViewsController (Testing)
120
121- (size_t)embeddedViewCount;
122
123// Returns the `FlutterPlatformView`'s `view` object associated with the view_id.
124//
125// If the `PlatformViewsController` does not contain any `FlutterPlatformView` object or
126// a `FlutterPlatformView` object associated with the view_id cannot be found, the method
127// returns nil.
128- (UIView* _Nullable)platformViewForId:(int64_t)viewId;
129
130// Composite the PlatformView with `viewId`.
131//
132// Every frame, during the paint traversal of the layer tree, this method is called for all
133// the PlatformViews in `_viewsToRecomposite`.
134//
135// Note that `_viewsToRecomposite` does not represent all the views in the view hierarchy,
136// if a PlatformView does not change its composition parameter from last frame, it is not
137// included in the `views_to_recomposite_`.
138- (void)compositeView:(int64_t)viewId withParams:(const flutter::EmbeddedViewParams&)params;
139
140- (const flutter::EmbeddedViewParams&)compositionParamsForView:(int64_t)viewId;
141
142- (std::vector<int64_t>&)previousCompositionOrder;
143
144@end
145
147
148#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
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...
instancetype NS_DESIGNATED_INITIALIZER()
const fml::RefPtr< fml::TaskRunner > & taskRunner
The task runner used to post rendering tasks to the platform thread.
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