1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXCODEC_PNG_PNGMODULE_H_
8 #define CORE_FXCODEC_PNG_PNGMODULE_H_
9 
10 #include <memory>
11 
12 #include "core/fxcodec/codec_module_iface.h"
13 
14 namespace fxcodec {
15 
16 class PngModule final : public ModuleIface {
17  public:
18   class Delegate {
19    public:
20     virtual bool PngReadHeader(int width,
21                                int height,
22                                int bpc,
23                                int pass,
24                                int* color_type,
25                                double* gamma) = 0;
26 
27     // Returns true on success. |pSrcBuf| will be set if this succeeds.
28     // |pSrcBuf| does not take ownership of the buffer.
29     virtual bool PngAskScanlineBuf(int line, uint8_t** pSrcBuf) = 0;
30 
31     virtual void PngFillScanlineBufCompleted(int pass, int line) = 0;
32   };
33 
34   PngModule();
35   ~PngModule() override;
36 
37   // ModuleIface:
38   FX_FILESIZE GetAvailInput(Context* pContext) const override;
39   bool Input(Context* pContext,
40              RetainPtr<CFX_CodecMemory> codec_memory,
41              CFX_DIBAttribute* pAttribute) override;
42 
43   std::unique_ptr<Context> Start(Delegate* pDelegate);
44 };
45 
46 }  // namespace fxcodec
47 
48 using PngModule = fxcodec::PngModule;
49 
50 #endif  // CORE_FXCODEC_PNG_PNGMODULE_H_
51