From 87d1c1fc1dc4455cb3695ed2df1a5fdf31e870b1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 25 Apr 2017 13:30:33 -0700 Subject: Remove remaining ICodec_* abstract classes They are only implemented in one way, and the layering does not required an interface here. Change-Id: Id87591ca237fb66dbfc5aa62b4cc11c2464f5ffa Reviewed-on: https://pdfium-review.googlesource.com/4496 Commit-Queue: dsinclair Reviewed-by: dsinclair --- BUILD.gn | 4 -- core/fxcodec/codec/ccodec_bmpmodule.h | 30 ++++++++---- core/fxcodec/codec/ccodec_gifmodule.h | 43 ++++++++++++---- core/fxcodec/codec/ccodec_pngmodule.h | 30 +++++++++--- core/fxcodec/codec/ccodec_progressivedecoder.h | 24 ++++----- core/fxcodec/codec/ccodec_tiffmodule.h | 17 ++++--- core/fxcodec/codec/fx_codec_progress.cpp | 28 +++++------ core/fxcodec/codec/icodec_bmpmodule.h | 51 ------------------- core/fxcodec/codec/icodec_gifmodule.h | 68 -------------------------- core/fxcodec/codec/icodec_pngmodule.h | 47 ------------------ core/fxcodec/codec/icodec_tiffmodule.h | 36 -------------- core/fxcodec/fx_codec.h | 32 ++++++------ 12 files changed, 128 insertions(+), 282 deletions(-) delete mode 100644 core/fxcodec/codec/icodec_bmpmodule.h delete mode 100644 core/fxcodec/codec/icodec_gifmodule.h delete mode 100644 core/fxcodec/codec/icodec_pngmodule.h delete mode 100644 core/fxcodec/codec/icodec_tiffmodule.h diff --git a/BUILD.gn b/BUILD.gn index a11c2c179e..938c01b8f3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -718,10 +718,6 @@ static_library("fxcodec") { "core/fxcodec/codec/ccodec_tiffmodule.cpp", "core/fxcodec/codec/ccodec_tiffmodule.h", "core/fxcodec/codec/fx_codec_progress.cpp", - "core/fxcodec/codec/icodec_bmpmodule.h", - "core/fxcodec/codec/icodec_gifmodule.h", - "core/fxcodec/codec/icodec_pngmodule.h", - "core/fxcodec/codec/icodec_tiffmodule.h", "core/fxcodec/lbmp/fx_bmp.cpp", "core/fxcodec/lbmp/fx_bmp.h", "core/fxcodec/lgif/fx_gif.cpp", diff --git a/core/fxcodec/codec/ccodec_bmpmodule.h b/core/fxcodec/codec/ccodec_bmpmodule.h index d07d9850c6..bdf6544251 100644 --- a/core/fxcodec/codec/ccodec_bmpmodule.h +++ b/core/fxcodec/codec/ccodec_bmpmodule.h @@ -7,21 +7,28 @@ #ifndef CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_ #define CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_ -#include "core/fxcodec/codec/icodec_bmpmodule.h" #include "core/fxcrt/fx_system.h" -class CCodec_BmpModule : public ICodec_BmpModule { +class CFX_DIBAttribute; +struct FXBMP_Context; + +class CCodec_BmpModule { public: + class Delegate { + public: + virtual bool BmpInputImagePositionBuf(uint32_t rcd_pos) = 0; + virtual void BmpReadScanline(int32_t row_num, uint8_t* row_buf) = 0; + }; + CCodec_BmpModule(); - ~CCodec_BmpModule() override; + ~CCodec_BmpModule(); - FXBMP_Context* Start() override; - void Finish(FXBMP_Context* pContext) override; - uint32_t GetAvailInput(FXBMP_Context* pContext, - uint8_t** avail_buf_ptr) override; + FXBMP_Context* Start(); + void Finish(FXBMP_Context* pContext); + uint32_t GetAvailInput(FXBMP_Context* pContext, uint8_t** avail_buf_ptr); void Input(FXBMP_Context* pContext, const uint8_t* src_buf, - uint32_t src_size) override; + uint32_t src_size); int32_t ReadHeader(FXBMP_Context* pContext, int32_t* width, int32_t* height, @@ -29,10 +36,13 @@ class CCodec_BmpModule : public ICodec_BmpModule { int32_t* components, int32_t* pal_num, uint32_t** pal_pp, - CFX_DIBAttribute* pAttribute) override; - int32_t LoadImage(FXBMP_Context* pContext) override; + CFX_DIBAttribute* pAttribute); + int32_t LoadImage(FXBMP_Context* pContext); + Delegate* GetDelegate() const { return m_pDelegate; } + void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; } protected: + Delegate* m_pDelegate; char m_szLastError[256]; }; diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h index 6830064d43..745f48a174 100644 --- a/core/fxcodec/codec/ccodec_gifmodule.h +++ b/core/fxcodec/codec/ccodec_gifmodule.h @@ -7,23 +7,42 @@ #ifndef CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_ #define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_ -#include "core/fxcodec/codec/icodec_gifmodule.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" -class CCodec_GifModule : public ICodec_GifModule { +class CFX_DIBAttribute; +struct FXGIF_Context; + +class CCodec_GifModule { public: + class Delegate { + public: + virtual void GifRecordCurrentPosition(uint32_t& cur_pos) = 0; + virtual uint8_t* GifAskLocalPaletteBuf(int32_t frame_num, + int32_t pal_size) = 0; + virtual 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) = 0; + virtual void GifReadScanline(int32_t row_num, uint8_t* row_buf) = 0; + }; + CCodec_GifModule(); - ~CCodec_GifModule() override; + ~CCodec_GifModule(); - FXGIF_Context* Start() override; - void Finish(FXGIF_Context* pContext) override; + FXGIF_Context* Start(); + void Finish(FXGIF_Context* pContext); uint32_t GetAvailInput(FXGIF_Context* pContext, - uint8_t** avail_buf_ptr = nullptr) override; + uint8_t** avail_buf_ptr = nullptr); void Input(FXGIF_Context* pContext, const uint8_t* src_buf, - uint32_t src_size) override; + uint32_t src_size); int32_t ReadHeader(FXGIF_Context* pContext, int* width, @@ -31,14 +50,18 @@ class CCodec_GifModule : public ICodec_GifModule { int* pal_num, void** pal_pp, int* bg_index, - CFX_DIBAttribute* pAttribute) override; + CFX_DIBAttribute* pAttribute); - int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num) override; + int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num); int32_t LoadFrame(FXGIF_Context* pContext, int frame_num, - CFX_DIBAttribute* pAttribute) override; + CFX_DIBAttribute* pAttribute); + + Delegate* GetDelegate() const { return m_pDelegate; } + void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; } protected: + Delegate* m_pDelegate; char m_szLastError[256]; }; diff --git a/core/fxcodec/codec/ccodec_pngmodule.h b/core/fxcodec/codec/ccodec_pngmodule.h index 0ca33f03c6..f0a08db66c 100644 --- a/core/fxcodec/codec/ccodec_pngmodule.h +++ b/core/fxcodec/codec/ccodec_pngmodule.h @@ -7,24 +7,42 @@ #ifndef CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_ #define CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_ -#include "core/fxcodec/codec/icodec_pngmodule.h" #include "core/fxcrt/fx_system.h" +class CFX_DIBAttribute; +struct FXPNG_Context; + #define PNG_ERROR_SIZE 256 -class CCodec_PngModule : public ICodec_PngModule { +class CCodec_PngModule { public: + class Delegate { + public: + virtual bool PngReadHeader(int width, + int height, + int bpc, + int pass, + int* color_type, + double* gamma) = 0; + virtual bool PngAskScanlineBuf(int line, uint8_t*& src_buf) = 0; + virtual void PngFillScanlineBufCompleted(int pass, int line) = 0; + }; + CCodec_PngModule(); - ~CCodec_PngModule() override; + ~CCodec_PngModule(); - FXPNG_Context* Start() override; - void Finish(FXPNG_Context* pContext) override; + FXPNG_Context* Start(); + void Finish(FXPNG_Context* pContext); bool Input(FXPNG_Context* pContext, const uint8_t* src_buf, uint32_t src_size, - CFX_DIBAttribute* pAttribute) override; + CFX_DIBAttribute* pAttribute); + + Delegate* GetDelegate() const { return m_pDelegate; } + void SetDelegate(Delegate* delegate) { m_pDelegate = delegate; } protected: + Delegate* m_pDelegate; char m_szLastError[PNG_ERROR_SIZE]; }; diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index cd96ee76a0..6081fe3c19 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -9,10 +9,10 @@ #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/codec/ccodec_bmpmodule.h" +#include "core/fxcodec/codec/ccodec_gifmodule.h" +#include "core/fxcodec/codec/ccodec_pngmodule.h" +#include "core/fxcodec/codec/ccodec_tiffmodule.h" #include "core/fxcodec/fx_codec_def.h" #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" @@ -25,9 +25,9 @@ class IFX_SeekableReadStream; class IFX_Pause; struct FXJPEG_Context; -class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, - public ICodec_GifModule::Delegate, - public ICodec_PngModule::Delegate { +class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, + public CCodec_GifModule::Delegate, + public CCodec_PngModule::Delegate { public: enum FXCodec_Format { FXCodec_Invalid = 0, @@ -168,7 +168,7 @@ class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, bool m_BmpIsTopBottom; FXCODEC_STATUS m_status; - // ICodec_PngModule::Delegate + // CCodec_PngModule::Delegate bool PngReadHeader(int width, int height, int bpc, @@ -178,7 +178,7 @@ class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, bool PngAskScanlineBuf(int line, uint8_t*& src_buf) override; void PngFillScanlineBufCompleted(int pass, int line) override; - // ICodec_GifModule::Delegate + // CCodec_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, @@ -192,14 +192,14 @@ class CCodec_ProgressiveDecoder : public ICodec_BmpModule::Delegate, bool interlace) override; void GifReadScanline(int32_t row_num, uint8_t* row_buf) override; - // ICodec_BmpModule::Delegate + // CCodec_BmpModule::Delegate bool BmpInputImagePositionBuf(uint32_t rcd_pos) override; void BmpReadScanline(int32_t row_num, uint8_t* row_buf) override; protected: - bool BmpReadMoreData(ICodec_BmpModule* pBmpModule, + bool BmpReadMoreData(CCodec_BmpModule* pBmpModule, FXCODEC_STATUS& err_status); - bool GifReadMoreData(ICodec_GifModule* pGifModule, + bool GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status); void GifDoubleLineResampleVert( const CFX_RetainPtr& pDeviceBitmap, diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h index 8878ad504e..be791e5cc2 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.h +++ b/core/fxcodec/codec/ccodec_tiffmodule.h @@ -7,26 +7,27 @@ #ifndef CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_ #define CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_ -#include "core/fxcodec/codec/icodec_tiffmodule.h" #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_system.h" +#include "core/fxge/dib/cfx_dibitmap.h" -class CCodec_TiffModule : public ICodec_TiffModule { - public: - ~CCodec_TiffModule() override {} +class CCodec_TiffContext; +class CFX_DIBAttribute; +class CCodec_TiffModule { + public: CCodec_TiffContext* CreateDecoder( - const CFX_RetainPtr& file_ptr) override; + const CFX_RetainPtr& file_ptr); bool LoadFrameInfo(CCodec_TiffContext* ctx, int32_t frame, int32_t* width, int32_t* height, int32_t* comps, int32_t* bpc, - CFX_DIBAttribute* pAttribute) override; + CFX_DIBAttribute* pAttribute); bool Decode(CCodec_TiffContext* ctx, - const CFX_RetainPtr& pDIBitmap) override; - void DestroyDecoder(CCodec_TiffContext* ctx) override; + const CFX_RetainPtr& pDIBitmap); + void DestroyDecoder(CCodec_TiffContext* ctx); }; #endif // CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_ diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 79f0bed415..6a95805dbe 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -572,7 +572,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass, } } -bool CCodec_ProgressiveDecoder::GifReadMoreData(ICodec_GifModule* pGifModule, +bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) { @@ -851,7 +851,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert( } } -bool CCodec_ProgressiveDecoder::BmpReadMoreData(ICodec_BmpModule* pBmpModule, +bool CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) @@ -1022,7 +1022,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, m_SrcSize = size; switch (imageType) { case FXCODEC_IMAGE_BMP: { - ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); + CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); if (!pBmpModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return false; @@ -1118,7 +1118,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, return false; } case FXCODEC_IMAGE_PNG: { - ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); + CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); if (!pPngModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return false; @@ -1175,7 +1175,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, return true; } case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (!pGifModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return false; @@ -1220,7 +1220,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, return false; } case FXCODEC_IMAGE_TIF: { - ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); + CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); if (!pTiffModule) { m_status = FXCODEC_STATUS_ERR_FORMAT; return false; @@ -1799,7 +1799,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames, m_status = FXCODEC_STATUS_DECODE_READY; return m_status; case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (!pGifModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; @@ -1933,7 +1933,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( return m_status; } case FXCODEC_IMAGE_PNG: { - ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); + CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); if (!pPngModule) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; @@ -1985,7 +1985,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( return m_status; } case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (!pGifModule) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; @@ -2006,7 +2006,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( return m_status; } case FXCODEC_IMAGE_BMP: { - ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); + CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); if (!pBmpModule) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; @@ -2081,7 +2081,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } case FXCODEC_IMAGE_PNG: { - ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); + CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); if (!pPngModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; @@ -2129,7 +2129,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (!pGifModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; @@ -2164,7 +2164,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } case FXCODEC_IMAGE_BMP: { - ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); + CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); if (!pBmpModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; @@ -2198,7 +2198,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } case FXCODEC_IMAGE_TIF: { - ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); + CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); if (!pTiffModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return m_status; diff --git a/core/fxcodec/codec/icodec_bmpmodule.h b/core/fxcodec/codec/icodec_bmpmodule.h deleted file mode 100644 index a67e20cf02..0000000000 --- a/core/fxcodec/codec/icodec_bmpmodule.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXCODEC_CODEC_ICODEC_BMPMODULE_H_ -#define CORE_FXCODEC_CODEC_ICODEC_BMPMODULE_H_ - -#include "core/fxcrt/fx_system.h" - -struct FXBMP_Context; -class CFX_DIBAttribute; - -// Virtual interface to avoid linking in a concrete implementation -// if we do not enable this codec. -class ICodec_BmpModule { - public: - class Delegate { - public: - virtual bool BmpInputImagePositionBuf(uint32_t rcd_pos) = 0; - virtual void BmpReadScanline(int32_t row_num, uint8_t* row_buf) = 0; - }; - - virtual ~ICodec_BmpModule() {} - - virtual FXBMP_Context* Start() = 0; - virtual void Finish(FXBMP_Context* pContext) = 0; - virtual uint32_t GetAvailInput(FXBMP_Context* pContext, - uint8_t** avail_buf_ptr) = 0; - virtual void Input(FXBMP_Context* pContext, - const uint8_t* src_buf, - uint32_t src_size) = 0; - virtual int32_t ReadHeader(FXBMP_Context* pContext, - int32_t* width, - int32_t* height, - bool* tb_flag, - int32_t* components, - int32_t* pal_num, - uint32_t** pal_pp, - CFX_DIBAttribute* pAttribute) = 0; - virtual int32_t LoadImage(FXBMP_Context* pContext) = 0; - - Delegate* GetDelegate() const { return m_pDelegate; } - void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; } - - protected: - Delegate* m_pDelegate; -}; - -#endif // CORE_FXCODEC_CODEC_ICODEC_BMPMODULE_H_ diff --git a/core/fxcodec/codec/icodec_gifmodule.h b/core/fxcodec/codec/icodec_gifmodule.h deleted file mode 100644 index 9dc0708ebe..0000000000 --- a/core/fxcodec/codec/icodec_gifmodule.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXCODEC_CODEC_ICODEC_GIFMODULE_H_ -#define CORE_FXCODEC_CODEC_ICODEC_GIFMODULE_H_ - -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxcrt/fx_system.h" - -class CFX_DIBAttribute; -struct FXGIF_Context; - -// Virtual interface to avoid linking in a concrete implementation -// if we do not enable this codec. -class ICodec_GifModule { - public: - class Delegate { - public: - virtual void GifRecordCurrentPosition(uint32_t& cur_pos) = 0; - virtual uint8_t* GifAskLocalPaletteBuf(int32_t frame_num, - int32_t pal_size) = 0; - virtual 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) = 0; - virtual void GifReadScanline(int32_t row_num, uint8_t* row_buf) = 0; - }; - - virtual ~ICodec_GifModule() {} - - virtual FXGIF_Context* Start() = 0; - virtual void Finish(FXGIF_Context* pContext) = 0; - virtual uint32_t GetAvailInput(FXGIF_Context* pContext, - uint8_t** avail_buf_ptr = nullptr) = 0; - - virtual void Input(FXGIF_Context* pContext, - const uint8_t* src_buf, - uint32_t src_size) = 0; - - virtual int32_t ReadHeader(FXGIF_Context* pContext, - int* width, - int* height, - int* pal_num, - void** pal_pp, - int* bg_index, - CFX_DIBAttribute* pAttribute) = 0; - - virtual int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num) = 0; - virtual int32_t LoadFrame(FXGIF_Context* pContext, - int frame_num, - CFX_DIBAttribute* pAttribute) = 0; - - Delegate* GetDelegate() const { return m_pDelegate; } - void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; } - - protected: - Delegate* m_pDelegate; -}; - -#endif // CORE_FXCODEC_CODEC_ICODEC_GIFMODULE_H_ diff --git a/core/fxcodec/codec/icodec_pngmodule.h b/core/fxcodec/codec/icodec_pngmodule.h deleted file mode 100644 index 63e61fe5b5..0000000000 --- a/core/fxcodec/codec/icodec_pngmodule.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXCODEC_CODEC_ICODEC_PNGMODULE_H_ -#define CORE_FXCODEC_CODEC_ICODEC_PNGMODULE_H_ - -#include "core/fxcrt/fx_system.h" - -class CFX_DIBAttribute; -struct FXPNG_Context; - -// Virtual interface to avoid linking in a concrete implementation -// if we do not enable this codec. -class ICodec_PngModule { - public: - class Delegate { - public: - virtual bool PngReadHeader(int width, - int height, - int bpc, - int pass, - int* color_type, - double* gamma) = 0; - virtual bool PngAskScanlineBuf(int line, uint8_t*& src_buf) = 0; - virtual void PngFillScanlineBufCompleted(int pass, int line) = 0; - }; - - virtual ~ICodec_PngModule() {} - - virtual FXPNG_Context* Start() = 0; - virtual void Finish(FXPNG_Context* pContext) = 0; - virtual bool Input(FXPNG_Context* pContext, - const uint8_t* src_buf, - uint32_t src_size, - CFX_DIBAttribute* pAttribute) = 0; - - Delegate* GetDelegate() const { return m_pDelegate; } - void SetDelegate(Delegate* delegate) { m_pDelegate = delegate; } - - protected: - Delegate* m_pDelegate; -}; - -#endif // CORE_FXCODEC_CODEC_ICODEC_PNGMODULE_H_ diff --git a/core/fxcodec/codec/icodec_tiffmodule.h b/core/fxcodec/codec/icodec_tiffmodule.h deleted file mode 100644 index 49abd1865f..0000000000 --- a/core/fxcodec/codec/icodec_tiffmodule.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXCODEC_CODEC_ICODEC_TIFFMODULE_H_ -#define CORE_FXCODEC_CODEC_ICODEC_TIFFMODULE_H_ - -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/fx_system.h" - -class CCodec_TiffContext; -class CFX_DIBAttribute; -class CFX_DIBitmap; -class IFX_SeekableReadStream; - -class ICodec_TiffModule { - public: - virtual ~ICodec_TiffModule() {} - - virtual CCodec_TiffContext* CreateDecoder( - const CFX_RetainPtr& file_ptr) = 0; - virtual bool LoadFrameInfo(CCodec_TiffContext* ctx, - int32_t frame, - int32_t* width, - int32_t* height, - int32_t* comps, - int32_t* bpc, - CFX_DIBAttribute* pAttribute) = 0; - virtual bool Decode(CCodec_TiffContext* ctx, - const CFX_RetainPtr& pDIBitmap) = 0; - virtual void DestroyDecoder(CCodec_TiffContext* ctx) = 0; -}; - -#endif // CORE_FXCODEC_CODEC_ICODEC_TIFFMODULE_H_ diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h index fa4956c095..f034ac28ed 100644 --- a/core/fxcodec/fx_codec.h +++ b/core/fxcodec/fx_codec.h @@ -25,10 +25,10 @@ #include "core/fxcrt/fx_coordinates.h" #ifdef PDF_ENABLE_XFA -#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/codec/ccodec_bmpmodule.h" +#include "core/fxcodec/codec/ccodec_gifmodule.h" +#include "core/fxcodec/codec/ccodec_pngmodule.h" +#include "core/fxcodec/codec/ccodec_tiffmodule.h" #endif // PDF_ENABLE_XFA class CFX_DIBSource; @@ -74,22 +74,22 @@ class CCodec_ModuleMgr { #ifdef PDF_ENABLE_XFA std::unique_ptr CreateProgressiveDecoder(); - void SetBmpModule(std::unique_ptr module) { + void SetBmpModule(std::unique_ptr module) { m_pBmpModule = std::move(module); } - void SetGifModule(std::unique_ptr module) { + void SetGifModule(std::unique_ptr module) { m_pGifModule = std::move(module); } - void SetPngModule(std::unique_ptr module) { + void SetPngModule(std::unique_ptr module) { m_pPngModule = std::move(module); } - void SetTiffModule(std::unique_ptr module) { + void SetTiffModule(std::unique_ptr module) { m_pTiffModule = std::move(module); } - ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } - ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } - ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } - ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } + CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } + CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } + CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } + CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } #endif // PDF_ENABLE_XFA protected: @@ -101,10 +101,10 @@ class CCodec_ModuleMgr { std::unique_ptr m_pIccModule; #ifdef PDF_ENABLE_XFA - std::unique_ptr m_pBmpModule; - std::unique_ptr m_pGifModule; - std::unique_ptr m_pPngModule; - std::unique_ptr m_pTiffModule; + std::unique_ptr m_pBmpModule; + std::unique_ptr m_pGifModule; + std::unique_ptr m_pPngModule; + std::unique_ptr m_pTiffModule; #endif // PDF_ENABLE_XFA std::unique_ptr m_pFlateModule; -- cgit v1.2.3