Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of emscripten_supports_offscreencanvas. NFC #21204

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/library_html5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var LibraryHtml5WebGL = {
emscripten_webgl_do_create_context__deps: [
#if OFFSCREENCANVAS_SUPPORT
'malloc',
'emscripten_supports_offscreencanvas',
#endif
#if PTHREADS && OFFSCREEN_FRAMEBUFFER
'emscripten_webgl_create_context_proxied',
Expand Down Expand Up @@ -95,7 +96,7 @@ var LibraryHtml5WebGL = {
dbg('Performance warning: forcing renderViaOffscreenBackBuffer=true and preserveDrawingBuffer=true since proxying WebGL rendering.');
#endif
// We will be proxying - if OffscreenCanvas is supported, we can proxy a bit more efficiently by avoiding having to create an Offscreen FBO.
if (typeof OffscreenCanvas == 'undefined') {
if (!_emscripten_supports_offscreencanvas()) {
{{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer, '1', 'i32') }}};
{{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.preserveDrawingBuffer, '1', 'i32') }}};
}
Expand All @@ -115,12 +116,12 @@ var LibraryHtml5WebGL = {
if (canvas.offscreenCanvas) canvas = canvas.offscreenCanvas;

#if GL_DEBUG
if (typeof OffscreenCanvas != 'undefined' && canvas instanceof OffscreenCanvas) dbg(`emscripten_webgl_create_context: Creating an OffscreenCanvas-based WebGL context on target "${targetStr}"`);
if (_emscripten_supports_offscreencanvas() && canvas instanceof OffscreenCanvas) dbg(`emscripten_webgl_create_context: Creating an OffscreenCanvas-based WebGL context on target "${targetStr}"`);
else if (typeof HTMLCanvasElement != 'undefined' && canvas instanceof HTMLCanvasElement) dbg(`emscripten_webgl_create_context: Creating an HTMLCanvasElement-based WebGL context on target "${targetStr}"`);
#endif

if (contextAttributes.explicitSwapControl) {
var supportsOffscreenCanvas = canvas.transferControlToOffscreen || (typeof OffscreenCanvas != 'undefined' && canvas instanceof OffscreenCanvas);
var supportsOffscreenCanvas = canvas.transferControlToOffscreen || (_emscripten_supports_offscreencanvas() && canvas instanceof OffscreenCanvas);

if (!supportsOffscreenCanvas) {
#if OFFSCREEN_FRAMEBUFFER
Expand Down
8 changes: 4 additions & 4 deletions test/canvas_animate_resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ int main()
printf("Created context with handle %u\n", (unsigned int)ctx);
if (!ctx)
{
EM_ASM({
if (typeof OffscreenCanvas === 'undefined') {
if (!emscripten_supports_offscreencanvas()) {
EM_ASM({
xhr = new XMLHttpRequest();
xhr.open('GET', 'http://localhost:8888/report_result?skipped:%20OffscreenCanvas%20is%20not%20supported!');
xhr.send();
setTimeout(function() { window.close() }, 2000);
}
});
});
}
return 0;
}
emscripten_webgl_make_context_current(ctx);
Expand Down
Loading