mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx: implement remaining GIFImageDecoderPlugin methods
This commit is contained in:
parent
e06518211b
commit
d5af7b220c
Notes:
sideshowbarker
2024-07-19 07:18:47 +09:00
Author: https://github.com/peterdn Commit: https://github.com/SerenityOS/serenity/commit/d5af7b220cc Pull-request: https://github.com/SerenityOS/serenity/pull/1950
1 changed files with 45 additions and 0 deletions
|
@ -447,6 +447,31 @@ bool load_gif_impl(GIFLoadingContext& context)
|
|||
return true;
|
||||
}
|
||||
|
||||
GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size)
|
||||
{
|
||||
m_context = make<GIFLoadingContext>();
|
||||
m_context->data = data;
|
||||
m_context->data_size = size;
|
||||
}
|
||||
|
||||
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() {}
|
||||
|
||||
Size GIFImageDecoderPlugin::size()
|
||||
{
|
||||
if (m_context->state == GIFLoadingContext::State::Error) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (m_context->state < GIFLoadingContext::State::BitmapDecoded) {
|
||||
if (!load_gif_impl(*m_context)) {
|
||||
m_context->state = GIFLoadingContext::State::Error;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return { m_context->width, m_context->height };
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> GIFImageDecoderPlugin::bitmap()
|
||||
{
|
||||
if (m_context->state == GIFLoadingContext::State::Error) {
|
||||
|
@ -467,4 +492,24 @@ RefPtr<Gfx::Bitmap> GIFImageDecoderPlugin::bitmap()
|
|||
return m_context->frames.first();
|
||||
}
|
||||
|
||||
void GIFImageDecoderPlugin::set_volatile()
|
||||
{
|
||||
for (auto& frame : m_context->frames) {
|
||||
frame->set_volatile();
|
||||
}
|
||||
}
|
||||
|
||||
bool GIFImageDecoderPlugin::set_nonvolatile()
|
||||
{
|
||||
if (m_context->frames.is_empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
for (auto& frame : m_context->frames) {
|
||||
success &= frame->set_nonvolatile();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue