10
10
#include < AK/LEB128.h>
11
11
#include < AK/MemoryStream.h>
12
12
#include < AK/Variant.h>
13
- #include < LibGfx/AntiAliasingPainter.h>
14
- #include < LibGfx/DeprecatedPainter.h>
15
13
#include < LibGfx/ImageFormats/TinyVGLoader.h>
16
14
#include < LibGfx/Line.h>
15
+ #include < LibGfx/Painter.h>
16
+ #include < LibGfx/Path.h>
17
17
#include < LibGfx/Point.h>
18
18
19
19
namespace Gfx {
@@ -254,9 +254,9 @@ class TinyVGReader {
254
254
return FloatLine { TRY (read_point ()), TRY (read_point ()) };
255
255
}
256
256
257
- ErrorOr<DeprecatedPath > read_path (u32 segment_count)
257
+ ErrorOr<Path > read_path (u32 segment_count)
258
258
{
259
- DeprecatedPath path;
259
+ Path path;
260
260
auto segment_lengths = TRY (FixedArray<u32>::create (segment_count));
261
261
for (auto & command_count : segment_lengths) {
262
262
command_count = TRY (read_var_uint ()) + 1 ;
@@ -366,8 +366,8 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
366
366
auto color_table = TRY (decode_color_table (stream, header.color_encoding , header.color_count ));
367
367
TinyVGReader reader { stream, header, color_table.span () };
368
368
369
- auto rectangle_to_path = [](FloatRect const & rect) -> DeprecatedPath {
370
- DeprecatedPath path;
369
+ auto rectangle_to_path = [](FloatRect const & rect) -> Path {
370
+ Path path;
371
371
path.move_to ({ rect.x (), rect.y () });
372
372
path.line_to ({ rect.x () + rect.width (), rect.y () });
373
373
path.line_to ({ rect.x () + rect.width (), rect.y () + rect.height () });
@@ -389,7 +389,7 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
389
389
break ;
390
390
case Command::FillPolygon: {
391
391
auto header = TRY (reader.read_fill_command_header (style_type));
392
- DeprecatedPath polygon;
392
+ Path polygon;
393
393
polygon.move_to (TRY (reader.read_point ()));
394
394
for (u32 i = 0 ; i < header.count - 1 ; i++)
395
395
polygon.line_to (TRY (reader.read_point ()));
@@ -412,7 +412,7 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
412
412
}
413
413
case Command::DrawLines: {
414
414
auto header = TRY (reader.read_draw_command_header (style_type));
415
- DeprecatedPath path;
415
+ Path path;
416
416
for (u32 i = 0 ; i < header.count ; i++) {
417
417
auto line = TRY (reader.read_line ());
418
418
path.move_to (line.a ());
@@ -424,7 +424,7 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
424
424
case Command::DrawLineStrip:
425
425
case Command::DrawLineLoop: {
426
426
auto header = TRY (reader.read_draw_command_header (style_type));
427
- DeprecatedPath path;
427
+ Path path;
428
428
path.move_to (TRY (reader.read_point ()));
429
429
for (u32 i = 0 ; i < header.count - 1 ; i++)
430
430
path.line_to (TRY (reader.read_point ()));
@@ -441,7 +441,7 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
441
441
}
442
442
case Command::OutlineFillPolygon: {
443
443
auto header = TRY (reader.read_outline_fill_command_header (style_type));
444
- DeprecatedPath polygon;
444
+ Path polygon;
445
445
polygon.move_to (TRY (reader.read_point ()));
446
446
for (u32 i = 0 ; i < header.count - 1 ; i++)
447
447
polygon.line_to (TRY (reader.read_point ()));
@@ -471,29 +471,29 @@ ErrorOr<NonnullRefPtr<TinyVGDecodedImageData>> TinyVGDecodedImageData::decode(St
471
471
return TRY (adopt_nonnull_ref_or_enomem (new (nothrow) TinyVGDecodedImageData ({ header.width , header.height }, move (draw_commands))));
472
472
}
473
473
474
- void TinyVGDecodedImageData::draw_transformed (DeprecatedPainter & painter, AffineTransform transform) const
474
+ void TinyVGDecodedImageData::draw_transformed (Painter & painter, AffineTransform transform) const
475
475
{
476
476
// FIXME: Correctly handle non-uniform scales.
477
477
auto scale = max (transform.x_scale (), transform.y_scale ());
478
- AntiAliasingPainter aa_painter { painter };
479
478
for (auto const & command : draw_commands ()) {
480
479
auto draw_path = command.path .copy_transformed (transform);
481
480
if (command.fill .has_value ()) {
482
481
auto fill_path = draw_path;
483
482
fill_path.close_all_subpaths ();
484
483
command.fill ->visit (
485
- [&](Color color) { aa_painter .fill_path (fill_path, color, WindingRule::EvenOdd); },
484
+ [&](Color color) { painter .fill_path (fill_path, color, WindingRule::EvenOdd); },
486
485
[&](NonnullRefPtr<SVGGradientPaintStyle> style) {
487
486
const_cast <SVGGradientPaintStyle&>(*style).set_gradient_transform (transform);
488
- aa_painter .fill_path (fill_path, style, 1 .0f , WindingRule::EvenOdd);
487
+ painter .fill_path (fill_path, style, 1 .0f , WindingRule::EvenOdd);
489
488
});
490
489
}
490
+
491
491
if (command.stroke .has_value ()) {
492
492
command.stroke ->visit (
493
- [&](Color color) { aa_painter .stroke_path (draw_path, color, command.stroke_width * scale); },
493
+ [&](Color color) { painter .stroke_path (draw_path, color, command.stroke_width * scale); },
494
494
[&](NonnullRefPtr<SVGGradientPaintStyle> style) {
495
495
const_cast <SVGGradientPaintStyle&>(*style).set_gradient_transform (transform);
496
- aa_painter .stroke_path (draw_path, style, command.stroke_width * scale);
496
+ painter .stroke_path (draw_path, style, command.stroke_width * scale, 1 . 0f );
497
497
});
498
498
}
499
499
}
0 commit comments