LibGfx: Use Skia for TinyVG rendering

This commit is contained in:
Pavel Shliak 2024-11-23 03:08:07 +04:00 committed by Jelle Raaijmakers
commit 39c500ec7c
Notes: github-actions[bot] 2024-11-25 11:15:23 +00:00
5 changed files with 51 additions and 31 deletions

View file

@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/DeprecatedPainter.h>
#include <LibGfx/PainterSkia.h>
#include <LibGfx/VectorGraphic.h>
namespace Gfx {
void VectorGraphic::draw_into(DeprecatedPainter& painter, IntRect const& dest, AffineTransform transform) const
void VectorGraphic::draw_into(Painter& painter, IntRect const& dest, AffineTransform transform) const
{
// Apply the transform then center within destination rectangle (this ignores any translation from the transform):
// This allows you to easily rotate or flip the image before painting.
@ -21,14 +21,14 @@ void VectorGraphic::draw_into(DeprecatedPainter& painter, IntRect const& dest, A
.multiply(AffineTransform {}.scale(scale, scale))
.multiply(AffineTransform {}.translate(-transformed_rect.location()))
.multiply(transform);
return draw_transformed(painter, view_transform);
draw_transformed(painter, view_transform);
}
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> VectorGraphic::bitmap(IntSize size, AffineTransform transform) const
{
auto bitmap = TRY(Bitmap::create(Gfx::BitmapFormat::BGRA8888, size));
DeprecatedPainter painter { *bitmap };
draw_into(painter, IntRect { {}, size }, transform);
auto painter = PainterSkia::create(bitmap);
draw_into(*painter, IntRect { {}, size }, transform);
return bitmap;
}