From b4a261855b34b4c8d938118762ae609a34a3ae99 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 1 Mar 2017 12:15:00 -0800 Subject: Create virtual codec APIs so chrome/fuzzers can link separately The one step to make an actual concrete class is conditionalized in fpdfview and is unconditional in the fuzzer. Also replace the clumsy C-style callbacks with a delegate interface as long as we are making new interfaces. Change-Id: I733a437483ce5e0c34211cfbbda05105336f55b5 Reviewed-on: https://pdfium-review.googlesource.com/2887 Commit-Queue: Tom Sepez Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fxcodec/codec/ccodec_progressivedecoder.h | 94 +++++++++++--------------- 1 file changed, 39 insertions(+), 55 deletions(-) (limited to 'core/fxcodec/codec/ccodec_progressivedecoder.h') diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index e97d1b9f78..61703dde29 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -9,27 +9,25 @@ #include +#include "core/fxcodec/codec/icodec_bmpmodule.h" +#include "core/fxcodec/codec/icodec_gifmodule.h" +#include "core/fxcodec/codec/icodec_pngmodule.h" +#include "core/fxcodec/codec/icodec_tiffmodule.h" #include "core/fxcodec/fx_codec_def.h" #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/fx_dib.h" -class CCodec_BmpModule; -class CCodec_GifContext; -class CCodec_GifModule; class CCodec_JpegModule; class CCodec_ModuleMgr; -class CCodec_PngContext; -class CCodec_TiffContext; class CFX_DIBAttribute; class IFX_SeekableReadStream; class IFX_Pause; -struct FXBMP_Context; -struct FXGIF_Context; struct FXJPEG_Context; -struct FXPNG_Context; -class CCodec_ProgressiveDecoder { +class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, + public ICodec_GifModule::Delegate, + public ICodec_PngModule::Delegate { public: enum FXCodec_Format { FXCodec_Invalid = 0, @@ -44,7 +42,7 @@ class CCodec_ProgressiveDecoder { }; explicit CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr); - ~CCodec_ProgressiveDecoder(); + virtual ~CCodec_ProgressiveDecoder(); FXCODEC_STATUS LoadImageInfo( const CFX_RetainPtr& pFile, @@ -170,60 +168,46 @@ class CCodec_ProgressiveDecoder { bool m_BmpIsTopBottom; FXCODEC_STATUS m_status; + // ICodec_PngModule::Delegate + bool PngReadHeader(int width, + int height, + int bpc, + int pass, + int* color_type, + double* gamma) override; + bool PngAskScanlineBuf(int line, uint8_t*& src_buf) override; + void PngFillScanlineBufCompleted(int pass, int line) override; + + // ICodec_GifModule::Delegate + void GifRecordCurrentPosition(uint32_t& cur_pos) override; + uint8_t* GifAskLocalPaletteBuf(int32_t frame_num, int32_t pal_size) override; + bool GifInputRecordPositionBuf(uint32_t rcd_pos, + const FX_RECT& img_rc, + int32_t pal_num, + void* pal_ptr, + int32_t delay_time, + bool user_input, + int32_t trans_index, + int32_t disposal_method, + bool interlace) override; + void GifReadScanline(int32_t row_num, uint8_t* row_buf) override; + + // ICodec_BmpModule::Delegate + bool BmpInputImagePositionBuf(uint32_t rcd_pos) override; + void BmpReadScanline(int32_t row_num, uint8_t* row_buf) override; + protected: -#ifdef PDF_ENABLE_XFA_PNG - static bool PngReadHeaderFunc(void* pModule, - int width, - int height, - int bpc, - int pass, - int* color_type, - double* gamma); - static bool PngAskScanlineBufFunc(void* pModule, int line, uint8_t*& src_buf); - static void PngFillScanlineBufCompletedFunc(void* pModule, - int pass, - int line); -#endif // PDF_ENABLE_XFA_PNG - -#ifdef PDF_ENABLE_XFA_GIF - static void GifRecordCurrentPositionCallback(void* pModule, - uint32_t& cur_pos); - static uint8_t* GifAskLocalPaletteBufCallback(void* pModule, - int32_t frame_num, - int32_t pal_size); - static bool GifInputRecordPositionBufCallback(void* pModule, - uint32_t rcd_pos, - const FX_RECT& img_rc, - int32_t pal_num, - void* pal_ptr, - int32_t delay_time, - bool user_input, - int32_t trans_index, - int32_t disposal_method, - bool interlace); - static void GifReadScanlineCallback(void* pModule, - int32_t row_num, - uint8_t* row_buf); - bool GifReadMoreData(CCodec_GifModule* pGifModule, + bool BmpReadMoreData(ICodec_BmpModule* pBmpModule, + FXCODEC_STATUS& err_status); + bool GifReadMoreData(ICodec_GifModule* pGifModule, FXCODEC_STATUS& err_status); void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); -#endif // PDF_ENABLE_XFA_GIF - -#ifdef PDF_ENABLE_XFA_BMP - static bool BmpInputImagePositionBufCallback(void* pModule, uint32_t rcd_pos); - static void BmpReadScanlineCallback(void* pModule, - int32_t row_num, - uint8_t* row_buf); void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap, int32_t des_line, uint8_t* src_scan, FXCodec_Format src_format); - bool BmpReadMoreData(CCodec_BmpModule* pBmpModule, - FXCODEC_STATUS& err_status); -#endif // PDF_ENABLE_XFA_BMP - bool DetectImageType(FXCODEC_IMAGE_TYPE imageType, CFX_DIBAttribute* pAttribute); void GetDownScale(int& down_scale); -- cgit v1.2.3