mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 04:52:23 +00:00
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:
parent
698bca686e
commit
1a01a71568
Notes:
github-actions[bot]
2024-11-09 20:20:58 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 1a01a71568
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2254
8 changed files with 1 additions and 39 deletions
|
@ -58,16 +58,6 @@ struct FillRect {
|
||||||
void translate_by(Gfx::IntPoint const& offset) { rect.translate_by(offset); }
|
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 {
|
struct DrawPaintingSurface {
|
||||||
Gfx::IntRect dst_rect;
|
Gfx::IntRect dst_rect;
|
||||||
NonnullRefPtr<Gfx::PaintingSurface> surface;
|
NonnullRefPtr<Gfx::PaintingSurface> surface;
|
||||||
|
@ -427,7 +417,6 @@ struct ApplyMaskBitmap {
|
||||||
using Command = Variant<
|
using Command = Variant<
|
||||||
DrawGlyphRun,
|
DrawGlyphRun,
|
||||||
FillRect,
|
FillRect,
|
||||||
DrawScaledBitmap,
|
|
||||||
DrawPaintingSurface,
|
DrawPaintingSurface,
|
||||||
DrawScaledImmutableBitmap,
|
DrawScaledImmutableBitmap,
|
||||||
DrawRepeatedImmutableBitmap,
|
DrawRepeatedImmutableBitmap,
|
||||||
|
|
|
@ -71,7 +71,6 @@ void DisplayListPlayer::execute(DisplayList& display_list)
|
||||||
// clang-format off
|
// clang-format off
|
||||||
HANDLE_COMMAND(DrawGlyphRun, draw_glyph_run)
|
HANDLE_COMMAND(DrawGlyphRun, draw_glyph_run)
|
||||||
else HANDLE_COMMAND(FillRect, fill_rect)
|
else HANDLE_COMMAND(FillRect, fill_rect)
|
||||||
else HANDLE_COMMAND(DrawScaledBitmap, draw_scaled_bitmap)
|
|
||||||
else HANDLE_COMMAND(DrawPaintingSurface, draw_painting_surface)
|
else HANDLE_COMMAND(DrawPaintingSurface, draw_painting_surface)
|
||||||
else HANDLE_COMMAND(DrawScaledImmutableBitmap, draw_scaled_immutable_bitmap)
|
else HANDLE_COMMAND(DrawScaledImmutableBitmap, draw_scaled_immutable_bitmap)
|
||||||
else HANDLE_COMMAND(DrawRepeatedImmutableBitmap, draw_repeated_immutable_bitmap)
|
else HANDLE_COMMAND(DrawRepeatedImmutableBitmap, draw_repeated_immutable_bitmap)
|
||||||
|
|
|
@ -45,7 +45,6 @@ public:
|
||||||
private:
|
private:
|
||||||
virtual void draw_glyph_run(DrawGlyphRun const&) = 0;
|
virtual void draw_glyph_run(DrawGlyphRun const&) = 0;
|
||||||
virtual void fill_rect(FillRect 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_painting_surface(DrawPaintingSurface const&) = 0;
|
||||||
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
||||||
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
||||||
|
|
|
@ -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);
|
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)
|
void DisplayListPlayerSkia::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command)
|
||||||
{
|
{
|
||||||
auto src_rect = to_skia_rect(command.src_rect);
|
auto src_rect = to_skia_rect(command.src_rect);
|
||||||
|
|
|
@ -33,7 +33,6 @@ private:
|
||||||
void draw_glyph_run(DrawGlyphRun const&) override;
|
void draw_glyph_run(DrawGlyphRun const&) override;
|
||||||
void fill_rect(FillRect const&) override;
|
void fill_rect(FillRect const&) override;
|
||||||
void draw_painting_surface(DrawPaintingSurface 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_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override;
|
||||||
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
||||||
void add_clip_rect(AddClipRect const&) override;
|
void add_clip_rect(AddClipRect const&) override;
|
||||||
|
|
|
@ -168,18 +168,6 @@ void DisplayListRecorder::draw_rect(Gfx::IntRect const& rect, Color color, bool
|
||||||
.rough = rough });
|
.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)
|
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())
|
if (dst_rect.is_empty())
|
||||||
|
|
|
@ -87,7 +87,6 @@ public:
|
||||||
|
|
||||||
void draw_rect(Gfx::IntRect const& rect, Color color, bool rough = false);
|
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_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);
|
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);
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ void VideoPaintable::paint(PaintContext& context, PaintPhase phase) const
|
||||||
|
|
||||||
auto paint_frame = [&](auto const& frame) {
|
auto paint_frame = [&](auto const& frame) {
|
||||||
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), frame->rect(), video_rect.to_type<int>());
|
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 = [&]() {
|
auto paint_transparent_black = [&]() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue