Flutter Engine
flutter::FlutterPlatformViewLayerPool Class Reference

#import <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 88 of file FlutterPlatformViews_Internal.h.

Constructor & Destructor Documentation

◆ FlutterPlatformViewLayerPool()

- FlutterPlatformViewLayerPool:

◆ ~FlutterPlatformViewLayerPool()

- FlutterPlatformViewLayerPool:

Method Documentation

◆ GetLayer()

- (shared_ptr< FlutterPlatformViewLayer >) flutter: (GrDirectContext *)  gr_context
(std::shared_ptr< IOSContext >)  ios_context 

Definition at line 23 of file FlutterPlatformViews.mm.

References flutter::IOSSurface::CreateGPUSurface(), fml::scoped_nsprotocol< NST *>::get(), and fml::scoped_nsprotocol< NST *>::reset().

Referenced by flutter::FlutterPlatformViewsController::SubmitFrame.

25  {
26  if (available_layer_index_ >= layers_.size()) {
27  std::shared_ptr<FlutterPlatformViewLayer> layer;
29  fml::scoped_nsobject<FlutterOverlayView> overlay_view_wrapper;
30 
31  if (!gr_context) {
32  overlay_view.reset([[FlutterOverlayView alloc] init]);
33  overlay_view_wrapper.reset([[FlutterOverlayView alloc] init]);
34 
35  std::unique_ptr<IOSSurface> ios_surface =
36  [overlay_view.get() createSurface:std::move(ios_context)];
37  std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface();
38 
39  layer = std::make_shared<FlutterPlatformViewLayer>(
40  std::move(overlay_view), std::move(overlay_view_wrapper), std::move(ios_surface),
41  std::move(surface));
42  } else {
43  CGFloat screenScale = [UIScreen mainScreen].scale;
44  overlay_view.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale]);
45  overlay_view_wrapper.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale]);
46 
47  std::unique_ptr<IOSSurface> ios_surface =
48  [overlay_view.get() createSurface:std::move(ios_context)];
49  std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface(gr_context);
50 
51  layer = std::make_shared<FlutterPlatformViewLayer>(
52  std::move(overlay_view), std::move(overlay_view_wrapper), std::move(ios_surface),
53  std::move(surface));
54  layer->gr_context = gr_context;
55  }
56  // The overlay view wrapper masks the overlay view.
57  // This is required to keep the backing surface size unchanged between frames.
58  //
59  // Otherwise, changing the size of the overlay would require a new surface,
60  // which can be very expensive.
61  //
62  // This is the case of an animation in which the overlay size is changing in every frame.
63  //
64  // +------------------------+
65  // | overlay_view |
66  // | +--------------+ | +--------------+
67  // | | wrapper | | == mask => | overlay_view |
68  // | +--------------+ | +--------------+
69  // +------------------------+
70  overlay_view_wrapper.get().clipsToBounds = YES;
71  [overlay_view_wrapper.get() addSubview:overlay_view];
72  layers_.push_back(layer);
73  }
74  std::shared_ptr<FlutterPlatformViewLayer> layer = layers_[available_layer_index_];
75  if (gr_context != layer->gr_context) {
76  layer->gr_context = gr_context;
77  // The overlay already exists, but the GrContext was changed so we need to recreate
78  // the rendering surface with the new GrContext.
79  IOSSurface* ios_surface = layer->ios_surface.get();
80  std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface(gr_context);
81  layer->surface = std::move(surface);
82  }
83  available_layer_index_++;
84  return layer;
85 }
void reset(NST * object=nil)

◆ GetUnusedLayers()

- (vector<) std:

Definition at line 92 of file FlutterPlatformViews.mm.

92  {
93  std::vector<std::shared_ptr<FlutterPlatformViewLayer>> results;
94  for (size_t i = available_layer_index_; i < layers_.size(); i++) {
95  results.push_back(layers_[i]);
96  }
97  return results;
98 }

◆ RecycleLayers()

- (void) FlutterPlatformViewLayerPool:

Definition at line 87 of file FlutterPlatformViews.mm.

87  {
88  available_layer_index_ = 0;
89 }

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