@@ -137,35 +137,35 @@ pthread_cond_t task_added = PTHREAD_COND_INITIALIZER;
137
137
/*********************
138
138
* FLUTTER CALLBACKS *
139
139
*********************/
140
- bool make_current (void * userdata ) {
140
+ bool make_current (void * userdata ) {
141
141
if (eglMakeCurrent (egl .display , egl .surface , egl .surface , egl .context ) != EGL_TRUE ) {
142
142
fprintf (stderr , "make_current: could not make the context current.\n" );
143
143
return false;
144
144
}
145
145
146
146
return true;
147
147
}
148
- bool clear_current (void * userdata ) {
148
+ bool clear_current (void * userdata ) {
149
149
if (eglMakeCurrent (egl .display , EGL_NO_SURFACE , EGL_NO_SURFACE , EGL_NO_CONTEXT ) != EGL_TRUE ) {
150
150
fprintf (stderr , "clear_current: could not clear the current context.\n" );
151
151
return false;
152
152
}
153
153
154
154
return true;
155
155
}
156
- void page_flip_handler (int fd , unsigned int frame , unsigned int sec , unsigned int usec , void * data ) {
156
+ void page_flip_handler (int fd , unsigned int frame , unsigned int sec , unsigned int usec , void * data ) {
157
157
int * waiting_for_flip = data ;
158
158
* waiting_for_flip = 0 ;
159
159
}
160
- void drm_fb_destroy_callback (struct gbm_bo * bo , void * data ) {
160
+ void drm_fb_destroy_callback (struct gbm_bo * bo , void * data ) {
161
161
struct drm_fb * fb = data ;
162
162
163
163
if (fb -> fb_id )
164
164
drmModeRmFB (drm .fd , fb -> fb_id );
165
165
166
166
free (fb );
167
167
}
168
- struct drm_fb * drm_fb_get_from_bo (struct gbm_bo * bo ) {
168
+ struct drm_fb * drm_fb_get_from_bo (struct gbm_bo * bo ) {
169
169
uint32_t width , height , format , strides [4 ] = {0 }, handles [4 ] = {0 }, offsets [4 ] = {0 }, flags = 0 ;
170
170
int ok = -1 ;
171
171
@@ -222,7 +222,7 @@ struct drm_fb* drm_fb_get_from_bo(struct gbm_bo *bo) {
222
222
223
223
return fb ;
224
224
}
225
- bool present (void * userdata ) {
225
+ bool present (void * userdata ) {
226
226
fd_set fds ;
227
227
struct gbm_bo * next_bo ;
228
228
struct drm_fb * fb ;
@@ -232,8 +232,6 @@ bool present(void* userdata) {
232
232
next_bo = gbm_surface_lock_front_buffer (gbm .surface );
233
233
fb = drm_fb_get_from_bo (next_bo );
234
234
235
- printf ("***PRESENT***\n" );
236
-
237
235
/* wait for vsync,
238
236
ok = drmModePageFlip(drm.fd, drm.crtc_id, fb->fb_id, DRM_MODE_PAGE_FLIP_EVENT, &drm.waiting_for_flip);
239
237
if (ok) {
@@ -274,12 +272,12 @@ bool present(void* userdata) {
274
272
275
273
return true;
276
274
}
277
- uint32_t fbo_callback (void * userdata ) {
275
+ uint32_t fbo_callback (void * userdata ) {
278
276
return 0 ;
279
277
}
280
- void cut_word_from_string (char * string , char * word ) {
278
+ void cut_word_from_string (char * string , char * word ) {
281
279
size_t word_length = strlen (word );
282
- char * word_in_str = strstr (string , word );
280
+ char * word_in_str = strstr (string , word );
283
281
284
282
// check if the given word is surrounded by spaces in the string
285
283
if (word_in_str
@@ -294,139 +292,123 @@ void cut_word_from_string(char* string, char* word) {
294
292
} while (word_in_str [i ++ + word_length ] != 0 );
295
293
}
296
294
}
297
- const GLubyte * hacked_glGetString (GLenum name ) {
298
- if (name == GL_EXTENSIONS ) {
299
- static GLubyte * extensions = NULL ;
300
-
301
- if (extensions == NULL ) {
302
- GLubyte * orig_extensions = (GLubyte * ) glGetString (GL_EXTENSIONS );
303
- size_t len_orig_extensions = strlen (orig_extensions );
304
-
305
- extensions = malloc (len_orig_extensions + 1 );
306
- strcpy (extensions , orig_extensions );
307
-
308
- /*
309
- * working (apparently)
310
- */
311
- //cut_word_from_string(extensions, "GL_EXT_blend_minmax");
312
- //cut_word_from_string(extensions, "GL_EXT_multi_draw_arrays");
313
- //cut_word_from_string(extensions, "GL_EXT_texture_format_BGRA8888");
314
- //cut_word_from_string(extensions, "GL_OES_compressed_ETC1_RGB8_texture");
315
- //cut_word_from_string(extensions, "GL_OES_depth24");
316
- //cut_word_from_string(extensions, "GL_OES_texture_npot");
317
- //cut_word_from_string(extensions, "GL_OES_vertex_half_float");
318
- //cut_word_from_string(extensions, "GL_OES_EGL_image");
319
- //cut_word_from_string(extensions, "GL_OES_depth_texture");
320
- //cut_word_from_string(extensions, "GL_AMD_performance_monitor");
321
- //cut_word_from_string(extensions, "GL_OES_EGL_image_external");
322
- //cut_word_from_string(extensions, "GL_EXT_occlusion_query_boolean");
323
- //cut_word_from_string(extensions, "GL_KHR_texture_compression_astc_ldr");
324
- //cut_word_from_string(extensions, "GL_EXT_compressed_ETC1_RGB8_sub_texture");
325
- //cut_word_from_string(extensions, "GL_EXT_draw_elements_base_vertex");
326
- //cut_word_from_string(extensions, "GL_EXT_texture_border_clamp");
327
- //cut_word_from_string(extensions, "GL_OES_draw_elements_base_vertex");
328
- //cut_word_from_string(extensions, "GL_OES_texture_border_clamp");
329
- //cut_word_from_string(extensions, "GL_KHR_texture_compression_astc_sliced_3d");
330
- //cut_word_from_string(extensions, "GL_MESA_tile_raster_order");
331
-
332
- /*
333
- * should be working, but isn't
334
- */
335
- cut_word_from_string (extensions , "GL_EXT_map_buffer_range" );
336
-
337
- /*
338
- * definitely broken
339
- */
340
- cut_word_from_string (extensions , "GL_OES_element_index_uint" );
341
- cut_word_from_string (extensions , "GL_OES_fbo_render_mipmap" );
342
- cut_word_from_string (extensions , "GL_OES_mapbuffer" );
343
- cut_word_from_string (extensions , "GL_OES_rgb8_rgba8" );
344
- cut_word_from_string (extensions , "GL_OES_stencil8" );
345
- cut_word_from_string (extensions , "GL_OES_texture_3D" );
346
- cut_word_from_string (extensions , "GL_OES_packed_depth_stencil" );
347
- cut_word_from_string (extensions , "GL_OES_get_program_binary" );
348
- cut_word_from_string (extensions , "GL_APPLE_texture_max_level" );
349
- cut_word_from_string (extensions , "GL_EXT_discard_framebuffer" );
350
- cut_word_from_string (extensions , "GL_EXT_read_format_bgra" );
351
- cut_word_from_string (extensions , "GL_EXT_frag_depth" );
352
- cut_word_from_string (extensions , "GL_NV_fbo_color_attachments" );
353
- cut_word_from_string (extensions , "GL_OES_EGL_sync" );
354
- cut_word_from_string (extensions , "GL_OES_vertex_array_object" );
355
- cut_word_from_string (extensions , "GL_EXT_unpack_subimage" );
356
- cut_word_from_string (extensions , "GL_NV_draw_buffers" );
357
- cut_word_from_string (extensions , "GL_NV_read_buffer" );
358
- cut_word_from_string (extensions , "GL_NV_read_depth" );
359
- cut_word_from_string (extensions , "GL_NV_read_depth_stencil" );
360
- cut_word_from_string (extensions , "GL_NV_read_stencil" );
361
- cut_word_from_string (extensions , "GL_EXT_draw_buffers" );
362
- cut_word_from_string (extensions , "GL_KHR_debug" );
363
- cut_word_from_string (extensions , "GL_OES_required_internalformat" );
364
- cut_word_from_string (extensions , "GL_OES_surfaceless_context" );
365
- cut_word_from_string (extensions , "GL_EXT_separate_shader_objects" );
366
- cut_word_from_string (extensions , "GL_KHR_context_flush_control" );
367
- cut_word_from_string (extensions , "GL_KHR_no_error" );
368
- cut_word_from_string (extensions , "GL_KHR_parallel_shader_compile" );
369
- }
295
+ const GLubyte * hacked_glGetString (GLenum name ) {
296
+ static GLubyte * extensions = NULL ;
370
297
371
- return extensions ;
372
- } else {
298
+ if (name != GL_EXTENSIONS )
373
299
return glGetString (name );
374
- }
375
- }
376
- const GLubyte * hacked2_glGetString (GLenum name ) {
377
- if (name == GL_EXTENSIONS ) {
378
- static GLubyte * extensions = NULL ;
379
300
380
- // no extensions.
381
- return "" ;
382
- } else {
383
- return glGetString ( name );
384
- }
385
- }
386
- void * proc_resolver ( void * userdata , const char * name ) {
387
- if ( name == NULL ) return NULL ;
301
+ if ( extensions == NULL ) {
302
+ GLubyte * orig_extensions = ( GLubyte * ) glGetString ( GL_EXTENSIONS ) ;
303
+
304
+ extensions = malloc ( strlen ( orig_extensions ) + 1 );
305
+ if (! extensions ) {
306
+ fprintf ( stderr , "Could not allocate memory for modified GL_EXTENSIONS string\n" );
307
+ return NULL ;
308
+ }
388
309
389
- static int is_videocore4 = -1 ;
390
- static int is_videocore6 = -1 ;
310
+ strcpy (extensions , orig_extensions );
311
+
312
+ /*
313
+ * working (apparently)
314
+ */
315
+ //cut_word_from_string(extensions, "GL_EXT_blend_minmax");
316
+ //cut_word_from_string(extensions, "GL_EXT_multi_draw_arrays");
317
+ //cut_word_from_string(extensions, "GL_EXT_texture_format_BGRA8888");
318
+ //cut_word_from_string(extensions, "GL_OES_compressed_ETC1_RGB8_texture");
319
+ //cut_word_from_string(extensions, "GL_OES_depth24");
320
+ //cut_word_from_string(extensions, "GL_OES_texture_npot");
321
+ //cut_word_from_string(extensions, "GL_OES_vertex_half_float");
322
+ //cut_word_from_string(extensions, "GL_OES_EGL_image");
323
+ //cut_word_from_string(extensions, "GL_OES_depth_texture");
324
+ //cut_word_from_string(extensions, "GL_AMD_performance_monitor");
325
+ //cut_word_from_string(extensions, "GL_OES_EGL_image_external");
326
+ //cut_word_from_string(extensions, "GL_EXT_occlusion_query_boolean");
327
+ //cut_word_from_string(extensions, "GL_KHR_texture_compression_astc_ldr");
328
+ //cut_word_from_string(extensions, "GL_EXT_compressed_ETC1_RGB8_sub_texture");
329
+ //cut_word_from_string(extensions, "GL_EXT_draw_elements_base_vertex");
330
+ //cut_word_from_string(extensions, "GL_EXT_texture_border_clamp");
331
+ //cut_word_from_string(extensions, "GL_OES_draw_elements_base_vertex");
332
+ //cut_word_from_string(extensions, "GL_OES_texture_border_clamp");
333
+ //cut_word_from_string(extensions, "GL_KHR_texture_compression_astc_sliced_3d");
334
+ //cut_word_from_string(extensions, "GL_MESA_tile_raster_order");
335
+
336
+ /*
337
+ * should be working, but isn't
338
+ */
339
+ cut_word_from_string (extensions , "GL_EXT_map_buffer_range" );
340
+
341
+ /*
342
+ * definitely broken
343
+ */
344
+ cut_word_from_string (extensions , "GL_OES_element_index_uint" );
345
+ cut_word_from_string (extensions , "GL_OES_fbo_render_mipmap" );
346
+ cut_word_from_string (extensions , "GL_OES_mapbuffer" );
347
+ cut_word_from_string (extensions , "GL_OES_rgb8_rgba8" );
348
+ cut_word_from_string (extensions , "GL_OES_stencil8" );
349
+ cut_word_from_string (extensions , "GL_OES_texture_3D" );
350
+ cut_word_from_string (extensions , "GL_OES_packed_depth_stencil" );
351
+ cut_word_from_string (extensions , "GL_OES_get_program_binary" );
352
+ cut_word_from_string (extensions , "GL_APPLE_texture_max_level" );
353
+ cut_word_from_string (extensions , "GL_EXT_discard_framebuffer" );
354
+ cut_word_from_string (extensions , "GL_EXT_read_format_bgra" );
355
+ cut_word_from_string (extensions , "GL_EXT_frag_depth" );
356
+ cut_word_from_string (extensions , "GL_NV_fbo_color_attachments" );
357
+ cut_word_from_string (extensions , "GL_OES_EGL_sync" );
358
+ cut_word_from_string (extensions , "GL_OES_vertex_array_object" );
359
+ cut_word_from_string (extensions , "GL_EXT_unpack_subimage" );
360
+ cut_word_from_string (extensions , "GL_NV_draw_buffers" );
361
+ cut_word_from_string (extensions , "GL_NV_read_buffer" );
362
+ cut_word_from_string (extensions , "GL_NV_read_depth" );
363
+ cut_word_from_string (extensions , "GL_NV_read_depth_stencil" );
364
+ cut_word_from_string (extensions , "GL_NV_read_stencil" );
365
+ cut_word_from_string (extensions , "GL_EXT_draw_buffers" );
366
+ cut_word_from_string (extensions , "GL_KHR_debug" );
367
+ cut_word_from_string (extensions , "GL_OES_required_internalformat" );
368
+ cut_word_from_string (extensions , "GL_OES_surfaceless_context" );
369
+ cut_word_from_string (extensions , "GL_EXT_separate_shader_objects" );
370
+ cut_word_from_string (extensions , "GL_KHR_context_flush_control" );
371
+ cut_word_from_string (extensions , "GL_KHR_no_error" );
372
+ cut_word_from_string (extensions , "GL_KHR_parallel_shader_compile" );
373
+ }
374
+
375
+ return extensions ;
376
+ }
377
+ void * proc_resolver (void * userdata , const char * name ) {
378
+ static int is_VC4 = -1 ;
379
+ void * address ;
391
380
392
381
/*
393
382
* The mesa V3D driver reports some OpenGL ES extensions as supported and working
394
383
* even though they aren't. hacked_glGetString is a workaround for this, which will
395
384
* cut out the non-working extensions from the list of supported extensions.
396
- */
385
+ */
397
386
398
- if (is_videocore4 == -1 ) {
399
- is_videocore4 = strcmp (egl .renderer , "VC4 V3D 2.1" ) == 0 ;
400
- if (is_videocore4 ) printf ("detected VideoCore IV as underlying graphics chip. Reporting modified GL_EXTENSIONS string that doesn't contain non-working extensions.\n" );
401
- }
402
- if (is_videocore6 == -1 ) {
403
- is_videocore6 = strcmp (egl .renderer , "V3D 4.2" ) == 0 ;
404
- if (is_videocore6 ) printf ("detected VideoCore VI as underlying graphics chip. Reporting no GL Extensions.\n" );
405
- }
387
+ if (name == NULL )
388
+ return NULL ;
406
389
407
- if (strcmp (name , "glGetString" ) == 0 ) {
408
- if (is_videocore4 ) {
409
- return hacked_glGetString ;
410
- } else if (is_videocore6 ) {
411
- return hacked2_glGetString ;
412
- }
413
- }
390
+ // first detect if we're running on a VideoCore 4 / using the VC4 driver.
391
+ if ((is_VC4 == -1 ) && (is_VC4 = strcmp (egl .renderer , "VC4 V3D 2.1" ) == 0 ))
392
+ printf ( "detected VideoCore IV as underlying graphics chip, and VC4 as the driver.\n"
393
+ "Reporting modified GL_EXTENSIONS string that doesn't contain non-working extensions.\n" );
394
+
395
+ // if we do, and the symbol to resolve is glGetString, we return our hacked_glGetString.
396
+ if (is_VC4 && (strcmp (name , "glGetString" ) == 0 ))
397
+ return hacked_glGetString ;
414
398
415
- void * address ;
416
- if ((address = dlsym (RTLD_DEFAULT , name )) || (address = eglGetProcAddress (name ))) {
399
+ if ((address = dlsym (RTLD_DEFAULT , name )) || (address = eglGetProcAddress (name )))
417
400
return address ;
418
- }
419
401
420
- printf ( " could not resolve symbol %s \n" , name );
402
+ fprintf ( stderr , "proc_resolver: could not resolve symbol \"%s\" \n" , name );
421
403
422
404
return NULL ;
423
405
}
424
- void on_platform_message (const FlutterPlatformMessage * message , void * userdata ) {
406
+ void on_platform_message (const FlutterPlatformMessage * message , void * userdata ) {
425
407
int ok ;
426
408
if ((ok = PluginRegistry_onPlatformMessage ((FlutterPlatformMessage * )message )) != 0 )
427
409
fprintf (stderr , "PluginRegistry_onPlatformMessage failed: %s\n" , strerror (ok ));
428
410
}
429
- void vsync_callback (void * userdata , intptr_t baton ) {
411
+ void vsync_callback (void * userdata , intptr_t baton ) {
430
412
// not yet implemented
431
413
fprintf (stderr , "flutter vsync callback not yet implemented\n" );
432
414
}
@@ -436,10 +418,8 @@ void vsync_callback(void* userdata, intptr_t baton) {
436
418
/************************
437
419
* PLATFORM TASK-RUNNER *
438
420
************************/
439
- void handle_sigusr1 (int _ ) {}
440
421
bool init_message_loop () {
441
422
platform_thread_id = pthread_self ();
442
-
443
423
return true;
444
424
}
445
425
bool message_loop (void ) {
0 commit comments