mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 01:56:38 +00:00
LibWeb: Add and use to_skia_point()
helper
This commit is contained in:
parent
2c8267babf
commit
386e151f96
Notes:
sideshowbarker
2024-07-17 18:23:22 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 386e151f96
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/574
1 changed files with 12 additions and 7 deletions
|
@ -205,6 +205,11 @@ DisplayListPlayerSkia::~DisplayListPlayerSkia()
|
||||||
m_flush_context();
|
m_flush_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SkPoint to_skia_point(auto const& point)
|
||||||
|
{
|
||||||
|
return SkPoint::Make(point.x(), point.y());
|
||||||
|
}
|
||||||
|
|
||||||
static SkRect to_skia_rect(auto const& rect)
|
static SkRect to_skia_rect(auto const& rect)
|
||||||
{
|
{
|
||||||
return SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
|
return SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
|
@ -602,8 +607,8 @@ CommandResult DisplayListPlayerSkia::paint_linear_gradient(PaintLinearGradient c
|
||||||
auto top = rect.center().translated(0, length / 2);
|
auto top = rect.center().translated(0, length / 2);
|
||||||
|
|
||||||
Array<SkPoint, 2> points;
|
Array<SkPoint, 2> points;
|
||||||
points[0] = SkPoint::Make(top.x(), top.y());
|
points[0] = to_skia_point(top);
|
||||||
points[1] = SkPoint::Make(bottom.x(), bottom.y());
|
points[1] = to_skia_point(bottom);
|
||||||
|
|
||||||
auto center = to_skia_rect(rect).center();
|
auto center = to_skia_rect(rect).center();
|
||||||
SkMatrix matrix;
|
SkMatrix matrix;
|
||||||
|
@ -796,8 +801,8 @@ SkPaint paint_style_to_skia_paint(Painting::SVGGradientPaintStyle const& paint_s
|
||||||
end_point.translate_by(bounding_rect.location());
|
end_point.translate_by(bounding_rect.location());
|
||||||
|
|
||||||
Array<SkPoint, 2> points;
|
Array<SkPoint, 2> points;
|
||||||
points[0] = SkPoint::Make(start_point.x(), start_point.y());
|
points[0] = to_skia_point(start_point);
|
||||||
points[1] = SkPoint::Make(end_point.x(), end_point.y());
|
points[1] = to_skia_point(end_point);
|
||||||
|
|
||||||
auto const& color_stops = linear_gradient_paint_style.color_stops();
|
auto const& color_stops = linear_gradient_paint_style.color_stops();
|
||||||
|
|
||||||
|
@ -901,8 +906,8 @@ CommandResult DisplayListPlayerSkia::draw_line(DrawLine const& command)
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return CommandResult::Continue;
|
return CommandResult::Continue;
|
||||||
|
|
||||||
auto from = SkPoint::Make(command.from.x(), command.from.y());
|
auto from = to_skia_point(command.from);
|
||||||
auto to = SkPoint::Make(command.to.x(), command.to.y());
|
auto to = to_skia_point(command.to);
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setStrokeWidth(command.thickness);
|
paint.setStrokeWidth(command.thickness);
|
||||||
|
@ -1084,7 +1089,7 @@ CommandResult DisplayListPlayerSkia::paint_radial_gradient(PaintRadialGradient c
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const& rect = command.rect;
|
auto const& rect = command.rect;
|
||||||
auto center = SkPoint::Make(command.center.x(), command.center.y());
|
auto center = to_skia_point(command.center);
|
||||||
auto radius = command.size.height();
|
auto radius = command.size.height();
|
||||||
auto shader = SkGradientShader::MakeRadial(center, radius, colors.data(), positions.data(), positions.size(), SkTileMode::kClamp, 0);
|
auto shader = SkGradientShader::MakeRadial(center, radius, colors.data(), positions.data(), positions.size(), SkTileMode::kClamp, 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue