• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CODEC_CCODEC_GIFMODULE_H_
8 #define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
9 
10 #include <memory>
11 #include <utility>
12 
13 #include "core/fxcodec/gif/cfx_gif.h"
14 #include "core/fxcrt/fx_coordinates.h"
15 #include "core/fxcrt/fx_system.h"
16 
17 class CFX_DIBAttribute;
18 
19 class CCodec_GifModule {
20  public:
21   class Context {
22    public:
~Context()23     virtual ~Context() {}
24   };
25 
26   class Delegate {
27    public:
28     virtual void GifRecordCurrentPosition(uint32_t& cur_pos) = 0;
29     virtual bool GifInputRecordPositionBuf(uint32_t rcd_pos,
30                                            const FX_RECT& img_rc,
31                                            int32_t pal_num,
32                                            void* pal_ptr,
33                                            int32_t delay_time,
34                                            bool user_input,
35                                            int32_t trans_index,
36                                            int32_t disposal_method,
37                                            bool interlace) = 0;
38     virtual void GifReadScanline(int32_t row_num, uint8_t* row_buf) = 0;
39   };
40 
41   CCodec_GifModule();
42   ~CCodec_GifModule();
43 
44   std::unique_ptr<Context> Start(Delegate* pDelegate);
45   uint32_t GetAvailInput(Context* context, uint8_t** avail_buf_ptr = nullptr);
46   void Input(Context* context, const uint8_t* src_buf, uint32_t src_size);
47   CFX_GifDecodeStatus ReadHeader(Context* context,
48                                  int* width,
49                                  int* height,
50                                  int* pal_num,
51                                  void** pal_pp,
52                                  int* bg_index,
53                                  CFX_DIBAttribute* pAttribute);
54   std::pair<CFX_GifDecodeStatus, size_t> LoadFrameInfo(Context* context);
55   CFX_GifDecodeStatus LoadFrame(Context* context,
56                                 size_t frame_num,
57                                 CFX_DIBAttribute* pAttribute);
58 };
59 
60 #endif  // CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
61