diff options
Diffstat (limited to 'core')
40 files changed, 1122 insertions, 1269 deletions
diff --git a/core/fpdfapi/fpdf_basic_module.cpp b/core/fpdfapi/fpdf_basic_module.cpp index 2dfc9fb1f6..efa93d6f76 100644 --- a/core/fpdfapi/fpdf_basic_module.cpp +++ b/core/fpdfapi/fpdf_basic_module.cpp @@ -41,24 +41,31 @@ void CPDF_ModuleMgr::SetPrivateData(void* module_id, PD_CALLBACK_FREEDATA callback) { m_privateData.SetPrivateData(module_id, pData, callback); } + void* CPDF_ModuleMgr::GetPrivateData(void* module_id) { return m_privateData.GetPrivateData(module_id); } -ICodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() { - return m_pCodecModule ? m_pCodecModule->GetFaxModule() : NULL; + +CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() { + return m_pCodecModule ? m_pCodecModule->GetFaxModule() : nullptr; } -ICodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() { - return m_pCodecModule ? m_pCodecModule->GetJpegModule() : NULL; + +CCodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() { + return m_pCodecModule ? m_pCodecModule->GetJpegModule() : nullptr; } -ICodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() { - return m_pCodecModule ? m_pCodecModule->GetJpxModule() : NULL; + +CCodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() { + return m_pCodecModule ? m_pCodecModule->GetJpxModule() : nullptr; } -ICodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() { - return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : NULL; + +CCodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() { + return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : nullptr; } -ICodec_IccModule* CPDF_ModuleMgr::GetIccModule() { - return m_pCodecModule ? m_pCodecModule->GetIccModule() : NULL; + +CCodec_IccModule* CPDF_ModuleMgr::GetIccModule() { + return m_pCodecModule ? m_pCodecModule->GetIccModule() : nullptr; } -ICodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() { - return m_pCodecModule ? m_pCodecModule->GetFlateModule() : NULL; + +CCodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() { + return m_pCodecModule ? m_pCodecModule->GetFlateModule() : nullptr; } diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index 79faebafc9..aa31f9cbac 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -863,12 +863,14 @@ FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, B = pBuf[2]; return TRUE; } - ICodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); + CCodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); if (!m_pProfile->m_pTransform || !pIccModule) { - if (m_pAlterCS) { + if (m_pAlterCS) return m_pAlterCS->GetRGB(pBuf, R, G, B); - } - R = G = B = 0.0f; + + R = 0.0f; + G = 0.0f; + B = 0.0f; return TRUE; } FX_FLOAT rgb[3]; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 5ec25d9fde..48bb667ec7 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -44,7 +44,7 @@ CPDF_StreamParser::~CPDF_StreamParser() { } } -uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, +uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder, uint8_t*& dest_buf, uint32_t& dest_size) { if (!pDecoder) { @@ -73,7 +73,7 @@ uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, return srcoff; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( +CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( const uint8_t* src_buf, uint32_t src_size, int width, @@ -89,7 +89,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, uint8_t*& dest_buf, uint32_t& dest_size) { if (decoder == "CCITTFaxDecode" || decoder == "CCF") { - ICodec_ScanlineDecoder* pDecoder = + CCodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); return DecodeAllScanlines(pDecoder, dest_buf, dest_size); } @@ -108,7 +108,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, dest_size); } if (decoder == "DCTDecode" || decoder == "DCT") { - ICodec_ScanlineDecoder* pDecoder = + CCodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( src_buf, limit, width, height, 0, pParam ? pParam->GetIntegerBy("ColorTransform", 1) : 1); diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index f81f41c89f..5e71002d4d 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -225,7 +225,7 @@ uint32_t RunLengthDecode(const uint8_t* src_buf, return ret; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( +CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( const uint8_t* src_buf, uint32_t src_size, int width, @@ -278,7 +278,7 @@ static FX_BOOL CheckFlateDecodeParams(int Colors, return TRUE; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( +CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( const uint8_t* src_buf, uint32_t src_size, int width, diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index 55e97a9d81..ec8a784623 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -866,7 +866,7 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { } return FALSE; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( +CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( const uint8_t* src_buf, uint32_t src_size, int width, diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 7b88e84399..350c8b85d6 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -70,7 +70,7 @@ T ClampValue(T value, T max_value) { // Wrapper class to use with std::unique_ptr for CJPX_Decoder. class JpxBitMapContext { public: - explicit JpxBitMapContext(ICodec_JpxModule* jpx_module) + explicit JpxBitMapContext(CCodec_JpxModule* jpx_module) : jpx_module_(jpx_module), decoder_(nullptr) {} ~JpxBitMapContext() { jpx_module_->DestroyDecoder(decoder_); } @@ -81,7 +81,7 @@ class JpxBitMapContext { CJPX_Decoder* decoder() { return decoder_; } private: - ICodec_JpxModule* const jpx_module_; // Weak pointer. + CCodec_JpxModule* const jpx_module_; // Weak pointer. CJPX_Decoder* decoder_; // Decoder, owned. // Disallow evil constructors @@ -129,7 +129,7 @@ CPDF_DIBSource::~CPDF_DIBSource() { m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); } if (m_pJbig2Context) { - ICodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module(); + CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module(); pJbig2Module->DestroyJbig2Context(m_pJbig2Context); } } @@ -344,7 +344,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { if (decoder == "JPXDecode") { return 0; } - ICodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module(); + CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module(); if (!m_pJbig2Context) { m_pJbig2Context = pJbig2Module->CreateJbig2Context(); if (m_pStreamAcc->GetImageParam()) { @@ -527,14 +527,14 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, return pCompData; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( +CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( const uint8_t* src_buf, uint32_t src_size, int width, int height, const CPDF_Dictionary* pParams); -ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( +CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( const uint8_t* src_buf, uint32_t src_size, int width, @@ -565,7 +565,7 @@ int CPDF_DIBSource::CreateDecoder() { FX_BOOL bTransform = FALSE; int comps; int bpc; - ICodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); + CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); if (pJpegModule->LoadInfo(src_data, src_size, m_Width, m_Height, comps, bpc, bTransform)) { if (m_nComponents != static_cast<uint32_t>(comps)) { @@ -628,7 +628,7 @@ int CPDF_DIBSource::CreateDecoder() { } void CPDF_DIBSource::LoadJpxBitmap() { - ICodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule(); + CCodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule(); if (!pJpxModule) return; diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h index eab6c9ff21..a94820ab8e 100644 --- a/core/fpdfapi/fpdf_render/render_int.h +++ b/core/fpdfapi/fpdf_render/render_int.h @@ -23,7 +23,7 @@ class CFX_GlyphBitmap; class CFX_ImageTransformer; class CPDF_ImageCacheEntry; class CPDF_ImageLoaderHandle; -class ICodec_ScanlineDecoder; +class CCodec_ScanlineDecoder; class CPDF_Type3Font; class CPDF_Type3Cache; class CPDF_Type3Char; @@ -605,7 +605,7 @@ class CPDF_DIBSource : public CFX_DIBSource { uint8_t* m_pLineBuf; uint8_t* m_pMaskedLine; std::unique_ptr<CFX_DIBitmap> m_pCachedBitmap; - std::unique_ptr<ICodec_ScanlineDecoder> m_pDecoder; + std::unique_ptr<CCodec_ScanlineDecoder> m_pDecoder; void* m_pJbig2Context; CPDF_DIBSource* m_pMask; std::unique_ptr<CPDF_StreamAcc> m_pGlobalStream; diff --git a/core/fpdfapi/include/cpdf_modulemgr.h b/core/fpdfapi/include/cpdf_modulemgr.h index a8be5af7dd..16a6e7bd4f 100644 --- a/core/fpdfapi/include/cpdf_modulemgr.h +++ b/core/fpdfapi/include/cpdf_modulemgr.h @@ -13,12 +13,12 @@ #include "core/fxcrt/include/fx_basic.h" class CCodec_ModuleMgr; -class ICodec_FaxModule; -class ICodec_FlateModule; -class ICodec_IccModule; -class ICodec_Jbig2Module; -class ICodec_JpegModule; -class ICodec_JpxModule; +class CCodec_FaxModule; +class CCodec_FlateModule; +class CCodec_IccModule; +class CCodec_Jbig2Module; +class CCodec_JpegModule; +class CCodec_JpxModule; class IPDF_PageModule; class IPDF_RenderModule; @@ -44,12 +44,12 @@ class CPDF_ModuleMgr { void LoadEmbeddedJapan1CMaps(); void LoadEmbeddedKorea1CMaps(); - ICodec_FaxModule* GetFaxModule(); - ICodec_JpegModule* GetJpegModule(); - ICodec_JpxModule* GetJpxModule(); - ICodec_Jbig2Module* GetJbig2Module(); - ICodec_IccModule* GetIccModule(); - ICodec_FlateModule* GetFlateModule(); + CCodec_FaxModule* GetFaxModule(); + CCodec_JpegModule* GetJpegModule(); + CCodec_JpxModule* GetJpxModule(); + CCodec_Jbig2Module* GetJbig2Module(); + CCodec_IccModule* GetIccModule(); + CCodec_FlateModule* GetFlateModule(); void SetPrivateData(void* module_id, void* pData, diff --git a/core/fxcodec/codec/ccodec_basicmodule.h b/core/fxcodec/codec/ccodec_basicmodule.h new file mode 100644 index 0000000000..4151b4f0f1 --- /dev/null +++ b/core/fxcodec/codec/ccodec_basicmodule.h @@ -0,0 +1,32 @@ +// Copyright 2016 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_CCODEC_BASICMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CCodec_ScanlineDecoder; + +class CCodec_BasicModule { + public: + FX_BOOL RunLengthEncode(const uint8_t* src_buf, + uint32_t src_size, + uint8_t*& dest_buf, + uint32_t& dest_size); + FX_BOOL A85Encode(const uint8_t* src_buf, + uint32_t src_size, + uint8_t*& dest_buf, + uint32_t& dest_size); + CCodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + int bpc); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_bmpmodule.h b/core/fxcodec/codec/ccodec_bmpmodule.h new file mode 100644 index 0000000000..b465edd874 --- /dev/null +++ b/core/fxcodec/codec/ccodec_bmpmodule.h @@ -0,0 +1,46 @@ +// Copyright 2016 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_CCODEC_BMPMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +struct FXBMP_Context; +class CFX_DIBAttribute; + +class CCodec_BmpModule { + public: + CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); } + + FXBMP_Context* Start(void* pModule); + 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); + + int32_t ReadHeader(FXBMP_Context* pContext, + int32_t* width, + int32_t* height, + FX_BOOL* tb_flag, + int32_t* components, + int32_t* pal_num, + uint32_t** pal_pp, + CFX_DIBAttribute* pAttribute); + int32_t LoadImage(FXBMP_Context* pContext); + + FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos); + void (*ReadScanlineCallback)(void* pModule, + int32_t row_num, + uint8_t* row_buf); + + protected: + FX_CHAR m_szLastError[256]; +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_faxmodule.h b/core/fxcodec/codec/ccodec_faxmodule.h new file mode 100644 index 0000000000..ad7e9b6063 --- /dev/null +++ b/core/fxcodec/codec/ccodec_faxmodule.h @@ -0,0 +1,34 @@ +// Copyright 2016 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_CCODEC_FAXMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CCodec_ScanlineDecoder; + +class CCodec_FaxModule { + public: + CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int K, + FX_BOOL EndOfLine, + FX_BOOL EncodedByteAlign, + FX_BOOL BlackIs1, + int Columns, + int Rows); + FX_BOOL Encode(const uint8_t* src_buf, + int width, + int height, + int pitch, + uint8_t*& dest_buf, + uint32_t& dest_size); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_flatemodule.h b/core/fxcodec/codec/ccodec_flatemodule.h new file mode 100644 index 0000000000..aee03719de --- /dev/null +++ b/core/fxcodec/codec/ccodec_flatemodule.h @@ -0,0 +1,51 @@ +// Copyright 2016 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_CCODEC_FLATEMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CCodec_ScanlineDecoder; + +class CCodec_FlateModule { + public: + CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + int bpc, + int predictor, + int Colors, + int BitsPerComponent, + int Columns); + uint32_t FlateOrLZWDecode(FX_BOOL bLZW, + const uint8_t* src_buf, + uint32_t src_size, + FX_BOOL bEarlyChange, + int predictor, + int Colors, + int BitsPerComponent, + int Columns, + uint32_t estimated_size, + uint8_t*& dest_buf, + uint32_t& dest_size); + FX_BOOL Encode(const uint8_t* src_buf, + uint32_t src_size, + int predictor, + int Colors, + int BitsPerComponent, + int Columns, + uint8_t*& dest_buf, + uint32_t& dest_size); + FX_BOOL Encode(const uint8_t* src_buf, + uint32_t src_size, + uint8_t*& dest_buf, + uint32_t& dest_size); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h new file mode 100644 index 0000000000..4878074407 --- /dev/null +++ b/core/fxcodec/codec/ccodec_gifmodule.h @@ -0,0 +1,63 @@ +// Copyright 2016 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_CCODEC_GIFMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +struct FXGIF_Context; + +class CCodec_GifModule { + public: + CCodec_GifModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); } + + FXGIF_Context* Start(void* pModule); + void Finish(FXGIF_Context* pContext); + + uint32_t GetAvailInput(FXGIF_Context* pContext, + uint8_t** avail_buf_ptr = nullptr); + void Input(FXGIF_Context* pContext, + const uint8_t* src_buf, + uint32_t src_size); + + int32_t ReadHeader(FXGIF_Context* pContext, + int* width, + int* height, + int* pal_num, + void** pal_pp, + int* bg_index, + CFX_DIBAttribute* pAttribute); + + int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num); + + int32_t LoadFrame(FXGIF_Context* pContext, + int frame_num, + CFX_DIBAttribute* pAttribute); + + void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos); + uint8_t* (*AskLocalPaletteBufCallback)(void* pModule, + int32_t frame_num, + int32_t pal_size); + FX_BOOL (*InputRecordPositionBufCallback)(void* pModule, + uint32_t rcd_pos, + const FX_RECT& img_rc, + int32_t pal_num, + void* pal_ptr, + int32_t delay_time, + FX_BOOL user_input, + int32_t trans_index, + int32_t disposal_method, + FX_BOOL interlace); + void (*ReadScanlineCallback)(void* pModule, + int32_t row_num, + uint8_t* row_buf); + + protected: + FX_CHAR m_szLastError[256]; +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h new file mode 100644 index 0000000000..9eabd38482 --- /dev/null +++ b/core/fxcodec/codec/ccodec_iccmodule.h @@ -0,0 +1,95 @@ +// Copyright 2016 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_CCODEC_ICCMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_ + +#include "core/fxcodec/include/fx_codec_def.h" +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" + +class CFX_BinaryBuf; +class CFX_IccProfileCache; +class CFX_IccTransformCache; +class CFX_PrivateData; +class IFX_FileRead; + +class CCodec_IccModule { + public: + enum IccCS { + IccCS_Unknown = 0, + IccCS_XYZ, + IccCS_Lab, + IccCS_Luv, + IccCS_YCbCr, + IccCS_Yxy, + IccCS_Hsv, + IccCS_Hls, + IccCS_Gray, + IccCS_Rgb, + IccCS_Cmyk, + IccCS_Cmy + }; + + struct IccParam { + uint32_t Version; + IccCS ColorSpace; + uint32_t dwProfileType; + uint32_t dwFormat; + uint8_t* pProfileData; + uint32_t dwProfileSize; + double Gamma; + }; + + ~CCodec_IccModule(); + + IccCS GetProfileCS(const uint8_t* pProfileData, unsigned int dwProfileSize); + IccCS GetProfileCS(IFX_FileRead* pFile); + void* CreateTransform(CCodec_IccModule::IccParam* pInputParam, + CCodec_IccModule::IccParam* pOutputParam, + CCodec_IccModule::IccParam* pProofParam = nullptr, + uint32_t dwIntent = Icc_INTENT_PERCEPTUAL, + uint32_t dwFlag = Icc_FLAGS_DEFAULT, + uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, + uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING); + void* CreateTransform_sRGB(const uint8_t* pProfileData, + uint32_t dwProfileSize, + uint32_t& nComponents, + int32_t intent = 0, + uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT); + void* CreateTransform_CMYK(const uint8_t* pSrcProfileData, + uint32_t dwSrcProfileSize, + uint32_t& nSrcComponents, + const uint8_t* pDstProfileData, + uint32_t dwDstProfileSize, + int32_t intent = 0, + uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT, + uint32_t dwDstFormat = Icc_FORMAT_DEFAULT); + void DestroyTransform(void* pTransform); + void Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOAT* pDestValues); + void TranslateScanline(void* pTransform, + uint8_t* pDest, + const uint8_t* pSrc, + int pixels); + void SetComponents(uint32_t nComponents) { m_nComponents = nComponents; } + + protected: + enum Icc_CLASS { + Icc_CLASS_INPUT = 0, + Icc_CLASS_OUTPUT, + Icc_CLASS_PROOF, + Icc_CLASS_MAX + }; + void* CreateProfile(CCodec_IccModule::IccParam* pIccParam, + Icc_CLASS ic, + CFX_BinaryBuf* pTransformKey); + + uint32_t m_nComponents; + std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform; + std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile; +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h new file mode 100644 index 0000000000..20578c8cdb --- /dev/null +++ b/core/fxcodec/codec/ccodec_jbig2module.h @@ -0,0 +1,34 @@ +// Copyright 2016 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_CCODEC_JBIG2MODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CPDF_StreamAcc; +class IFX_Pause; + +class CCodec_Jbig2Module { + public: + CCodec_Jbig2Module() {} + ~CCodec_Jbig2Module(); + + void* CreateJbig2Context(); + FXCODEC_STATUS StartDecode(void* pJbig2Context, + CFX_PrivateData* pPrivateData, + uint32_t width, + uint32_t height, + CPDF_StreamAcc* src_stream, + CPDF_StreamAcc* global_stream, + uint8_t* dest_buf, + uint32_t dest_pitch, + IFX_Pause* pPause); + FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* pPause); + void DestroyJbig2Context(void* pJbig2Context); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_ diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h new file mode 100644 index 0000000000..98554fea1c --- /dev/null +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -0,0 +1,68 @@ +// Copyright 2016 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_CCODEC_JPEGMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CCodec_ScanlineDecoder; +class CFX_DIBSource; +struct FXJPEG_Context; + +#ifdef PDF_ENABLE_XFA +class CFX_DIBAttribute; +#endif // PDF_ENABLE_XFA + +class CCodec_JpegModule { + public: + CCodec_JpegModule() {} + CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + FX_BOOL ColorTransform); + FX_BOOL LoadInfo(const uint8_t* src_buf, + uint32_t src_size, + int& width, + int& height, + int& num_components, + int& bits_per_components, + FX_BOOL& color_transform, + uint8_t** icc_buf_ptr = nullptr, + uint32_t* icc_length = nullptr); + FX_BOOL Encode(const CFX_DIBSource* pSource, + uint8_t*& dest_buf, + FX_STRSIZE& dest_size, + int quality = 75, + const uint8_t* icc_buf = nullptr, + uint32_t icc_length = 0); + FXJPEG_Context* Start(); + void Finish(FXJPEG_Context* pContext); + void Input(FXJPEG_Context* pContext, + const uint8_t* src_buf, + uint32_t src_size); + +#ifndef PDF_ENABLE_XFA + int ReadHeader(FXJPEG_Context* pContext, + int* width, + int* height, + int* nComps); +#else // PDF_ENABLE_XFA + int ReadHeader(FXJPEG_Context* pContext, + int* width, + int* height, + int* nComps, + CFX_DIBAttribute* pAttribute); +#endif // PDF_ENABLE_XFA + + int StartScanline(FXJPEG_Context* pContext, int down_scale); + FX_BOOL ReadScanline(FXJPEG_Context* pContext, uint8_t* dest_buf); + uint32_t GetAvailInput(FXJPEG_Context* pContext, uint8_t** avail_buf_ptr); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_jpxmodule.h b/core/fxcodec/codec/ccodec_jpxmodule.h new file mode 100644 index 0000000000..149e8a7c9a --- /dev/null +++ b/core/fxcodec/codec/ccodec_jpxmodule.h @@ -0,0 +1,36 @@ +// Copyright 2016 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_CCODEC_JPXMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_ + +#include <vector> + +#include "core/fxcrt/include/fx_system.h" + +class CJPX_Decoder; +class CPDF_ColorSpace; + +class CCodec_JpxModule { + public: + CCodec_JpxModule(); + ~CCodec_JpxModule(); + + CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, + uint32_t src_size, + CPDF_ColorSpace* cs); + void GetImageInfo(CJPX_Decoder* pDecoder, + uint32_t* width, + uint32_t* height, + uint32_t* components); + bool Decode(CJPX_Decoder* pDecoder, + uint8_t* dest_data, + int pitch, + const std::vector<uint8_t>& offsets); + void DestroyDecoder(CJPX_Decoder* pDecoder); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_pngmodule.h b/core/fxcodec/codec/ccodec_pngmodule.h new file mode 100644 index 0000000000..23b5d4b5b9 --- /dev/null +++ b/core/fxcodec/codec/ccodec_pngmodule.h @@ -0,0 +1,42 @@ +// Copyright 2016 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_CCODEC_PNGMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CFX_DIBAttribute; +struct FXPNG_Context; + +#define PNG_ERROR_SIZE 256 + +class CCodec_PngModule { + public: + CCodec_PngModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); } + + FXPNG_Context* Start(void* pModule); + void Finish(FXPNG_Context* pContext); + FX_BOOL Input(FXPNG_Context* pContext, + const uint8_t* src_buf, + uint32_t src_size, + CFX_DIBAttribute* pAttribute); + + FX_BOOL (*ReadHeaderCallback)(void* pModule, + int width, + int height, + int bpc, + int pass, + int* color_type, + double* gamma); + FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf); + void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line); + + protected: + FX_CHAR m_szLastError[PNG_ERROR_SIZE]; +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_ diff --git a/core/fxcodec/codec/ccodec_scanlinedecoder.h b/core/fxcodec/codec/ccodec_scanlinedecoder.h new file mode 100644 index 0000000000..cd18c8d76e --- /dev/null +++ b/core/fxcodec/codec/ccodec_scanlinedecoder.h @@ -0,0 +1,46 @@ +// Copyright 2016 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_CCODEC_SCANLINEDECODER_H_ +#define CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_ + +#include "core/fxcrt/include/fx_system.h" + +class IFX_Pause; + +class CCodec_ScanlineDecoder { + public: + CCodec_ScanlineDecoder(); + virtual ~CCodec_ScanlineDecoder(); + + const uint8_t* GetScanline(int line); + FX_BOOL SkipToScanline(int line, IFX_Pause* pPause); + + int GetWidth() { return m_OutputWidth; } + int GetHeight() { return m_OutputHeight; } + int CountComps() { return m_nComps; } + int GetBPC() { return m_bpc; } + + virtual uint32_t GetSrcOffset() = 0; + + protected: + virtual FX_BOOL v_Rewind() = 0; + virtual uint8_t* v_GetNextLine() = 0; + + uint8_t* ReadNextLine(); + + int m_OrigWidth; + int m_OrigHeight; + int m_OutputWidth; + int m_OutputHeight; + int m_nComps; + int m_bpc; + uint32_t m_Pitch; + int m_NextLine; + uint8_t* m_pLastScanline; +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_ diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h new file mode 100644 index 0000000000..d746bb7e85 --- /dev/null +++ b/core/fxcodec/codec/ccodec_tiffmodule.h @@ -0,0 +1,35 @@ +// Copyright 2016 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_CCODEC_TIFFMODULE_H_ +#define CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CCodec_TiffContext; +class CFX_DIBAttribute; +class CFX_DIBitmap; +class IFX_FileRead; + +class CCodec_TiffModule { + public: + ~CCodec_TiffModule() {} + + CCodec_TiffContext* CreateDecoder(IFX_FileRead* file_ptr); + + void GetFrames(CCodec_TiffContext* ctx, int32_t& frames); + FX_BOOL LoadFrameInfo(CCodec_TiffContext* ctx, + int32_t frame, + uint32_t& width, + uint32_t& height, + uint32_t& comps, + uint32_t& bpc, + CFX_DIBAttribute* pAttribute); + FX_BOOL Decode(CCodec_TiffContext* ctx, class CFX_DIBitmap* pDIBitmap); + void DestroyDecoder(CCodec_TiffContext* ctx); +}; + +#endif // CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_ diff --git a/core/fxcodec/codec/codec_int.h b/core/fxcodec/codec/codec_int.h index ed9bcac349..e0d2ff494f 100644 --- a/core/fxcodec/codec/codec_int.h +++ b/core/fxcodec/codec/codec_int.h @@ -16,362 +16,10 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxcodec/jbig2/JBig2_Context.h" -#include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. +#include "third_party/libopenjpeg20/openjpeg.h" -class CFX_IccProfileCache; -class CFX_IccTransformCache; class CPDF_ColorSpace; -class CCodec_BasicModule : public ICodec_BasicModule { - public: - // ICodec_BasicModule: - FX_BOOL RunLengthEncode(const uint8_t* src_buf, - uint32_t src_size, - uint8_t*& dest_buf, - uint32_t& dest_size) override; - FX_BOOL A85Encode(const uint8_t* src_buf, - uint32_t src_size, - uint8_t*& dest_buf, - uint32_t& dest_size) override; - ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc) override; -}; - -class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { - public: - CCodec_ScanlineDecoder(); - ~CCodec_ScanlineDecoder() override; - - // ICodec_ScanlineDecoder - const uint8_t* GetScanline(int line) override; - FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) override; - int GetWidth() override { return m_OutputWidth; } - int GetHeight() override { return m_OutputHeight; } - int CountComps() override { return m_nComps; } - int GetBPC() override { return m_bpc; } - - protected: - virtual FX_BOOL v_Rewind() = 0; - virtual uint8_t* v_GetNextLine() = 0; - - uint8_t* ReadNextLine(); - - int m_OrigWidth; - int m_OrigHeight; - int m_OutputWidth; - int m_OutputHeight; - int m_nComps; - int m_bpc; - uint32_t m_Pitch; - int m_NextLine; - uint8_t* m_pLastScanline; -}; - -class CCodec_FaxModule : public ICodec_FaxModule { - public: - // ICodec_FaxModule: - ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int K, - FX_BOOL EndOfLine, - FX_BOOL EncodedByteAlign, - FX_BOOL BlackIs1, - int Columns, - int Rows) override; - FX_BOOL Encode(const uint8_t* src_buf, - int width, - int height, - int pitch, - uint8_t*& dest_buf, - uint32_t& dest_size) override; -}; - -class CCodec_FlateModule : public ICodec_FlateModule { - public: - virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc, - int predictor, - int Colors, - int BitsPerComponent, - int Columns); - virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW, - const uint8_t* src_buf, - uint32_t src_size, - FX_BOOL bEarlyChange, - int predictor, - int Colors, - int BitsPerComponent, - int Columns, - uint32_t estimated_size, - uint8_t*& dest_buf, - uint32_t& dest_size); - virtual FX_BOOL Encode(const uint8_t* src_buf, - uint32_t src_size, - int predictor, - int Colors, - int BitsPerComponent, - int Columns, - uint8_t*& dest_buf, - uint32_t& dest_size); - virtual FX_BOOL Encode(const uint8_t* src_buf, - uint32_t src_size, - uint8_t*& dest_buf, - uint32_t& dest_size); -}; - -class CCodec_JpegModule : public ICodec_JpegModule { - public: - CCodec_JpegModule() {} - ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - FX_BOOL ColorTransform) override; - FX_BOOL LoadInfo(const uint8_t* src_buf, - uint32_t src_size, - int& width, - int& height, - int& num_components, - int& bits_per_components, - FX_BOOL& color_transform, - uint8_t** icc_buf_ptr, - uint32_t* icc_length) override; - FX_BOOL Encode(const CFX_DIBSource* pSource, - uint8_t*& dest_buf, - FX_STRSIZE& dest_size, - int quality, - const uint8_t* icc_buf, - uint32_t icc_length) override; - void* Start() override; - void Finish(void* pContext) override; - void Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size) override; -#ifndef PDF_ENABLE_XFA - int ReadHeader(void* pContext, int* width, int* height, int* nComps) override; -#else // PDF_ENABLE_XFA - int ReadHeader(void* pContext, - int* width, - int* height, - int* nComps, - CFX_DIBAttribute* pAttribute) override; -#endif // PDF_ENABLE_XFA - int StartScanline(void* pContext, int down_scale) override; - FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override; - uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; -}; - -#ifdef PDF_ENABLE_XFA -#define PNG_ERROR_SIZE 256 -class CCodec_PngModule : public ICodec_PngModule { - public: - CCodec_PngModule() { FXSYS_memset(m_szLastError, '\0', PNG_ERROR_SIZE); } - - virtual void* Start(void* pModule); - virtual void Finish(void* pContext); - virtual FX_BOOL Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size, - CFX_DIBAttribute* pAttribute); - - protected: - FX_CHAR m_szLastError[PNG_ERROR_SIZE]; -}; -class CCodec_GifModule : public ICodec_GifModule { - public: - CCodec_GifModule() { FXSYS_memset(m_szLastError, '\0', 256); } - virtual void* Start(void* pModule); - virtual void Finish(void* pContext); - virtual uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); - virtual void Input(void* pContext, const uint8_t* src_buf, uint32_t src_size); - - virtual int32_t ReadHeader(void* pContext, - int* width, - int* height, - int* pal_num, - void** pal_pp, - int* bg_index, - CFX_DIBAttribute* pAttribute); - - virtual int32_t LoadFrameInfo(void* pContext, int* frame_num); - - virtual int32_t LoadFrame(void* pContext, - int frame_num, - CFX_DIBAttribute* pAttribute); - - protected: - FX_CHAR m_szLastError[256]; -}; -class CCodec_BmpModule : public ICodec_BmpModule { - public: - CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); } - void* Start(void* pModule) override; - void Finish(void* pContext) override; - uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; - void Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size) override; - int32_t ReadHeader(void* pContext, - int32_t* width, - int32_t* height, - FX_BOOL* tb_flag, - int32_t* components, - int32_t* pal_num, - uint32_t** pal_pp, - CFX_DIBAttribute* pAttribute) override; - int32_t LoadImage(void* pContext) override; - - protected: - FX_CHAR m_szLastError[256]; -}; -#endif // PDF_ENABLE_XFA - -class CCodec_IccModule : public ICodec_IccModule { - public: - ~CCodec_IccModule() override; - - // ICodec_IccModule: - IccCS GetProfileCS(const uint8_t* pProfileData, - unsigned int dwProfileSize) override; - IccCS GetProfileCS(IFX_FileRead* pFile) override; - void* CreateTransform(ICodec_IccModule::IccParam* pInputParam, - ICodec_IccModule::IccParam* pOutputParam, - ICodec_IccModule::IccParam* pProofParam = NULL, - uint32_t dwIntent = Icc_INTENT_PERCEPTUAL, - uint32_t dwFlag = Icc_FLAGS_DEFAULT, - uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, - uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) override; - void* CreateTransform_sRGB( - const uint8_t* pProfileData, - uint32_t dwProfileSize, - uint32_t& nComponents, - int32_t intent = 0, - uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) override; - void* CreateTransform_CMYK( - const uint8_t* pSrcProfileData, - uint32_t dwSrcProfileSize, - uint32_t& nSrcComponents, - const uint8_t* pDstProfileData, - uint32_t dwDstProfileSize, - int32_t intent = 0, - uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT, - uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) override; - void DestroyTransform(void* pTransform) override; - void Translate(void* pTransform, - FX_FLOAT* pSrcValues, - FX_FLOAT* pDestValues) override; - void TranslateScanline(void* pTransform, - uint8_t* pDest, - const uint8_t* pSrc, - int pixels) override; - void SetComponents(uint32_t nComponents) override { - m_nComponents = nComponents; - } - - protected: - enum Icc_CLASS { - Icc_CLASS_INPUT = 0, - Icc_CLASS_OUTPUT, - Icc_CLASS_PROOF, - Icc_CLASS_MAX - }; - void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, - Icc_CLASS ic, - CFX_BinaryBuf* pTransformKey); - - uint32_t m_nComponents; - std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform; - std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile; -}; - -class CCodec_JpxModule : public ICodec_JpxModule { - public: - CCodec_JpxModule(); - ~CCodec_JpxModule() override; - - // ICodec_JpxModule: - CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - CPDF_ColorSpace* cs) override; - void GetImageInfo(CJPX_Decoder* pDecoder, - uint32_t* width, - uint32_t* height, - uint32_t* components) override; - bool Decode(CJPX_Decoder* pDecoder, - uint8_t* dest_data, - int pitch, - const std::vector<uint8_t>& offsets) override; - void DestroyDecoder(CJPX_Decoder* pDecoder) override; -}; - -#ifdef PDF_ENABLE_XFA -class CCodec_TiffModule : public ICodec_TiffModule { - public: - // ICodec_TiffModule - void* CreateDecoder(IFX_FileRead* file_ptr) override; - void GetFrames(void* ctx, int32_t& frames) override; - FX_BOOL LoadFrameInfo(void* ctx, - int32_t frame, - uint32_t& width, - uint32_t& height, - uint32_t& comps, - uint32_t& bpc, - CFX_DIBAttribute* pAttribute) override; - FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) override; - void DestroyDecoder(void* ctx) override; - - protected: - ~CCodec_TiffModule() override {} -}; -#endif // PDF_ENABLE_XFA - -class CCodec_Jbig2Context { - public: - CCodec_Jbig2Context(); - ~CCodec_Jbig2Context() {} - - uint32_t m_width; - uint32_t m_height; - CPDF_StreamAcc* m_pGlobalStream; - CPDF_StreamAcc* m_pSrcStream; - uint8_t* m_dest_buf; - uint32_t m_dest_pitch; - IFX_Pause* m_pPause; - CJBig2_Context* m_pContext; - CJBig2_Image* m_dest_image; -}; -class CCodec_Jbig2Module : public ICodec_Jbig2Module { - public: - CCodec_Jbig2Module() {} - ~CCodec_Jbig2Module() override; - - // ICodec_Jbig2Module - void* CreateJbig2Context() override; - FXCODEC_STATUS StartDecode(void* pJbig2Context, - CFX_PrivateData* pPrivateData, - uint32_t width, - uint32_t height, - CPDF_StreamAcc* src_stream, - CPDF_StreamAcc* global_stream, - uint8_t* dest_buf, - uint32_t dest_pitch, - IFX_Pause* pPause) override; - FXCODEC_STATUS ContinueDecode(void* pJbig2Context, - IFX_Pause* pPause) override; - void DestroyJbig2Context(void* pJbig2Context) override; -}; - struct DecodeData { public: DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index 77dd363c9d..a0356929a5 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -7,6 +7,7 @@ #include "core/fxcodec/include/fx_codec.h" #include <cmath> +#include <memory> #include <utility> #include "core/fxcodec/codec/codec_int.h" @@ -397,18 +398,20 @@ void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) { count -= used_bytes; m_Operator = 257 - count; } -ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder( + +CCodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder( const uint8_t* src_buf, uint32_t src_size, int width, int height, int nComps, int bpc) { - CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; + std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder( + new CCodec_RLScanlineDecoder); if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, bpc)) { - delete pRLScanlineDecoder; - return NULL; + return nullptr; } - return pRLScanlineDecoder; + + return pRLScanlineDecoder.release(); } diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp index 0fed151217..03390cfea3 100644 --- a/core/fxcodec/codec/fx_codec_bmp.cpp +++ b/core/fxcodec/codec/fx_codec_bmp.cpp @@ -42,24 +42,25 @@ static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); } -void* CCodec_BmpModule::Start(void* pModule) { - FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context)); - if (p == NULL) { - return NULL; - } + +FXBMP_Context* CCodec_BmpModule::Start(void* pModule) { + FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1); + if (!p) + return nullptr; + FXSYS_memset(p, 0, sizeof(FXBMP_Context)); - if (p == NULL) { - return NULL; - } + if (!p) + return nullptr; + p->m_AllocFunc = bmp_alloc_func; p->m_FreeFunc = bmp_free_func; - p->bmp_ptr = NULL; + p->bmp_ptr = nullptr; p->parent_ptr = (void*)this; p->child_ptr = pModule; p->bmp_ptr = bmp_create_decompress(); - if (p->bmp_ptr == NULL) { + if (!p->bmp_ptr) { FX_Free(p); - return NULL; + return nullptr; } p->bmp_ptr->context_ptr = (void*)p; p->bmp_ptr->err_ptr = m_szLastError; @@ -68,14 +69,14 @@ void* CCodec_BmpModule::Start(void* pModule) { p->bmp_ptr->bmp_get_data_position_fn = bmp_get_data_position; return p; } -void CCodec_BmpModule::Finish(void* pContext) { - FXBMP_Context* p = (FXBMP_Context*)pContext; - if (p) { - bmp_destroy_decompress(&p->bmp_ptr); - p->m_FreeFunc(p); + +void CCodec_BmpModule::Finish(FXBMP_Context* ctx) { + if (ctx) { + bmp_destroy_decompress(&ctx->bmp_ptr); + ctx->m_FreeFunc(ctx); } } -int32_t CCodec_BmpModule::ReadHeader(void* pContext, +int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx, int32_t* width, int32_t* height, FX_BOOL* tb_flag, @@ -83,43 +84,41 @@ int32_t CCodec_BmpModule::ReadHeader(void* pContext, int32_t* pal_num, uint32_t** pal_pp, CFX_DIBAttribute* pAttribute) { - FXBMP_Context* p = (FXBMP_Context*)pContext; - if (setjmp(p->bmp_ptr->jmpbuf)) { + if (setjmp(ctx->bmp_ptr->jmpbuf)) { return 0; } - int32_t ret = bmp_read_header(p->bmp_ptr); + int32_t ret = bmp_read_header(ctx->bmp_ptr); if (ret != 1) { return ret; } - *width = p->bmp_ptr->width; - *height = p->bmp_ptr->height; - *tb_flag = p->bmp_ptr->imgTB_flag; - *components = p->bmp_ptr->components; - *pal_num = p->bmp_ptr->pal_num; - *pal_pp = p->bmp_ptr->pal_ptr; + *width = ctx->bmp_ptr->width; + *height = ctx->bmp_ptr->height; + *tb_flag = ctx->bmp_ptr->imgTB_flag; + *components = ctx->bmp_ptr->components; + *pal_num = ctx->bmp_ptr->pal_num; + *pal_pp = ctx->bmp_ptr->pal_ptr; if (pAttribute) { pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER; - pAttribute->m_nXDPI = p->bmp_ptr->dpi_x; - pAttribute->m_nYDPI = p->bmp_ptr->dpi_y; - pAttribute->m_nBmpCompressType = p->bmp_ptr->compress_flag; + pAttribute->m_nXDPI = ctx->bmp_ptr->dpi_x; + pAttribute->m_nYDPI = ctx->bmp_ptr->dpi_y; + pAttribute->m_nBmpCompressType = ctx->bmp_ptr->compress_flag; } return 1; } -int32_t CCodec_BmpModule::LoadImage(void* pContext) { - FXBMP_Context* p = (FXBMP_Context*)pContext; - if (setjmp(p->bmp_ptr->jmpbuf)) { + +int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) { + if (setjmp(ctx->bmp_ptr->jmpbuf)) return 0; - } - return bmp_decode_image(p->bmp_ptr); + return bmp_decode_image(ctx->bmp_ptr); } -uint32_t CCodec_BmpModule::GetAvailInput(void* pContext, + +uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx, uint8_t** avial_buf_ptr) { - FXBMP_Context* p = (FXBMP_Context*)pContext; - return bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr); + return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr); } -void CCodec_BmpModule::Input(void* pContext, + +void CCodec_BmpModule::Input(FXBMP_Context* ctx, const uint8_t* src_buf, uint32_t src_size) { - FXBMP_Context* p = (FXBMP_Context*)pContext; - bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size); + bmp_input_buffer(ctx->bmp_ptr, (uint8_t*)src_buf, src_size); } diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 898b0d0251..91f9eb2eb8 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -810,7 +810,7 @@ FX_BOOL CCodec_FaxModule::Encode(const uint8_t* src_buf, encoder.Encode(dest_buf, dest_size); return TRUE; } -ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder( +CCodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder( const uint8_t* src_buf, uint32_t src_size, int width, diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index 16cde3e5ea..d1b4a5f985 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -897,7 +897,7 @@ uint32_t CCodec_FlateScanlineDecoder::GetSrcOffset() { return FPDFAPI_FlateGetTotalIn(m_pFlate); } -ICodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder( +CCodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder( const uint8_t* src_buf, uint32_t src_size, int width, diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp index 5fc0d094d8..b7362ca4b3 100644 --- a/core/fxcodec/codec/fx_codec_gif.cpp +++ b/core/fxcodec/codec/fx_codec_gif.cpp @@ -69,21 +69,22 @@ static FX_BOOL gif_get_record_position(gif_decompress_struct_p gif_ptr, pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method, interlace); } -void* CCodec_GifModule::Start(void* pModule) { - FXGIF_Context* p = (FXGIF_Context*)FX_Alloc(uint8_t, sizeof(FXGIF_Context)); - if (p == NULL) { - return NULL; - } + +FXGIF_Context* CCodec_GifModule::Start(void* pModule) { + FXGIF_Context* p = FX_Alloc(FXGIF_Context, 1); + if (!p) + return nullptr; + FXSYS_memset(p, 0, sizeof(FXGIF_Context)); p->m_AllocFunc = gif_alloc_func; p->m_FreeFunc = gif_free_func; - p->gif_ptr = NULL; + p->gif_ptr = nullptr; p->parent_ptr = (void*)this; p->child_ptr = pModule; p->gif_ptr = gif_create_decompress(); - if (p->gif_ptr == NULL) { + if (!p->gif_ptr) { FX_Free(p); - return NULL; + return nullptr; } p->gif_ptr->context_ptr = (void*)p; p->gif_ptr->err_ptr = m_szLastError; @@ -94,68 +95,66 @@ void* CCodec_GifModule::Start(void* pModule) { p->gif_ptr->gif_get_record_position_fn = gif_get_record_position; return p; } -void CCodec_GifModule::Finish(void* pContext) { - FXGIF_Context* p = (FXGIF_Context*)pContext; - if (p) { - gif_destroy_decompress(&p->gif_ptr); - p->m_FreeFunc(p); + +void CCodec_GifModule::Finish(FXGIF_Context* ctx) { + if (ctx) { + gif_destroy_decompress(&ctx->gif_ptr); + ctx->m_FreeFunc(ctx); } } -int32_t CCodec_GifModule::ReadHeader(void* pContext, + +int32_t CCodec_GifModule::ReadHeader(FXGIF_Context* ctx, int* width, int* height, int* pal_num, void** pal_pp, int* bg_index, CFX_DIBAttribute* pAttribute) { - FXGIF_Context* p = (FXGIF_Context*)pContext; - if (setjmp(p->gif_ptr->jmpbuf)) { + if (setjmp(ctx->gif_ptr->jmpbuf)) return 0; - } - int32_t ret = gif_read_header(p->gif_ptr); - if (ret != 1) { + + int32_t ret = gif_read_header(ctx->gif_ptr); + if (ret != 1) return ret; - } - if (pAttribute) { - } - *width = p->gif_ptr->width; - *height = p->gif_ptr->height; - *pal_num = p->gif_ptr->global_pal_num; - *pal_pp = p->gif_ptr->global_pal_ptr; - *bg_index = p->gif_ptr->bc_index; + + *width = ctx->gif_ptr->width; + *height = ctx->gif_ptr->height; + *pal_num = ctx->gif_ptr->global_pal_num; + *pal_pp = ctx->gif_ptr->global_pal_ptr; + *bg_index = ctx->gif_ptr->bc_index; return 1; } -int32_t CCodec_GifModule::LoadFrameInfo(void* pContext, int* frame_num) { - FXGIF_Context* p = (FXGIF_Context*)pContext; - if (setjmp(p->gif_ptr->jmpbuf)) { + +int32_t CCodec_GifModule::LoadFrameInfo(FXGIF_Context* ctx, int* frame_num) { + if (setjmp(ctx->gif_ptr->jmpbuf)) return 0; - } - int32_t ret = gif_get_frame(p->gif_ptr); - if (ret != 1) { + + int32_t ret = gif_get_frame(ctx->gif_ptr); + if (ret != 1) return ret; - } - *frame_num = gif_get_frame_num(p->gif_ptr); + + *frame_num = gif_get_frame_num(ctx->gif_ptr); return 1; } -int32_t CCodec_GifModule::LoadFrame(void* pContext, + +int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx, int frame_num, CFX_DIBAttribute* pAttribute) { - FXGIF_Context* p = (FXGIF_Context*)pContext; - if (setjmp(p->gif_ptr->jmpbuf)) { + if (setjmp(ctx->gif_ptr->jmpbuf)) return 0; - } - int32_t ret = gif_load_frame(p->gif_ptr, frame_num); + + int32_t ret = gif_load_frame(ctx->gif_ptr, frame_num); if (ret == 1) { if (pAttribute) { pAttribute->m_nGifLeft = - p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left; + ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left; pAttribute->m_nGifTop = - p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top; - pAttribute->m_fAspectRatio = p->gif_ptr->pixel_aspect; - if (p->gif_ptr->cmt_data_ptr) { + ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top; + pAttribute->m_fAspectRatio = ctx->gif_ptr->pixel_aspect; + if (ctx->gif_ptr->cmt_data_ptr) { const uint8_t* buf = - (const uint8_t*)p->gif_ptr->cmt_data_ptr->GetBuffer(0); - uint32_t len = p->gif_ptr->cmt_data_ptr->GetLength(); + (const uint8_t*)ctx->gif_ptr->cmt_data_ptr->GetBuffer(0); + uint32_t len = ctx->gif_ptr->cmt_data_ptr->GetLength(); if (len > 21) { uint8_t size = *buf++; if (size) { @@ -174,14 +173,14 @@ int32_t CCodec_GifModule::LoadFrame(void* pContext, } return ret; } -uint32_t CCodec_GifModule::GetAvailInput(void* pContext, + +uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx, uint8_t** avial_buf_ptr) { - FXGIF_Context* p = (FXGIF_Context*)pContext; - return gif_get_avail_input(p->gif_ptr, avial_buf_ptr); + return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr); } -void CCodec_GifModule::Input(void* pContext, + +void CCodec_GifModule::Input(FXGIF_Context* ctx, const uint8_t* src_buf, uint32_t src_size) { - FXGIF_Context* p = (FXGIF_Context*)pContext; - gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size); + gif_input_buffer(ctx->gif_ptr, (uint8_t*)src_buf, src_size); } diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 74801e57a0..324c01ad0b 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -251,41 +251,41 @@ void* CreateProfile_Gray(double gamma) { cmsFreeToneCurve(curve); return profile; } -ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) { +CCodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) { if (!pProfile) { - return ICodec_IccModule::IccCS_Unknown; + return CCodec_IccModule::IccCS_Unknown; } switch (cmsGetColorSpace(pProfile)) { case cmsSigXYZData: - return ICodec_IccModule::IccCS_XYZ; + return CCodec_IccModule::IccCS_XYZ; case cmsSigLabData: - return ICodec_IccModule::IccCS_Lab; + return CCodec_IccModule::IccCS_Lab; case cmsSigLuvData: - return ICodec_IccModule::IccCS_Luv; + return CCodec_IccModule::IccCS_Luv; case cmsSigYCbCrData: - return ICodec_IccModule::IccCS_YCbCr; + return CCodec_IccModule::IccCS_YCbCr; case cmsSigYxyData: - return ICodec_IccModule::IccCS_Yxy; + return CCodec_IccModule::IccCS_Yxy; case cmsSigRgbData: - return ICodec_IccModule::IccCS_Rgb; + return CCodec_IccModule::IccCS_Rgb; case cmsSigGrayData: - return ICodec_IccModule::IccCS_Gray; + return CCodec_IccModule::IccCS_Gray; case cmsSigHsvData: - return ICodec_IccModule::IccCS_Hsv; + return CCodec_IccModule::IccCS_Hsv; case cmsSigHlsData: - return ICodec_IccModule::IccCS_Hls; + return CCodec_IccModule::IccCS_Hls; case cmsSigCmykData: - return ICodec_IccModule::IccCS_Cmyk; + return CCodec_IccModule::IccCS_Cmyk; case cmsSigCmyData: - return ICodec_IccModule::IccCS_Cmy; + return CCodec_IccModule::IccCS_Cmy; default: - return ICodec_IccModule::IccCS_Unknown; + return CCodec_IccModule::IccCS_Unknown; } } -ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( +CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( const uint8_t* pProfileData, uint32_t dwProfileSize) { - ICodec_IccModule::IccCS cs; + CCodec_IccModule::IccCS cs; cmsHPROFILE hProfile = cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize); if (!hProfile) { @@ -297,11 +297,11 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( } return cs; } -ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) { +CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) { if (!pFile) { return IccCS_Unknown; } - ICodec_IccModule::IccCS cs; + CCodec_IccModule::IccCS cs; uint32_t dwSize = (uint32_t)pFile->GetSize(); uint8_t* pBuf = FX_Alloc(uint8_t, dwSize); pFile->ReadBlock(pBuf, 0, dwSize); @@ -406,7 +406,7 @@ CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) { AppendBlock(&i, sizeof(uint32_t)); return *this; } -void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, +void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam, Icc_CLASS ic, CFX_BinaryBuf* pTransformKey) { CFX_IccProfileCache* pCache = NULL; @@ -469,9 +469,9 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, return pCache->m_pProfile; } void* CCodec_IccModule::CreateTransform( - ICodec_IccModule::IccParam* pInputParam, - ICodec_IccModule::IccParam* pOutputParam, - ICodec_IccModule::IccParam* pProofParam, + CCodec_IccModule::IccParam* pInputParam, + CCodec_IccModule::IccParam* pOutputParam, + CCodec_IccModule::IccParam* pProofParam, uint32_t dwIntent, uint32_t dwFlag, uint32_t dwPrfIntent, diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp index 96f6836190..b5e32f130d 100644 --- a/core/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/fxcodec/codec/fx_codec_jbig.cpp @@ -9,6 +9,26 @@ #include "core/fxcodec/codec/codec_int.h" #include "core/fxcodec/include/fx_codec.h" +namespace { + +class CCodec_Jbig2Context { + public: + CCodec_Jbig2Context(); + ~CCodec_Jbig2Context() {} + + uint32_t m_width; + uint32_t m_height; + CPDF_StreamAcc* m_pGlobalStream; + CPDF_StreamAcc* m_pSrcStream; + uint8_t* m_dest_buf; + uint32_t m_dest_pitch; + IFX_Pause* m_pPause; + CJBig2_Context* m_pContext; + CJBig2_Image* m_dest_image; +}; + +} // namespace + // Holds per-document JBig2 related data. class JBig2DocumentContext : public CFX_DestructObject { public: diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 9a2a0ee4a3..608bf52969 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -476,7 +476,7 @@ uint8_t* CCodec_JpegDecoder::v_GetNextLine() { uint32_t CCodec_JpegDecoder::GetSrcOffset() { return (uint32_t)(m_SrcSize - src.bytes_in_buffer); } -ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder( +CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder( const uint8_t* src_buf, uint32_t src_size, int width, @@ -551,7 +551,7 @@ static void* jpeg_alloc_func(unsigned int size) { static void jpeg_free_func(void* p) { FX_Free(p); } -void* CCodec_JpegModule::Start() { +FXJPEG_Context* CCodec_JpegModule::Start() { FXJPEG_Context* p = FX_Alloc(FXJPEG_Context, 1); p->m_AllocFunc = jpeg_alloc_func; p->m_FreeFunc = jpeg_free_func; @@ -575,85 +575,83 @@ void* CCodec_JpegModule::Start() { p->m_SkipSize = 0; return p; } -void CCodec_JpegModule::Finish(void* pContext) { - FXJPEG_Context* p = (FXJPEG_Context*)pContext; - jpeg_destroy_decompress(&p->m_Info); - p->m_FreeFunc(p); + +void CCodec_JpegModule::Finish(FXJPEG_Context* ctx) { + jpeg_destroy_decompress(&ctx->m_Info); + ctx->m_FreeFunc(ctx); } -void CCodec_JpegModule::Input(void* pContext, + +void CCodec_JpegModule::Input(FXJPEG_Context* ctx, const unsigned char* src_buf, uint32_t src_size) { - FXJPEG_Context* p = (FXJPEG_Context*)pContext; - if (p->m_SkipSize) { - if (p->m_SkipSize > src_size) { - p->m_SrcMgr.bytes_in_buffer = 0; - p->m_SkipSize -= src_size; + if (ctx->m_SkipSize) { + if (ctx->m_SkipSize > src_size) { + ctx->m_SrcMgr.bytes_in_buffer = 0; + ctx->m_SkipSize -= src_size; return; } - src_size -= p->m_SkipSize; - src_buf += p->m_SkipSize; - p->m_SkipSize = 0; + src_size -= ctx->m_SkipSize; + src_buf += ctx->m_SkipSize; + ctx->m_SkipSize = 0; } - p->m_SrcMgr.next_input_byte = src_buf; - p->m_SrcMgr.bytes_in_buffer = src_size; + ctx->m_SrcMgr.next_input_byte = src_buf; + ctx->m_SrcMgr.bytes_in_buffer = src_size; } #ifdef PDF_ENABLE_XFA -int CCodec_JpegModule::ReadHeader(void* pContext, +int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx, int* width, int* height, int* nComps, CFX_DIBAttribute* pAttribute) { #else // PDF_ENABLE_XFA -int CCodec_JpegModule::ReadHeader(void* pContext, +int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx, int* width, int* height, int* nComps) { #endif // PDF_ENABLE_XFA - FXJPEG_Context* p = (FXJPEG_Context*)pContext; - if (setjmp(p->m_JumpMark) == -1) { + if (setjmp(ctx->m_JumpMark) == -1) return 1; - } - int ret = jpeg_read_header(&p->m_Info, true); - if (ret == JPEG_SUSPENDED) { + + int ret = jpeg_read_header(&ctx->m_Info, true); + if (ret == JPEG_SUSPENDED) return 2; - } - if (ret != JPEG_HEADER_OK) { + if (ret != JPEG_HEADER_OK) return 1; - } - *width = p->m_Info.image_width; - *height = p->m_Info.image_height; - *nComps = p->m_Info.num_components; + + *width = ctx->m_Info.image_width; + *height = ctx->m_Info.image_height; + *nComps = ctx->m_Info.num_components; #ifdef PDF_ENABLE_XFA - _JpegLoadAttribute(&p->m_Info, pAttribute); + _JpegLoadAttribute(&ctx->m_Info, pAttribute); #endif return 0; } -int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) { - FXJPEG_Context* p = (FXJPEG_Context*)pContext; - if (setjmp(p->m_JumpMark) == -1) { + +int CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) { + if (setjmp(ctx->m_JumpMark) == -1) return 0; - } - p->m_Info.scale_denom = down_scale; - return jpeg_start_decompress(&p->m_Info); + + ctx->m_Info.scale_denom = down_scale; + return jpeg_start_decompress(&ctx->m_Info); } -FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, + +FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, unsigned char* dest_buf) { - FXJPEG_Context* p = (FXJPEG_Context*)pContext; - if (setjmp(p->m_JumpMark) == -1) { + if (setjmp(ctx->m_JumpMark) == -1) return FALSE; - } - int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1); + + int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1); return nlines == 1; } -uint32_t CCodec_JpegModule::GetAvailInput(void* pContext, + +uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx, uint8_t** avail_buf_ptr) { if (avail_buf_ptr) { *avail_buf_ptr = NULL; - if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { - *avail_buf_ptr = - (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; + if (ctx->m_SrcMgr.bytes_in_buffer > 0) { + *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte; } } - return (uint32_t)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; + return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer; } diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp index 29ea794b5d..61d4cebdbb 100644 --- a/core/fxcodec/codec/fx_codec_png.cpp +++ b/core/fxcodec/codec/fx_codec_png.cpp @@ -195,34 +195,36 @@ static void _png_get_row_func(png_structp png_ptr, } pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num); } -void* CCodec_PngModule::Start(void* pModule) { + +FXPNG_Context* CCodec_PngModule::Start(void* pModule) { FXPNG_Context* p = (FXPNG_Context*)FX_Alloc(uint8_t, sizeof(FXPNG_Context)); - if (p == NULL) { - return NULL; - } + if (!p) + return nullptr; + p->m_AllocFunc = _png_alloc_func; p->m_FreeFunc = _png_free_func; - p->png_ptr = NULL; - p->info_ptr = NULL; + p->png_ptr = nullptr; + p->info_ptr = nullptr; p->parent_ptr = (void*)this; p->child_ptr = pModule; - p->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (p->png_ptr == NULL) { + p->png_ptr = + png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); + if (!p->png_ptr) { FX_Free(p); - return NULL; + return nullptr; } p->info_ptr = png_create_info_struct(p->png_ptr); - if (p->info_ptr == NULL) { - png_destroy_read_struct(&(p->png_ptr), (png_infopp)NULL, (png_infopp)NULL); + if (!p->info_ptr) { + png_destroy_read_struct(&(p->png_ptr), nullptr, nullptr); FX_Free(p); - return NULL; + return nullptr; } if (setjmp(png_jmpbuf(p->png_ptr))) { if (p) { - png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL); + png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), nullptr); FX_Free(p); } - return NULL; + return nullptr; } png_set_progressive_read_fn(p->png_ptr, p, _png_get_header_func, _png_get_row_func, _png_get_end_func); @@ -230,25 +232,25 @@ void* CCodec_PngModule::Start(void* pModule) { (png_error_ptr)_png_warning_data); return p; } -void CCodec_PngModule::Finish(void* pContext) { - FXPNG_Context* p = (FXPNG_Context*)pContext; - if (p) { - png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL); - p->m_FreeFunc(p); + +void CCodec_PngModule::Finish(FXPNG_Context* ctx) { + if (ctx) { + png_destroy_read_struct(&(ctx->png_ptr), &(ctx->info_ptr), nullptr); + ctx->m_FreeFunc(ctx); } } -FX_BOOL CCodec_PngModule::Input(void* pContext, + +FX_BOOL CCodec_PngModule::Input(FXPNG_Context* ctx, const uint8_t* src_buf, uint32_t src_size, CFX_DIBAttribute* pAttribute) { - FXPNG_Context* p = (FXPNG_Context*)pContext; - if (setjmp(png_jmpbuf(p->png_ptr))) { + if (setjmp(png_jmpbuf(ctx->png_ptr))) { if (pAttribute && 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) { - _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute); + _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute); } return FALSE; } - png_process_data(p->png_ptr, p->info_ptr, (uint8_t*)src_buf, src_size); + png_process_data(ctx->png_ptr, ctx->info_ptr, (uint8_t*)src_buf, src_size); return TRUE; } diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 89e4b25dbb..95a90b3e68 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -4,18 +4,26 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fxcodec/codec/fx_codec_progress.h" +#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h" #include "core/fxcodec/include/fx_codec.h" #include "core/fxge/include/fx_dib.h" -void CFXCODEC_WeightTable::Calc(int dest_len, - int dest_min, - int dest_max, - int src_len, - int src_min, - int src_max, - FX_BOOL bInterpol) { +#define FXCODEC_BLOCK_SIZE 4096 +#define FXCODEC_PNG_GAMMA 2.2 + +#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ +#undef FXCODEC_PNG_GAMMA +#define FXCODEC_PNG_GAMMA 1.7 +#endif + +void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, + int dest_min, + int dest_max, + int src_len, + int src_min, + int src_max, + FX_BOOL bInterpol) { if (m_pWeightTables) { FX_Free(m_pWeightTables); } @@ -113,7 +121,9 @@ void CFXCODEC_WeightTable::Calc(int dest_len, } } } -void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) { +void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, + int src_len, + FX_BOOL bInterpol) { if (m_pWeightTables) { FX_Free(m_pWeightTables); } @@ -173,7 +183,8 @@ void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) { pWeight->m_Weights[1] = 0; } } -void CFXCODEC_VertTable::Calc(int dest_len, int src_len) { +void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, + int src_len) { if (m_pWeightTables) { FX_Free(m_pWeightTables); } @@ -294,7 +305,7 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { FX_Free(m_pSrcPalette); } FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( - ICodec_JpegModule* pJpegModule, + CCodec_JpegModule* pJpegModule, FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) { @@ -552,7 +563,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule, } } } -FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(ICodec_GifModule* pGifModule, +FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) { @@ -834,7 +845,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert( GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y); } } -FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(ICodec_BmpModule* pBmpModule, +FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, FXCODEC_STATUS& err_status) { uint32_t dwSize = (uint32_t)m_pFile->GetSize(); if (dwSize <= m_offSet) { @@ -1008,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_SrcSize = size; switch (imageType) { case FXCODEC_IMAGE_BMP: { - ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); + CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); if (pBmpModule == NULL) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; @@ -1063,7 +1074,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( return FALSE; } break; case FXCODEC_IMAGE_JPG: { - ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); + CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); if (pJpegModule == NULL) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; @@ -1106,7 +1117,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( return FALSE; } break; case FXCODEC_IMAGE_PNG: { - ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); + CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); if (pPngModule == NULL) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; @@ -1167,7 +1178,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } } break; case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (pGifModule == NULL) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; @@ -1219,7 +1230,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( return FALSE; } break; case FXCODEC_IMAGE_TIF: { - ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); + CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); if (pTiffModule == NULL) { m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; @@ -1799,7 +1810,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames, frames = m_FrameNumber = 1; return m_status = FXCODEC_STATUS_DECODE_READY; case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); while (TRUE) { int32_t readResult = pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber); @@ -1888,7 +1899,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } switch (m_imagType) { case FXCODEC_IMAGE_JPG: { - ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); + CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); int down_scale = 1; GetDownScale(down_scale); FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); @@ -1924,7 +1935,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; } break; case FXCODEC_IMAGE_PNG: { - ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); + CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); if (pPngModule == NULL) { m_pDeviceBitmap = NULL; m_pFile = NULL; @@ -1972,7 +1983,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; } break; case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (pGifModule == NULL) { m_pDeviceBitmap = NULL; m_pFile = NULL; @@ -1991,7 +2002,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; } break; case FXCODEC_IMAGE_BMP: { - ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); + CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); if (pBmpModule == NULL) { m_pDeviceBitmap = NULL; m_pFile = NULL; @@ -2031,7 +2042,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } switch (m_imagType) { case FXCODEC_IMAGE_JPG: { - ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); + CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); while (TRUE) { FX_BOOL readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); @@ -2061,7 +2072,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } break; case FXCODEC_IMAGE_PNG: { - ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); + CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); while (TRUE) { uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet; uint32_t input_size = @@ -2101,7 +2112,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } break; case FXCODEC_IMAGE_GIF: { - ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); + CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); while (TRUE) { int32_t readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr); @@ -2128,7 +2139,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } break; case FXCODEC_IMAGE_BMP: { - ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); + CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); while (TRUE) { int32_t readRes = pBmpModule->LoadImage(m_pBmpContext); while (readRes == 2) { @@ -2154,7 +2165,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } } break; case FXCODEC_IMAGE_TIF: { - ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); + CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); FX_BOOL ret = FALSE; if (m_pDeviceBitmap->GetBPP() == 32 && m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX && @@ -2296,6 +2307,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } return FXCODEC_STATUS_ERROR; } -ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { +CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { return new CCodec_ProgressiveDecoder(this); } diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp index f0f2ab2e96..d4dc139265 100644 --- a/core/fxcodec/codec/fx_codec_tiff.cpp +++ b/core/fxcodec/codec/fx_codec_tiff.cpp @@ -512,33 +512,35 @@ FX_BOOL CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) { } return FALSE; } -void* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) { + +CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) { CCodec_TiffContext* pDecoder = new CCodec_TiffContext; if (!pDecoder->InitDecoder(file_ptr)) { delete pDecoder; - return NULL; + return nullptr; } return pDecoder; } -void CCodec_TiffModule::GetFrames(void* ctx, int32_t& frames) { - CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx; - pDecoder->GetFrames(frames); + +void CCodec_TiffModule::GetFrames(CCodec_TiffContext* ctx, int32_t& frames) { + ctx->GetFrames(frames); } -FX_BOOL CCodec_TiffModule::LoadFrameInfo(void* ctx, + +FX_BOOL CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx, int32_t frame, uint32_t& width, uint32_t& height, uint32_t& comps, uint32_t& bpc, CFX_DIBAttribute* pAttribute) { - CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx; - return pDecoder->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute); + return ctx->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute); } -FX_BOOL CCodec_TiffModule::Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) { - CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx; - return pDecoder->Decode(pDIBitmap); + +FX_BOOL CCodec_TiffModule::Decode(CCodec_TiffContext* ctx, + class CFX_DIBitmap* pDIBitmap) { + return ctx->Decode(pDIBitmap); } -void CCodec_TiffModule::DestroyDecoder(void* ctx) { - CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx; - delete pDecoder; + +void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) { + delete ctx; } diff --git a/core/fxcodec/codec/fx_codec_progress.h b/core/fxcodec/codec/include/ccodec_progressivedecoder.h index e8e885b3b5..83b73e1ba7 100644 --- a/core/fxcodec/codec/fx_codec_progress.h +++ b/core/fxcodec/codec/include/ccodec_progressivedecoder.h @@ -4,108 +4,161 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_ -#define CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_ +#ifndef CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_ +#define CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_ -#include "core/fxcodec/include/fx_codec.h" -#include "core/fxcrt/include/fx_memory.h" +#include "core/fxcodec/include/fx_codec_def.h" #include "core/fxcrt/include/fx_system.h" #include "core/fxge/include/fx_dib.h" -#define FXCODEC_BLOCK_SIZE 4096 -#define FXCODEC_PNG_GAMMA 2.2 - -#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ -#undef FXCODEC_PNG_GAMMA -#define FXCODEC_PNG_GAMMA 1.7 -#endif - -struct PixelWeight { - int m_SrcStart; - int m_SrcEnd; - int m_Weights[1]; -}; - -class CFXCODEC_WeightTable { - public: - CFXCODEC_WeightTable() { m_pWeightTables = NULL; } - ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); } - - void Calc(int dest_len, - int dest_min, - int dest_max, - int src_len, - int src_min, - int src_max, - FX_BOOL bInterpol); - PixelWeight* GetPixelWeight(int pixel) { - return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize); - } - - int m_DestMin, m_ItemSize; - uint8_t* m_pWeightTables; -}; -class CFXCODEC_HorzTable { +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_FileRead; +class IFX_Pause; +struct FXBMP_Context; +struct FXGIF_Context; +struct FXJPEG_Context; +struct FXPNG_Context; + +class CCodec_ProgressiveDecoder { public: - CFXCODEC_HorzTable() { m_pWeightTables = NULL; } - ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); } + enum FXCodec_Format { + FXCodec_Invalid = 0, + FXCodec_1bppGray = 0x101, + FXCodec_1bppRgb = 0x001, + FXCodec_8bppGray = 0x108, + FXCodec_8bppRgb = 0x008, + FXCodec_Rgb = 0x018, + FXCodec_Rgb32 = 0x020, + FXCodec_Argb = 0x220, + FXCodec_Cmyk = 0x120 + }; - void Calc(int dest_len, int src_len, FX_BOOL bInterpol); - PixelWeight* GetPixelWeight(int pixel) { - return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize); - } - - int m_ItemSize; - uint8_t* m_pWeightTables; -}; -class CFXCODEC_VertTable { - public: - CFXCODEC_VertTable() { m_pWeightTables = NULL; } - ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); } - void Calc(int dest_len, int src_len); - PixelWeight* GetPixelWeight(int pixel) { - return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize); - } - int m_ItemSize; - uint8_t* m_pWeightTables; -}; -enum FXCodec_Format { - FXCodec_Invalid = 0, - FXCodec_1bppGray = 0x101, - FXCodec_1bppRgb = 0x001, - FXCodec_8bppGray = 0x108, - FXCodec_8bppRgb = 0x008, - FXCodec_Rgb = 0x018, - FXCodec_Rgb32 = 0x020, - FXCodec_Argb = 0x220, - FXCodec_Cmyk = 0x120 -}; -class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder { - public: CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr); - ~CCodec_ProgressiveDecoder() override; + ~CCodec_ProgressiveDecoder(); FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile, FXCODEC_IMAGE_TYPE imageType, - CFX_DIBAttribute* pAttribute) override; + CFX_DIBAttribute* pAttribute); - FXCODEC_IMAGE_TYPE GetType() const override { return m_imagType; } - int32_t GetWidth() const override { return m_SrcWidth; } - int32_t GetHeight() const override { return m_SrcHeight; } - int32_t GetNumComponents() const override { return m_SrcComponents; } - int32_t GetBPC() const override { return m_SrcBPC; } - void SetClipBox(FX_RECT* clip) override; + FXCODEC_IMAGE_TYPE GetType() const { return m_imagType; } + int32_t GetWidth() const { return m_SrcWidth; } + int32_t GetHeight() const { return m_SrcHeight; } + int32_t GetNumComponents() const { return m_SrcComponents; } + int32_t GetBPC() const { return m_SrcBPC; } + void SetClipBox(FX_RECT* clip); - FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause) override; + FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause = nullptr); FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap, int start_x, int start_y, int size_x, int size_y, - int32_t frames, - FX_BOOL bInterpol) override; + int32_t frames = 0, + FX_BOOL bInterpol = TRUE); + + FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = nullptr); + + struct PixelWeight { + int m_SrcStart; + int m_SrcEnd; + int m_Weights[1]; + }; + + class CFXCODEC_WeightTable { + public: + CFXCODEC_WeightTable() { m_pWeightTables = NULL; } + ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); } + + void Calc(int dest_len, + int dest_min, + int dest_max, + int src_len, + int src_min, + int src_max, + FX_BOOL bInterpol); + PixelWeight* GetPixelWeight(int pixel) { + return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize); + } + + int m_DestMin, m_ItemSize; + uint8_t* m_pWeightTables; + }; + + class CFXCODEC_HorzTable { + public: + CFXCODEC_HorzTable() { m_pWeightTables = NULL; } + ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); } + + void Calc(int dest_len, int src_len, FX_BOOL bInterpol); + PixelWeight* GetPixelWeight(int pixel) { + return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize); + } + + int m_ItemSize; + uint8_t* m_pWeightTables; + }; + + class CFXCODEC_VertTable { + public: + CFXCODEC_VertTable() { m_pWeightTables = NULL; } + ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); } + void Calc(int dest_len, int src_len); + PixelWeight* GetPixelWeight(int pixel) { + return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize); + } + int m_ItemSize; + uint8_t* m_pWeightTables; + }; - FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause) override; + IFX_FileRead* m_pFile; + CCodec_ModuleMgr* m_pCodecMgr; + FXJPEG_Context* m_pJpegContext; + FXPNG_Context* m_pPngContext; + FXGIF_Context* m_pGifContext; + FXBMP_Context* m_pBmpContext; + CCodec_TiffContext* m_pTiffContext; + FXCODEC_IMAGE_TYPE m_imagType; + uint32_t m_offSet; + uint8_t* m_pSrcBuf; + uint32_t m_SrcSize; + uint8_t* m_pDecodeBuf; + int m_ScanlineSize; + CFX_DIBitmap* m_pDeviceBitmap; + FX_BOOL m_bInterpol; + CFXCODEC_WeightTable m_WeightHorz; + CFXCODEC_VertTable m_WeightVert; + CFXCODEC_HorzTable m_WeightHorzOO; + int m_SrcWidth; + int m_SrcHeight; + int m_SrcComponents; + int m_SrcBPC; + FX_RECT m_clipBox; + int m_startX; + int m_startY; + int m_sizeX; + int m_sizeY; + int m_TransMethod; + FX_ARGB* m_pSrcPalette; + int m_SrcPaletteNumber; + int m_SrcRow; + FXCodec_Format m_SrcFormat; + int m_SrcPassNumber; + int m_FrameNumber; + int m_FrameCur; + int m_GifBgIndex; + uint8_t* m_pGifPalette; + int32_t m_GifPltNumber; + int m_GifTransIndex; + FX_RECT m_GifFrameRect; + FX_BOOL m_BmpIsTopBottom; + FXCODEC_STATUS m_status; protected: static FX_BOOL PngReadHeaderFunc(void* pModule, @@ -158,64 +211,20 @@ class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder { uint8_t* src_scan, FXCodec_Format src_format); void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); - FX_BOOL JpegReadMoreData(ICodec_JpegModule* pJpegModule, + FX_BOOL JpegReadMoreData(CCodec_JpegModule* pJpegModule, FXCODEC_STATUS& err_status); void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap, int32_t des_line, uint8_t* src_scan, FXCodec_Format src_format); - FX_BOOL GifReadMoreData(ICodec_GifModule* pGifModule, + FX_BOOL GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status); void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); - FX_BOOL BmpReadMoreData(ICodec_BmpModule* pBmpModule, + FX_BOOL BmpReadMoreData(CCodec_BmpModule* pBmpModule, FXCODEC_STATUS& err_status); void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row); - - public: - IFX_FileRead* m_pFile; - CCodec_ModuleMgr* m_pCodecMgr; - void* m_pJpegContext; - void* m_pPngContext; - void* m_pGifContext; - void* m_pBmpContext; - void* m_pTiffContext; - FXCODEC_IMAGE_TYPE m_imagType; - uint32_t m_offSet; - uint8_t* m_pSrcBuf; - uint32_t m_SrcSize; - uint8_t* m_pDecodeBuf; - int m_ScanlineSize; - CFX_DIBitmap* m_pDeviceBitmap; - FX_BOOL m_bInterpol; - CFXCODEC_WeightTable m_WeightHorz; - CFXCODEC_VertTable m_WeightVert; - CFXCODEC_HorzTable m_WeightHorzOO; - int m_SrcWidth; - int m_SrcHeight; - int m_SrcComponents; - int m_SrcBPC; - FX_RECT m_clipBox; - int m_startX; - int m_startY; - int m_sizeX; - int m_sizeY; - int m_TransMethod; - FX_ARGB* m_pSrcPalette; - int m_SrcPaletteNumber; - int m_SrcRow; - FXCodec_Format m_SrcFormat; - int m_SrcPassNumber; - int m_FrameNumber; - int m_FrameCur; - int m_GifBgIndex; - uint8_t* m_pGifPalette; - int32_t m_GifPltNumber; - int m_GifTransIndex; - FX_RECT m_GifFrameRect; - FX_BOOL m_BmpIsTopBottom; - FXCODEC_STATUS m_status; }; -#endif // CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_ +#endif // CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_ diff --git a/core/fxcodec/include/fx_codec.h b/core/fxcodec/include/fx_codec.h index 4e7dbd5a8d..4853e26a6a 100644 --- a/core/fxcodec/include/fx_codec.h +++ b/core/fxcodec/include/fx_codec.h @@ -11,32 +11,31 @@ #include <memory> #include <vector> -#include "core/fxcrt/include/fx_basic.h" -#include "core/fxcrt/include/fx_coordinates.h" // For FX_RECT. +#include "core/fxcodec/codec/ccodec_basicmodule.h" +#include "core/fxcodec/codec/ccodec_faxmodule.h" +#include "core/fxcodec/codec/ccodec_flatemodule.h" +#include "core/fxcodec/codec/ccodec_iccmodule.h" +#include "core/fxcodec/codec/ccodec_jbig2module.h" +#include "core/fxcodec/codec/ccodec_jpegmodule.h" +#include "core/fxcodec/codec/ccodec_jpxmodule.h" +#include "core/fxcodec/codec/ccodec_scanlinedecoder.h" #include "core/fxcodec/include/fx_codec_def.h" +#include "core/fxcrt/include/fx_basic.h" +#include "core/fxcrt/include/fx_coordinates.h" class CFX_DIBSource; class CJPX_Decoder; class CPDF_ColorSpace; class CPDF_StreamAcc; -class ICodec_BasicModule; -class ICodec_FaxModule; -class ICodec_FlateModule; -class ICodec_IccModule; -class ICodec_Jbig2Module; -class ICodec_JpegModule; -class ICodec_JpxModule; -class ICodec_ScanlineDecoder; #ifdef PDF_ENABLE_XFA -class ICodec_BmpModule; -class ICodec_GifModule; -class ICodec_PngModule; -class ICodec_ProgressiveDecoder; -class ICodec_TiffModule; -#endif // PDF_ENABLE_XFA +#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" + +class CCodec_ProgressiveDecoder; -#ifdef PDF_ENABLE_XFA class CFX_DIBAttribute { public: CFX_DIBAttribute(); @@ -61,464 +60,38 @@ class CCodec_ModuleMgr { public: CCodec_ModuleMgr(); - ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } - ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } - ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } - ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } - ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } - ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } - ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } + CCodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } + CCodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } + CCodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } + CCodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } + CCodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } + CCodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } + CCodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } #ifdef PDF_ENABLE_XFA - ICodec_ProgressiveDecoder* CreateProgressiveDecoder(); - ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } - ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } - ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } - ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } + CCodec_ProgressiveDecoder* CreateProgressiveDecoder(); + CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } + CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } + CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } + CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } #endif // PDF_ENABLE_XFA protected: - std::unique_ptr<ICodec_BasicModule> m_pBasicModule; - std::unique_ptr<ICodec_FaxModule> m_pFaxModule; - std::unique_ptr<ICodec_JpegModule> m_pJpegModule; - std::unique_ptr<ICodec_JpxModule> m_pJpxModule; - std::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; - std::unique_ptr<ICodec_IccModule> m_pIccModule; -#ifdef PDF_ENABLE_XFA - std::unique_ptr<ICodec_PngModule> m_pPngModule; - std::unique_ptr<ICodec_GifModule> m_pGifModule; - std::unique_ptr<ICodec_BmpModule> m_pBmpModule; - std::unique_ptr<ICodec_TiffModule> m_pTiffModule; -#endif // PDF_ENABLE_XFA - std::unique_ptr<ICodec_FlateModule> m_pFlateModule; -}; -class ICodec_BasicModule { - public: - virtual ~ICodec_BasicModule() {} - virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, - uint32_t src_size, - uint8_t*& dest_buf, - uint32_t& dest_size) = 0; - virtual FX_BOOL A85Encode(const uint8_t* src_buf, - uint32_t src_size, - uint8_t*& dest_buf, - uint32_t& dest_size) = 0; - virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc) = 0; -}; - -class ICodec_ScanlineDecoder { - public: - virtual ~ICodec_ScanlineDecoder() {} - - virtual uint32_t GetSrcOffset() = 0; - - virtual const uint8_t* GetScanline(int line) = 0; - - virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) = 0; - - virtual int GetWidth() = 0; - - virtual int GetHeight() = 0; - - virtual int CountComps() = 0; - - virtual int GetBPC() = 0; -}; - -class ICodec_FlateModule { - public: - virtual ~ICodec_FlateModule() {} - virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc, - int predictor, - int Colors, - int BitsPerComponent, - int Columns) = 0; - virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW, - const uint8_t* src_buf, - uint32_t src_size, - FX_BOOL bEarlyChange, - int predictor, - int Colors, - int BitsPerComponent, - int Columns, - uint32_t estimated_size, - uint8_t*& dest_buf, - uint32_t& dest_size) = 0; - virtual FX_BOOL Encode(const uint8_t* src_buf, - uint32_t src_size, - int predictor, - int Colors, - int BitsPerComponent, - int Columns, - uint8_t*& dest_buf, - uint32_t& dest_size) = 0; - virtual FX_BOOL Encode(const uint8_t* src_buf, - uint32_t src_size, - uint8_t*& dest_buf, - uint32_t& dest_size) = 0; -}; -class ICodec_FaxModule { - public: - virtual ~ICodec_FaxModule() {} - - virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int K, - FX_BOOL EndOfLine, - FX_BOOL EncodedByteAlign, - FX_BOOL BlackIs1, - int Columns, - int Rows) = 0; - - virtual FX_BOOL Encode(const uint8_t* src_buf, - int width, - int height, - int pitch, - uint8_t*& dest_buf, - uint32_t& dest_size) = 0; -}; -class ICodec_JpegModule { - public: - virtual ~ICodec_JpegModule() {} - - virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - FX_BOOL ColorTransform) = 0; - - virtual FX_BOOL LoadInfo(const uint8_t* src_buf, - uint32_t src_size, - int& width, - int& height, - int& num_components, - int& bits_per_components, - FX_BOOL& color_transform, - uint8_t** icc_buf_ptr = NULL, - uint32_t* icc_length = NULL) = 0; - - virtual FX_BOOL Encode(const class CFX_DIBSource* pSource, - uint8_t*& dest_buf, - FX_STRSIZE& dest_size, - int quality = 75, - const uint8_t* icc_buf = NULL, - uint32_t icc_length = 0) = 0; - - virtual void* Start() = 0; - - virtual void Finish(void* pContext) = 0; - - virtual void Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size) = 0; + std::unique_ptr<CCodec_BasicModule> m_pBasicModule; + std::unique_ptr<CCodec_FaxModule> m_pFaxModule; + std::unique_ptr<CCodec_JpegModule> m_pJpegModule; + std::unique_ptr<CCodec_JpxModule> m_pJpxModule; + std::unique_ptr<CCodec_Jbig2Module> m_pJbig2Module; + std::unique_ptr<CCodec_IccModule> m_pIccModule; #ifdef PDF_ENABLE_XFA - virtual int ReadHeader(void* pContext, - int* width, - int* height, - int* nComps, - CFX_DIBAttribute* pAttribute) = 0; -#else // PDF_ENABLE_XFA - virtual int ReadHeader(void* pContext, - int* width, - int* height, - int* nComps) = 0; + std::unique_ptr<CCodec_PngModule> m_pPngModule; + std::unique_ptr<CCodec_GifModule> m_pGifModule; + std::unique_ptr<CCodec_BmpModule> m_pBmpModule; + std::unique_ptr<CCodec_TiffModule> m_pTiffModule; #endif // PDF_ENABLE_XFA - virtual int StartScanline(void* pContext, int down_scale) = 0; - - virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0; - - virtual uint32_t GetAvailInput(void* pContext, - uint8_t** avail_buf_ptr = NULL) = 0; -}; - -class ICodec_JpxModule { - public: - virtual ~ICodec_JpxModule() {} - - virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - CPDF_ColorSpace* cs) = 0; - - virtual void GetImageInfo(CJPX_Decoder* pDecoder, - uint32_t* width, - uint32_t* height, - uint32_t* components) = 0; - - virtual bool Decode(CJPX_Decoder* pDecoder, - uint8_t* dest_data, - int pitch, - const std::vector<uint8_t>& offsets) = 0; - - virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0; -}; -#ifdef PDF_ENABLE_XFA -class ICodec_PngModule { - public: - virtual ~ICodec_PngModule() {} - - virtual void* Start(void* pModule) = 0; - - virtual void Finish(void* pContext) = 0; - - virtual FX_BOOL Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size, - CFX_DIBAttribute* pAttribute) = 0; - - FX_BOOL (*ReadHeaderCallback)(void* pModule, - int width, - int height, - int bpc, - int pass, - int* color_type, - double* gamma); - - FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf); - - void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line); -}; -class ICodec_GifModule { - public: - virtual ~ICodec_GifModule() {} - - virtual void* Start(void* pModule) = 0; - - virtual void Finish(void* pContext) = 0; - - virtual uint32_t GetAvailInput(void* pContext, - uint8_t** avail_buf_ptr = NULL) = 0; - - virtual void Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size) = 0; - - virtual int32_t ReadHeader(void* pContext, - int* width, - int* height, - int* pal_num, - void** pal_pp, - int* bg_index, - CFX_DIBAttribute* pAttribute) = 0; - - virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0; - - void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos); - - uint8_t* (*AskLocalPaletteBufCallback)(void* pModule, - int32_t frame_num, - int32_t pal_size); - - virtual int32_t LoadFrame(void* pContext, - int frame_num, - CFX_DIBAttribute* pAttribute) = 0; - - FX_BOOL (*InputRecordPositionBufCallback)(void* pModule, - uint32_t rcd_pos, - const FX_RECT& img_rc, - int32_t pal_num, - void* pal_ptr, - int32_t delay_time, - FX_BOOL user_input, - int32_t trans_index, - int32_t disposal_method, - FX_BOOL interlace); - - void (*ReadScanlineCallback)(void* pModule, - int32_t row_num, - uint8_t* row_buf); -}; -class ICodec_BmpModule { - public: - virtual ~ICodec_BmpModule() {} - - virtual void* Start(void* pModule) = 0; - - virtual void Finish(void* pContext) = 0; - - virtual uint32_t GetAvailInput(void* pContext, - uint8_t** avail_buf_ptr = NULL) = 0; - - virtual void Input(void* pContext, - const uint8_t* src_buf, - uint32_t src_size) = 0; - - virtual int32_t ReadHeader(void* pContext, - int32_t* width, - int32_t* height, - FX_BOOL* tb_flag, - int32_t* components, - int* pal_num, - uint32_t** pal_pp, - CFX_DIBAttribute* pAttribute) = 0; - - virtual int32_t LoadImage(void* pContext) = 0; - - FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos); - - void (*ReadScanlineCallback)(void* pModule, - int32_t row_num, - uint8_t* row_buf); -}; -class ICodec_TiffModule { - public: - virtual ~ICodec_TiffModule() {} - - virtual void* CreateDecoder(IFX_FileRead* file_ptr) = 0; - - virtual void GetFrames(void* ctx, int32_t& frames) = 0; - - virtual FX_BOOL LoadFrameInfo(void* ctx, - int32_t frame, - uint32_t& width, - uint32_t& height, - uint32_t& comps, - uint32_t& bpc, - CFX_DIBAttribute* pAttribute) = 0; - - virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0; - - virtual void DestroyDecoder(void* ctx) = 0; -}; -#endif - -class ICodec_Jbig2Module { - public: - virtual ~ICodec_Jbig2Module() {} - - virtual void* CreateJbig2Context() = 0; - - virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, - CFX_PrivateData* pPrivateData, - uint32_t width, - uint32_t height, - CPDF_StreamAcc* src_stream, - CPDF_StreamAcc* global_stream, - uint8_t* dest_buf, - uint32_t dest_pitch, - IFX_Pause* pPause) = 0; - - virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, - IFX_Pause* pPause) = 0; - virtual void DestroyJbig2Context(void* pJbig2Content) = 0; -}; -#ifdef PDF_ENABLE_XFA -class ICodec_ProgressiveDecoder { - public: - virtual ~ICodec_ProgressiveDecoder() {} - - virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile, - FXCODEC_IMAGE_TYPE imageType, - CFX_DIBAttribute* pAttribute) = 0; - - virtual FXCODEC_IMAGE_TYPE GetType() const = 0; - virtual int32_t GetWidth() const = 0; - virtual int32_t GetHeight() const = 0; - virtual int32_t GetNumComponents() const = 0; - virtual int32_t GetBPC() const = 0; - - virtual void SetClipBox(FX_RECT* clip) = 0; - - virtual FXCODEC_STATUS GetFrames(int32_t& frames, - IFX_Pause* pPause = NULL) = 0; - - virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap, - int32_t start_x, - int32_t start_y, - int32_t size_x, - int32_t size_y, - int32_t frames = 0, - FX_BOOL bInterpol = TRUE) = 0; - - virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0; -}; -#endif // PDF_ENABLE_XFA - -class ICodec_IccModule { - public: - enum IccCS { - IccCS_Unknown = 0, - IccCS_XYZ, - IccCS_Lab, - IccCS_Luv, - IccCS_YCbCr, - IccCS_Yxy, - IccCS_Hsv, - IccCS_Hls, - IccCS_Gray, - IccCS_Rgb, - IccCS_Cmyk, - IccCS_Cmy - }; - - struct IccParam { - uint32_t Version; - IccCS ColorSpace; - uint32_t dwProfileType; - uint32_t dwFormat; - uint8_t* pProfileData; - uint32_t dwProfileSize; - double Gamma; - }; - - virtual ~ICodec_IccModule() {} - - virtual IccCS GetProfileCS(const uint8_t* pProfileData, - unsigned int dwProfileSize) = 0; - - virtual IccCS GetProfileCS(IFX_FileRead* pFile) = 0; - - virtual void* CreateTransform( - ICodec_IccModule::IccParam* pInputParam, - ICodec_IccModule::IccParam* pOutputParam, - ICodec_IccModule::IccParam* pProofParam = NULL, - uint32_t dwIntent = Icc_INTENT_PERCEPTUAL, - uint32_t dwFlag = Icc_FLAGS_DEFAULT, - uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, - uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) = 0; - - virtual void* CreateTransform_sRGB( - const uint8_t* pProfileData, - uint32_t dwProfileSize, - uint32_t& nComponents, - int32_t intent = 0, - uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) = 0; - - virtual void* CreateTransform_CMYK( - const uint8_t* pSrcProfileData, - uint32_t dwSrcProfileSize, - uint32_t& nSrcComponents, - const uint8_t* pDstProfileData, - uint32_t dwDstProfileSize, - int32_t intent = 0, - uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT, - uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) = 0; - - virtual void DestroyTransform(void* pTransform) = 0; - - virtual void Translate(void* pTransform, - FX_FLOAT* pSrcValues, - FX_FLOAT* pDestValues) = 0; - - virtual void TranslateScanline(void* pTransform, - uint8_t* pDest, - const uint8_t* pSrc, - int pixels) = 0; - virtual void SetComponents(uint32_t nComponents) = 0; + std::unique_ptr<CCodec_FlateModule> m_pFlateModule; }; void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels); diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 811e65c4e9..364185534e 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -1106,7 +1106,7 @@ class CFX_Renderer { FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); - ICodec_IccModule* pIccModule = NULL; + CCodec_IccModule* pIccModule = NULL; if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { pIccTransform = NULL; @@ -1529,7 +1529,7 @@ FX_BOOL _DibSetPixel(CFX_DIBitmap* pDevice, FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag); int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, diff --git a/core/fxge/dib/fx_dib_composite.cpp b/core/fxge/dib/fx_dib_composite.cpp index a9a3039ef7..18d73d1f25 100644 --- a/core/fxge/dib/fx_dib_composite.cpp +++ b/core/fxge/dib/fx_dib_composite.cpp @@ -287,7 +287,7 @@ void _CompositeRow_Argb2Graya(uint8_t* dest_scan, const uint8_t* src_alpha_scan, uint8_t* dst_alpha_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = nullptr; + CCodec_IccModule* pIccModule = nullptr; if (pIccTransform) pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); @@ -490,7 +490,7 @@ inline void _CompositeRow_Argb2Gray(uint8_t* dest_scan, const uint8_t* clip_scan, const uint8_t* src_alpha_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = NULL; + CCodec_IccModule* pIccModule = nullptr; uint8_t gray; if (pIccTransform) pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); @@ -586,7 +586,7 @@ inline void _CompositeRow_Rgb2Gray(uint8_t* dest_scan, int blend_type, const uint8_t* clip_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = NULL; + CCodec_IccModule* pIccModule = nullptr; uint8_t gray; if (pIccTransform) { pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); @@ -636,7 +636,7 @@ void _CompositeRow_Rgb2Graya(uint8_t* dest_scan, const uint8_t* clip_scan, uint8_t* dest_alpha_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = NULL; + CCodec_IccModule* pIccModule = nullptr; if (pIccTransform) { pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); } @@ -1442,7 +1442,7 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan, uint8_t* src_cache_scan, void* pIccTransform) { uint8_t* dp = src_cache_scan; - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_alpha_scan) { if (dest_alpha_scan) { @@ -1536,7 +1536,7 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(uint8_t* dest_scan, uint8_t* dest_alpha_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1562,7 +1562,7 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip_Transform( uint8_t* dest_alpha_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1587,7 +1587,7 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_Clip_Transform( uint8_t* dest_alpha_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1611,7 +1611,7 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform( uint8_t* dest_alpha_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1637,7 +1637,7 @@ inline void _CompositeRow_Argb2Rgb_Blend_Transform( const uint8_t* src_alpha_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_alpha_scan) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1688,7 +1688,7 @@ inline void _CompositeRow_Argb2Rgb_NoBlend_Transform( const uint8_t* src_alpha_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_alpha_scan) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1737,7 +1737,7 @@ inline void _CompositeRow_Rgb2Rgb_Blend_NoClip_Transform( int src_Bpp, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1762,7 +1762,7 @@ inline void _CompositeRow_Rgb2Rgb_Blend_Clip_Transform(uint8_t* dest_scan, const uint8_t* clip_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1786,7 +1786,7 @@ inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform( int src_Bpp, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -1811,7 +1811,7 @@ inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform( const uint8_t* clip_scan, uint8_t* src_cache_scan, void* pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (src_Bpp == 3) { pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, @@ -3965,9 +3965,8 @@ inline FX_BOOL _ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, int& mask_green, int& mask_blue, int& mask_black, - void* icc_module, + CCodec_IccModule* pIccModule, void* pIccTransform) { - ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; if (alpha_flag >> 8) { mask_alpha = alpha_flag & 0xff; mask_red = FXSYS_GetCValue(mask_color); @@ -4028,9 +4027,8 @@ inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, FXDIB_Format dest_format, uint32_t*& pDestPalette, uint32_t* pSrcPalette, - void* icc_module, + CCodec_IccModule* pIccModule, void* pIccTransform) { - ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; FX_BOOL isSrcCmyk = !!(src_format & 0x0400); FX_BOOL isDstCmyk = !!(dest_format & 0x0400); pDestPalette = NULL; @@ -4186,7 +4184,7 @@ FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, m_DestFormat = dest_format; m_BlendType = blend_type; m_bRgbByteOrder = bRgbByteOrder; - ICodec_IccModule* pIccModule = NULL; + CCodec_IccModule* pIccModule = nullptr; if (CFX_GEModule::Get()->GetCodecModule()) { pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); } @@ -4803,7 +4801,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, if (!IsAlphaMask()) { if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, &gray, color_p, 1); } else { @@ -4877,7 +4875,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, return FALSE; } if (pIccTransform && CFX_GEModule::Get()->GetCodecModule()) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); } else { diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp index 7484620b8f..da380ee567 100644 --- a/core/fxge/dib/fx_dib_convert.cpp +++ b/core/fxge/dib/fx_dib_convert.cpp @@ -192,7 +192,7 @@ FX_BOOL ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf, bgr_ptr[4] = FXARGB_G(src_plt[1]); bgr_ptr[5] = FXARGB_R(src_plt[1]); } - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt, 2); } else { @@ -254,7 +254,7 @@ FX_BOOL ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, *bgr_ptr++ = FXARGB_R(src_plt[i]); } } - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt, 256); @@ -293,7 +293,7 @@ FX_BOOL ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf, void* pIccTransform) { int Bpp = pSrcBitmap->GetBPP() / 8; if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); if (Bpp == 3 || pSrcBitmap->IsCmykImage()) { for (int row = 0; row < height; row++) { @@ -401,7 +401,7 @@ FX_BOOL ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf, } bgr_ptr = (uint8_t*)plt; } - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, (const uint8_t*)plt, plt_size); @@ -499,7 +499,7 @@ FX_BOOL ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, dst_plt); if (ret && pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); for (int i = 0; i < 256; i++) { FX_ARGB* plt = dst_plt + i; @@ -589,7 +589,7 @@ FX_BOOL ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format, bgr_ptr[5] = FXARGB_R(src_plt[1]); } if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, (const uint8_t*)plt, 2); @@ -650,7 +650,7 @@ FX_BOOL ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, plt[i] = FXCMYK_TODIB(src_plt[i]); } } - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, (const uint8_t*)plt, 256); @@ -688,7 +688,7 @@ FX_BOOL ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf, int src_top, void* pIccTransform) { if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; @@ -726,7 +726,7 @@ FX_BOOL ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf, } } if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; @@ -745,7 +745,7 @@ FX_BOOL ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, void* pIccTransform) { int comps = pSrcBitmap->GetBPP() / 8; if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; @@ -782,7 +782,7 @@ FX_BOOL ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf, int src_top, void* pIccTransform) { if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); for (int row = 0; row < height; row++) { uint8_t* dest_scan = dest_buf + row * dest_pitch; diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 4503fd506f..f781392e67 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -490,7 +490,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, uint8_t* color_p = (uint8_t*)&dst_color; if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); } else { diff --git a/core/fxge/ge/fx_ge_ps.cpp b/core/fxge/ge/fx_ge_ps.cpp index 241a184ed1..98253336a1 100644 --- a/core/fxge/ge/fx_ge_ps.cpp +++ b/core/fxge/ge/fx_ge_ps.cpp @@ -506,7 +506,7 @@ void CFX_PSRenderer::SetColor(uint32_t color, } FX_BOOL bCMYK = FALSE; if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index e074fa4f26..f65e34a3e8 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -158,7 +158,7 @@ void _Color2Argb(FX_ARGB& argb, } uint8_t bgra[4]; if (pIccTransform) { - ICodec_IccModule* pIccModule = + CCodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |