mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-03 06:39:07 +00:00
LibGfx: Use Skia for TinyVG rendering
This commit is contained in:
parent
331f26a88b
commit
39c500ec7c
Notes:
github-actions[bot]
2024-11-25 11:15:23 +00:00
Author: https://github.com/shlyakpavel
Commit: 39c500ec7c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2512
Reviewed-by: https://github.com/gmta ✅
5 changed files with 51 additions and 31 deletions
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/DeprecatedPainter.h>
|
||||
#include <LibGfx/PainterSkia.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <UI/Qt/StringUtils.h>
|
||||
#include <UI/Qt/TVGIconEngine.h>
|
||||
|
||||
|
@ -34,15 +35,32 @@ QPixmap TVGIconEngine::pixmap(QSize const& size, QIcon::Mode mode, QIcon::State
|
|||
if (QPixmapCache::find(key, &pixmap))
|
||||
return pixmap;
|
||||
auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { size.width(), size.height() }));
|
||||
Gfx::DeprecatedPainter painter { *bitmap };
|
||||
m_image_data->draw_into(painter, bitmap->rect());
|
||||
|
||||
auto painter = Gfx::PainterSkia::create(bitmap);
|
||||
painter->clear_rect(bitmap->rect().to_type<float>(), Gfx::Color::Transparent);
|
||||
|
||||
m_image_data->draw_into(*painter, bitmap->rect());
|
||||
|
||||
for (auto const& filter : m_filters) {
|
||||
if (filter->mode() == mode) {
|
||||
painter.blit_filtered({}, *bitmap, bitmap->rect(), filter->function(), false);
|
||||
for (int y = 0; y < bitmap->height(); ++y) {
|
||||
for (int x = 0; x < bitmap->width(); ++x) {
|
||||
auto original_color = bitmap->get_pixel(x, y);
|
||||
auto filtered_color = filter->function()(original_color);
|
||||
bitmap->set_pixel(x, y, filtered_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
QImage qimage { bitmap->scanline_u8(0), bitmap->width(), bitmap->height(), QImage::Format::Format_ARGB32 };
|
||||
|
||||
QImage qimage(
|
||||
bitmap->scanline_u8(0),
|
||||
bitmap->width(),
|
||||
bitmap->height(),
|
||||
static_cast<qsizetype>(bitmap->pitch()),
|
||||
QImage::Format::Format_ARGB32);
|
||||
|
||||
pixmap = QPixmap::fromImage(qimage);
|
||||
if (!pixmap.isNull())
|
||||
QPixmapCache::insert(key, pixmap);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue