mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +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
@@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefCountForwarder.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibGL/GLContext.h>
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace Web::WebGL {
|
||||
|
||||
class WebGLRenderingContextBase
|
||||
: public RefCounted<WebGLRenderingContextBase>
|
||||
: public RefCountForwarder<HTML::HTMLCanvasElement>
|
||||
, public Weakable<WebGLRenderingContextBase> {
|
||||
public:
|
||||
virtual ~WebGLRenderingContextBase();
|
||||
@@ -63,8 +63,6 @@ protected:
|
||||
WebGLRenderingContextBase(HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
|
||||
|
||||
private:
|
||||
WeakPtr<HTML::HTMLCanvasElement> m_canvas_element;
|
||||
|
||||
NonnullOwnPtr<GL::GLContext> m_context;
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#context-creation-parameters
|
||||
@@ -87,6 +85,9 @@ private:
|
||||
|
||||
GLenum m_error { GL_NO_ERROR };
|
||||
|
||||
HTML::HTMLCanvasElement& canvas_element();
|
||||
HTML::HTMLCanvasElement const& canvas_element() const;
|
||||
|
||||
void needs_to_present();
|
||||
void set_error(GLenum error);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user