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

#include <compositor_software.h>

Inheritance diagram for flutter::CompositorSoftware:
flutter::Compositor

Public Member Functions

 CompositorSoftware ()
 
bool CreateBackingStore (const FlutterBackingStoreConfig &config, FlutterBackingStore *result) override
 |Compositor|
 
bool CollectBackingStore (const FlutterBackingStore *store) override
 |Compositor|
 
bool Present (FlutterWindowsView *view, const FlutterLayer **layers, size_t layers_count) override
 |Compositor|
 
- Public Member Functions inherited from flutter::Compositor
virtual ~Compositor ()=default
 

Detailed Description

Definition at line 17 of file compositor_software.h.

Constructor & Destructor Documentation

◆ CompositorSoftware()

flutter::CompositorSoftware::CompositorSoftware ( )

Definition at line 84 of file compositor_software.cc.

84{}

Member Function Documentation

◆ CollectBackingStore()

bool flutter::CompositorSoftware::CollectBackingStore ( const FlutterBackingStore store)
overridevirtual

|Compositor|

Implements flutter::Compositor.

Definition at line 107 of file compositor_software.cc.

107 {
108 std::free(const_cast<void*>(store->software.allocation));
109 return true;
110}
SI void store(P *ptr, const T &val)

◆ CreateBackingStore()

bool flutter::CompositorSoftware::CreateBackingStore ( const FlutterBackingStoreConfig config,
FlutterBackingStore result 
)
overridevirtual

|Compositor|

Implements flutter::Compositor.

Definition at line 86 of file compositor_software.cc.

88 {
89 size_t size = config.size.width * config.size.height * 4;
90 void* allocation = std::calloc(size, sizeof(uint8_t));
91 if (!allocation) {
92 return false;
93 }
94
96 result->software.allocation = allocation;
97 result->software.height = config.size.height;
98 result->software.row_bytes = config.size.width * 4;
99 result->software.user_data = nullptr;
100 result->software.destruction_callback = [](void* user_data) {
101 // Backing store destroyed in `CompositorSoftware::CollectBackingStore`, set
102 // on FlutterCompositor.collect_backing_store_callback during engine start.
103 };
104 return true;
105}
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
Definition embedder.h:1742
GAsyncResult * result
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
double height
Definition embedder.h:423
double width
Definition embedder.h:422

◆ Present()

bool flutter::CompositorSoftware::Present ( FlutterWindowsView view,
const FlutterLayer **  layers,
size_t  layers_count 
)
overridevirtual

|Compositor|

Implements flutter::Compositor.

Definition at line 112 of file compositor_software.cc.

114 {
115 FML_DCHECK(view != nullptr);
116
117 // Clear the view if there are no layers to present.
118 if (layers_count == 0) {
119 return view->ClearSoftwareBitmap();
120 }
121
122 // Bypass composition logic if there is only one layer.
123 if (layers_count == 1) {
124 const FlutterLayer* layer = layers[0];
125 FML_DCHECK(layer != nullptr);
127 layer->offset.x == 0 && layer->offset.y == 0) {
128 auto& backing_store = *layer->backing_store;
129 FML_DCHECK(backing_store.type == kFlutterBackingStoreTypeSoftware);
130 auto& software = backing_store.software;
131 return view->PresentSoftwareBitmap(software.allocation,
132 software.row_bytes, software.height);
133 }
134 }
135
136 // Composite many layers.
137 FlutterRect bounds = CalculateBounds(layers, layers_count);
138 // Truncate from double to integer to represent whole pixels.
139 int x_min = static_cast<int>(bounds.left);
140 int x_max = static_cast<int>(bounds.right);
141 int y_min = static_cast<int>(bounds.top);
142 int y_max = static_cast<int>(bounds.bottom);
143
144 int width = x_max - x_min;
145 int height = y_max - y_min;
146 std::vector<uint32_t> allocation(width * height, kOpaqueBlack);
147
148 for (const FlutterLayer** layer = layers; layer < layers + layers_count;
149 layer++) {
150 // TODO(schectman): handle platform view type layers.
151 // https://github.com/flutter/flutter/issues/143375
152 if ((*layer)->type == kFlutterLayerContentTypeBackingStore) {
153 BlendLayer(allocation, **layer, x_min, y_min, width, height);
154 } else {
156 return false;
157 }
158 }
159
160 return view->PresentSoftwareBitmap(static_cast<void*>(allocation.data()),
161 width * sizeof(uint32_t), height);
162}
@ kFlutterLayerContentTypeBackingStore
Definition embedder.h:1791
#define FML_UNREACHABLE()
Definition logging.h:109
#define FML_DCHECK(condition)
Definition logging.h:103
Optional< SkRect > bounds
Definition SkRecords.h:189
constexpr int kOpaqueBlack
int32_t height
int32_t width
FlutterPoint offset
Definition embedder.h:1833
FlutterLayerContentType type
Definition embedder.h:1822
const FlutterBackingStore * backing_store
Definition embedder.h:1826
A structure to represent a rectangle.
Definition embedder.h:435

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