mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-12 01:46:46 +02:00
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:
committed by
Gregory Bertilson
parent
40f2abb7fe
commit
76c79ee522
Notes:
github-actions[bot]
2026-05-05 19:40:28 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/76c79ee522b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9249 Reviewed-by: https://github.com/Zaggy1024 ✅
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user