mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
LibGfx: Let Painter care about TinyVG transforms
This helps us with non-uniform scales, and makes things simple
This commit is contained in:
parent
0b1c7d6af2
commit
ea469fbeab
Notes:
github-actions[bot]
2024-12-14 22:30:42 +00:00
Author: https://github.com/shlyakpavel
Commit: ea469fbeab
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2717
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta
5 changed files with 19 additions and 31 deletions
|
@ -471,29 +471,25 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
|
|||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) TinyVGDecodedImageData({ header.width, header.height }, move(draw_commands))));
|
||||
}
|
||||
|
||||
void TinyVGDecodedImageData::draw_transformed(Painter& painter, AffineTransform transform) const
|
||||
void TinyVGDecodedImageData::draw(Painter& painter) const
|
||||
{
|
||||
// FIXME: Correctly handle non-uniform scales.
|
||||
auto scale = max(transform.x_scale(), transform.y_scale());
|
||||
for (auto const& command : draw_commands()) {
|
||||
auto draw_path = command.path.copy_transformed(transform);
|
||||
auto draw_path = command.path;
|
||||
if (command.fill.has_value()) {
|
||||
auto fill_path = draw_path;
|
||||
fill_path.close_all_subpaths();
|
||||
command.fill->visit(
|
||||
[&](Color color) { painter.fill_path(fill_path, color, WindingRule::EvenOdd); },
|
||||
[&](NonnullRefPtr<SVGGradientPaintStyle> style) {
|
||||
const_cast<SVGGradientPaintStyle&>(*style).set_gradient_transform(transform);
|
||||
[&](NonnullRefPtr<SVGGradientPaintStyle> const& style) {
|
||||
painter.fill_path(fill_path, style, 1.0f, WindingRule::EvenOdd);
|
||||
});
|
||||
}
|
||||
|
||||
if (command.stroke.has_value()) {
|
||||
command.stroke->visit(
|
||||
[&](Color color) { painter.stroke_path(draw_path, color, command.stroke_width * scale); },
|
||||
[&](NonnullRefPtr<SVGGradientPaintStyle> style) {
|
||||
const_cast<SVGGradientPaintStyle&>(*style).set_gradient_transform(transform);
|
||||
painter.stroke_path(draw_path, style, command.stroke_width * scale, 1.0f);
|
||||
[&](Color color) { painter.stroke_path(draw_path, color, command.stroke_width); },
|
||||
[&](NonnullRefPtr<SVGGradientPaintStyle> const& style) {
|
||||
painter.stroke_path(draw_path, style, command.stroke_width, 1.0f);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue