ladybird/Libraries/LibWeb/HTML/Canvas/AbstractCanvasMixin.h
Aliaksandr Kalenik a80babffb6 LibWeb+Compositor: Run canvas contexts in the Compositor
Canvas rendering is a major remaining path where WebContent directly
owns GPU-facing drawing state. Back 2D and WebGL canvas contexts with
remote Compositor transports, so WebContent talks to canvas surfaces
through IPC while the Compositor owns the rasterization resources.

This is a large step toward GPU sandboxing because canvas GPU work now
lives behind the Compositor boundary. It also gives OffscreenCanvas the
process-independent canvas plumbing that HTMLCanvasElement now uses,
making worker-owned canvases possible without another WebContent-local
rendering path.
2026-06-17 19:07:32 +02:00

30 lines
1,004 B
C++

/*
* Copyright (c) 2026, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/CanvasCommandList.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Canvas/DrawingState.h>
#include <LibWeb/HTML/HTMLCanvasElement.h>
#include <LibWeb/HTML/OffscreenCanvas.h>
#pragma once
namespace Web::HTML {
class AbstractCanvasMixin {
protected:
virtual Variant<GC::Ref<HTMLCanvasElement>, GC::Ref<OffscreenCanvas>> canvas_element() = 0;
virtual Variant<GC::Ref<HTMLCanvasElement>, GC::Ref<OffscreenCanvas>> canvas_element() const = 0;
virtual DrawingState& drawing_state() = 0;
virtual DrawingState const& drawing_state() const = 0;
virtual JS::Realm& my_realm() = 0;
virtual Gfx::Path& mutable_path() = 0;
virtual Gfx::CanvasCommandList* canvas_command_list() = 0;
virtual CSS::ComputationContext computation_context_for_drawing_state() const = 0;
Optional<Color> parse_a_css_color_value(StringView const& value) const;
};
}