1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

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.
This commit is contained in:
Lucas CHOLLET 2023-03-12 18:45:41 -04:00 committed by Andreas Kling
parent 4554d10fe5
commit 24087ef6eb

View file

@ -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;
@ -111,22 +111,6 @@ bool PortableImageDecoderPlugin<TContext>::set_nonvolatile(bool& was_purged)
return m_context->bitmap->set_nonvolatile(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)
{