src/video/emscripten/SDL_emscriptenvideo.c
changeset 12574 109c919d61f6
parent 12571 aa455cfe9ff3
child 12576 8d61748ac590
equal deleted inserted replaced
12573:296d155a8ce5 12574:109c919d61f6
   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     /* set a fake size to check if there is any CSS sizing the canvas */
   209     /* set a fake size to check if there is any CSS sizing the canvas */
   210     emscripten_set_canvas_size(1, 1);
   210     emscripten_set_canvas_element_size(NULL, 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) != 1 || SDL_floor(css_h) != 1;
   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) {
   218         scaled_h = css_h * wdata->pixel_ratio;
   218         scaled_h = css_h * wdata->pixel_ratio;
   219 
   219 
   220         SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
   220         SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
   221     }
   221     }
   222 
   222 
   223     emscripten_set_canvas_size(scaled_w, scaled_h);
   223     emscripten_set_canvas_element_size(NULL, scaled_w, scaled_h);
   224 
   224 
   225     /* 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 */
   226     if (!wdata->external_size) {
   226     if (!wdata->external_size) {
   227         if (wdata->pixel_ratio != 1.0f) {
   227         if (wdata->pixel_ratio != 1.0f) {
   228             /*scale canvas down*/
   228             /*scale canvas down*/
   268         data = (SDL_WindowData *) window->driverdata;
   268         data = (SDL_WindowData *) window->driverdata;
   269         /* update pixel ratio */
   269         /* update pixel ratio */
   270         if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
   270         if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
   271             data->pixel_ratio = emscripten_get_device_pixel_ratio();
   271             data->pixel_ratio = emscripten_get_device_pixel_ratio();
   272         }
   272         }
   273         emscripten_set_canvas_size(window->w * data->pixel_ratio, window->h * data->pixel_ratio);
   273         emscripten_set_canvas_element_size(NULL, window->w * data->pixel_ratio, window->h * data->pixel_ratio);
   274 
   274 
   275         /*scale canvas down*/
   275         /*scale canvas down*/
   276         if (!data->external_size && data->pixel_ratio != 1.0f) {
   276         if (!data->external_size && data->pixel_ratio != 1.0f) {
   277             emscripten_set_element_css_size(NULL, window->w, window->h);
   277             emscripten_set_element_css_size(NULL, window->w, window->h);
   278         }
   278         }