summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h17
-rw-r--r--core/fxcodec/codec/fx_codec.cpp31
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp16
-rw-r--r--core/fxcodec/fx_codec.h56
-rw-r--r--core/fxcodec/fx_codec_def.h2
5 files changed, 84 insertions, 38 deletions
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index 476a7c1b4a..07716a80ae 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -12,7 +12,6 @@
#include <vector>
#include "core/fxcodec/codec/ccodec_bmpmodule.h"
-#include "core/fxcodec/codec/ccodec_gifmodule.h"
#include "core/fxcodec/codec/ccodec_jpegmodule.h"
#include "core/fxcodec/fx_codec_def.h"
#include "core/fxcrt/fx_system.h"
@@ -21,6 +20,10 @@
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
+#ifdef PDF_ENABLE_XFA_GIF
+#include "core/fxcodec/codec/ccodec_gifmodule.h"
+#endif // PDF_ENABLE_XFA_gif
+
#ifdef PDF_ENABLE_XFA_PNG
#include "core/fxcodec/codec/ccodec_pngmodule.h"
#endif // PDF_ENABLE_XFA_PNG
@@ -36,7 +39,9 @@ class IFX_SeekableReadStream;
class CCodec_Dummy {}; // Placeholder to work around C++ syntax issues
class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
+#ifdef PDF_ENABLE_XFA_GIF
public CCodec_GifModule::Delegate,
+#endif // PDF_ENABLE_XFA_GIF
#ifdef PDF_ENABLE_XFA_PNG
public CCodec_PngModule::Delegate,
#endif // PDF_ENABLE_XFA_PNG
@@ -146,6 +151,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
void PngFillScanlineBufCompleted(int pass, int line) override;
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
// CCodec_GifModule::Delegate
void GifRecordCurrentPosition(uint32_t& cur_pos) override;
bool GifInputRecordPositionBuf(uint32_t rcd_pos,
@@ -158,6 +164,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
int32_t disposal_method,
bool interlace) override;
void GifReadScanline(int32_t row_num, uint8_t* row_buf) override;
+#endif // PDF_ENABLE_XFA_GIF
// CCodec_BmpModule::Delegate
bool BmpInputImagePositionBuf(uint32_t rcd_pos) override;
@@ -171,6 +178,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
FXCODEC_STATUS BmpStartDecode(const RetainPtr<CFX_DIBitmap>& pDIBitmap);
FXCODEC_STATUS BmpContinueDecode();
+#ifdef PDF_ENABLE_XFA_GIF
bool GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status);
bool GifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
@@ -179,6 +187,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
void GifDoubleLineResampleVert(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
int dest_row);
+#endif // PDF_ENABLE_XFA_GIF
bool JpegReadMoreData(CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status);
@@ -229,7 +238,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
#ifdef PDF_ENABLE_XFA_PNG
std::unique_ptr<CCodec_PngModule::Context> m_pPngContext;
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
std::unique_ptr<CCodec_GifModule::Context> m_pGifContext;
+#endif // PDF_ENABLE_XFA_GIF
std::unique_ptr<CCodec_BmpModule::Context> m_pBmpContext;
#ifdef PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_TiffModule::Context> m_pTiffContext;
@@ -260,14 +271,16 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
int m_SrcPassNumber;
size_t m_FrameNumber;
size_t m_FrameCur;
+#ifdef PDF_ENABLE_XFA_GIF
int m_GifBgIndex;
CFX_GifPalette* m_pGifPalette;
int32_t m_GifPltNumber;
int m_GifTransIndex;
FX_RECT m_GifFrameRect;
+ bool m_InvalidateGifBuffer;
+#endif // PDF_ENABLE_XFA_GIF
bool m_BmpIsTopBottom;
FXCODEC_STATUS m_status;
- bool m_InvalidateGifBuffer;
};
#endif // CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_
diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp
index 22e4bc50cc..e58da052aa 100644
--- a/core/fxcodec/codec/fx_codec.cpp
+++ b/core/fxcodec/codec/fx_codec.cpp
@@ -26,13 +26,6 @@
#include "third_party/base/logging.h"
#include "third_party/base/ptr_util.h"
-#ifdef 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"
-#endif // PDF_ENABLE_XFA
-
namespace {
const uint8_t g_CMYK[81 * 81 * 3] = {
@@ -1364,25 +1357,6 @@ CCodec_ModuleMgr::CCodec_ModuleMgr()
CCodec_ModuleMgr::~CCodec_ModuleMgr() {}
-#ifdef PDF_ENABLE_XFA
-void CCodec_ModuleMgr::SetBmpModule(std::unique_ptr<CCodec_BmpModule> module) {
- m_pBmpModule = std::move(module);
-}
-
-void CCodec_ModuleMgr::SetGifModule(std::unique_ptr<CCodec_GifModule> module) {
- m_pGifModule = std::move(module);
-}
-
-void CCodec_ModuleMgr::SetPngModule(std::unique_ptr<CCodec_PngModule> module) {
- m_pPngModule = std::move(module);
-}
-
-void CCodec_ModuleMgr::SetTiffModule(
- std::unique_ptr<CCodec_TiffModule> module) {
- m_pTiffModule = std::move(module);
-}
-#endif // PDF_ENABLE_XFA
-
bool CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf,
uint32_t src_size,
uint8_t** dest_buf,
@@ -1540,11 +1514,14 @@ CFX_DIBAttribute::CFX_DIBAttribute()
m_nYDPI(-1),
m_fAspectRatio(-1.0f),
m_wDPIUnit(0),
+#ifdef PDF_ENABLE_XFA_GIF
m_nGifLeft(0),
m_nGifTop(0),
m_pGifLocalPalette(nullptr),
m_nGifLocalPalNum(0),
- m_nBmpCompressType(0) {}
+#endif // PDF_ENABLE_XFA_GIF
+ m_nBmpCompressType(0) {
+}
CFX_DIBAttribute::~CFX_DIBAttribute() {
for (const auto& pair : m_Exif)
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index bfd60acd0e..1d6bc708db 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -275,13 +275,15 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder(
m_FrameNumber = 0;
m_FrameCur = 0;
m_SrcPaletteNumber = 0;
+#ifdef PDF_ENABLE_XFA_GIF
m_GifPltNumber = 0;
m_GifBgIndex = 0;
m_pGifPalette = nullptr;
m_GifTransIndex = -1;
m_GifFrameRect = FX_RECT(0, 0, 0, 0);
- m_BmpIsTopBottom = false;
m_InvalidateGifBuffer = true;
+#endif // PDF_ENABLE_XFA_GIF
+ m_BmpIsTopBottom = false;
}
CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
@@ -450,6 +452,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass,
}
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
void CCodec_ProgressiveDecoder::GifRecordCurrentPosition(uint32_t& cur_pos) {
uint32_t remain_size =
m_pCodecMgr->GetGifModule()->GetAvailInput(m_pGifContext.get());
@@ -608,6 +611,7 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num,
if (bLastPass)
GifDoubleLineResampleVert(pDIBitmap, scale_y, dest_row);
}
+#endif // PDF_ENABLE_XFA_GIF
bool CCodec_ProgressiveDecoder::BmpInputImagePositionBuf(uint32_t rcd_pos) {
m_offSet = rcd_pos;
@@ -923,6 +927,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::BmpContinueDecode() {
}
}
+#ifdef PDF_ENABLE_XFA_GIF
bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status) {
if (static_cast<uint32_t>(m_pFile->GetSize()) <= m_offSet)
@@ -1151,6 +1156,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
GifDoubleLineResampleVert(pDeviceBitmap, scale_y, dest_row + (int)scale_y);
}
}
+#endif // PDF_ENABLE_XFA_GIF
bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status) {
@@ -1735,8 +1741,10 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
case FXCODEC_IMAGE_PNG:
return PngDetectImageType(pAttribute, size);
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF:
return GifDetectImageType(pAttribute, size);
+#endif // PDF_ENABLE_XFA_GIF
#ifdef PDF_ENABLE_XFA_TIFF
case FXCODEC_IMAGE_TIFF:
return TiffDetectImageType(pAttribute, size);
@@ -2309,6 +2317,7 @@ std::pair<FXCODEC_STATUS, size_t> CCodec_ProgressiveDecoder::GetFrames() {
m_FrameNumber = 1;
m_status = FXCODEC_STATUS_DECODE_READY;
return {m_status, 1};
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (!pGifModule) {
@@ -2336,6 +2345,7 @@ std::pair<FXCODEC_STATUS, size_t> CCodec_ProgressiveDecoder::GetFrames() {
return {m_status, 0};
}
}
+#endif // PDF_ENABLE_XFA_GIF
default:
return {FXCODEC_STATUS_ERROR, 0};
}
@@ -2401,8 +2411,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(
case FXCODEC_IMAGE_PNG:
return PngStartDecode(pDIBitmap);
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF:
return GifStartDecode(pDIBitmap);
+#endif // PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_BMP:
return BmpStartDecode(pDIBitmap);
#ifdef PDF_ENABLE_XFA_TIFF
@@ -2426,8 +2438,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
case FXCODEC_IMAGE_PNG:
return PngContinueDecode();
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF:
return GifContinueDecode();
+#endif // PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_BMP:
return BmpContinueDecode();
#ifdef PDF_ENABLE_XFA_TIFF
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index 5ed29d4da5..b5e8d8ad39 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -18,6 +18,22 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_string.h"
+#ifdef PDF_ENABLE_XFA
+#include "core/fxcodec/codec/ccodec_bmpmodule.h"
+
+#ifdef PDF_ENABLE_XFA_GIF
+#include "core/fxcodec/codec/ccodec_gifmodule.h"
+#endif // PDF_ENABLE_XFA_GIF
+
+#ifdef PDF_ENABLE_XFA_PNG
+#include "core/fxcodec/codec/ccodec_pngmodule.h"
+#endif // PDF_ENABLE_XFA_PNG
+
+#ifdef PDF_ENABLE_XFA_TIFF
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
+#endif // PDF_ENABLE_XFA_TIFF
+#endif // PDF_ENABLE_XFA
+
class CCodec_BasicModule;
class CCodec_FaxModule;
class CCodec_FlateModule;
@@ -31,11 +47,7 @@ class CPDF_ColorSpace;
class CPDF_StreamAcc;
#ifdef PDF_ENABLE_XFA
-class CCodec_BmpModule;
-class CCodec_GifModule;
-class CCodec_PngModule;
class CCodec_ProgressiveDecoder;
-class CCodec_TiffModule;
class CFX_DIBAttribute {
public:
@@ -46,10 +58,12 @@ class CFX_DIBAttribute {
int32_t m_nYDPI;
float m_fAspectRatio;
uint16_t m_wDPIUnit;
+#ifdef PDF_ENABLE_XFA_GIF
int32_t m_nGifLeft;
int32_t m_nGifTop;
uint32_t* m_pGifLocalPalette;
uint32_t m_nGifLocalPalNum;
+#endif // PDF_ENABLE_XFA_GIF
int32_t m_nBmpCompressType;
std::map<uint32_t, void*> m_Exif;
};
@@ -70,14 +84,31 @@ class CCodec_ModuleMgr {
#ifdef PDF_ENABLE_XFA
std::unique_ptr<CCodec_ProgressiveDecoder> CreateProgressiveDecoder();
- void SetBmpModule(std::unique_ptr<CCodec_BmpModule> module);
- void SetGifModule(std::unique_ptr<CCodec_GifModule> module);
- void SetPngModule(std::unique_ptr<CCodec_PngModule> module);
- void SetTiffModule(std::unique_ptr<CCodec_TiffModule> module);
CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
+ void SetBmpModule(std::unique_ptr<CCodec_BmpModule> module) {
+ m_pBmpModule = std::move(module);
+ }
+
+#ifdef PDF_ENABLE_XFA_GIF
CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
+ void SetGifModule(std::unique_ptr<CCodec_GifModule> module) {
+ m_pGifModule = std::move(module);
+ }
+#endif // PDF_ENABLE_XFA_GIF
+
+#ifdef PDF_ENABLE_XFA_PNG
CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
+ void SetPngModule(std::unique_ptr<CCodec_PngModule> module) {
+ m_pPngModule = std::move(module);
+ }
+#endif // PDF_ENABLE_XFA_PNG
+
+#ifdef PDF_ENABLE_XFA_TIFF
CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
+ void SetTiffModule(std::unique_ptr<CCodec_TiffModule> module) {
+ m_pTiffModule = std::move(module);
+ }
+#endif // PDF_ENABLE_XFA_TIFF
#endif // PDF_ENABLE_XFA
protected:
@@ -90,9 +121,18 @@ class CCodec_ModuleMgr {
#ifdef PDF_ENABLE_XFA
std::unique_ptr<CCodec_BmpModule> m_pBmpModule;
+
+#ifdef PDF_ENABLE_XFA_GIF
std::unique_ptr<CCodec_GifModule> m_pGifModule;
+#endif // PDF_ENABLE_XFA_GIF
+
+#ifdef PDF_ENABLE_XFA_PNG
std::unique_ptr<CCodec_PngModule> m_pPngModule;
+#endif // PDF_ENABLE_XFA_PNG
+
+#ifdef PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_TiffModule> m_pTiffModule;
+#endif // PDF_ENABLE_XFA_TIFF
#endif // PDF_ENABLE_XFA
std::unique_ptr<CCodec_FlateModule> m_pFlateModule;
diff --git a/core/fxcodec/fx_codec_def.h b/core/fxcodec/fx_codec_def.h
index b7944ee1c1..f7d6916aa5 100644
--- a/core/fxcodec/fx_codec_def.h
+++ b/core/fxcodec/fx_codec_def.h
@@ -31,7 +31,9 @@ enum FXCODEC_IMAGE_TYPE {
#ifdef PDF_ENABLE_XFA_PNG
FXCODEC_IMAGE_PNG,
#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
FXCODEC_IMAGE_GIF,
+#endif // PDF_ENABLE_XFA_GIF
#ifdef PDF_ENABLE_XFA_TIFF
FXCODEC_IMAGE_TIFF,
#endif // PDF_ENABLE_XFA_TIFF