1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:47:44 +00:00

LibGL: Make GL::create_context fallible

Propagate errors in places that are already set up to handle them, like
WebGLRenderingContext and the Tubes demo, and convert other callers
to using MUST.
This commit is contained in:
Andrew Kaster 2022-09-16 05:58:30 -06:00 committed by Andreas Kling
parent 7e5080ea53
commit 8ed5ed3ec0
7 changed files with 14 additions and 20 deletions

View file

@ -41,18 +41,12 @@ JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> WebGLRenderingContext::c
return JS::GCPtr<WebGLRenderingContext> { nullptr };
}
#ifndef __serenity__
// FIXME: Make WebGL work on other platforms.
(void)window;
(void)context_attributes;
dbgln("FIXME: WebGL not supported on the current platform");
fire_webgl_context_creation_error(canvas_element);
return JS::GCPtr<WebGLRenderingContext> { nullptr };
#else
// FIXME: LibGL currently doesn't propagate context creation errors.
auto context = GL::create_context(*canvas_element.bitmap());
return window.heap().allocate<WebGLRenderingContext>(window.realm(), window, canvas_element, move(context), context_attributes, context_attributes);
#endif
auto context_or_error = GL::create_context(*canvas_element.bitmap());
if (context_or_error.is_error()) {
fire_webgl_context_creation_error(canvas_element);
return JS::GCPtr<WebGLRenderingContext> { nullptr };
}
return window.heap().allocate<WebGLRenderingContext>(window.realm(), window, canvas_element, context_or_error.release_value(), context_attributes, context_attributes);
}
WebGLRenderingContext::WebGLRenderingContext(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)