From 12968ff025bb7bdff01af9f2a40acdf5ddaefb1f Mon Sep 17 00:00:00 2001 From: Mehran Kamal <29648490+mehrankamal@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:25:41 +0500 Subject: [PATCH] LibGfx: Move to_skia_cap, to_skia_join to SkiaUtils --- Libraries/LibGfx/SkiaUtils.h | 27 +++++++++++++++++++ .../LibWeb/Painting/DisplayListPlayerSkia.cpp | 26 ------------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Libraries/LibGfx/SkiaUtils.h b/Libraries/LibGfx/SkiaUtils.h index f5f9f5c796f..4d484682fc1 100644 --- a/Libraries/LibGfx/SkiaUtils.h +++ b/Libraries/LibGfx/SkiaUtils.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,32 @@ constexpr SkColor to_skia_color(Gfx::Color const& color) return SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue()); } +constexpr SkPaint::Join to_skia_join(Gfx::Path::JoinStyle const& join_style) +{ + switch (join_style) { + case Gfx::Path::JoinStyle::Round: + return SkPaint::kRound_Join; + case Gfx::Path::JoinStyle::Bevel: + return SkPaint::kBevel_Join; + case Gfx::Path::JoinStyle::Miter: + return SkPaint::kMiter_Join; + } + VERIFY_NOT_REACHED(); +} + +constexpr SkPaint::Cap to_skia_cap(Gfx::Path::CapStyle const& cap_style) +{ + switch (cap_style) { + case Gfx::Path::CapStyle::Butt: + return SkPaint::kButt_Cap; + case Gfx::Path::CapStyle::Round: + return SkPaint::kRound_Cap; + case Gfx::Path::CapStyle::Square: + return SkPaint::kSquare_Cap; + } + VERIFY_NOT_REACHED(); +} + constexpr SkColor4f to_skia_color4f(Color const& color) { return { diff --git a/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp b/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp index da0479d07ea..0be7022ba5a 100644 --- a/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp +++ b/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp @@ -651,32 +651,6 @@ void DisplayListPlayerSkia::fill_path_using_paint_style(FillPathUsingPaintStyle surface().canvas().drawPath(path, paint); } -static SkPaint::Cap to_skia_cap(Gfx::Path::CapStyle const& cap_style) -{ - switch (cap_style) { - case Gfx::Path::CapStyle::Butt: - return SkPaint::kButt_Cap; - case Gfx::Path::CapStyle::Round: - return SkPaint::kRound_Cap; - case Gfx::Path::CapStyle::Square: - return SkPaint::kSquare_Cap; - } - VERIFY_NOT_REACHED(); -} - -static SkPaint::Join to_skia_join(Gfx::Path::JoinStyle const& join_style) -{ - switch (join_style) { - case Gfx::Path::JoinStyle::Round: - return SkPaint::kRound_Join; - case Gfx::Path::JoinStyle::Bevel: - return SkPaint::kBevel_Join; - case Gfx::Path::JoinStyle::Miter: - return SkPaint::kMiter_Join; - } - VERIFY_NOT_REACHED(); -} - void DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const& command) { // Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.