1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

LibWeb: Make 2D and 3D canvas rendering contexts GC-allocated

This commit is contained in:
Andreas Kling 2022-09-02 15:53:02 +02:00
parent b8d485e6f0
commit 4452b5ca09
11 changed files with 107 additions and 61 deletions

View file

@ -7,12 +7,14 @@
#include <AK/Debug.h>
#include <LibGL/GLContext.h>
#include <LibWeb/HTML/HTMLCanvasElement.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
namespace Web::WebGL {
WebGLRenderingContextBase::WebGLRenderingContextBase(HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
: m_canvas_element(canvas_element)
WebGLRenderingContextBase::WebGLRenderingContextBase(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
: PlatformObject(window.realm())
, m_canvas_element(canvas_element)
, m_context(move(context))
, m_context_creation_parameters(move(context_creation_parameters))
, m_actual_context_parameters(move(actual_context_parameters))
@ -21,6 +23,12 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(HTML::HTMLCanvasElement& ca
WebGLRenderingContextBase::~WebGLRenderingContextBase() = default;
void WebGLRenderingContextBase::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_canvas_element.ptr());
}
#define RETURN_WITH_WEBGL_ERROR_IF(condition, error) \
if (condition) { \
dbgln_if(WEBGL_CONTEXT_DEBUG, "{}(): error {:#x}", __func__, error); \