diff options
author | Nico Weber <thakis@chromium.org> | 2023-02-25 22:15:34 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-26 15:54:22 +0100 |
commit | 3c5450b8beb01b19a54dbc70080e1373bd7d57b7 (patch) | |
tree | 16e64f168f270212f0c201b611edf34e5585256e /Userland | |
parent | 0393a37843b65d2caea0582da16b02c0747da675 (diff) | |
download | serenity-3c5450b8beb01b19a54dbc70080e1373bd7d57b7.zip |
LibGfx: Implement is_animated() and frame_count() for webp plugin
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/WebPLoader.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/WebPLoader.cpp b/Userland/Libraries/LibGfx/WebPLoader.cpp index 646b6efb42..93a40361ae 100644 --- a/Userland/Libraries/LibGfx/WebPLoader.cpp +++ b/Userland/Libraries/LibGfx/WebPLoader.cpp @@ -519,8 +519,15 @@ ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> WebPImageDecoderPlugin::create(Readon bool WebPImageDecoderPlugin::is_animated() { - // FIXME - return false; + if (m_context->state == WebPLoadingContext::State::Error) + return false; + + if (m_context->state < WebPLoadingContext::State::FirstChunkDecoded) { + if (decode_webp_first_chunk(*m_context).is_error()) + return false; + } + + return m_context->first_chunk->type == FourCC("VP8X") && m_context->vp8x_header.has_animation; } size_t WebPImageDecoderPlugin::loop_count() @@ -531,8 +538,15 @@ size_t WebPImageDecoderPlugin::loop_count() size_t WebPImageDecoderPlugin::frame_count() { - // FIXME - return 1; + if (!is_animated()) + return 1; + + if (m_context->state < WebPLoadingContext::State::ChunksDecoded) { + if (decode_webp_chunks(*m_context).is_error()) + return 1; + } + + return m_context->animation_frame_chunks.size(); } ErrorOr<ImageFrameDescriptor> WebPImageDecoderPlugin::frame(size_t index) |