diff --git a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn index 6603c0f1f60..57ea6d76121 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn @@ -31,6 +31,7 @@ shared_library("LibGfx") { "Color.cpp", "DeltaE.cpp", "DeprecatedPainter.cpp", + "DeprecatedPath.cpp", "EdgeFlagPathRasterizer.cpp", "Filters/ColorBlindnessFilter.cpp", "Filters/FastBoxBlurFilter.cpp", @@ -80,7 +81,6 @@ shared_library("LibGfx") { "ImageFormats/WebPWriterLossless.cpp", "ImmutableBitmap.cpp", "Palette.cpp", - "Path.cpp", "PathClipper.cpp", "Point.cpp", "Rect.cpp", diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp index 552985d4a23..48b5b2bc822 100644 --- a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp +++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp @@ -193,7 +193,7 @@ void AntiAliasingPainter::draw_line(FloatPoint actual_from, FloatPoint actual_to draw_anti_aliased_line(actual_from, actual_to, color, thickness, style, alternate_color, line_length_mode); } -void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thickness) +void AntiAliasingPainter::stroke_path(DeprecatedPath const& path, Color color, float thickness) { if (thickness <= 0) return; @@ -201,7 +201,7 @@ void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thick fill_path(path.stroke_to_fill(thickness), color); } -void AntiAliasingPainter::stroke_path(Path const& path, Gfx::PaintStyle const& paint_style, float thickness, float opacity) +void AntiAliasingPainter::stroke_path(DeprecatedPath const& path, Gfx::PaintStyle const& paint_style, float thickness, float opacity) { if (thickness <= 0) return; diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.h b/Userland/Libraries/LibGfx/AntiAliasingPainter.h index 3f85a55796d..d11ede2ecdb 100644 --- a/Userland/Libraries/LibGfx/AntiAliasingPainter.h +++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.h @@ -7,10 +7,10 @@ #pragma once #include +#include #include #include #include -#include #include #include @@ -37,11 +37,11 @@ public: draw_line(line.a(), line.b(), color, thickness, style, alternate_color, line_length_mode); } - void fill_path(Path const&, Color, WindingRule rule = WindingRule::Nonzero); - void fill_path(Path const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero); + void fill_path(DeprecatedPath const&, Color, WindingRule rule = WindingRule::Nonzero); + void fill_path(DeprecatedPath const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero); - void stroke_path(Path const&, Color, float thickness); - void stroke_path(Path const&, PaintStyle const& paint_style, float thickness, float opacity = 1.0f); + void stroke_path(DeprecatedPath const&, Color, float thickness); + void stroke_path(DeprecatedPath const&, PaintStyle const& paint_style, float thickness, float opacity = 1.0f); void translate(float dx, float dy) { m_transform.translate(dx, dy); } void translate(FloatPoint delta) { m_transform.translate(delta); } diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index a451ff556ce..8ef54b98b62 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -8,6 +8,7 @@ set(SOURCES Color.cpp DeltaE.cpp DeprecatedPainter.cpp + DeprecatedPath.cpp EdgeFlagPathRasterizer.cpp FontCascadeList.cpp Font/Emoji.cpp @@ -56,7 +57,6 @@ set(SOURCES ImmutableBitmap.cpp MedianCut.cpp Palette.cpp - Path.cpp PathClipper.cpp Painter.cpp PainterSkia.cpp diff --git a/Userland/Libraries/LibGfx/DeprecatedPainter.cpp b/Userland/Libraries/LibGfx/DeprecatedPainter.cpp index 786dcfc04cf..667cb028409 100644 --- a/Userland/Libraries/LibGfx/DeprecatedPainter.cpp +++ b/Userland/Libraries/LibGfx/DeprecatedPainter.cpp @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -1227,7 +1227,7 @@ DeprecatedPainterStateSaver::~DeprecatedPainterStateSaver() m_painter.restore(); } -void DeprecatedPainter::stroke_path(Path const& path, Color color, int thickness) +void DeprecatedPainter::stroke_path(DeprecatedPath const& path, Color color, int thickness) { if (thickness <= 0) return; diff --git a/Userland/Libraries/LibGfx/DeprecatedPainter.h b/Userland/Libraries/LibGfx/DeprecatedPainter.h index 1619ce100f9..69561493ca8 100644 --- a/Userland/Libraries/LibGfx/DeprecatedPainter.h +++ b/Userland/Libraries/LibGfx/DeprecatedPainter.h @@ -79,10 +79,10 @@ public: static void for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function&); static void for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_point_0, FloatPoint control_point_1, FloatPoint p1, FloatPoint p2, Function&&); - void stroke_path(Path const&, Color, int thickness); + void stroke_path(DeprecatedPath const&, Color, int thickness); - void fill_path(Path const&, Color, WindingRule rule = WindingRule::Nonzero); - void fill_path(Path const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero); + void fill_path(DeprecatedPath const&, Color, WindingRule rule = WindingRule::Nonzero); + void fill_path(DeprecatedPath const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero); void add_clip_rect(IntRect const& rect); void clear_clip_rect(); diff --git a/Userland/Libraries/LibGfx/Path.cpp b/Userland/Libraries/LibGfx/DeprecatedPath.cpp similarity index 90% rename from Userland/Libraries/LibGfx/Path.cpp rename to Userland/Libraries/LibGfx/DeprecatedPath.cpp index d33cb1a0c0a..a0e3f80e2b2 100644 --- a/Userland/Libraries/LibGfx/Path.cpp +++ b/Userland/Libraries/LibGfx/DeprecatedPath.cpp @@ -9,13 +9,13 @@ #include #include #include +#include #include -#include #include namespace Gfx { -void Path::approximate_elliptical_arc_with_cubic_beziers(FloatPoint center, FloatSize radii, float x_axis_rotation, float theta, float theta_delta) +void DeprecatedPath::approximate_elliptical_arc_with_cubic_beziers(FloatPoint center, FloatSize radii, float x_axis_rotation, float theta, float theta_delta) { float sin_x_rotation; float cos_x_rotation; @@ -63,7 +63,7 @@ void Path::approximate_elliptical_arc_with_cubic_beziers(FloatPoint center, Floa approximate_arc_between(prev, t); } -void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rotation, bool large_arc, bool sweep) +void DeprecatedPath::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rotation, bool large_arc, bool sweep) { auto next_point = point; @@ -77,7 +77,7 @@ void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rot // Step 1 of out-of-range radii correction if (rx == 0.0 || ry == 0.0) { - append_segment(next_point); + append_segment(next_point); return; } @@ -158,7 +158,7 @@ void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rot theta_delta); } -void Path::text(Utf8View text, Font const& font) +void DeprecatedPath::text(Utf8View text, Font const& font) { if (!is(font)) { // FIXME: This API only accepts Gfx::Font for ease of use. @@ -178,7 +178,7 @@ void Path::text(Utf8View text, Font const& font) IncludeLeftBearing::Yes); } -Path Path::place_text_along(Utf8View text, Font const& font) const +DeprecatedPath DeprecatedPath::place_text_along(Utf8View text, Font const& font) const { if (!is(font)) { // FIXME: This API only accepts Gfx::Font for ease of use. @@ -206,7 +206,7 @@ Path Path::place_text_along(Utf8View text, Font const& font) const }; auto& scaled_font = static_cast(font); - Gfx::Path result_path; + Gfx::DeprecatedPath result_path; Gfx::for_each_glyph_position( {}, text, font, [&](Gfx::DrawGlyphOrEmoji glyph_or_emoji) { auto* glyph = glyph_or_emoji.get_pointer(); @@ -223,7 +223,7 @@ Path Path::place_text_along(Utf8View text, Font const& font) const // Find the angle between the start and end points on the path. auto delta = *end - *start; auto angle = AK::atan2(delta.y(), delta.x()); - Gfx::Path glyph_path; + Gfx::DeprecatedPath glyph_path; // Rotate the glyph then move it to start point. scaled_font.append_glyph_path_to(glyph_path, glyph->glyph_id); auto transform = Gfx::AffineTransform {} @@ -237,13 +237,13 @@ Path Path::place_text_along(Utf8View text, Font const& font) const return result_path; } -void Path::close() +void DeprecatedPath::close() { // If there's no `moveto` starting this subpath assume the start is (0, 0). FloatPoint first_point_in_subpath = { 0, 0 }; for (auto it = end(); it-- != begin();) { auto segment = *it; - if (segment.command() == PathSegment::MoveTo) { + if (segment.command() == DeprecatedPathSegment::MoveTo) { first_point_in_subpath = segment.point(); break; } @@ -252,7 +252,7 @@ void Path::close() line_to(first_point_in_subpath); } -void Path::close_all_subpaths() +void DeprecatedPath::close_all_subpaths() { auto it = begin(); // Note: Get the end outside the loop as closing subpaths will move the end. @@ -261,7 +261,7 @@ void Path::close_all_subpaths() // If there's no `moveto` starting this subpath assume the start is (0, 0). FloatPoint first_point_in_subpath = { 0, 0 }; auto segment = *it; - if (segment.command() == PathSegment::MoveTo) { + if (segment.command() == DeprecatedPathSegment::MoveTo) { first_point_in_subpath = segment.point(); ++it; } @@ -269,7 +269,7 @@ void Path::close_all_subpaths() FloatPoint cursor = first_point_in_subpath; while (it < end) { auto segment = *it; - if (segment.command() == PathSegment::MoveTo) + if (segment.command() == DeprecatedPathSegment::MoveTo) break; cursor = segment.point(); ++it; @@ -282,26 +282,26 @@ void Path::close_all_subpaths() } } -ByteString Path::to_byte_string() const +ByteString DeprecatedPath::to_byte_string() const { // Dumps this path as an SVG compatible string. StringBuilder builder; - if (is_empty() || m_commands.first() != PathSegment::MoveTo) + if (is_empty() || m_commands.first() != DeprecatedPathSegment::MoveTo) builder.append("M 0,0"sv); for (auto segment : *this) { if (!builder.is_empty()) builder.append(' '); switch (segment.command()) { - case PathSegment::MoveTo: + case DeprecatedPathSegment::MoveTo: builder.append('M'); break; - case PathSegment::LineTo: + case DeprecatedPathSegment::LineTo: builder.append('L'); break; - case PathSegment::QuadraticBezierCurveTo: + case DeprecatedPathSegment::QuadraticBezierCurveTo: builder.append('Q'); break; - case PathSegment::CubicBezierCurveTo: + case DeprecatedPathSegment::CubicBezierCurveTo: builder.append('C'); break; } @@ -311,7 +311,7 @@ ByteString Path::to_byte_string() const return builder.to_byte_string(); } -void Path::segmentize_path() +void DeprecatedPath::segmentize_path() { Vector segments; FloatBoundingBox bounding_box; @@ -324,20 +324,20 @@ void Path::segmentize_path() FloatPoint cursor { 0, 0 }; for (auto segment : *this) { switch (segment.command()) { - case PathSegment::MoveTo: + case DeprecatedPathSegment::MoveTo: bounding_box.add_point(segment.point()); break; - case PathSegment::LineTo: { + case DeprecatedPathSegment::LineTo: { add_line(cursor, segment.point()); break; } - case PathSegment::QuadraticBezierCurveTo: { + case DeprecatedPathSegment::QuadraticBezierCurveTo: { DeprecatedPainter::for_each_line_segment_on_bezier_curve(segment.through(), cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) { add_line(p0, p1); }); break; } - case PathSegment::CubicBezierCurveTo: { + case DeprecatedPathSegment::CubicBezierCurveTo: { DeprecatedPainter::for_each_line_segment_on_cubic_bezier_curve(segment.through_0(), segment.through_1(), cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) { add_line(p0, p1); }); @@ -350,9 +350,9 @@ void Path::segmentize_path() m_split_lines = SplitLines { move(segments), bounding_box }; } -Path Path::copy_transformed(Gfx::AffineTransform const& transform) const +DeprecatedPath DeprecatedPath::copy_transformed(Gfx::AffineTransform const& transform) const { - Path result; + DeprecatedPath result; result.m_commands = m_commands; result.m_points.ensure_capacity(m_points.size()); for (auto point : m_points) @@ -388,7 +388,7 @@ private: ReadonlySpan m_span; }; -Path Path::stroke_to_fill(float thickness) const +DeprecatedPath DeprecatedPath::stroke_to_fill(float thickness) const { // Note: This convolves a polygon with the path using the algorithm described // in https://keithp.com/~keithp/talks/cairo2003.pdf (3.1 Stroking Splines via Convolution) @@ -397,7 +397,7 @@ Path Path::stroke_to_fill(float thickness) const auto lines = split_lines(); if (lines.is_empty()) - return Path {}; + return DeprecatedPath {}; // Paths can be disconnected, which a pain to deal with, so split it up. Vector> segments; @@ -476,7 +476,7 @@ Path Path::stroke_to_fill(float thickness) const return (target_angle - current_angle) <= AK::Pi; }; - Path convolution; + DeprecatedPath convolution; for (auto& segment : segments) { RoundTrip shape { segment }; diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/DeprecatedPath.h similarity index 77% rename from Userland/Libraries/LibGfx/Path.h rename to Userland/Libraries/LibGfx/DeprecatedPath.h index 00d5f9b588c..d12caebefc9 100644 --- a/Userland/Libraries/LibGfx/Path.h +++ b/Userland/Libraries/LibGfx/DeprecatedPath.h @@ -16,9 +16,9 @@ namespace Gfx { -class Path; +class DeprecatedPath; -class PathSegment { +class DeprecatedPathSegment { public: enum Command : u8 { MoveTo, @@ -60,7 +60,7 @@ public: VERIFY_NOT_REACHED(); } - PathSegment(Command command, ReadonlySpan points) + DeprecatedPathSegment(Command command, ReadonlySpan points) : m_command(command) , m_points(points) {}; @@ -85,7 +85,7 @@ public: PathSegmentIterator operator++() { if (m_command_index < m_commands.size()) - m_point_index += PathSegment::points_per_command(m_commands[m_command_index++]); + m_point_index += DeprecatedPathSegment::points_per_command(m_commands[m_command_index++]); return *this; } PathSegmentIterator operator++(int) @@ -98,7 +98,7 @@ public: PathSegmentIterator operator--() { if (m_command_index > 0) - m_point_index -= PathSegment::points_per_command(m_commands[--m_command_index]); + m_point_index -= DeprecatedPathSegment::points_per_command(m_commands[--m_command_index]); return *this; } PathSegmentIterator operator--(int) @@ -108,10 +108,10 @@ public: return old; } - PathSegment operator*() const + DeprecatedPathSegment operator*() const { auto command = m_commands[m_command_index]; - return PathSegment { command, m_points.span().slice(m_point_index, PathSegment::points_per_command(command)) }; + return DeprecatedPathSegment { command, m_points.span().slice(m_point_index, DeprecatedPathSegment::points_per_command(command)) }; } PathSegmentIterator& operator=(PathSegmentIterator const& other) @@ -122,10 +122,10 @@ public: } PathSegmentIterator(PathSegmentIterator const&) = default; - friend Path; + friend DeprecatedPath; private: - PathSegmentIterator(Vector const& points, Vector const& commands, size_t point_index = 0, size_t command_index = 0) + PathSegmentIterator(Vector const& points, Vector const& commands, size_t point_index = 0, size_t command_index = 0) : m_points(points) , m_commands(commands) , m_point_index(point_index) @@ -133,25 +133,25 @@ private: { } - // Note: Store reference to vectors from Gfx::Path so appending segments does not invalidate iterators. + // Note: Store reference to vectors from Gfx::DeprecatedPath so appending segments does not invalidate iterators. Vector const& m_points; - Vector const& m_commands; + Vector const& m_commands; size_t m_point_index { 0 }; size_t m_command_index { 0 }; }; -class Path { +class DeprecatedPath { public: - Path() = default; + DeprecatedPath() = default; void move_to(FloatPoint point) { - append_segment(point); + append_segment(point); } void line_to(FloatPoint point) { - append_segment(point); + append_segment(point); invalidate_split_lines(); } @@ -167,13 +167,13 @@ public: void quadratic_bezier_curve_to(FloatPoint through, FloatPoint point) { - append_segment(through, point); + append_segment(through, point); invalidate_split_lines(); } void cubic_bezier_curve_to(FloatPoint c1, FloatPoint c2, FloatPoint p2) { - append_segment(c1, c2, p2); + append_segment(c1, c2, p2); invalidate_split_lines(); } @@ -195,16 +195,16 @@ public: void close(); void close_all_subpaths(); - Path stroke_to_fill(float thickness) const; + DeprecatedPath stroke_to_fill(float thickness) const; - Path place_text_along(Utf8View text, Font const&) const; + DeprecatedPath place_text_along(Utf8View text, Font const&) const; - Path copy_transformed(AffineTransform const&) const; + DeprecatedPath copy_transformed(AffineTransform const&) const; ReadonlySpan split_lines() const { if (!m_split_lines.has_value()) { - const_cast(this)->segmentize_path(); + const_cast(this)->segmentize_path(); VERIFY(m_split_lines.has_value()); } return m_split_lines->lines; @@ -216,7 +216,7 @@ public: return m_split_lines->bounding_box; } - void append_path(Path const& path) + void append_path(DeprecatedPath const& path) { m_commands.extend(path.m_commands); m_points.extend(path.m_points); @@ -242,7 +242,7 @@ public: void clear() { - *this = Path {}; + *this = DeprecatedPath {}; } private: @@ -254,11 +254,11 @@ private: } void segmentize_path(); - template + template void append_segment(Args&&... args) { constexpr auto point_count = sizeof...(Args); - static_assert(point_count == PathSegment::points_per_command(command)); + static_assert(point_count == DeprecatedPathSegment::points_per_command(command)); FloatPoint points[] { args... }; // Note: This should maintain the invariant that `m_points.last()` is always the last point in the path. m_points.append(points, point_count); @@ -266,7 +266,7 @@ private: } Vector m_points {}; - Vector m_commands {}; + Vector m_commands {}; struct SplitLines { Vector lines; diff --git a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp index d4e76da78e4..133be64ad1d 100644 --- a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp +++ b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp @@ -99,13 +99,13 @@ EdgeFlagPathRasterizer::EdgeFlagPathRasterizer(IntSize size) } template -void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, Path const& path, Color color, WindingRule winding_rule, FloatPoint offset) +void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, DeprecatedPath const& path, Color color, WindingRule winding_rule, FloatPoint offset) { fill_internal(painter, path, color, winding_rule, offset); } template -void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, Path const& path, PaintStyle const& style, float opacity, WindingRule winding_rule, FloatPoint offset) +void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, DeprecatedPath const& path, PaintStyle const& style, float opacity, WindingRule winding_rule, FloatPoint offset) { style.paint(enclosing_int_rect(path.bounding_box()), [&](PaintStyle::SamplerFunction sampler) { if (opacity == 0.0f) @@ -122,7 +122,7 @@ void EdgeFlagPathRasterizer::fill(DeprecatedPainter& painter, P } template -void EdgeFlagPathRasterizer::fill_internal(DeprecatedPainter& painter, Path const& path, auto color_or_function, WindingRule winding_rule, FloatPoint offset) +void EdgeFlagPathRasterizer::fill_internal(DeprecatedPainter& painter, DeprecatedPath const& path, auto color_or_function, WindingRule winding_rule, FloatPoint offset) { auto bounding_box = enclosing_int_rect(path.bounding_box().translated(offset)); auto dest_rect = bounding_box.translated(painter.translation()); @@ -430,7 +430,7 @@ FLATTEN __attribute__((hot)) void EdgeFlagPathRasterizer::write color_or_function, write_scanline_with_fast_fills, write_scanline_pixelwise); } -static IntSize path_bounds(Gfx::Path const& path) +static IntSize path_bounds(Gfx::DeprecatedPath const& path) { return enclosing_int_rect(path.bounding_box()).size(); } @@ -439,25 +439,25 @@ static IntSize path_bounds(Gfx::Path const& path) // since it would be harder to turn it off for the standard painter. // The samples are reduced to 8 for Gfx::DeprecatedPainter though as a "speedy" option. -void DeprecatedPainter::fill_path(Path const& path, Color color, WindingRule winding_rule) +void DeprecatedPainter::fill_path(DeprecatedPath const& path, Color color, WindingRule winding_rule) { EdgeFlagPathRasterizer<8> rasterizer(path_bounds(path)); rasterizer.fill(*this, path, color, winding_rule); } -void DeprecatedPainter::fill_path(Path const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule) +void DeprecatedPainter::fill_path(DeprecatedPath const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule) { EdgeFlagPathRasterizer<8> rasterizer(path_bounds(path)); rasterizer.fill(*this, path, paint_style, opacity, winding_rule); } -void AntiAliasingPainter::fill_path(Path const& path, Color color, WindingRule winding_rule) +void AntiAliasingPainter::fill_path(DeprecatedPath const& path, Color color, WindingRule winding_rule) { EdgeFlagPathRasterizer<32> rasterizer(path_bounds(path)); rasterizer.fill(m_underlying_painter, path, color, winding_rule, m_transform.translation()); } -void AntiAliasingPainter::fill_path(Path const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule) +void AntiAliasingPainter::fill_path(DeprecatedPath const& path, PaintStyle const& paint_style, float opacity, WindingRule winding_rule) { EdgeFlagPathRasterizer<32> rasterizer(path_bounds(path)); rasterizer.fill(m_underlying_painter, path, paint_style, opacity, winding_rule, m_transform.translation()); diff --git a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h index 3f959fcbb53..37b55e40938 100644 --- a/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h +++ b/Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.h @@ -11,9 +11,9 @@ #include #include #include +#include #include #include -#include #include namespace Gfx { @@ -147,8 +147,8 @@ class EdgeFlagPathRasterizer { public: EdgeFlagPathRasterizer(IntSize); - void fill(DeprecatedPainter&, Path const&, Color, WindingRule, FloatPoint offset = {}); - void fill(DeprecatedPainter&, Path const&, PaintStyle const&, float opacity, WindingRule, FloatPoint offset = {}); + void fill(DeprecatedPainter&, DeprecatedPath const&, Color, WindingRule, FloatPoint offset = {}); + void fill(DeprecatedPainter&, DeprecatedPath const&, PaintStyle const&, float opacity, WindingRule, FloatPoint offset = {}); private: using SubpixelSample = Detail::Sample; @@ -174,7 +174,7 @@ private: } }; - void fill_internal(DeprecatedPainter&, Path const&, auto color_or_function, WindingRule, FloatPoint offset); + void fill_internal(DeprecatedPainter&, DeprecatedPath const&, auto color_or_function, WindingRule, FloatPoint offset); Detail::Edge* plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent&, Detail::Edge* active_edges = nullptr); template diff --git a/Userland/Libraries/LibGfx/Font/Font.h b/Userland/Libraries/LibGfx/Font/Font.h index f0f562e76ea..d0a50a9b07b 100644 --- a/Userland/Libraries/LibGfx/Font/Font.h +++ b/Userland/Libraries/LibGfx/Font/Font.h @@ -75,7 +75,7 @@ public: virtual u16 weight() const = 0; virtual bool contains_glyph(u32 code_point) const = 0; - virtual bool append_glyph_path_to(Gfx::Path&, u32 glyph_id) const = 0; + virtual bool append_glyph_path_to(Gfx::DeprecatedPath&, u32 glyph_id) const = 0; virtual u32 glyph_id_for_code_point(u32 code_point) const = 0; virtual float glyph_left_bearing(u32 code_point) const = 0; virtual float glyph_width(u32 code_point) const = 0; diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp index 904663ec8fe..272573f799b 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp @@ -6,8 +6,8 @@ #include #include +#include #include -#include #include namespace OpenType { @@ -246,7 +246,7 @@ ReadonlyBytes Glyf::Glyph::program() const return m_slice.slice(instructions_start + 2, num_instructions); } -void Glyf::Glyph::append_path_impl(Gfx::Path& path, Gfx::AffineTransform const& transform) const +void Glyf::Glyph::append_path_impl(Gfx::DeprecatedPath& path, Gfx::AffineTransform const& transform) const { if (m_num_contours == 0) return; @@ -302,7 +302,7 @@ void Glyf::Glyph::append_path_impl(Gfx::Path& path, Gfx::AffineTransform const& } } -bool Glyf::Glyph::append_simple_path(Gfx::Path& path, i16 font_ascender, i16 font_descender, float x_scale, float y_scale) const +bool Glyf::Glyph::append_simple_path(Gfx::DeprecatedPath& path, i16 font_ascender, i16 font_descender, float x_scale, float y_scale) const { if (m_xmin > m_xmax) [[unlikely]] { dbgln("OpenType: Glyph has invalid xMin ({}) > xMax ({})", m_xmin, m_xmax); diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Glyf.h b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.h index b70ab4a6508..7347e3f1c2e 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Glyf.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.h @@ -11,9 +11,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -74,7 +74,7 @@ public: } template - bool append_path(Gfx::Path& path, i16 font_ascender, i16 font_descender, float x_scale, float y_scale, GlyphCb glyph_callback) const + bool append_path(Gfx::DeprecatedPath& path, i16 font_ascender, i16 font_descender, float x_scale, float y_scale, GlyphCb glyph_callback) const { switch (m_type) { case Type::Simple: @@ -118,11 +118,11 @@ public: u32 m_offset { 0 }; }; - void append_path_impl(Gfx::Path&, Gfx::AffineTransform const&) const; - bool append_simple_path(Gfx::Path&, i16 ascender, i16 descender, float x_scale, float y_scale) const; + void append_path_impl(Gfx::DeprecatedPath&, Gfx::AffineTransform const&) const; + bool append_simple_path(Gfx::DeprecatedPath&, i16 ascender, i16 descender, float x_scale, float y_scale) const; template - void resolve_composite_path_loop(Gfx::Path& path, Gfx::AffineTransform const& transform, GlyphCb glyph_callback) const + void resolve_composite_path_loop(Gfx::DeprecatedPath& path, Gfx::AffineTransform const& transform, GlyphCb glyph_callback) const { ComponentIterator component_iterator(m_slice); @@ -147,7 +147,7 @@ public: } template - bool append_composite_path(Gfx::Path& path, i16 font_ascender, float x_scale, float y_scale, GlyphCb glyph_callback) const + bool append_composite_path(Gfx::DeprecatedPath& path, i16 font_ascender, float x_scale, float y_scale, GlyphCb glyph_callback) const { auto affine = Gfx::AffineTransform() .translate(path.last_point()) diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp index 9aa3c8d484c..a68b1100a38 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Typeface.cpp @@ -526,7 +526,7 @@ Typeface::AscenderAndDescender Typeface::resolve_ascender_and_descender() const return { ascender, descender }; } -Optional Typeface::extract_and_append_glyph_path_to(Gfx::Path& path, u32 glyph_id, i16 ascender, i16 descender, float x_scale, float y_scale) const +Optional Typeface::extract_and_append_glyph_path_to(Gfx::DeprecatedPath& path, u32 glyph_id, i16 ascender, i16 descender, float x_scale, float y_scale) const { if (!m_loca.has_value() || !m_glyf.has_value()) { return {}; @@ -560,7 +560,7 @@ Optional Typeface::extract_and_append_glyph_path_to(Gfx::Path& path return {}; } -bool Typeface::append_glyph_path_to(Gfx::Path& path, u32 glyph_id, float x_scale, float y_scale) const +bool Typeface::append_glyph_path_to(Gfx::DeprecatedPath& path, u32 glyph_id, float x_scale, float y_scale) const { auto ascender_and_descender = resolve_ascender_and_descender(); return extract_and_append_glyph_path_to(path, glyph_id, ascender_and_descender.ascender, ascender_and_descender.descender, x_scale, y_scale).has_value(); diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Typeface.h b/Userland/Libraries/LibGfx/Font/OpenType/Typeface.h index e30ba49cafe..5523218fbbe 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Typeface.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Typeface.h @@ -58,7 +58,7 @@ public: virtual Gfx::ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale, float point_width, float point_height) const override; virtual float glyph_advance(u32 glyph_id, float x_scale, float y_scale, float point_width, float point_height) const override; virtual float glyphs_horizontal_kerning(u32 left_glyph_id, u32 right_glyph_id, float x_scale) const override; - virtual bool append_glyph_path_to(Gfx::Path&, u32 glyph_id, float x_scale, float y_scale) const override; + virtual bool append_glyph_path_to(Gfx::DeprecatedPath&, u32 glyph_id, float x_scale, float y_scale) const override; virtual u32 glyph_count() const override; virtual u16 units_per_em() const override; virtual u32 glyph_id_for_code_point(u32 code_point) const override; @@ -99,7 +99,7 @@ private: AscenderAndDescender resolve_ascender_and_descender() const; - Optional extract_and_append_glyph_path_to(Gfx::Path&, u32 glyph_id, i16 ascender, i16 descender, float x_scale, float y_scale) const; + Optional extract_and_append_glyph_path_to(Gfx::DeprecatedPath&, u32 glyph_id, i16 ascender, i16 descender, float x_scale, float y_scale) const; RefPtr color_bitmap(u32 glyph_id) const; diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp index e955221fb90..afa3c6cfaaa 100644 --- a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp +++ b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp @@ -63,7 +63,7 @@ ALWAYS_INLINE float ScaledFont::unicode_view_width(T const& view) const return longest_width; } -bool ScaledFont::append_glyph_path_to(Gfx::Path& path, u32 glyph_id) const +bool ScaledFont::append_glyph_path_to(Gfx::DeprecatedPath& path, u32 glyph_id) const { return m_typeface->append_glyph_path_to(path, glyph_id, m_x_scale, m_y_scale); } diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.h b/Userland/Libraries/LibGfx/Font/ScaledFont.h index 65649f90dbd..83157242280 100644 --- a/Userland/Libraries/LibGfx/Font/ScaledFont.h +++ b/Userland/Libraries/LibGfx/Font/ScaledFont.h @@ -35,7 +35,7 @@ public: virtual float glyph_or_emoji_width(Utf8CodePointIterator&) const override; virtual float glyphs_horizontal_kerning(u32 left_code_point, u32 right_code_point) const override; virtual u32 glyph_id_for_code_point(u32 code_point) const override { return m_typeface->glyph_id_for_code_point(code_point); } - virtual bool append_glyph_path_to(Gfx::Path&, u32 glyph_id) const override; + virtual bool append_glyph_path_to(Gfx::DeprecatedPath&, u32 glyph_id) const override; virtual float preferred_line_height() const override { return metrics().height() + metrics().line_gap; } virtual int x_height() const override { return m_point_height; } // FIXME: Read from font virtual u8 baseline() const override { return m_point_height; } // FIXME: Read from font diff --git a/Userland/Libraries/LibGfx/Font/Typeface.h b/Userland/Libraries/LibGfx/Font/Typeface.h index 90556bf05fd..95f2e2332c1 100644 --- a/Userland/Libraries/LibGfx/Font/Typeface.h +++ b/Userland/Libraries/LibGfx/Font/Typeface.h @@ -9,10 +9,10 @@ #include #include #include +#include #include #include #include -#include #define POINTS_PER_INCH 72.0f #define DEFAULT_DPI 96 @@ -51,7 +51,7 @@ public: virtual ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale, float point_width, float point_height) const = 0; virtual float glyph_advance(u32 glyph_id, float x_scale, float y_scale, float point_width, float point_height) const = 0; virtual float glyphs_horizontal_kerning(u32 left_glyph_id, u32 right_glyph_id, float x_scale) const = 0; - virtual bool append_glyph_path_to(Gfx::Path&, u32 glyph_id, float x_scale, float y_scale) const = 0; + virtual bool append_glyph_path_to(Gfx::DeprecatedPath&, u32 glyph_id, float x_scale, float y_scale) const = 0; virtual u32 glyph_count() const = 0; virtual u16 units_per_em() const = 0; diff --git a/Userland/Libraries/LibGfx/Forward.h b/Userland/Libraries/LibGfx/Forward.h index e08e6c7ea47..723c7450fbf 100644 --- a/Userland/Libraries/LibGfx/Forward.h +++ b/Userland/Libraries/LibGfx/Forward.h @@ -30,7 +30,7 @@ class DeprecatedPainter; class Painter; class Palette; class PaletteImpl; -class Path; +class DeprecatedPath; class ShareableBitmap; struct SystemTheme; diff --git a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp index 9836c148e90..82bd2722630 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.cpp @@ -255,9 +255,9 @@ public: return FloatLine { TRY(read_point()), TRY(read_point()) }; } - ErrorOr read_path(u32 segment_count) + ErrorOr read_path(u32 segment_count) { - Path path; + DeprecatedPath path; auto segment_lengths = TRY(FixedArray::create(segment_count)); for (auto& command_count : segment_lengths) { command_count = TRY(read_var_uint()) + 1; @@ -367,8 +367,8 @@ ErrorOr> TinyVGDecodedImageData::decode(St auto color_table = TRY(decode_color_table(stream, header.color_encoding, header.color_count)); TinyVGReader reader { stream, header, color_table.span() }; - auto rectangle_to_path = [](FloatRect const& rect) -> Path { - Path path; + auto rectangle_to_path = [](FloatRect const& rect) -> DeprecatedPath { + DeprecatedPath path; path.move_to({ rect.x(), rect.y() }); path.line_to({ rect.x() + rect.width(), rect.y() }); path.line_to({ rect.x() + rect.width(), rect.y() + rect.height() }); @@ -390,7 +390,7 @@ ErrorOr> TinyVGDecodedImageData::decode(St break; case Command::FillPolygon: { auto header = TRY(reader.read_fill_command_header(style_type)); - Path polygon; + DeprecatedPath polygon; polygon.move_to(TRY(reader.read_point())); for (u32 i = 0; i < header.count - 1; i++) polygon.line_to(TRY(reader.read_point())); @@ -413,7 +413,7 @@ ErrorOr> TinyVGDecodedImageData::decode(St } case Command::DrawLines: { auto header = TRY(reader.read_draw_command_header(style_type)); - Path path; + DeprecatedPath path; for (u32 i = 0; i < header.count; i++) { auto line = TRY(reader.read_line()); path.move_to(line.a()); @@ -425,7 +425,7 @@ ErrorOr> TinyVGDecodedImageData::decode(St case Command::DrawLineStrip: case Command::DrawLineLoop: { auto header = TRY(reader.read_draw_command_header(style_type)); - Path path; + DeprecatedPath path; path.move_to(TRY(reader.read_point())); for (u32 i = 0; i < header.count - 1; i++) path.line_to(TRY(reader.read_point())); @@ -442,7 +442,7 @@ ErrorOr> TinyVGDecodedImageData::decode(St } case Command::OutlineFillPolygon: { auto header = TRY(reader.read_outline_fill_command_header(style_type)); - Path polygon; + DeprecatedPath polygon; polygon.move_to(TRY(reader.read_point())); for (u32 i = 0; i < header.count - 1; i++) polygon.line_to(TRY(reader.read_point())); diff --git a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h index 2138ed5b7c2..044e7ee9b2d 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h +++ b/Userland/Libraries/LibGfx/ImageFormats/TinyVGLoader.h @@ -10,10 +10,10 @@ #include #include #include +#include #include #include #include -#include #include namespace Gfx { @@ -41,7 +41,7 @@ public: using Style = Variant>; struct DrawCommand { - Path path; + DeprecatedPath path; Optional