1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +00:00

LibGfx: Remove ImageDecoderPlugin::bitmap() in favor of frame(index)

To encourage proper support for multi-frame images throughout the
system, get rid of the single-frame convenience bitmap() API.
This commit is contained in:
Andreas Kling 2021-11-18 13:47:29 +01:00
parent 750f1d580a
commit 2b866e3c9b
22 changed files with 105 additions and 155 deletions

View file

@ -1240,21 +1240,6 @@ IntSize JPGImageDecoderPlugin::size()
return {};
}
RefPtr<Gfx::Bitmap> JPGImageDecoderPlugin::bitmap()
{
if (m_context->state == JPGLoadingContext::State::Error)
return nullptr;
if (m_context->state < JPGLoadingContext::State::BitmapDecoded) {
if (!decode_jpg(*m_context)) {
m_context->state = JPGLoadingContext::State::Error;
return nullptr;
}
m_context->state = JPGLoadingContext::State::BitmapDecoded;
}
return m_context->bitmap;
}
void JPGImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@ -1295,7 +1280,19 @@ ImageFrameDescriptor JPGImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
return { bitmap(), 0 };
if (m_context->state == JPGLoadingContext::State::Error)
return {};
if (m_context->state < JPGLoadingContext::State::BitmapDecoded) {
if (!decode_jpg(*m_context)) {
m_context->state = JPGLoadingContext::State::Error;
return {};
}
m_context->state = JPGLoadingContext::State::BitmapDecoded;
}
return { m_context->bitmap, 0 };
}
}