@@ -38,7 +38,6 @@ struct egl_offscreen_render_surface {
3838 uuid_t uuid ;
3939#endif
4040
41- enum pixfmt pixel_format ;
4241 EGLDisplay egl_display ;
4342 EGLSurface egl_surface ;
4443 EGLConfig egl_config ;
@@ -67,57 +66,35 @@ ATTR_PURE struct egl_offscreen_render_surface *__checked_cast_egl_offscreen_rend
6766
6867void egl_offscreen_render_surface_deinit (struct surface * s );
6968static 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 );
7171static int egl_offscreen_render_surface_fill (struct render_surface * s , FlutterBackingStore * fl_store );
7272static int egl_offscreen_render_surface_queue_present (struct render_surface * s , const FlutterBackingStore * fl_store );
7373
7474static int egl_offscreen_render_surface_init (
7575 struct egl_offscreen_render_surface * s ,
7676 struct tracer * tracer ,
7777 struct vec2i size ,
78- struct gl_renderer * renderer ,
79- enum pixfmt pixel_format ,
80- EGLConfig egl_config
78+ struct gl_renderer * renderer
8179) {
8280 EGLDisplay egl_display ;
8381 EGLSurface egl_surface ;
8482 EGLBoolean egl_ok ;
83+ EGLConfig egl_config ;
8584 int ok ;
8685
8786 ASSERT_NOT_NULL (renderer );
88- ASSUME_PIXFMT_VALID (pixel_format );
8987 egl_display = gl_renderer_get_egl_display (renderer );
9088 ASSERT_NOT_NULL (egl_display );
9189
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-
11090 /// 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 );
11193 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 ;
12198 }
12299
123100// EGLAttribKHR is defined by EGL_KHR_cl_event2.
@@ -160,7 +137,6 @@ static int egl_offscreen_render_surface_init(
160137#ifdef DEBUG
161138 uuid_copy (& s -> uuid , uuid );
162139#endif
163- s -> pixel_format = pixel_format ;
164140 s -> egl_display = egl_display ;
165141 s -> egl_surface = egl_surface ;
166142 s -> egl_config = egl_config ;
@@ -179,19 +155,12 @@ static int egl_offscreen_render_surface_init(
179155 * @param compositor The compositor that this surface will be registered to when calling surface_register.
180156 * @param size The size of the surface.
181157 * @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.
187158 * @return struct egl_offscreen_render_surface*
188159 */
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 (
190161 struct tracer * tracer ,
191162 struct vec2i size ,
192- struct gl_renderer * renderer ,
193- enum pixfmt pixel_format ,
194- EGLConfig egl_config
163+ struct gl_renderer * renderer
195164) {
196165 struct egl_offscreen_render_surface * surface ;
197166 int ok ;
@@ -201,14 +170,7 @@ struct egl_offscreen_render_surface *egl_offscreen_render_surface_new_with_egl_c
201170 goto fail_return_null ;
202171 }
203172
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 );
212174 if (ok != 0 ) {
213175 goto fail_free_surface ;
214176 }
@@ -222,25 +184,6 @@ struct egl_offscreen_render_surface *egl_offscreen_render_surface_new_with_egl_c
222184 return NULL ;
223185}
224186
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-
244187void egl_offscreen_render_surface_deinit (struct surface * s ) {
245188 struct egl_offscreen_render_surface * egl_surface ;
246189
@@ -279,30 +222,33 @@ egl_offscreen_render_surface_present_fbdev(struct surface *s, const struct fl_la
279222
280223static int egl_offscreen_render_surface_fill (struct render_surface * s , FlutterBackingStore * fl_store ) {
281224 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 ,
286230
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 ,
289233
290- /*
234+ /*
291235 * even though the compositor will call surface_ref too to fill the FlutterBackingStore.user_data,
292236 * we need to ref two times because flutter will call both this destruction callback and the
293237 * compositor collect callback
294238 */
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+ };
297243 return 0 ;
298244}
299245
300246static int egl_offscreen_render_surface_queue_present (struct render_surface * s , const FlutterBackingStore * fl_store ) {
301247 (void ) s ;
302248 (void ) fl_store ;
303-
249+
304250 // nothing to do here
305-
251+
306252 return 0 ;
307253}
308254
0 commit comments