ladybird/Libraries/LibMedia/VideoFrame.cpp
Aliaksandr Kalenik 40f2abb7fe 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.
2026-05-05 14:39:17 -05:00

39 lines
862 B
C++

/*
* Copyright (c) 2022-2026, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImmutableBitmap.h>
#include <LibGfx/YUVData.h>
#include "VideoFrame.h"
namespace Media {
VideoFrame::VideoFrame(
AK::Duration timestamp,
AK::Duration duration,
Gfx::Size<u32> size,
u8 bit_depth,
Gfx::ColorSpace color_space,
NonnullOwnPtr<Gfx::YUVData> yuv_data)
: m_timestamp(timestamp)
, m_duration(duration)
, m_size(size)
, m_bit_depth(bit_depth)
, m_color_space(move(color_space))
, m_yuv_data(move(yuv_data))
{
}
VideoFrame::~VideoFrame() = default;
ErrorOr<NonnullRefPtr<Gfx::ImmutableBitmap>> VideoFrame::to_immutable_bitmap() const
{
auto bitmap = TRY(m_yuv_data->to_bitmap());
return Gfx::ImmutableBitmap::create(bitmap);
}
}