mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +00:00
LibWeb: Save Gfx::ImmutableBitmap in ApplyBitmapMask display list item
This allows to delete duplicated code between DisplayListPlayerSkia.cpp and ImmutableBitmap.cpp responsible for wrapping Gfx::Bitmap in SkImage.
This commit is contained in:
parent
e02ca0480f
commit
68f58b23ce
Notes:
github-actions[bot]
2024-11-10 16:21:25 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 68f58b23ce
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2261
9 changed files with 10 additions and 45 deletions
|
@ -239,40 +239,6 @@ static SkRRect to_skia_rrect(auto const& rect, CornerRadii const& corner_radii)
|
|||
return rrect;
|
||||
}
|
||||
|
||||
static SkColorType to_skia_color_type(Gfx::BitmapFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case Gfx::BitmapFormat::Invalid:
|
||||
return kUnknown_SkColorType;
|
||||
case Gfx::BitmapFormat::BGRA8888:
|
||||
case Gfx::BitmapFormat::BGRx8888:
|
||||
return kBGRA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBA8888:
|
||||
return kRGBA_8888_SkColorType;
|
||||
case Gfx::BitmapFormat::RGBx8888:
|
||||
return kRGB_888x_SkColorType;
|
||||
default:
|
||||
return kUnknown_SkColorType;
|
||||
}
|
||||
}
|
||||
|
||||
static SkBitmap to_skia_bitmap(Gfx::Bitmap const& bitmap)
|
||||
{
|
||||
SkColorType color_type = to_skia_color_type(bitmap.format());
|
||||
SkAlphaType alpha_type = bitmap.alpha_type() == Gfx::AlphaType::Premultiplied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
||||
SkImageInfo image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type);
|
||||
SkBitmap sk_bitmap;
|
||||
sk_bitmap.setInfo(image_info);
|
||||
|
||||
if (!sk_bitmap.installPixels(image_info, const_cast<Gfx::ARGB32*>(bitmap.begin()), bitmap.width() * 4)) {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
sk_bitmap.setImmutable();
|
||||
|
||||
return sk_bitmap;
|
||||
}
|
||||
|
||||
static SkMatrix to_skia_matrix(Gfx::AffineTransform const& affine_transform)
|
||||
{
|
||||
SkScalar affine[6];
|
||||
|
@ -1151,8 +1117,7 @@ void DisplayListPlayerSkia::apply_mask_bitmap(ApplyMaskBitmap const& command)
|
|||
{
|
||||
auto& canvas = surface().canvas();
|
||||
|
||||
auto sk_bitmap = to_skia_bitmap(*command.bitmap);
|
||||
auto mask_image = SkImages::RasterFromBitmap(sk_bitmap);
|
||||
auto const* mask_image = command.bitmap->sk_image();
|
||||
|
||||
char const* sksl_shader = nullptr;
|
||||
if (command.kind == Gfx::Bitmap::MaskKind::Luminance) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue