This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,31 @@ uint32_t fl_backing_store_provider_get_gl_target(FlBackingStoreProvider* self) {
77
77
return GL_TEXTURE_2D;
78
78
}
79
79
80
+ static int gl_version (uint32_t major, uint32_t minor) {
81
+ return (major << 16 ) | minor;
82
+ }
83
+
80
84
uint32_t fl_backing_store_provider_get_gl_format (FlBackingStoreProvider* self) {
85
+ // Flutter defines SK_R32_SHIFT=16, so SK_PMCOLOR_BYTE_ORDER should be BGRA.
86
+ // In Linux kN32_SkColorType is assumed to be kBGRA_8888_SkColorType.
87
+ // So we must choose a valid gl format to be compatible with surface format
88
+ // BGRA8.
89
+ // Following logics are copied from Skia GrGLCaps.cpp
90
+
91
+ if (epoxy_is_desktop_gl ()) {
92
+ if (epoxy_gl_version () >= gl_version (1 , 2 ) ||
93
+ epoxy_has_gl_extension (" GL_EXT_bgra" )) {
94
+ return GL_RGBA8;
95
+ }
96
+ } else {
97
+ // For OpenGL ES.
98
+ if (epoxy_has_gl_extension (" GL_EXT_texture_format_BGRA8888" ) ||
99
+ (epoxy_has_gl_extension (" GL_APPLE_texture_format_BGRA8888" ) &&
100
+ epoxy_gl_version () >= gl_version (3 , 0 ))) {
101
+ return GL_BGRA8_EXT;
102
+ }
103
+ }
104
+ g_critical (" Failed to determine valid GL format for Flutter rendering" );
81
105
return GL_RGBA8;
82
106
}
83
107
Original file line number Diff line number Diff line change @@ -374,6 +374,18 @@ static void _glTexImage2D(GLenum target,
374
374
GLenum type,
375
375
const void * pixels) {}
376
376
377
+ bool epoxy_has_gl_extension (const char * extension) {
378
+ return false ;
379
+ }
380
+
381
+ bool epoxy_is_desktop_gl (void ) {
382
+ return false ;
383
+ }
384
+
385
+ int epoxy_gl_version (void ) {
386
+ return 0 ;
387
+ }
388
+
377
389
#ifdef __GNUC__
378
390
#define CONSTRUCT (_func ) static void _func (void ) __attribute__((constructor));
379
391
#define DESTRUCT (_func ) static void _func (void ) __attribute__((destructor));
You can’t perform that action at this time.
0 commit comments