mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
We already had the API, but drawing to the canvas was not affected by any created CanvasPattern. This moves CanvasPatternPaintStyle to LibGfx so we don't have to reach into LibWeb, and implements the plumbing to let Skia use images as a fill pattern.
36 lines
988 B
C++
36 lines
988 B
C++
/*
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
|
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
|
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/PaintStyle.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/HTML/Canvas/CanvasDrawImage.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class CanvasPattern final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(CanvasPattern, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(CanvasPattern);
|
|
|
|
public:
|
|
static WebIDL::ExceptionOr<GC::Ptr<CanvasPattern>> create(JS::Realm&, CanvasImageSource const& image, StringView repetition);
|
|
|
|
~CanvasPattern();
|
|
|
|
NonnullRefPtr<Gfx::PaintStyle> to_gfx_paint_style() { return m_pattern; }
|
|
|
|
private:
|
|
CanvasPattern(JS::Realm&, Gfx::CanvasPatternPaintStyle&);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
NonnullRefPtr<Gfx::CanvasPatternPaintStyle> m_pattern;
|
|
};
|
|
|
|
}
|