Flutter Engine
 
Loading...
Searching...
No Matches
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}
FlutterSoftwareBackingStore software
The description of the software backing store.
Definition embedder.h:2079

References FlutterSoftwareBackingStore::allocation, and FlutterBackingStore::software.

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ 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:2053
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
FlutterSize size
The size of the render target the engine expects to render into.
Definition embedder.h:2093
FlutterBackingStoreType type
Specifies the type of backing store.
Definition embedder.h:2071
double height
Definition embedder.h:629
double width
Definition embedder.h:628
VoidCallback destruction_callback
Definition embedder.h:1941
size_t row_bytes
The number of bytes in a single row of the allocation.
Definition embedder.h:1932
size_t height
The number of rows in the allocation.
Definition embedder.h:1934

References FlutterSoftwareBackingStore::allocation, FlutterSoftwareBackingStore::destruction_callback, FlutterSize::height, FlutterSoftwareBackingStore::height, kFlutterBackingStoreTypeSoftware, FlutterSoftwareBackingStore::row_bytes, flutter::size, FlutterBackingStoreConfig::size, FlutterBackingStore::software, FlutterBackingStore::type, user_data, FlutterSoftwareBackingStore::user_data, and FlutterSize::width.

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ 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:2102
FlView * view
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
#define FML_UNREACHABLE()
Definition logging.h:128
#define FML_DCHECK(condition)
Definition logging.h:122
constexpr int kOpaqueBlack
int32_t height
int32_t width
FlutterPoint offset
Definition embedder.h:2145
FlutterLayerContentType type
Definition embedder.h:2134
const FlutterBackingStore * backing_store
Definition embedder.h:2138
A structure to represent a rectangle.
Definition embedder.h:641
double bottom
Definition embedder.h:645
double top
Definition embedder.h:643
double left
Definition embedder.h:642
double right
Definition embedder.h:644

References FlutterLayer::backing_store, FlutterRect::bottom, FML_DCHECK, FML_UNREACHABLE, height, kFlutterBackingStoreTypeSoftware, kFlutterLayerContentTypeBackingStore, flutter::kOpaqueBlack, layers, layers_count, FlutterRect::left, FlutterLayer::offset, FlutterRect::right, FlutterRect::top, FlutterLayer::type, view, width, FlutterPoint::x, and FlutterPoint::y.

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().


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