Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | List of all members
flutter::FlutterPlatformViewLayerPool Class Reference

#include <FlutterPlatformViews_Internal.h>

Instance Methods

() - FlutterPlatformViewLayerPool
 
() - ~FlutterPlatformViewLayerPool
 
(std::shared_ptr< FlutterPlatformViewLayer >) - GetLayer
 
(std::vector< std::shared_ptr< FlutterPlatformViewLayer > >) - GetUnusedLayers
 
(void) - RecycleLayers
 

Detailed Description

Definition at line 167 of file FlutterPlatformViews_Internal.h.

Constructor & Destructor Documentation

◆ FlutterPlatformViewLayerPool

- FlutterPlatformViewLayerPool:

◆ ~FlutterPlatformViewLayerPool

- FlutterPlatformViewLayerPool:

Method Documentation

◆ GetLayer

- (shared_ptr< FlutterPlatformViewLayer >) flutter: (GrDirectContext *)  gr_context
(const std::shared_ptr< IOSContext > &)  ios_context
(MTLPixelFormat)  pixel_format 

Definition at line 80 of file FlutterPlatformViews.mm.

83 {
84 if (available_layer_index_ >= layers_.size()) {
85 std::shared_ptr<FlutterPlatformViewLayer> layer;
87 fml::scoped_nsobject<UIView> overlay_view_wrapper;
88
89 bool impeller_enabled = !!ios_context->GetImpellerContext();
90 if (!gr_context && !impeller_enabled) {
91 overlay_view.reset([[FlutterOverlayView alloc] init]);
92 overlay_view_wrapper.reset([[FlutterOverlayView alloc] init]);
93
94 auto ca_layer = fml::scoped_nsobject<CALayer>{[[overlay_view.get() layer] retain]};
95 std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create(ios_context, ca_layer);
96 std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface();
97
98 layer = std::make_shared<FlutterPlatformViewLayer>(
99 std::move(overlay_view), std::move(overlay_view_wrapper), std::move(ios_surface),
100 std::move(surface));
101 } else {
102 CGFloat screenScale = [UIScreen mainScreen].scale;
103 overlay_view.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale
104 pixelFormat:pixel_format]);
105 overlay_view_wrapper.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale
106 pixelFormat:pixel_format]);
107
108 auto ca_layer = fml::scoped_nsobject<CALayer>{[[overlay_view.get() layer] retain]};
109 std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create(ios_context, ca_layer);
110 std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface(gr_context);
111
112 layer = std::make_shared<FlutterPlatformViewLayer>(
113 std::move(overlay_view), std::move(overlay_view_wrapper), std::move(ios_surface),
114 std::move(surface));
115 layer->gr_context = gr_context;
116 }
117 // The overlay view wrapper masks the overlay view.
118 // This is required to keep the backing surface size unchanged between frames.
119 //
120 // Otherwise, changing the size of the overlay would require a new surface,
121 // which can be very expensive.
122 //
123 // This is the case of an animation in which the overlay size is changing in every frame.
124 //
125 // +------------------------+
126 // | overlay_view |
127 // | +--------------+ | +--------------+
128 // | | wrapper | | == mask => | overlay_view |
129 // | +--------------+ | +--------------+
130 // +------------------------+
131 layer->overlay_view_wrapper.get().clipsToBounds = YES;
132 [layer->overlay_view_wrapper.get() addSubview:layer->overlay_view];
133 layers_.push_back(layer);
134 }
135 std::shared_ptr<FlutterPlatformViewLayer> layer = layers_[available_layer_index_];
136 if (gr_context != layer->gr_context) {
137 layer->gr_context = gr_context;
138 // The overlay already exists, but the GrContext was changed so we need to recreate
139 // the rendering surface with the new GrContext.
140 IOSSurface* ios_surface = layer->ios_surface.get();
141 std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface(gr_context);
142 layer->surface = std::move(surface);
143 }
144 available_layer_index_++;
145 return layer;
146}
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, const fml::scoped_nsobject< CALayer > &layer)
void reset(NST *object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
VkSurfaceKHR surface
Definition main.cc:49

◆ GetUnusedLayers

- (vector<) std:

Definition at line 153 of file FlutterPlatformViews.mm.

153 {
154 std::vector<std::shared_ptr<FlutterPlatformViewLayer>> results;
155 for (size_t i = available_layer_index_; i < layers_.size(); i++) {
156 results.push_back(layers_[i]);
157 }
158 return results;
159}

◆ RecycleLayers

- (void) FlutterPlatformViewLayerPool:

Definition at line 148 of file FlutterPlatformViews.mm.

148 {
149 available_layer_index_ = 0;
150}

The documentation for this class was generated from the following files: