Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_compositor_software.cc File Reference

Go to the source code of this file.

Classes

struct  _FlCompositorSoftware
 

Functions

static void fl_compositor_software_dispose (GObject *object)
 
static void fl_compositor_software_class_init (FlCompositorSoftwareClass *klass)
 
static void fl_compositor_software_init (FlCompositorSoftware *self)
 
FlCompositorSoftware * fl_compositor_software_new ()
 
gboolean fl_compositor_software_composite_layers (FlCompositorSoftware *self, const FlutterLayer **layers, size_t layers_count)
 
void fl_compositor_software_get_frame_size (FlCompositorSoftware *self, size_t *width, size_t *height)
 
gboolean fl_compositor_software_render (FlCompositorSoftware *self, cairo_t *cr, gint scale_factor)
 

Function Documentation

◆ fl_compositor_software_class_init()

static void fl_compositor_software_class_init ( FlCompositorSoftwareClass *  klass)
static

Definition at line 33 of file fl_compositor_software.cc.

34 {
35 G_OBJECT_CLASS(klass)->dispose = fl_compositor_software_dispose;
36}
static void fl_compositor_software_dispose(GObject *object)

References fl_compositor_software_dispose().

◆ fl_compositor_software_composite_layers()

gboolean fl_compositor_software_composite_layers ( FlCompositorSoftware *  compositor,
const FlutterLayer **  layers,
size_t  layers_count 
)

fl_compositor_software_composite_layers: @compositor: an #FlCompositorSoftware. @layers: layers to be composited. Each layer must be a backing store layer (kFlutterLayerContentTypeBackingStore) backed by a software backing store (kFlutterBackingStoreTypeSoftware). @layers_count: number of layers.

Combines and stores the provided layers as the current frame.

Returns TRUE if successful.

Definition at line 45 of file fl_compositor_software.cc.

47 {
48 if (layers_count == 0) {
49 return TRUE;
50 }
51
52 self->width = layers[0]->size.width;
53 self->height = layers[0]->size.height;
54
55 // TODO(robert-ancell): Support multiple layers
56 if (layers_count == 1) {
57 const FlutterLayer* layer = layers[0];
60 const FlutterBackingStore* backing_store = layer->backing_store;
61
62 size_t allocation_length =
63 backing_store->software.row_bytes * backing_store->software.height;
64 unsigned char* old_data = self->surface != nullptr
65 ? cairo_image_surface_get_data(self->surface)
66 : nullptr;
67 unsigned char* data =
68 static_cast<unsigned char*>(g_realloc(old_data, allocation_length));
69 memcpy(data, backing_store->software.allocation, allocation_length);
70 cairo_surface_destroy(self->surface);
71 self->surface = cairo_image_surface_create_for_data(
72 data, CAIRO_FORMAT_ARGB32, backing_store->software.row_bytes / 4,
73 backing_store->software.height, backing_store->software.row_bytes);
74 }
75
76 return TRUE;
77}
@ kFlutterLayerContentTypeBackingStore
Definition embedder.h:2157
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
Definition embedder.h:2108
const FlutterLayer size_t layers_count
const FlutterLayer ** layers
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
FlutterBackingStoreType type
Specifies the type of backing store.
Definition embedder.h:2126
FlutterSoftwareBackingStore software
The description of the software backing store.
Definition embedder.h:2134
FlutterLayerContentType type
Definition embedder.h:2189
const FlutterBackingStore * backing_store
Definition embedder.h:2193
FlutterSize size
The size of the layer (in physical pixels).
Definition embedder.h:2202
double height
Definition embedder.h:636
double width
Definition embedder.h:635
size_t row_bytes
The number of bytes in a single row of the allocation.
Definition embedder.h:1987
size_t height
The number of rows in the allocation.
Definition embedder.h:1989

References FlutterSoftwareBackingStore::allocation, FlutterLayer::backing_store, FlutterSize::height, FlutterSoftwareBackingStore::height, kFlutterBackingStoreTypeSoftware, kFlutterLayerContentTypeBackingStore, layers, layers_count, FlutterSoftwareBackingStore::row_bytes, self, FlutterLayer::size, FlutterBackingStore::software, TRUE, FlutterBackingStore::type, FlutterLayer::type, and FlutterSize::width.

Referenced by fl_view_renderer_software_present_layers(), TEST_F(), and TEST_F().

◆ fl_compositor_software_dispose()

static void fl_compositor_software_dispose ( GObject *  object)
static

Definition at line 22 of file fl_compositor_software.cc.

22 {
23 FlCompositorSoftware* self = FL_COMPOSITOR_SOFTWARE(object);
24
25 if (self->surface != nullptr) {
26 g_free(cairo_image_surface_get_data(self->surface));
27 }
28 g_clear_pointer(&self->surface, cairo_surface_destroy);
29
30 G_OBJECT_CLASS(fl_compositor_software_parent_class)->dispose(object);
31}

References self.

Referenced by fl_compositor_software_class_init().

◆ fl_compositor_software_get_frame_size()

void fl_compositor_software_get_frame_size ( FlCompositorSoftware *  compositor,
size_t *  width,
size_t *  height 
)

fl_compositor_software_get_frame_size: @compositor: an #FlCompositorSoftware. @width: location to write frame width in pixels. @height: location to write frame height in pixels.

Get the size of the stored frame. The size is zero if there is no frame yet.

Definition at line 79 of file fl_compositor_software.cc.

81 {
82 if (width != nullptr) {
83 *width = self->width;
84 }
85 if (height != nullptr) {
86 *height = self->height;
87 }
88}
int32_t height
int32_t width

References height, self, and width.

Referenced by G_DEFINE_TYPE(), TEST_F(), TEST_F(), and wait_for_frame().

◆ fl_compositor_software_init()

static void fl_compositor_software_init ( FlCompositorSoftware *  self)
static

Definition at line 38 of file fl_compositor_software.cc.

38{}

◆ fl_compositor_software_new()

FlCompositorSoftware * fl_compositor_software_new ( )

Definition at line 40 of file fl_compositor_software.cc.

40 {
41 return FL_COMPOSITOR_SOFTWARE(
42 g_object_new(fl_compositor_software_get_type(), nullptr));
43}

Referenced by fl_view_renderer_software_realize(), and FlCompositorSoftwareTest::SetUp().

◆ fl_compositor_software_render()

gboolean fl_compositor_software_render ( FlCompositorSoftware *  compositor,
cairo_t *  cr,
gint  scale_factor 
)

fl_compositor_software_render: @compositor: an #FlCompositorSoftware. @cr: a Cairo rendering context. @scale_factor: the device scale factor to render at.

Renders the stored frame.

Returns TRUE if successful.

Definition at line 90 of file fl_compositor_software.cc.

92 {
93 if (self->surface == nullptr) {
94 return FALSE;
95 }
96
97 cairo_surface_set_device_scale(self->surface, scale_factor, scale_factor);
98 cairo_set_source_surface(cr, self->surface, 0.0, 0.0);
99 cairo_paint(cr);
100
101 return TRUE;
102}

References self, and TRUE.

Referenced by fl_view_renderer_software_draw(), TEST_F(), and TEST_F().