summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2023-03-12 18:45:41 -0400
committerAndreas Kling <kling@serenityos.org>2023-03-24 10:56:58 +0100
commit24087ef6eb8bfc86b40a21954ee94e0094a7d758 (patch)
treed047e0fc948fd6ed112834033a3a90ea946f1759 /Userland/Libraries/LibGfx
parent4554d10fe5482b9048535acf82362639169b52cd (diff)
downloadserenity-24087ef6eb8bfc86b40a21954ee94e0094a7d758.zip
LibGfx: Return true from `PortableImageDecoderPlugin::initialize()`
Reading the two magic bytes are always done in `decode()` by calling `read_magic_number()`. So no need to read it twice.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h18
1 files changed, 1 insertions, 17 deletions
diff --git a/Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h b/Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h
index 655f836054..df9dda312f 100644
--- a/Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h
+++ b/Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h
@@ -59,7 +59,7 @@ public:
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
- virtual bool initialize() override;
+ virtual bool initialize() override { return true; }
virtual bool is_animated() override;
virtual size_t loop_count() override;
virtual size_t frame_count() override;
@@ -112,22 +112,6 @@ bool PortableImageDecoderPlugin<TContext>::set_nonvolatile(bool& was_purged)
}
template<typename TContext>
-bool PortableImageDecoderPlugin<TContext>::initialize()
-{
- using Context = TContext;
- if (m_context->data_size < 2)
- return false;
-
- if (m_context->data[0] == 'P' && m_context->data[1] == Context::FormatDetails::ascii_magic_number)
- return true;
-
- if (m_context->data[0] == 'P' && m_context->data[1] == Context::FormatDetails::binary_magic_number)
- return true;
-
- return false;
-}
-
-template<typename TContext>
ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> PortableImageDecoderPlugin<TContext>::create(ReadonlyBytes data)
{
return adopt_nonnull_own_or_enomem(new (nothrow) PortableImageDecoderPlugin<TContext>(data.data(), data.size()));