• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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_CODEC_ICODEC_GIFMODULE_H_
8 #define CORE_FXCODEC_CODEC_ICODEC_GIFMODULE_H_
9 
10 #include "core/fxcrt/fx_coordinates.h"
11 #include "core/fxcrt/fx_system.h"
12 
13 class CFX_DIBAttribute;
14 struct FXGIF_Context;
15 
16 // Virtual interface to avoid linking in a concrete implementation
17 // if we do not enable this codec.
18 class ICodec_GifModule {
19  public:
20   class Delegate {
21    public:
22     virtual void GifRecordCurrentPosition(uint32_t& cur_pos) = 0;
23     virtual uint8_t* GifAskLocalPaletteBuf(int32_t frame_num,
24                                            int32_t pal_size) = 0;
25     virtual bool GifInputRecordPositionBuf(uint32_t rcd_pos,
26                                            const FX_RECT& img_rc,
27                                            int32_t pal_num,
28                                            void* pal_ptr,
29                                            int32_t delay_time,
30                                            bool user_input,
31                                            int32_t trans_index,
32                                            int32_t disposal_method,
33                                            bool interlace) = 0;
34     virtual void GifReadScanline(int32_t row_num, uint8_t* row_buf) = 0;
35   };
36 
~ICodec_GifModule()37   virtual ~ICodec_GifModule() {}
38 
39   virtual FXGIF_Context* Start() = 0;
40   virtual void Finish(FXGIF_Context* pContext) = 0;
41   virtual uint32_t GetAvailInput(FXGIF_Context* pContext,
42                                  uint8_t** avail_buf_ptr = nullptr) = 0;
43 
44   virtual void Input(FXGIF_Context* pContext,
45                      const uint8_t* src_buf,
46                      uint32_t src_size) = 0;
47 
48   virtual int32_t ReadHeader(FXGIF_Context* pContext,
49                              int* width,
50                              int* height,
51                              int* pal_num,
52                              void** pal_pp,
53                              int* bg_index,
54                              CFX_DIBAttribute* pAttribute) = 0;
55 
56   virtual int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num) = 0;
57   virtual int32_t LoadFrame(FXGIF_Context* pContext,
58                             int frame_num,
59                             CFX_DIBAttribute* pAttribute) = 0;
60 
GetDelegate()61   Delegate* GetDelegate() const { return m_pDelegate; }
SetDelegate(Delegate * pDelegate)62   void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; }
63 
64  protected:
65   Delegate* m_pDelegate;
66 };
67 
68 #endif  // CORE_FXCODEC_CODEC_ICODEC_GIFMODULE_H_
69