mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-21 19:30:27 +00:00
This saves us from having our own color conversion code, which was taking up a fair amount of time in VideoDataProvider. With this change, we should be able to play high resolution videos without interruptions on machines where the CPU can keep up with decoding. In order to make this change, ImmutableBitmap is now able to be constructed with YUV data instead of an RBG bitmap. It holds onto a YUVData instance that stores the buffers of image data, since Skia itself doesn't take ownership of them. In order to support greater than 8 bits of color depth, we normalize the 10- or 12-bit color values into a 16-bit range.
47 lines
905 B
C++
47 lines
905 B
C++
/*
|
|
* Copyright (c) 2026, Gregory Bertilson <gregory@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibGfx/ImmutableBitmap.h>
|
|
|
|
#include "TimedImage.h"
|
|
|
|
namespace Media {
|
|
|
|
TimedImage::TimedImage(AK::Duration timestamp, NonnullRefPtr<Gfx::ImmutableBitmap>&& image)
|
|
: m_timestamp(timestamp)
|
|
, m_image(move(image))
|
|
{
|
|
}
|
|
|
|
TimedImage::TimedImage() = default;
|
|
TimedImage::~TimedImage() = default;
|
|
|
|
AK::Duration const& TimedImage::timestamp() const
|
|
{
|
|
VERIFY(is_valid());
|
|
return m_timestamp;
|
|
}
|
|
|
|
NonnullRefPtr<Gfx::ImmutableBitmap> TimedImage::image() const
|
|
{
|
|
VERIFY(is_valid());
|
|
return *m_image;
|
|
}
|
|
|
|
NonnullRefPtr<Gfx::ImmutableBitmap> TimedImage::release_image()
|
|
{
|
|
VERIFY(is_valid());
|
|
m_timestamp = AK::Duration::zero();
|
|
return m_image.release_nonnull();
|
|
}
|
|
|
|
void TimedImage::clear()
|
|
{
|
|
m_timestamp = AK::Duration::zero();
|
|
m_image = nullptr;
|
|
}
|
|
|
|
}
|