@@ -38,7 +38,6 @@ struct egl_offscreen_render_surface {
38
38
uuid_t uuid ;
39
39
#endif
40
40
41
- enum pixfmt pixel_format ;
42
41
EGLDisplay egl_display ;
43
42
EGLSurface egl_surface ;
44
43
EGLConfig egl_config ;
@@ -67,57 +66,35 @@ ATTR_PURE struct egl_offscreen_render_surface *__checked_cast_egl_offscreen_rend
67
66
68
67
void egl_offscreen_render_surface_deinit (struct surface * s );
69
68
static int egl_offscreen_render_surface_present_kms (struct surface * s , const struct fl_layer_props * props , struct kms_req_builder * builder );
70
- static int egl_offscreen_render_surface_present_fbdev (struct surface * s , const struct fl_layer_props * props , struct fbdev_commit_builder * builder );
69
+ static int
70
+ egl_offscreen_render_surface_present_fbdev (struct surface * s , const struct fl_layer_props * props , struct fbdev_commit_builder * builder );
71
71
static int egl_offscreen_render_surface_fill (struct render_surface * s , FlutterBackingStore * fl_store );
72
72
static int egl_offscreen_render_surface_queue_present (struct render_surface * s , const FlutterBackingStore * fl_store );
73
73
74
74
static int egl_offscreen_render_surface_init (
75
75
struct egl_offscreen_render_surface * s ,
76
76
struct tracer * tracer ,
77
77
struct vec2i size ,
78
- struct gl_renderer * renderer ,
79
- enum pixfmt pixel_format ,
80
- EGLConfig egl_config
78
+ struct gl_renderer * renderer
81
79
) {
82
80
EGLDisplay egl_display ;
83
81
EGLSurface egl_surface ;
84
82
EGLBoolean egl_ok ;
83
+ EGLConfig egl_config ;
85
84
int ok ;
86
85
87
86
ASSERT_NOT_NULL (renderer );
88
- ASSUME_PIXFMT_VALID (pixel_format );
89
87
egl_display = gl_renderer_get_egl_display (renderer );
90
88
ASSERT_NOT_NULL (egl_display );
91
89
92
- #ifdef DEBUG
93
- if (egl_config != EGL_NO_CONFIG_KHR ) {
94
- EGLint value = 0 ;
95
-
96
- egl_ok = eglGetConfigAttrib (egl_display , egl_config , EGL_NATIVE_VISUAL_ID , & value );
97
- if (egl_ok == EGL_FALSE ) {
98
- LOG_EGL_ERROR (eglGetError (), "Couldn't query pixel format of EGL framebuffer config. eglGetConfigAttrib" );
99
- return EIO ;
100
- }
101
-
102
- ASSERT_EQUALS_MSG (
103
- value ,
104
- get_pixfmt_info (pixel_format )-> gbm_format ,
105
- "EGL framebuffer config pixel format doesn't match the argument pixel format."
106
- );
107
- }
108
- #endif
109
-
110
90
/// TODO: Think about allowing different tilings / modifiers here
91
+ // choose a config
92
+ egl_config = gl_renderer_choose_pbuffer_config (renderer , 8 , 8 , 8 , 8 );
111
93
if (egl_config == EGL_NO_CONFIG_KHR ) {
112
- // choose a config
113
- egl_config = gl_renderer_choose_config_direct (renderer , pixel_format );
114
- if (egl_config == EGL_NO_CONFIG_KHR ) {
115
- LOG_ERROR (
116
- "EGL doesn't supported the specified pixel format %s. Try a different one (ARGB8888 should always work).\n" ,
117
- get_pixfmt_info (pixel_format )-> name
118
- );
119
- return EINVAL ;
120
- }
94
+ LOG_ERROR (
95
+ "EGL doesn't supported the hardcoded software rendering pixel format ARGB8888.\n"
96
+ );
97
+ return EINVAL ;
121
98
}
122
99
123
100
// EGLAttribKHR is defined by EGL_KHR_cl_event2.
@@ -160,7 +137,6 @@ static int egl_offscreen_render_surface_init(
160
137
#ifdef DEBUG
161
138
uuid_copy (& s -> uuid , uuid );
162
139
#endif
163
- s -> pixel_format = pixel_format ;
164
140
s -> egl_display = egl_display ;
165
141
s -> egl_surface = egl_surface ;
166
142
s -> egl_config = egl_config ;
@@ -179,19 +155,12 @@ static int egl_offscreen_render_surface_init(
179
155
* @param compositor The compositor that this surface will be registered to when calling surface_register.
180
156
* @param size The size of the surface.
181
157
* @param renderer The EGL/OpenGL used to create any GL surfaces.
182
- * @param pixel_format The pixel format to be used by the framebuffers of the surface.
183
- * @param egl_config The EGLConfig used for creating the EGLSurface.
184
- * @param allowed_modifiers The list of modifiers that gbm_surface_create_with_modifiers can choose from.
185
- * NULL if not specified. (In that case, gbm_surface_create will be used)
186
- * @param n_allowed_modifiers The number of modifiers in @param allowed_modifiers.
187
158
* @return struct egl_offscreen_render_surface*
188
159
*/
189
- struct egl_offscreen_render_surface * egl_offscreen_render_surface_new_with_egl_config (
160
+ struct egl_offscreen_render_surface * egl_offscreen_render_surface_new (
190
161
struct tracer * tracer ,
191
162
struct vec2i size ,
192
- struct gl_renderer * renderer ,
193
- enum pixfmt pixel_format ,
194
- EGLConfig egl_config
163
+ struct gl_renderer * renderer
195
164
) {
196
165
struct egl_offscreen_render_surface * surface ;
197
166
int ok ;
@@ -201,14 +170,7 @@ struct egl_offscreen_render_surface *egl_offscreen_render_surface_new_with_egl_c
201
170
goto fail_return_null ;
202
171
}
203
172
204
- ok = egl_offscreen_render_surface_init (
205
- surface ,
206
- tracer ,
207
- size ,
208
- renderer ,
209
- pixel_format ,
210
- egl_config
211
- );
173
+ ok = egl_offscreen_render_surface_init (surface , tracer , size , renderer );
212
174
if (ok != 0 ) {
213
175
goto fail_free_surface ;
214
176
}
@@ -222,25 +184,6 @@ struct egl_offscreen_render_surface *egl_offscreen_render_surface_new_with_egl_c
222
184
return NULL ;
223
185
}
224
186
225
- /**
226
- * @brief Create a new gbm_surface based render surface.
227
- *
228
- * @param compositor The compositor that this surface will be registered to when calling surface_register.
229
- * @param size The size of the surface.
230
- * @param device The GBM device used to allocate the surface.
231
- * @param renderer The EGL/OpenGL used to create any GL surfaces.
232
- * @param pixel_format The pixel format to be used by the framebuffers of the surface.
233
- * @return struct egl_offscreen_render_surface*
234
- */
235
- struct egl_offscreen_render_surface * egl_offscreen_render_surface_new (
236
- struct tracer * tracer ,
237
- struct vec2i size ,
238
- struct gl_renderer * renderer ,
239
- enum pixfmt pixel_format
240
- ) {
241
- return egl_offscreen_render_surface_new_with_egl_config (tracer , size , renderer , pixel_format , EGL_NO_CONFIG_KHR );
242
- }
243
-
244
187
void egl_offscreen_render_surface_deinit (struct surface * s ) {
245
188
struct egl_offscreen_render_surface * egl_surface ;
246
189
@@ -279,30 +222,33 @@ egl_offscreen_render_surface_present_fbdev(struct surface *s, const struct fl_la
279
222
280
223
static int egl_offscreen_render_surface_fill (struct render_surface * s , FlutterBackingStore * fl_store ) {
281
224
fl_store -> type = kFlutterBackingStoreTypeOpenGL ;
282
- fl_store -> open_gl = (FlutterOpenGLBackingStore
283
- ){ .type = kFlutterOpenGLTargetTypeFramebuffer ,
284
- .framebuffer = { /* for some reason flutter wants this to be GL_BGRA8_EXT, contrary to what the docs say */
285
- .target = GL_BGRA8_EXT ,
225
+ fl_store -> open_gl = (FlutterOpenGLBackingStore ) {
226
+ .type = kFlutterOpenGLTargetTypeFramebuffer ,
227
+ .framebuffer = {
228
+ /* for some reason flutter wants this to be GL_BGRA8_EXT, contrary to what the docs say */
229
+ .target = GL_BGRA8_EXT ,
286
230
287
- /* 0 refers to the window surface, instead of to an FBO */
288
- .name = 0 ,
231
+ /* 0 refers to the window surface, instead of to an FBO */
232
+ .name = 0 ,
289
233
290
- /*
234
+ /*
291
235
* even though the compositor will call surface_ref too to fill the FlutterBackingStore.user_data,
292
236
* we need to ref two times because flutter will call both this destruction callback and the
293
237
* compositor collect callback
294
238
*/
295
- .user_data = surface_ref (CAST_SURFACE_UNCHECKED (s )),
296
- .destruction_callback = surface_unref_void } };
239
+ .user_data = surface_ref (CAST_SURFACE_UNCHECKED (s )),
240
+ .destruction_callback = surface_unref_void ,
241
+ },
242
+ };
297
243
return 0 ;
298
244
}
299
245
300
246
static int egl_offscreen_render_surface_queue_present (struct render_surface * s , const FlutterBackingStore * fl_store ) {
301
247
(void ) s ;
302
248
(void ) fl_store ;
303
-
249
+
304
250
// nothing to do here
305
-
251
+
306
252
return 0 ;
307
253
}
308
254
0 commit comments