mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibGfx+LibWeb: Add new Path class with Skia backend, use for 2D canvas
This thing is essentially a wrapper around an SkPath, although we do some indirection via a PathImpl class to keep the door open for alternative rasterizer/path backends in the future. We also update the 2D canvas code, since that was the only code that used Painter+DeprecatedPath, and this allows us to just drop that code instead of temporarily supporting it until the next commit.
This commit is contained in:
parent
c8f09312f7
commit
a3cc03f180
Notes:
github-actions[bot]
2024-08-20 07:38:18 +00:00
Author: https://github.com/awesomekling
Commit: a3cc03f180
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1024
15 changed files with 417 additions and 93 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/DeprecatedPath.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibWeb/Geometry/DOMPointReadOnly.h>
|
||||
#include <LibWeb/HTML/Canvas/CanvasState.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
@ -30,8 +30,8 @@ public:
|
|||
WebIDL::ExceptionOr<void> arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise);
|
||||
WebIDL::ExceptionOr<void> ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise);
|
||||
|
||||
Gfx::DeprecatedPath& path() { return m_path; }
|
||||
Gfx::DeprecatedPath const& path() const { return m_path; }
|
||||
Gfx::Path& path() { return m_path; }
|
||||
Gfx::Path const& path() const { return m_path; }
|
||||
|
||||
protected:
|
||||
explicit CanvasPath(Bindings::PlatformObject& self)
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
JS::NonnullGCPtr<Bindings::PlatformObject> m_self;
|
||||
Optional<CanvasState const&> m_canvas_state;
|
||||
Gfx::DeprecatedPath m_path;
|
||||
Gfx::Path m_path;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibGfx/PathClipper.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibGfx/WindingRule.h>
|
||||
#include <LibWeb/Bindings/CanvasRenderingContext2DPrototype.h>
|
||||
#include <LibWeb/HTML/CanvasGradient.h>
|
||||
#include <LibWeb/HTML/CanvasPattern.h>
|
||||
|
@ -23,6 +24,11 @@ namespace Web::HTML {
|
|||
// https://html.spec.whatwg.org/multipage/canvas.html#canvasstate
|
||||
class CanvasState {
|
||||
public:
|
||||
struct ClipPath {
|
||||
Gfx::Path path;
|
||||
Gfx::WindingRule winding_rule;
|
||||
};
|
||||
|
||||
virtual ~CanvasState() = default;
|
||||
|
||||
void save();
|
||||
|
@ -81,7 +87,7 @@ public:
|
|||
bool image_smoothing_enabled { true };
|
||||
Bindings::ImageSmoothingQuality image_smoothing_quality { Bindings::ImageSmoothingQuality::Low };
|
||||
float global_alpha = { 1 };
|
||||
Optional<Gfx::ClipPath> clip;
|
||||
Optional<ClipPath> clip;
|
||||
RefPtr<CSS::CSSStyleValue> font_style_value { nullptr };
|
||||
RefPtr<Gfx::Font const> current_font { nullptr };
|
||||
Bindings::CanvasTextAlign text_align { Bindings::CanvasTextAlign::Start };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue