| Flutter Linux Embedder |

Classes | Functions
fl_backing_store_provider.cc File Reference
`#include "fl_backing_store_provider.h"`
`#include <epoxy/gl.h>`

Go to the source code of this file.

## Classes
struct | _FlBackingStoreProvider

## Functions
static void | fl_backing_store_provider_dispose (GObject *object)
static void | fl_backing_store_provider_class_init (FlBackingStoreProviderClass *klass)
static void | fl_backing_store_provider_init (FlBackingStoreProvider *self)
FlBackingStoreProvider * | fl_backing_store_provider_new (int width, int height)
uint32_t | fl_backing_store_provider_get_gl_framebuffer_id (FlBackingStoreProvider *self)
uint32_t | fl_backing_store_provider_get_gl_texture_id (FlBackingStoreProvider *self)
uint32_t | fl_backing_store_provider_get_gl_target (FlBackingStoreProvider *self)
uint32_t | fl_backing_store_provider_get_gl_format (FlBackingStoreProvider *self)
GdkRectangle | fl_backing_store_provider_get_geometry (FlBackingStoreProvider *self)

## Function Documentation

## ◆ fl_backing_store_provider_class_init()

static void fl_backing_store_provider_class_init | ( | FlBackingStoreProviderClass * | klass | ) |
| static

Definition at line 28 of file fl_backing_store_provider.cc.

29 {
30 G_OBJECT_CLASS(klass)->dispose = fl_backing_store_provider_dispose;
31 }

References fl_backing_store_provider_dispose().

## ◆ fl_backing_store_provider_dispose()

static void fl_backing_store_provider_dispose | ( | GObject * | object | ) |
| static

Definition at line 19 of file fl_backing_store_provider.cc.

19 {
20 FlBackingStoreProvider* self = FL_BACKING_STORE_PROVIDER(object);
21
22 glDeleteFramebuffers(1, &self->framebuffer_id);
23 glDeleteTextures(1, &self->texture_id);
24
25 G_OBJECT_CLASS(fl_backing_store_provider_parent_class)->dispose(object);
26 }

Referenced by fl_backing_store_provider_class_init().

## ◆ fl_backing_store_provider_get_geometry()

GdkRectangle fl_backing_store_provider_get_geometry | ( | FlBackingStoreProvider * | provider | ) |

fl_backing_store_provider_get_geometry: @provider: an #FlBackingStoreProvider.

Gets geometry of framebuffer.

Returns: geometry of backing store.

Definition at line 105 of file fl_backing_store_provider.cc.

106 {
107 return self->geometry;
108 }

Referenced by fl_renderer_render().

## ◆ fl_backing_store_provider_get_gl_format()

uint32_t fl_backing_store_provider_get_gl_format | ( | FlBackingStoreProvider * | provider | ) |

fl_backing_store_provider_get_gl_format: @provider: an #FlBackingStoreProvider.

Gets texture format (example GL_RGBA8).

Returns: texture format.

Definition at line 80 of file fl_backing_store_provider.cc.

80 {
81 // Flutter defines SK_R32_SHIFT=16, so SK_PMCOLOR_BYTE_ORDER should be BGRA.
82 // In Linux kN32_SkColorType is assumed to be kBGRA_8888_SkColorType.
83 // So we must choose a valid gl format to be compatible with surface format
84 // BGRA8.
85 // Following logic is copied from Skia GrGLCaps.cpp:
86 // https://github.com/google/skia/blob/4738ed711e03212aceec3cd502a4adb545f38e63/src/gpu/ganesh/gl/GrGLCaps.cpp#L1963-L2116
87
88 if (epoxy_is_desktop_gl()) {
89 // For OpenGL.
90 if (epoxy_gl_version() >= 12 || epoxy_has_gl_extension("GL_EXT_bgra")) {
91 return GL_RGBA8;
92 }
93 } else {
94 // For OpenGL ES.
95 if (epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888") ||
96 (epoxy_has_gl_extension("GL_APPLE_texture_format_BGRA8888") &&
97 epoxy_gl_version() >= 30)) {
98 return GL_BGRA8_EXT;
99 }
100 }
101 g_critical("Failed to determine valid GL format for Flutter rendering");
102 return GL_RGBA8;
103 }

Referenced by fl_renderer_create_backing_store().

## ◆ fl_backing_store_provider_get_gl_framebuffer_id()

uint32_t fl_backing_store_provider_get_gl_framebuffer_id | ( | FlBackingStoreProvider * | provider | ) |

fl_backing_store_provider_get_gl_framebuffer_id: @provider: an #FlBackingStoreProvider.

Gets created framebuffer id.

Returns: gl framebuffer id, 0 if creation failed.

Definition at line 66 of file fl_backing_store_provider.cc.

67 {
68 return self->framebuffer_id;
69 }

Referenced by fl_renderer_create_backing_store().

## ◆ fl_backing_store_provider_get_gl_target()

uint32_t fl_backing_store_provider_get_gl_target | ( | FlBackingStoreProvider * | provider | ) |

fl_backing_store_provider_get_gl_target: @provider: an #FlBackingStoreProvider.

Gets target texture (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE).

Returns: target texture.

Definition at line 76 of file fl_backing_store_provider.cc.

76 {
77 return GL_TEXTURE_2D;
78 }

## ◆ fl_backing_store_provider_get_gl_texture_id()

uint32_t fl_backing_store_provider_get_gl_texture_id | ( | FlBackingStoreProvider * | provider | ) |

fl_backing_store_provider_get_gl_texture_id: @provider: an #FlBackingStoreProvider.

Gets created texture id.

Returns: gl texture id, 0 if creation failed.

Definition at line 71 of file fl_backing_store_provider.cc.

72 {
73 return self->texture_id;
74 }

Referenced by fl_renderer_render().

## ◆ fl_backing_store_provider_init()

static void fl_backing_store_provider_init | ( | FlBackingStoreProvider * | self | ) |
| static

Definition at line 33 of file fl_backing_store_provider.cc.

33 {}

## ◆ fl_backing_store_provider_new()

FlBackingStoreProvider* fl_backing_store_provider_new | ( | int | width,
|  | int | height
| ) |  |

Definition at line 35 of file fl_backing_store_provider.cc.

35 {
36 FlBackingStoreProvider* provider = FL_BACKING_STORE_PROVIDER(
37 g_object_new(fl_backing_store_provider_get_type(), nullptr));
38
39 provider->geometry = {
40 .x = 0,
41 .y = 0,
42 .width = width,
43 .height = height,
44 };
45
46 glGenTextures(1, &provider->texture_id);
47 glGenFramebuffers(1, &provider->framebuffer_id);
48
49 glBindFramebuffer(GL_FRAMEBUFFER, provider->framebuffer_id);
50
51 glBindTexture(GL_TEXTURE_2D, provider->texture_id);
52 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
53 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
54 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
55 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
56 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA,
57 GL_UNSIGNED_BYTE, NULL);
58 glBindTexture(GL_TEXTURE_2D, 0);
59
60 glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
61 GL_TEXTURE_2D, provider->texture_id, 0);
62
63 return provider;
64 }

References height, and width.

Referenced by fl_renderer_create_backing_store().

height
G_BEGIN_DECLS int height
Definition: fl_backing_store_provider.h:37
fl_backing_store_provider_dispose
static void fl_backing_store_provider_dispose(GObject *object)
Definition: fl_backing_store_provider.cc:19
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38