ladybird/Userland/Libraries/LibGfx/PathSkia.h
Andreas Kling a3cc03f180 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.
2024-08-20 09:30:05 +02:00

52 lines
1.6 KiB
C++

/*
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGfx/Path.h>
class SkPath;
namespace Gfx {
class PathImplSkia final : public PathImpl {
public:
static NonnullOwnPtr<Gfx::PathImplSkia> create();
virtual ~PathImplSkia() override;
virtual void clear() override;
virtual void move_to(Gfx::FloatPoint const&) override;
virtual void line_to(Gfx::FloatPoint const&) override;
virtual void close_all_subpaths() override;
virtual void close() override;
virtual void elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rotation, bool large_arc, bool sweep) override;
virtual void arc_to(FloatPoint point, float radius, bool large_arc, bool sweep) override;
virtual void quadratic_bezier_curve_to(FloatPoint through, FloatPoint point) override;
virtual void cubic_bezier_curve_to(FloatPoint c1, FloatPoint c2, FloatPoint p2) override;
virtual void text(Utf8View, Font const&) override;
virtual void append_path(Gfx::Path const&) override;
virtual void intersect(Gfx::Path const&) override;
[[nodiscard]] virtual bool is_empty() const override;
virtual Gfx::FloatPoint last_point() const override;
virtual Gfx::FloatRect bounding_box() const override;
virtual NonnullOwnPtr<PathImpl> clone() const override;
virtual NonnullOwnPtr<PathImpl> copy_transformed(Gfx::AffineTransform const&) const override;
SkPath const& sk_path() const { return *m_path; }
SkPath& sk_path() { return *m_path; }
private:
PathImplSkia();
Gfx::FloatPoint m_last_move_to;
NonnullOwnPtr<SkPath> m_path;
};
}