| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::CompositorSoftware Class Reference

`#include <compositor_software.h>`

Inheritance diagram for flutter::CompositorSoftware:

## Public Member Functions
| CompositorSoftware (FlutterWindowsEngine *engine)
bool | CreateBackingStore (const FlutterBackingStoreConfig &config, FlutterBackingStore *result) override
| |Compositor| More...
bool | CollectBackingStore (const FlutterBackingStore *store) override
| |Compositor| More...
bool | Present (FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count) override
| |Compositor| More...
Public Member Functions inherited from flutter::Compositor
virtual | ~Compositor ()=default

## Detailed Description

Definition at line 16 of file compositor_software.h.

## Constructor & Destructor Documentation

## ◆ CompositorSoftware()

flutter::CompositorSoftware::CompositorSoftware | ( | FlutterWindowsEngine * | engine | ) |

Definition at line 12 of file compositor_software.cc.

13 : engine_(engine) {}

## Member Function Documentation

## ◆ CollectBackingStore()

bool flutter::CompositorSoftware::CollectBackingStore | ( | const FlutterBackingStore * | store | ) |
| override virtual

|Compositor|

Implements flutter::Compositor.

Definition at line 36 of file compositor_software.cc.

36 {
37 std::free(const_cast<void*>(store->software.allocation));
38 return true;
39 }

## ◆ CreateBackingStore()

bool flutter::CompositorSoftware::CreateBackingStore | ( | const FlutterBackingStoreConfig & | config,
|  | FlutterBackingStore * | result
| ) |  |
| override virtual

|Compositor|

Implements flutter::Compositor.

Definition at line 15 of file compositor_software.cc.

17 {
18 size_t size = config.size.width * config.size.height * 4;
19 void* allocation = std::calloc(size, sizeof(uint8_t));
20 if (!allocation) {
21 return false;
22 }
23
24 result->type = kFlutterBackingStoreTypeSoftware;
25 result->software.allocation = allocation;
26 result->software.height = config.size.height;
27 result->software.row_bytes = config.size.width * 4;
28 result->software.user_data = nullptr;
29 result->software.destruction_callback = [](void* user_data) {
30 // Backing store destroyed in `CompositorSoftware::CollectBackingStore`, set
31 // on FlutterCompositor.collect_backing_store_callback during engine start.
32 };
33 return true;
34 }

References user_data.

## ◆ Present()

bool flutter::CompositorSoftware::Present | ( | FlutterViewId | view_id,
|  | const FlutterLayer ** | layers,
|  | size_t | layers_count
| ) |  |
| override virtual

|Compositor|

Implements flutter::Compositor.

Definition at line 41 of file compositor_software.cc.

43 {
44 FlutterWindowsView* view = engine_->view(view_id);
45 if (!view) {
46 return false;
47 }
48
49 // Clear the view if there are no layers to present.
50 if (layers_count == 0) {
51 return view->ClearSoftwareBitmap();
52 }
53
54 // TODO: Support compositing layers and platform views.
55 // See: https://github.com/flutter/flutter/issues/31713
56 FML_DCHECK(layers_count == 1);
57 FML_DCHECK(layers[0]->offset.x == 0 && layers[0]->offset.y == 0);
58 FML_DCHECK(layers[0]->type == kFlutterLayerContentTypeBackingStore);
59 FML_DCHECK(layers[0]->backing_store->type ==
60 kFlutterBackingStoreTypeSoftware);
61
62 const auto& backing_store = layers[0]->backing_store->software;
63
64 return view->PresentSoftwareBitmap(
65 backing_store.allocation, backing_store.row_bytes, backing_store.height);
66 }

References flutter::FlutterWindowsView::ClearSoftwareBitmap(), flutter::FlutterWindowsView::PresentSoftwareBitmap(), type, and flutter::FlutterWindowsEngine::view().

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

- shell/platform/windows/compositor_software.h
- shell/platform/windows/compositor_software.cc

flutter::FlutterWindowsEngine::view
FlutterWindowsView * view(FlutterViewId view_id) const
Definition: flutter_windows_engine.cc:533
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:52
type
enum flutter::testing::@87::KeyboardChange::Type type
flutter::FlutterWindowsView::ClearSoftwareBitmap
virtual bool ClearSoftwareBitmap()
Definition: flutter_windows_view.cc:645