1414// If not defined, the pthread that owns the OffscreenCanvas is using emscripten_set_main_loop() so periodically yields back to the event loop.
1515// #define TEST_SYNC_BLOCKING_LOOP
1616
17- void thread_local_main_loop ()
18- {
17+ void thread_local_main_loop () {
1918 int w = 0 , h = 0 ;
2019 emscripten_get_canvas_element_size (" #canvas" , &w, &h);
2120 if (w == 699 && h == 299 ) {
@@ -27,11 +26,10 @@ void thread_local_main_loop()
2726
2827 emscripten_force_exit (0 );
2928 }
30- printf (" %dx%d\n " , w, h);
29+ printf (" thread_local_main_loop: %dx%d\n " , w, h);
3130}
3231
33- void *thread_main (void *arg)
34- {
32+ void *thread_main (void *arg) {
3533 EmscriptenWebGLContextAttributes attr;
3634 emscripten_webgl_init_context_attributes (&attr);
3735 attr.explicitSwapControl = EM_TRUE;
@@ -57,31 +55,28 @@ void *thread_main(void *arg)
5755 return 0 ;
5856}
5957
60- void resize_canvas (void *)
61- {
58+ void resize_canvas (void * arg) {
6259 // Test that on the main thread, we can observe size changes to the canvas size.
6360 int w, h;
6461 emscripten_get_canvas_element_size (" #canvas" , &w, &h);
62+ printf (" Main thread saw canvas to get resized to %dx%d.\n " , w, h);
6563 assert (w == 355 && " We did not observe the effect of pthread having resized OffscreenCanvas" );
6664 assert (h == 233 );
67- printf (" Main thread saw canvas to get resized to %dx%d.\n " , w, h);
6865
6966 // Test that on the main thread, we can also change the size. (pthread listens to see this)
7067 printf (" Main thread resizing OffscreenCanvas to size 699x299.\n " );
7168 emscripten_set_canvas_element_size (" #canvas" , 699 , 299 );
7269}
7370
7471// should be able to do this regardless of offscreen canvas support
75- void get_canvas_size ()
76- {
72+ void get_canvas_size () {
7773 int w, h;
7874 emscripten_get_canvas_element_size (" #canvas" , &w, &h);
7975 assert (h == 150 );
8076 assert (w == 300 );
8177}
8278
83- int main ()
84- {
79+ int main () {
8580 get_canvas_size ();
8681 if (!emscripten_supports_offscreencanvas ()) {
8782 printf (" Current browser does not support OffscreenCanvas. Skipping the rest of the tests.\n " );
0 commit comments