diff --git a/Libraries/LibWeb/Painting/Command.h b/Libraries/LibWeb/Painting/Command.h index 0a8dd6024cd..c6da54cff80 100644 --- a/Libraries/LibWeb/Painting/Command.h +++ b/Libraries/LibWeb/Painting/Command.h @@ -405,7 +405,7 @@ struct ApplyTransform { struct ApplyMaskBitmap { Gfx::IntPoint origin; - NonnullRefPtr bitmap; + NonnullRefPtr bitmap; Gfx::Bitmap::MaskKind kind; void translate_by(Gfx::IntPoint const& offset) diff --git a/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp b/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp index 6508afe883f..1b46ed207ef 100644 --- a/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp +++ b/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp @@ -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(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) { diff --git a/Libraries/LibWeb/Painting/DisplayListRecorder.cpp b/Libraries/LibWeb/Painting/DisplayListRecorder.cpp index 9bf413274b7..8a2c03c88b1 100644 --- a/Libraries/LibWeb/Painting/DisplayListRecorder.cpp +++ b/Libraries/LibWeb/Painting/DisplayListRecorder.cpp @@ -406,7 +406,7 @@ void DisplayListRecorder::apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatr }); } -void DisplayListRecorder::apply_mask_bitmap(Gfx::IntPoint origin, Gfx::Bitmap const& bitmap, Gfx::Bitmap::MaskKind kind) +void DisplayListRecorder::apply_mask_bitmap(Gfx::IntPoint origin, Gfx::ImmutableBitmap const& bitmap, Gfx::Bitmap::MaskKind kind) { append(ApplyMaskBitmap { .origin = origin, diff --git a/Libraries/LibWeb/Painting/DisplayListRecorder.h b/Libraries/LibWeb/Painting/DisplayListRecorder.h index c3e6b1cb26f..0883408220f 100644 --- a/Libraries/LibWeb/Painting/DisplayListRecorder.h +++ b/Libraries/LibWeb/Painting/DisplayListRecorder.h @@ -141,7 +141,7 @@ public: void apply_opacity(float opacity); void apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatrix4x4); - void apply_mask_bitmap(Gfx::IntPoint origin, Gfx::Bitmap const&, Gfx::Bitmap::MaskKind); + void apply_mask_bitmap(Gfx::IntPoint origin, Gfx::ImmutableBitmap const&, Gfx::Bitmap::MaskKind); DisplayListRecorder(DisplayList&); ~DisplayListRecorder(); diff --git a/Libraries/LibWeb/Painting/PaintableBox.h b/Libraries/LibWeb/Painting/PaintableBox.h index 8a1c0180cf0..53db1b4185a 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.h +++ b/Libraries/LibWeb/Painting/PaintableBox.h @@ -37,7 +37,7 @@ public: virtual Optional get_masking_area() const; virtual Optional get_mask_type() const { return {}; } - virtual RefPtr calculate_mask(PaintContext&, CSSPixelRect const&) const { return {}; } + virtual RefPtr calculate_mask(PaintContext&, CSSPixelRect const&) const { return {}; } Layout::NodeWithStyleAndBoxModelMetrics& layout_node_with_style_and_box_metrics() { return static_cast(Paintable::layout_node()); } Layout::NodeWithStyleAndBoxModelMetrics const& layout_node_with_style_and_box_metrics() const { return static_cast(Paintable::layout_node()); } diff --git a/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h b/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h index 6457f249403..6272882a9f3 100644 --- a/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h +++ b/Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h @@ -29,7 +29,7 @@ public: virtual JS::GCPtr dom_node_of_svg() const override { return dom_node(); } virtual Optional get_masking_area() const override { return get_masking_area_of_svg(); } virtual Optional get_mask_type() const override { return get_mask_type_of_svg(); } - virtual RefPtr calculate_mask(PaintContext& paint_context, CSSPixelRect const& masking_area) const override { return calculate_mask_of_svg(paint_context, masking_area); } + virtual RefPtr calculate_mask(PaintContext& paint_context, CSSPixelRect const& masking_area) const override { return calculate_mask_of_svg(paint_context, masking_area); } protected: SVGForeignObjectPaintable(Layout::SVGForeignObjectBox const&); diff --git a/Libraries/LibWeb/Painting/SVGGraphicsPaintable.h b/Libraries/LibWeb/Painting/SVGGraphicsPaintable.h index 097a446a3bd..b45b69fac3a 100644 --- a/Libraries/LibWeb/Painting/SVGGraphicsPaintable.h +++ b/Libraries/LibWeb/Painting/SVGGraphicsPaintable.h @@ -54,7 +54,7 @@ public: virtual JS::GCPtr dom_node_of_svg() const override { return dom_node(); } virtual Optional get_masking_area() const override { return get_masking_area_of_svg(); } virtual Optional get_mask_type() const override { return get_mask_type_of_svg(); } - virtual RefPtr calculate_mask(PaintContext& paint_context, CSSPixelRect const& masking_area) const override { return calculate_mask_of_svg(paint_context, masking_area); } + virtual RefPtr calculate_mask(PaintContext& paint_context, CSSPixelRect const& masking_area) const override { return calculate_mask_of_svg(paint_context, masking_area); } void set_computed_transforms(ComputedTransforms computed_transforms) { diff --git a/Libraries/LibWeb/Painting/SVGMaskable.cpp b/Libraries/LibWeb/Painting/SVGMaskable.cpp index e53ddd28a31..22e781ff170 100644 --- a/Libraries/LibWeb/Painting/SVGMaskable.cpp +++ b/Libraries/LibWeb/Painting/SVGMaskable.cpp @@ -73,7 +73,7 @@ Optional SVGMaskable::get_mask_type_of_svg() const return {}; } -RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& context, CSSPixelRect const& masking_area) const +RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& context, CSSPixelRect const& masking_area) const { auto const& graphics_element = verify_cast(*dom_node_of_svg()); auto mask_rect = context.enclosing_device_rect(masking_area); @@ -108,7 +108,7 @@ RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& context, CS if (!mask_bitmap) mask_bitmap = clip_bitmap; } - return mask_bitmap; + return Gfx::ImmutableBitmap::create(*mask_bitmap); } } diff --git a/Libraries/LibWeb/Painting/SVGMaskable.h b/Libraries/LibWeb/Painting/SVGMaskable.h index 4a4628cf6f2..22a16cebf41 100644 --- a/Libraries/LibWeb/Painting/SVGMaskable.h +++ b/Libraries/LibWeb/Painting/SVGMaskable.h @@ -19,7 +19,7 @@ public: Optional get_masking_area_of_svg() const; Optional get_mask_type_of_svg() const; - RefPtr calculate_mask_of_svg(PaintContext&, CSSPixelRect const& masking_area) const; + RefPtr calculate_mask_of_svg(PaintContext&, CSSPixelRect const& masking_area) const; }; }