瀏覽代碼

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.
Lucas CHOLLET 2 年之前
父節點
當前提交
24087ef6eb
共有 1 個文件被更改,包括 1 次插入17 次删除
  1. 1 17
      Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h

+ 1 - 17
Userland/Libraries/LibGfx/ImageFormats/PortableImageMapLoader.h

@@ -59,7 +59,7 @@ public:
     virtual void set_volatile() override;
     virtual void set_volatile() override;
     [[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) 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 bool is_animated() override;
     virtual size_t loop_count() override;
     virtual size_t loop_count() override;
     virtual size_t frame_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);
     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>
 template<typename TContext>
 ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> PortableImageDecoderPlugin<TContext>::create(ReadonlyBytes data)
 ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> PortableImageDecoderPlugin<TContext>::create(ReadonlyBytes data)
 {
 {