mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
LibWeb+LibGfx: Paint miter_limit for SVG and Canvas
This commit is contained in:
parent
87ec5b32b0
commit
a64902ba25
Notes:
github-actions[bot]
2025-04-14 17:01:47 +00:00
Author: https://github.com/mehrankamal
Commit: a64902ba25
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4349
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 10 additions and 7 deletions
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness) = 0;
|
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness) = 0;
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) = 0;
|
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) = 0;
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) = 0;
|
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) = 0;
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const&, Gfx::Path::JoinStyle const&) = 0;
|
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const&, Gfx::Path::JoinStyle const&, float miter_limit) = 0;
|
||||||
|
|
||||||
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule) = 0;
|
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule) = 0;
|
||||||
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) = 0;
|
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) = 0;
|
||||||
|
|
|
@ -225,7 +225,7 @@ void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& pain
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_style, ReadonlySpan<Gfx::Filter> filters, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const& cap_style, Gfx::Path::JoinStyle const& join_style)
|
void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_style, ReadonlySpan<Gfx::Filter> filters, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const& cap_style, Gfx::Path::JoinStyle const& join_style, float miter_limit)
|
||||||
{
|
{
|
||||||
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
||||||
if (thickness <= 0)
|
if (thickness <= 0)
|
||||||
|
@ -240,6 +240,7 @@ void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& pain
|
||||||
paint.setStrokeWidth(thickness);
|
paint.setStrokeWidth(thickness);
|
||||||
paint.setStrokeCap(to_skia_cap(cap_style));
|
paint.setStrokeCap(to_skia_cap(cap_style));
|
||||||
paint.setStrokeJoin(to_skia_join(join_style));
|
paint.setStrokeJoin(to_skia_join(join_style));
|
||||||
|
paint.setStrokeMiter(miter_limit);
|
||||||
paint.setBlender(to_skia_blender(compositing_and_blending_operator));
|
paint.setBlender(to_skia_blender(compositing_and_blending_operator));
|
||||||
impl().with_canvas([&](auto& canvas) {
|
impl().with_canvas([&](auto& canvas) {
|
||||||
canvas.drawPath(sk_path, paint);
|
canvas.drawPath(sk_path, paint);
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness) override;
|
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness) override;
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) override;
|
virtual void stroke_path(Gfx::Path const&, Gfx::Color, float thickness, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) override;
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) override;
|
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) override;
|
||||||
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const&, Gfx::Path::JoinStyle const&) override;
|
virtual void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const&, Gfx::Path::JoinStyle const&, float miter_limit) override;
|
||||||
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule) override;
|
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule) override;
|
||||||
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) override;
|
virtual void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) override;
|
||||||
virtual void fill_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::WindingRule) override;
|
virtual void fill_path(Gfx::Path const&, Gfx::PaintStyle const&, ReadonlySpan<Gfx::Filter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::WindingRule) override;
|
||||||
|
|
|
@ -329,10 +329,10 @@ void CanvasRenderingContext2D::stroke_internal(Gfx::Path const& path)
|
||||||
|
|
||||||
auto& state = drawing_state();
|
auto& state = drawing_state();
|
||||||
|
|
||||||
// FIXME: Honor state's miter_limit, dash_list, and line_dash_offset.
|
// FIXME: Honor state's dash_list, and line_dash_offset.
|
||||||
auto line_cap = to_gfx_cap(state.line_cap);
|
auto line_cap = to_gfx_cap(state.line_cap);
|
||||||
auto line_join = to_gfx_join(state.line_join);
|
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);
|
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);
|
||||||
|
|
||||||
did_draw(path.bounding_box());
|
did_draw(path.bounding_box());
|
||||||
}
|
}
|
||||||
|
|
|
@ -663,7 +663,7 @@ void DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const&
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: Use .miter_limit, .dash_array, .dash_offset.
|
// FIXME: Use .dash_array, .dash_offset.
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
@ -672,6 +672,7 @@ void DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const&
|
||||||
paint.setStrokeCap(to_skia_cap(command.cap_style));
|
paint.setStrokeCap(to_skia_cap(command.cap_style));
|
||||||
paint.setStrokeJoin(to_skia_join(command.join_style));
|
paint.setStrokeJoin(to_skia_join(command.join_style));
|
||||||
paint.setColor(to_skia_color(command.color));
|
paint.setColor(to_skia_color(command.color));
|
||||||
|
paint.setStrokeMiter(command.miter_limit);
|
||||||
auto path = to_skia_path(command.path);
|
auto path = to_skia_path(command.path);
|
||||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
|
@ -683,7 +684,7 @@ void DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsingPaintSt
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: Use .miter_limit, .dash_array, .dash_offset.
|
// FIXME: Use .dash_array, .dash_offset.
|
||||||
auto path = to_skia_path(command.path);
|
auto path = to_skia_path(command.path);
|
||||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
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>());
|
auto paint = paint_style_to_skia_paint(*command.paint_style, command.bounding_rect().to_type<float>());
|
||||||
|
@ -693,6 +694,7 @@ void DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsingPaintSt
|
||||||
paint.setStrokeWidth(command.thickness);
|
paint.setStrokeWidth(command.thickness);
|
||||||
paint.setStrokeCap(to_skia_cap(command.cap_style));
|
paint.setStrokeCap(to_skia_cap(command.cap_style));
|
||||||
paint.setStrokeJoin(to_skia_join(command.join_style));
|
paint.setStrokeJoin(to_skia_join(command.join_style));
|
||||||
|
paint.setStrokeMiter(command.miter_limit);
|
||||||
surface().canvas().drawPath(path, paint);
|
surface().canvas().drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Add table
Add a link
Reference in a new issue