LibGfx: Move to_skia_cap, to_skia_join to SkiaUtils

This commit is contained in:
Mehran Kamal 2025-03-14 21:25:41 +05:00 committed by Alexander Kalenik
parent 23151de217
commit 12968ff025
Notes: github-actions[bot] 2025-03-15 13:03:33 +00:00
2 changed files with 27 additions and 26 deletions

View file

@ -18,6 +18,7 @@
#include <core/SkColor.h>
#include <core/SkColorType.h>
#include <core/SkImageFilter.h>
#include <core/SkPaint.h>
#include <core/SkPath.h>
#include <core/SkSamplingOptions.h>
@ -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 {

View file

@ -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.