Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
flutter::FlutterCompositor Class Reference

#include <FlutterCompositor.h>

Public Member Functions

 FlutterCompositor (id< FlutterViewProvider > view_provider, FlutterTimeConverter *time_converter, FlutterPlatformViewController *platform_views_controller)
 
 ~FlutterCompositor ()=default
 
bool CreateBackingStore (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
 
bool Present (FlutterViewIdentifier view_id, const FlutterLayer **layers, size_t layers_count)
 

Detailed Description

Definition at line 36 of file FlutterCompositor.h.

Constructor & Destructor Documentation

◆ FlutterCompositor()

FlutterCompositor::FlutterCompositor ( id< FlutterViewProvider view_provider,
FlutterTimeConverter time_converter,
FlutterPlatformViewController platform_views_controller 
)

Definition at line 35 of file FlutterCompositor.mm.

38 : view_provider_(view_provider),
39 time_converter_(time_converter),
40 platform_view_controller_(platform_view_controller) {
41 FML_CHECK(view_provider != nullptr) << "view_provider cannot be nullptr";
42}
#define FML_CHECK(condition)
Definition logging.h:85

◆ ~FlutterCompositor()

flutter::FlutterCompositor::~FlutterCompositor ( )
default

Member Function Documentation

◆ CreateBackingStore()

bool FlutterCompositor::CreateBackingStore ( const FlutterBackingStoreConfig config,
FlutterBackingStore backing_store_out 
)

Definition at line 44 of file FlutterCompositor.mm.

45 {
46 // TODO(dkwingsmt): This class only supports single-view for now. As more
47 // classes are gradually converted to multi-view, it should get the view ID
48 // from somewhere.
49 FlutterView* view = [view_provider_ viewForIdentifier:kFlutterImplicitViewId];
50 if (!view) {
51 return false;
52 }
53
54 CGSize size = CGSizeMake(config->size.width, config->size.height);
55 FlutterSurface* surface = [view.surfaceManager surfaceForSize:size];
56 memset(backing_store_out, 0, sizeof(FlutterBackingStore));
57 backing_store_out->struct_size = sizeof(FlutterBackingStore);
58 backing_store_out->type = kFlutterBackingStoreTypeMetal;
59 backing_store_out->metal.struct_size = sizeof(FlutterMetalBackingStore);
60 backing_store_out->metal.texture = surface.asFlutterMetalTexture;
61 return true;
62}
@ kFlutterBackingStoreTypeMetal
Specifies a Metal backing store. This is backed by a Metal texture.
Definition embedder.h:1744
VkSurfaceKHR surface
Definition main.cc:49
FlutterSurfaceManager * surfaceManager
Definition FlutterView.h:57
constexpr int64_t kFlutterImplicitViewId
Definition constants.h:35
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
FlutterSize size
The size of the render target the engine expects to render into.
Definition embedder.h:1782
FlutterMetalBackingStore metal
Definition embedder.h:1772
FlutterBackingStoreType type
Specifies the type of backing store.
Definition embedder.h:1760
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStore).
Definition embedder.h:1754
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalBackingStore).
Definition embedder.h:1658
FlutterMetalTexture texture
Definition embedder.h:1663
double height
Definition embedder.h:423
double width
Definition embedder.h:422

◆ Present()

bool FlutterCompositor::Present ( FlutterViewIdentifier  view_id,
const FlutterLayer **  layers,
size_t  layers_count 
)

Definition at line 64 of file FlutterCompositor.mm.

66 {
67 FlutterView* view = [view_provider_ viewForIdentifier:view_id];
68 if (!view) {
69 return false;
70 }
71
72 NSMutableArray* surfaces = [NSMutableArray array];
73 for (size_t i = 0; i < layers_count; i++) {
74 const FlutterLayer* layer = layers[i];
77 [FlutterSurface fromFlutterMetalTexture:&layer->backing_store->metal.texture];
78
79 if (surface) {
82 info.offset = CGPointMake(layer->offset.x, layer->offset.y);
83 info.zIndex = i;
85 if (present_info != nullptr && present_info->paint_region != nullptr) {
86 auto paint_region = present_info->paint_region;
87 // Safe because the size of FlutterRect is not expected to change.
88 info.paintRegion = std::vector<FlutterRect>(
89 paint_region->rects, paint_region->rects + paint_region->rects_count);
90 }
91 [surfaces addObject:info];
92 }
93 }
94 }
95
96 CFTimeInterval presentation_time = 0;
97
98 if (layers_count > 0 && layers[0]->presentation_time != 0) {
99 presentation_time = [time_converter_ engineTimeToCAMediaTime:layers[0]->presentation_time];
100 }
101
102 // Notify block below may be called asynchronously, hence the need to copy
103 // the layer information instead of passing the original pointers from embedder.
104 auto layers_copy = std::make_shared<std::vector<LayerVariant>>(CopyLayers(layers, layers_count));
105
106 [view.surfaceManager
107 presentSurfaces:surfaces
108 atTime:presentation_time
109 notify:^{
110 // Gets a presenter or create a new one for the view.
111 ViewPresenter& presenter = presenters_[view_id];
112 presenter.PresentPlatformViews(view, *layers_copy, platform_view_controller_);
113 }];
114
115 return true;
116}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kFlutterLayerContentTypeBackingStore
Definition embedder.h:1791
init(device_serial, adb_binary)
Definition _adb_path.py:12
FlutterPoint offset
Definition embedder.h:1833
FlutterLayerContentType type
Definition embedder.h:1822
const FlutterBackingStore * backing_store
Definition embedder.h:1826
FlutterBackingStorePresentInfo * backing_store_present_info
Definition embedder.h:1839
uint64_t presentation_time
Definition embedder.h:1843

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