LibWeb: Delete DrawScaledBitmap display list item type

It's possible to replaces all uses of this item by wrapping Gfx::Bitmap
in Gfx::ImmutableBitmap.
This commit is contained in:
Aliaksandr Kalenik 2024-11-09 05:55:20 +01:00 committed by Alexander Kalenik
parent 698bca686e
commit 1a01a71568
Notes: github-actions[bot] 2024-11-09 20:20:58 +00:00
8 changed files with 1 additions and 39 deletions

View file

@ -58,16 +58,6 @@ struct FillRect {
void translate_by(Gfx::IntPoint const& offset) { rect.translate_by(offset); }
};
struct DrawScaledBitmap {
Gfx::IntRect dst_rect;
NonnullRefPtr<Gfx::Bitmap> bitmap;
Gfx::IntRect src_rect;
Gfx::ScalingMode scaling_mode;
[[nodiscard]] Gfx::IntRect bounding_rect() const { return dst_rect; }
void translate_by(Gfx::IntPoint const& offset) { dst_rect.translate_by(offset); }
};
struct DrawPaintingSurface {
Gfx::IntRect dst_rect;
NonnullRefPtr<Gfx::PaintingSurface> surface;
@ -427,7 +417,6 @@ struct ApplyMaskBitmap {
using Command = Variant<
DrawGlyphRun,
FillRect,
DrawScaledBitmap,
DrawPaintingSurface,
DrawScaledImmutableBitmap,
DrawRepeatedImmutableBitmap,

View file

@ -71,7 +71,6 @@ void DisplayListPlayer::execute(DisplayList& display_list)
// clang-format off
HANDLE_COMMAND(DrawGlyphRun, draw_glyph_run)
else HANDLE_COMMAND(FillRect, fill_rect)
else HANDLE_COMMAND(DrawScaledBitmap, draw_scaled_bitmap)
else HANDLE_COMMAND(DrawPaintingSurface, draw_painting_surface)
else HANDLE_COMMAND(DrawScaledImmutableBitmap, draw_scaled_immutable_bitmap)
else HANDLE_COMMAND(DrawRepeatedImmutableBitmap, draw_repeated_immutable_bitmap)

View file

@ -45,7 +45,6 @@ public:
private:
virtual void draw_glyph_run(DrawGlyphRun const&) = 0;
virtual void fill_rect(FillRect const&) = 0;
virtual void draw_scaled_bitmap(DrawScaledBitmap const&) = 0;
virtual void draw_painting_surface(DrawPaintingSurface const&) = 0;
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;

View file

@ -366,17 +366,6 @@ void DisplayListPlayerSkia::draw_painting_surface(DrawPaintingSurface const& com
canvas.drawImageRect(image, src_rect, dst_rect, to_skia_sampling_options(command.scaling_mode), &paint, SkCanvas::kStrict_SrcRectConstraint);
}
void DisplayListPlayerSkia::draw_scaled_bitmap(DrawScaledBitmap const& command)
{
auto src_rect = to_skia_rect(command.src_rect);
auto dst_rect = to_skia_rect(command.dst_rect);
auto bitmap = to_skia_bitmap(command.bitmap);
auto image = SkImages::RasterFromBitmap(bitmap);
auto& canvas = surface().canvas();
SkPaint paint;
canvas.drawImageRect(image, src_rect, dst_rect, to_skia_sampling_options(command.scaling_mode), &paint, SkCanvas::kStrict_SrcRectConstraint);
}
void DisplayListPlayerSkia::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command)
{
auto src_rect = to_skia_rect(command.src_rect);

View file

@ -33,7 +33,6 @@ private:
void draw_glyph_run(DrawGlyphRun const&) override;
void fill_rect(FillRect const&) override;
void draw_painting_surface(DrawPaintingSurface const&) override;
void draw_scaled_bitmap(DrawScaledBitmap const&) override;
void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override;
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
void add_clip_rect(AddClipRect const&) override;

View file

@ -168,18 +168,6 @@ void DisplayListRecorder::draw_rect(Gfx::IntRect const& rect, Color color, bool
.rough = rough });
}
void DisplayListRecorder::draw_scaled_bitmap(Gfx::IntRect const& dst_rect, Gfx::Bitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode)
{
if (dst_rect.is_empty())
return;
append(DrawScaledBitmap {
.dst_rect = dst_rect,
.bitmap = bitmap,
.src_rect = src_rect,
.scaling_mode = scaling_mode,
});
}
void DisplayListRecorder::draw_painting_surface(Gfx::IntRect const& dst_rect, NonnullRefPtr<Gfx::PaintingSurface> surface, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode)
{
if (dst_rect.is_empty())

View file

@ -87,7 +87,6 @@ public:
void draw_rect(Gfx::IntRect const& rect, Color color, bool rough = false);
void draw_scaled_bitmap(Gfx::IntRect const& dst_rect, Gfx::Bitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor);
void draw_painting_surface(Gfx::IntRect const& dst_rect, NonnullRefPtr<Gfx::PaintingSurface>, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor);
void draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_rect, Gfx::ImmutableBitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor);

View file

@ -130,7 +130,7 @@ void VideoPaintable::paint(PaintContext& context, PaintPhase phase) const
auto paint_frame = [&](auto const& frame) {
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), frame->rect(), video_rect.to_type<int>());
context.display_list_recorder().draw_scaled_bitmap(video_rect.to_type<int>(), *frame, frame->rect(), scaling_mode);
context.display_list_recorder().draw_scaled_immutable_bitmap(video_rect.to_type<int>(), Gfx::ImmutableBitmap::create(*frame), frame->rect(), scaling_mode);
};
auto paint_transparent_black = [&]() {