mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb+LibGfx: Paint dash array and offset for SVG and Canvas
This commit is contained in:
parent
a64902ba25
commit
6ba60188b4
Notes:
github-actions[bot]
2025-04-14 17:01:40 +00:00
Author: https://github.com/mehrankamal
Commit: 6ba60188b4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4349
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 16 additions and 7 deletions
|
|
@ -329,10 +329,16 @@ void CanvasRenderingContext2D::stroke_internal(Gfx::Path const& path)
|
|||
|
||||
auto& state = drawing_state();
|
||||
|
||||
// FIXME: Honor state's dash_list, and line_dash_offset.
|
||||
auto line_cap = to_gfx_cap(state.line_cap);
|
||||
auto line_join = to_gfx_join(state.line_join);
|
||||
painter->stroke_path(path, state.stroke_style.to_gfx_paint_style(), state.filters, state.line_width, state.global_alpha, state.current_compositing_and_blending_operator, line_cap, line_join, state.miter_limit);
|
||||
// FIXME: Need a Vector<float> for rendering dash_array, but state.dash_list is Vector<double>.
|
||||
// Maybe possible to avoid creating copies?
|
||||
auto dash_array = Vector<float> {};
|
||||
dash_array.ensure_capacity(state.dash_list.size());
|
||||
for (auto const& dash : state.dash_list) {
|
||||
dash_array.append(static_cast<float>(dash));
|
||||
}
|
||||
painter->stroke_path(path, state.stroke_style.to_gfx_paint_style(), state.filters, state.line_width, state.global_alpha, state.current_compositing_and_blending_operator, line_cap, line_join, state.miter_limit, dash_array, state.line_dash_offset);
|
||||
|
||||
did_draw(path.bounding_box());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -663,7 +663,6 @@ void DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const&
|
|||
if (!command.thickness)
|
||||
return;
|
||||
|
||||
// FIXME: Use .dash_array, .dash_offset.
|
||||
auto& canvas = surface().canvas();
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
|
|
@ -673,6 +672,7 @@ void DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const&
|
|||
paint.setStrokeJoin(to_skia_join(command.join_style));
|
||||
paint.setColor(to_skia_color(command.color));
|
||||
paint.setStrokeMiter(command.miter_limit);
|
||||
paint.setPathEffect(SkDashPathEffect::Make(command.dash_array.data(), command.dash_array.size(), command.dash_offset));
|
||||
auto path = to_skia_path(command.path);
|
||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||
canvas.drawPath(path, paint);
|
||||
|
|
@ -684,7 +684,6 @@ void DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsingPaintSt
|
|||
if (!command.thickness)
|
||||
return;
|
||||
|
||||
// FIXME: Use .dash_array, .dash_offset.
|
||||
auto path = to_skia_path(command.path);
|
||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||
auto paint = paint_style_to_skia_paint(*command.paint_style, command.bounding_rect().to_type<float>());
|
||||
|
|
@ -695,6 +694,7 @@ void DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsingPaintSt
|
|||
paint.setStrokeCap(to_skia_cap(command.cap_style));
|
||||
paint.setStrokeJoin(to_skia_join(command.join_style));
|
||||
paint.setStrokeMiter(command.miter_limit);
|
||||
paint.setPathEffect(SkDashPathEffect::Make(command.dash_array.data(), command.dash_array.size(), command.dash_offset));
|
||||
surface().canvas().drawPath(path, paint);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue