src/video/emscripten/SDL_emscriptenvideo.c
changeset 12571 aa455cfe9ff3
parent 12503 806492103856
child 12574 109c919d61f6
equal deleted inserted replaced
12570:bb39a14d510c 12571:aa455cfe9ff3
   204     }
   204     }
   205 
   205 
   206     scaled_w = SDL_floor(window->w * wdata->pixel_ratio);
   206     scaled_w = SDL_floor(window->w * wdata->pixel_ratio);
   207     scaled_h = SDL_floor(window->h * wdata->pixel_ratio);
   207     scaled_h = SDL_floor(window->h * wdata->pixel_ratio);
   208 
   208 
   209     emscripten_set_canvas_size(scaled_w, scaled_h);
   209     /* set a fake size to check if there is any CSS sizing the canvas */
   210 
   210     emscripten_set_canvas_size(1, 1);
   211     emscripten_get_element_css_size(NULL, &css_w, &css_h);
   211     emscripten_get_element_css_size(NULL, &css_w, &css_h);
   212 
   212 
   213     wdata->external_size = SDL_floor(css_w) != scaled_w || SDL_floor(css_h) != scaled_h;
   213     wdata->external_size = SDL_floor(css_w) != 1 || SDL_floor(css_h) != 1;
   214 
   214 
   215     if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) {
   215     if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) {
   216         /* external css has resized us */
   216         /* external css has resized us */
   217         scaled_w = css_w * wdata->pixel_ratio;
   217         scaled_w = css_w * wdata->pixel_ratio;
   218         scaled_h = css_h * wdata->pixel_ratio;
   218         scaled_h = css_h * wdata->pixel_ratio;
   219 
   219 
   220         emscripten_set_canvas_size(scaled_w, scaled_h);
       
   221         SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
   220         SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
   222     }
   221     }
       
   222 
       
   223     emscripten_set_canvas_size(scaled_w, scaled_h);
   223 
   224 
   224     /* if the size is not being controlled by css, we need to scale down for hidpi */
   225     /* if the size is not being controlled by css, we need to scale down for hidpi */
   225     if (!wdata->external_size) {
   226     if (!wdata->external_size) {
   226         if (wdata->pixel_ratio != 1.0f) {
   227         if (wdata->pixel_ratio != 1.0f) {
   227             /*scale canvas down*/
   228             /*scale canvas down*/