mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +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
|
@ -7,6 +7,7 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibGfx/DeprecatedPath.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibWeb/Bindings/SVGPathElementPrototype.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
@ -104,9 +105,10 @@ void SVGPathElement::attribute_changed(FlyString const& name, Optional<String> c
|
|||
m_instructions = AttributeParser::parse_path_data(value.value_or(String {}));
|
||||
}
|
||||
|
||||
Gfx::DeprecatedPath path_from_path_instructions(ReadonlySpan<PathInstruction> instructions)
|
||||
template<typename PathType>
|
||||
PathType path_from_path_instructions(ReadonlySpan<PathInstruction> instructions)
|
||||
{
|
||||
Gfx::DeprecatedPath path;
|
||||
PathType path;
|
||||
Optional<Gfx::FloatPoint> previous_control_point;
|
||||
PathInstructionType last_instruction = PathInstructionType::Invalid;
|
||||
|
||||
|
@ -272,9 +274,19 @@ Gfx::DeprecatedPath path_from_path_instructions(ReadonlySpan<PathInstruction> in
|
|||
return path;
|
||||
}
|
||||
|
||||
Gfx::Path path_from_path_instructions(ReadonlySpan<PathInstruction> instructions)
|
||||
{
|
||||
return path_from_path_instructions<Gfx::Path>(instructions);
|
||||
}
|
||||
|
||||
Gfx::DeprecatedPath deprecated_path_from_path_instructions(ReadonlySpan<PathInstruction> instructions)
|
||||
{
|
||||
return path_from_path_instructions<Gfx::DeprecatedPath>(instructions);
|
||||
}
|
||||
|
||||
Gfx::DeprecatedPath SVGPathElement::get_path(CSSPixelSize)
|
||||
{
|
||||
return path_from_path_instructions(m_instructions);
|
||||
return deprecated_path_from_path_instructions(m_instructions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue