17 G_DEFINE_TYPE(FlBackingStoreProvider, fl_backing_store_provider, G_TYPE_OBJECT)
20 FlBackingStoreProvider*
self = FL_BACKING_STORE_PROVIDER(
object);
22 glDeleteFramebuffers(1, &self->framebuffer_id);
23 glDeleteTextures(1, &self->texture_id);
25 G_OBJECT_CLASS(fl_backing_store_provider_parent_class)->dispose(
object);
29 FlBackingStoreProviderClass* klass) {
36 FlBackingStoreProvider* provider = FL_BACKING_STORE_PROVIDER(
37 g_object_new(fl_backing_store_provider_get_type(),
nullptr));
39 provider->geometry = {
46 glGenTextures(1, &provider->texture_id);
47 glGenFramebuffers(1, &provider->framebuffer_id);
49 glBindFramebuffer(GL_FRAMEBUFFER, provider->framebuffer_id);
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);
60 glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
61 GL_TEXTURE_2D, provider->texture_id, 0);
67 FlBackingStoreProvider*
self) {
68 return self->framebuffer_id;
72 FlBackingStoreProvider*
self) {
73 return self->texture_id;
88 if (epoxy_is_desktop_gl()) {
90 if (epoxy_gl_version() >= 12 || epoxy_has_gl_extension(
"GL_EXT_bgra")) {
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)) {
101 g_critical(
"Failed to determine valid GL format for Flutter rendering");
106 FlBackingStoreProvider*
self) {
107 return self->geometry;