Emscripten: Use set_canvas_element_size
authorCharlie Birks <charlie@daftgames.net>
Tue, 29 Jan 2019 12:18:56 +0000
changeset 12574109c919d61f6
parent 12573 296d155a8ce5
child 12575 62f907f026bb
Emscripten: Use set_canvas_element_size
This will be needed for supporting multiple canvases and set_canvas_size
is deprecated anyway.
src/video/emscripten/SDL_emscriptenevents.c
src/video/emscripten/SDL_emscriptenvideo.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Tue Jan 29 12:14:54 2019 +0000
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Tue Jan 29 12:18:56 2019 +0000
     1.3 @@ -604,7 +604,7 @@
     1.4                  emscripten_get_element_css_size(NULL, &w, &h);
     1.5              }
     1.6  
     1.7 -            emscripten_set_canvas_size(w * window_data->pixel_ratio, h * window_data->pixel_ratio);
     1.8 +            emscripten_set_canvas_element_size(NULL, w * window_data->pixel_ratio, h * window_data->pixel_ratio);
     1.9  
    1.10              /* set_canvas_size unsets this */
    1.11              if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
     2.1 --- a/src/video/emscripten/SDL_emscriptenvideo.c	Tue Jan 29 12:14:54 2019 +0000
     2.2 +++ b/src/video/emscripten/SDL_emscriptenvideo.c	Tue Jan 29 12:18:56 2019 +0000
     2.3 @@ -207,7 +207,7 @@
     2.4      scaled_h = SDL_floor(window->h * wdata->pixel_ratio);
     2.5  
     2.6      /* set a fake size to check if there is any CSS sizing the canvas */
     2.7 -    emscripten_set_canvas_size(1, 1);
     2.8 +    emscripten_set_canvas_element_size(NULL, 1, 1);
     2.9      emscripten_get_element_css_size(NULL, &css_w, &css_h);
    2.10  
    2.11      wdata->external_size = SDL_floor(css_w) != 1 || SDL_floor(css_h) != 1;
    2.12 @@ -220,7 +220,7 @@
    2.13          SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
    2.14      }
    2.15  
    2.16 -    emscripten_set_canvas_size(scaled_w, scaled_h);
    2.17 +    emscripten_set_canvas_element_size(NULL, scaled_w, scaled_h);
    2.18  
    2.19      /* if the size is not being controlled by css, we need to scale down for hidpi */
    2.20      if (!wdata->external_size) {
    2.21 @@ -270,7 +270,7 @@
    2.22          if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
    2.23              data->pixel_ratio = emscripten_get_device_pixel_ratio();
    2.24          }
    2.25 -        emscripten_set_canvas_size(window->w * data->pixel_ratio, window->h * data->pixel_ratio);
    2.26 +        emscripten_set_canvas_element_size(NULL, window->w * data->pixel_ratio, window->h * data->pixel_ratio);
    2.27  
    2.28          /*scale canvas down*/
    2.29          if (!data->external_size && data->pixel_ratio != 1.0f) {