mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb/WebGL: Forward the render context ref count to HTMLCanvasElement
This allows HTMLCanvasElement and WebGL rendering contexts to share their lifetime, as JS allows them to arbitrarily access them at any time and WebGLRCB.canvas expects a non-null return value.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 09:56:01 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/0ec8a19a34 Pull-request: https://github.com/SerenityOS/serenity/pull/14341
@@ -12,7 +12,7 @@
|
||||
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)
|
||||
: RefCountForwarder(canvas_element)
|
||||
, m_context(move(context))
|
||||
, m_context_creation_parameters(move(context_creation_parameters))
|
||||
, m_actual_context_parameters(move(actual_context_parameters))
|
||||
@@ -67,15 +67,23 @@ void WebGLRenderingContextBase::present()
|
||||
}
|
||||
}
|
||||
|
||||
HTML::HTMLCanvasElement& WebGLRenderingContextBase::canvas_element()
|
||||
{
|
||||
return ref_count_target();
|
||||
}
|
||||
|
||||
HTML::HTMLCanvasElement const& WebGLRenderingContextBase::canvas_element() const
|
||||
{
|
||||
return ref_count_target();
|
||||
}
|
||||
|
||||
void WebGLRenderingContextBase::needs_to_present()
|
||||
{
|
||||
m_should_present = true;
|
||||
|
||||
if (!m_canvas_element)
|
||||
if (!canvas_element().layout_node())
|
||||
return;
|
||||
if (!m_canvas_element->layout_node())
|
||||
return;
|
||||
m_canvas_element->layout_node()->set_needs_display();
|
||||
canvas_element().layout_node()->set_needs_display();
|
||||
}
|
||||
|
||||
void WebGLRenderingContextBase::set_error(GLenum error)
|
||||
|
||||
Reference in New Issue
Block a user