LibGfx+LibWeb: Add DecodedImageFrame

Decoded image data should not continue to traffic in ImmutableBitmap now
that the bitmap wrapper is being retired. Introduce DecodedImageFrame as
the paintable decoded-image unit and store a Bitmap plus ColorSpace in
it directly.

Thread the new frame type through decoded image data, display-list
image commands, filters, canvas drawImage, patterns, WebGL texture
upload, and CSS/SVG image consumers. ImmutableBitmap remains only at
the legacy boundaries that still need it, such as HTML video snapshots
and callers that explicitly ask for a bitmap snapshot.

This keeps color-space ownership with the decoded frame while making
the expensive or legacy ImmutableBitmap path explicit at the few call
sites that still need it.
This commit is contained in:
Aliaksandr Kalenik
2026-05-05 13:52:33 +02:00
committed by Gregory Bertilson
parent 3c25d080b1
commit 40f2abb7fe
Notes: github-actions[bot] 2026-05-05 19:40:35 +00:00
53 changed files with 368 additions and 214 deletions

View File

@@ -5,8 +5,6 @@
*/
#include <LibGC/Heap.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImmutableBitmap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/HTML/BitmapDecodedImageData.h>
#include <LibWeb/Painting/DisplayListRecorder.h>
@@ -30,11 +28,11 @@ BitmapDecodedImageData::BitmapDecodedImageData(Vector<Frame>&& frames, size_t lo
BitmapDecodedImageData::~BitmapDecodedImageData() = default;
RefPtr<Gfx::ImmutableBitmap> BitmapDecodedImageData::bitmap(size_t frame_index, Gfx::IntSize) const
RefPtr<Gfx::DecodedImageFrame> BitmapDecodedImageData::frame(size_t frame_index, Gfx::IntSize) const
{
if (frame_index >= m_frames.size())
return nullptr;
return m_frames[frame_index].bitmap;
return m_frames[frame_index].frame;
}
int BitmapDecodedImageData::frame_duration(size_t frame_index) const
@@ -46,27 +44,27 @@ int BitmapDecodedImageData::frame_duration(size_t frame_index) const
Optional<CSSPixels> BitmapDecodedImageData::intrinsic_width() const
{
return m_frames.first().bitmap->width();
return m_frames.first().frame->width();
}
Optional<CSSPixels> BitmapDecodedImageData::intrinsic_height() const
{
return m_frames.first().bitmap->height();
return m_frames.first().frame->height();
}
Optional<CSSPixelFraction> BitmapDecodedImageData::intrinsic_aspect_ratio() const
{
return CSSPixels(m_frames.first().bitmap->width()) / CSSPixels(m_frames.first().bitmap->height());
return CSSPixels(m_frames.first().frame->width()) / CSSPixels(m_frames.first().frame->height());
}
Optional<Gfx::IntRect> BitmapDecodedImageData::frame_rect(size_t frame_index) const
{
return m_frames[frame_index].bitmap->rect();
return m_frames[frame_index].frame->rect();
}
void BitmapDecodedImageData::paint(DisplayListRecordingContext& context, size_t frame_index, Gfx::IntRect dst_rect, Gfx::IntRect clip_rect, Gfx::ScalingMode scaling_mode) const
{
context.display_list_recorder().draw_scaled_immutable_bitmap(dst_rect, clip_rect, *m_frames[frame_index].bitmap, scaling_mode);
context.display_list_recorder().draw_scaled_decoded_image_frame(dst_rect, clip_rect, *m_frames[frame_index].frame, scaling_mode);
}
}