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

@@ -7,7 +7,8 @@
*/
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImmutableBitmap.h>
#include <LibGfx/DecodedImageFrame.h>
#include <LibGfx/YUVData.h>
#include <LibMedia/Sinks/DisplayingVideoSink.h>
#include <LibMedia/VideoFrame.h>
#include <LibWeb/Bindings/HTMLVideoElement.h>
@@ -338,7 +339,7 @@ HTMLVideoElement::Representation HTMLVideoElement::current_representation() cons
return Representation::VideoFrame;
}
RefPtr<Gfx::ImmutableBitmap> HTMLVideoElement::bitmap() const
RefPtr<Gfx::DecodedImageFrame> HTMLVideoElement::current_decoded_image_frame() const
{
auto const& sink = selected_video_track_sink();
if (sink == nullptr)
@@ -346,23 +347,13 @@ RefPtr<Gfx::ImmutableBitmap> HTMLVideoElement::bitmap() const
auto current_frame = sink->current_frame();
if (!current_frame)
return nullptr;
auto bitmap_or_error = current_frame->to_immutable_bitmap();
auto bitmap_or_error = current_frame->yuv_data().to_bitmap();
if (bitmap_or_error.is_error()) {
dbgln("Could not convert video frame to bitmap: {}", bitmap_or_error.release_error());
return nullptr;
}
return bitmap_or_error.release_value();
}
Gfx::ColorSpace const* HTMLVideoElement::current_frame_color_space() const
{
auto const& sink = selected_video_track_sink();
if (sink == nullptr)
return nullptr;
auto current_frame = sink->current_frame();
if (!current_frame)
return nullptr;
return &current_frame->color_space();
auto bitmap = bitmap_or_error.release_value();
return Gfx::DecodedImageFrame::create(NonnullRefPtr<Gfx::Bitmap const> { *bitmap }, current_frame->color_space());
}
}