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