Skip to content

Fix canvas resize options when using EmscriptenFullscreenStrategy #2

@devappd

Description

@devappd

See JSEvents_resizeCanvasForFullscreen, where strategy is supplied.

Our resize options resizeCanvasOnFullscreenChange and adjustViewportByDevicePixelRatio are appropriate when using the default strategy (via emscripten_request_fullscreen()). However, this differs when specifying the strategy by emscripten_request_fullscreen_strategy() and emscripten_request_softfullscreen():

  • EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE does not apply any canvas sizing behavior. This is default.
  • EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF is equivalent to { resizeCanvasOnFullscreenChange: true, adjustViewportByDevicePixelRatio: false}
  • EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF is equivalent to { resizeCanvasOnFullscreenChange: true, adjustViewportByDevicePixelRatio: true}

Resolution

  • Make resizeCanvasOnFullscreenChange and adjustViewportByDevicePixelRatio into private variables
  • When triggering fullscreen from JS-side, set these both true
  • Patch JSEvents.resizeCanvasForFullscreen to set these both variables to true if EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE, otherwise set both variables to false
  • Disable all the above behavior if resizeCanvasOnElementSizing is false
  • fixCanvasViewport is still necessary for non-fullscreen operations. In the canvas resize handler, attach this call to resizeCanvasOnElementSizing instead of adjustViewportByDevicePixelRatio.
  • Expose EMSCRIPTEN_FULLSCREEN_FILTERING_NEAREST/BILINEAR (CSS is only changed from default for NEAREST -- image-rendering: optimize-speed;

Notes

  • How well does soft-fullscreen work in React, etc.?
  • If I want to implement scaled canvas sizing (render at half resolution, etc.), I have to do so on JS-side; emscripten does not provide functions for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions