LibGfx: Remove ImmutableBitmap

DecodedImageFrame now owns decoded bitmap pixels directly, so the
separate ImmutableBitmap wrapper no longer carries useful semantics.
Remove the class and pass decoded image frames or bitmaps at the
boundaries where pixels are actually required.

The Skia image cache now keys off DecodedImageFrame, matching the
display-list commands that paint decoded images. Video frames stay
owned by LibMedia, with the explicit YUV-to-bitmap conversion living
at HTMLVideoElement's decoded-frame entry point for canvas and WebGL
callers.
This commit is contained in:
Aliaksandr Kalenik
2026-05-05 14:13:30 +02:00
committed by Gregory Bertilson
parent 40f2abb7fe
commit 76c79ee522
Notes: github-actions[bot] 2026-05-05 19:40:28 +00:00
49 changed files with 128 additions and 350 deletions

View File

@@ -9,7 +9,6 @@
#include <LibGC/Weak.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/DecodedImageFrame.h>
#include <LibGfx/ImmutableBitmap.h>
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/Bindings/HTMLImageElement.h>
#include <LibWeb/CSS/ComputedProperties.h>
@@ -242,17 +241,10 @@ void HTMLImageElement::adjust_computed_style(CSS::ComputedProperties& style)
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None)));
}
RefPtr<Gfx::ImmutableBitmap> HTMLImageElement::immutable_bitmap() const
RefPtr<Gfx::DecodedImageFrame> HTMLImageElement::default_image_frame_sized(Gfx::IntSize size) const
{
return current_image_bitmap();
}
RefPtr<Gfx::ImmutableBitmap> HTMLImageElement::default_image_bitmap_sized(Gfx::IntSize size) const
{
if (auto data = m_current_request->image_data()) {
if (auto frame = data->frame(0, size))
return Gfx::ImmutableBitmap::create(frame->bitmap_ref());
}
if (auto data = m_current_request->image_data())
return data->frame(0, size);
return nullptr;
}
@@ -282,12 +274,10 @@ Optional<CSSPixelFraction> HTMLImageElement::intrinsic_aspect_ratio() const
return {};
}
RefPtr<Gfx::ImmutableBitmap> HTMLImageElement::current_image_bitmap_sized(Gfx::IntSize size) const
RefPtr<Gfx::DecodedImageFrame> HTMLImageElement::current_image_frame_sized(Gfx::IntSize size) const
{
if (auto data = m_current_request->image_data()) {
if (auto frame = data->frame(m_current_frame_index, size))
return Gfx::ImmutableBitmap::create(frame->bitmap_ref());
}
if (auto data = m_current_request->image_data())
return data->frame(m_current_frame_index, size);
return nullptr;
}
@@ -313,7 +303,7 @@ WebIDL::UnsignedLong HTMLImageElement::width() const
// ...or else the density-corrected intrinsic width and height of the image, in CSS pixels,
// if the image has intrinsic dimensions and is available but not being rendered.
if (auto bitmap = current_image_bitmap())
if (auto bitmap = current_image_frame())
return bitmap->width();
// ...or else 0, if the image is not available or does not have intrinsic dimensions.
@@ -344,7 +334,7 @@ WebIDL::UnsignedLong HTMLImageElement::height() const
// ...or else the density-corrected intrinsic height and height of the image, in CSS pixels,
// if the image has intrinsic dimensions and is available but not being rendered.
if (auto bitmap = current_image_bitmap())
if (auto bitmap = current_image_frame())
return bitmap->height();
// ...or else 0, if the image is not available or does not have intrinsic dimensions.
@@ -363,7 +353,7 @@ unsigned HTMLImageElement::natural_width() const
{
// Return the density-corrected intrinsic width of the image, in CSS pixels,
// if the image has intrinsic dimensions and is available.
if (auto bitmap = current_image_bitmap())
if (auto bitmap = current_image_frame())
return bitmap->width();
// ...or else 0.
@@ -375,7 +365,7 @@ unsigned HTMLImageElement::natural_height() const
{
// Return the density-corrected intrinsic height of the image, in CSS pixels,
// if the image has intrinsic dimensions and is available.
if (auto bitmap = current_image_bitmap())
if (auto bitmap = current_image_frame())
return bitmap->height();
// ...or else 0.