mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb: Delegate painting surface allocation to canvas's active context
This change prepares for the addition of WebGL support, where painting surface allocation process will differ from that of context2d.
This commit is contained in:
parent
e683700fe6
commit
f719b05ab9
Notes:
github-actions[bot]
2024-12-03 22:37:53 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: f719b05ab9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2688
Reviewed-by: https://github.com/ADKaster ✅
8 changed files with 116 additions and 67 deletions
|
@ -24,11 +24,14 @@ public:
|
|||
|
||||
virtual ~HTMLCanvasElement() override;
|
||||
|
||||
bool allocate_painting_surface(size_t minimum_width = 0, size_t minimum_height = 0);
|
||||
RefPtr<Gfx::PaintingSurface> surface() { return m_surface; }
|
||||
RefPtr<Gfx::PaintingSurface const> surface() const { return m_surface; }
|
||||
Gfx::IntSize bitmap_size_for_canvas(size_t minimum_width = 0, size_t minimum_height = 0) const;
|
||||
|
||||
JS::ThrowCompletionOr<RenderingContext> get_context(String const& type, JS::Value options);
|
||||
enum class HasOrCreatedContext {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
HasOrCreatedContext create_2d_context();
|
||||
|
||||
WebIDL::UnsignedLong width() const;
|
||||
WebIDL::UnsignedLong height() const;
|
||||
|
@ -41,6 +44,9 @@ public:
|
|||
|
||||
void present();
|
||||
|
||||
RefPtr<Gfx::PaintingSurface> surface() const;
|
||||
void allocate_painting_surface_if_needed();
|
||||
|
||||
private:
|
||||
HTMLCanvasElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
@ -52,16 +58,9 @@ private:
|
|||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::StyleProperties) override;
|
||||
virtual void adjust_computed_style(CSS::StyleProperties&) override;
|
||||
|
||||
enum class HasOrCreatedContext {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
HasOrCreatedContext create_2d_context();
|
||||
JS::ThrowCompletionOr<HasOrCreatedContext> create_webgl_context(JS::Value options);
|
||||
void reset_context_to_default_state();
|
||||
|
||||
RefPtr<Gfx::PaintingSurface> m_surface;
|
||||
void notify_context_about_canvas_size_change();
|
||||
|
||||
Variant<GC::Ref<HTML::CanvasRenderingContext2D>, GC::Ref<WebGL::WebGLRenderingContext>, Empty> m_context;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue