summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-27 10:12:59 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-27 18:37:42 +0000
commit73c9f3bb3d82563d6d4496c4b0204d5c0825e8a2 (patch)
treebbc3e4e303f5f0a0a2e3931bfde01436130220bb
parent717a4fc857d66017cecc4c8f8285713135b9dc68 (diff)
downloadpdfium-73c9f3bb3d82563d6d4496c4b0204d5c0825e8a2.tar.xz
Allow building XFA without additional codecs.
This is something we'd like to try for initial XFA launches adding in codecs as justified by results in the wild. Adding statistics for the unsupported cases is a follow-up exercise once this builds correctly. We always build all the additional libraries, to allow fuzzers to link against them even if we are not shipping them. The linker will sort it out for the actual code. Rename some files to match the classes contained within. That the existing tests seem to pass with the codecs disabled warrants further investigation. Change-Id: Iad269db91289f12dc9f5dda8f48121d27a0c4367 Reviewed-on: https://pdfium-review.googlesource.com/2836 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--BUILD.gn20
-rw-r--r--core/fxcodec/codec/ccodec_bmpmodule.cpp (renamed from core/fxcodec/codec/fx_codec_bmp.cpp)3
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.cpp (renamed from core/fxcodec/codec/fx_codec_gif.cpp)3
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.h2
-rw-r--r--core/fxcodec/codec/ccodec_pngmodule.cpp (renamed from core/fxcodec/codec/fx_codec_png.cpp)2
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h30
-rw-r--r--core/fxcodec/codec/ccodec_tiffmodule.cpp (renamed from core/fxcodec/codec/fx_codec_tiff.cpp)2
-rw-r--r--core/fxcodec/codec/fx_codec.cpp14
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp62
-rw-r--r--core/fxcodec/fx_codec.h48
-rw-r--r--pdfium.gni12
11 files changed, 164 insertions, 34 deletions
diff --git a/BUILD.gn b/BUILD.gn
index beb6ec3651..dc15e9ef51 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -33,6 +33,18 @@ config("pdfium_common_config") {
if (pdf_enable_xfa) {
defines += [ "PDF_ENABLE_XFA" ]
+ if (pdf_enable_xfa_bmp) {
+ defines += [ "PDF_ENABLE_XFA_BMP" ]
+ }
+ if (pdf_enable_xfa_gif) {
+ defines += [ "PDF_ENABLE_XFA_GIF" ]
+ }
+ if (pdf_enable_xfa_png) {
+ defines += [ "PDF_ENABLE_XFA_PNG" ]
+ }
+ if (pdf_enable_xfa_tiff) {
+ defines += [ "PDF_ENABLE_XFA_TIFF" ]
+ }
}
if (pdf_use_win32_gdi) {
@@ -687,16 +699,16 @@ static_library("fxcodec") {
if (pdf_enable_xfa) {
sources += [
+ "core/fxcodec/codec/ccodec_bmpmodule.cpp",
"core/fxcodec/codec/ccodec_bmpmodule.h",
+ "core/fxcodec/codec/ccodec_gifmodule.cpp",
"core/fxcodec/codec/ccodec_gifmodule.h",
+ "core/fxcodec/codec/ccodec_pngmodule.cpp",
"core/fxcodec/codec/ccodec_pngmodule.h",
"core/fxcodec/codec/ccodec_progressivedecoder.h",
+ "core/fxcodec/codec/ccodec_tiffmodule.cpp",
"core/fxcodec/codec/ccodec_tiffmodule.h",
- "core/fxcodec/codec/fx_codec_bmp.cpp",
- "core/fxcodec/codec/fx_codec_gif.cpp",
- "core/fxcodec/codec/fx_codec_png.cpp",
"core/fxcodec/codec/fx_codec_progress.cpp",
- "core/fxcodec/codec/fx_codec_tiff.cpp",
"core/fxcodec/lbmp/fx_bmp.cpp",
"core/fxcodec/lbmp/fx_bmp.h",
"core/fxcodec/lgif/fx_gif.cpp",
diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/ccodec_bmpmodule.cpp
index ae83d3f1ef..c6ebd2d939 100644
--- a/core/fxcodec/codec/fx_codec_bmp.cpp
+++ b/core/fxcodec/codec/ccodec_bmpmodule.cpp
@@ -4,10 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fxcodec/codec/ccodec_bmpmodule.h"
+
#include "core/fxcodec/codec/codec_int.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcodec/lbmp/fx_bmp.h"
#include "core/fxge/fx_dib.h"
+
struct FXBMP_Context {
bmp_decompress_struct_p bmp_ptr;
void* parent_ptr;
diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index fadf18f251..e3b2648c43 100644
--- a/core/fxcodec/codec/fx_codec_gif.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -4,10 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fxcodec/codec/ccodec_gifmodule.h"
+
#include "core/fxcodec/codec/codec_int.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcodec/lgif/fx_gif.h"
#include "core/fxge/fx_dib.h"
+
struct FXGIF_Context {
gif_decompress_struct_p gif_ptr;
void* parent_ptr;
diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h
index fac621d256..21ac92d6c7 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.h
+++ b/core/fxcodec/codec/ccodec_gifmodule.h
@@ -7,8 +7,10 @@
#ifndef CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
#define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
+#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
+class CFX_DIBAttribute;
struct FXGIF_Context;
class CCodec_GifModule {
diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp
index 579c85bf09..d3e24cd9ea 100644
--- a/core/fxcodec/codec/fx_codec_png.cpp
+++ b/core/fxcodec/codec/ccodec_pngmodule.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fxcodec/codec/ccodec_pngmodule.h"
+
#include <algorithm>
#include "core/fxcodec/codec/codec_int.h"
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index 614146f79d..e97d1b9f78 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -171,6 +171,7 @@ class CCodec_ProgressiveDecoder {
FXCODEC_STATUS m_status;
protected:
+#ifdef PDF_ENABLE_XFA_PNG
static bool PngReadHeaderFunc(void* pModule,
int width,
int height,
@@ -182,6 +183,9 @@ class CCodec_ProgressiveDecoder {
static void PngFillScanlineBufCompletedFunc(void* pModule,
int pass,
int line);
+#endif // PDF_ENABLE_XFA_PNG
+
+#ifdef PDF_ENABLE_XFA_GIF
static void GifRecordCurrentPositionCallback(void* pModule,
uint32_t& cur_pos);
static uint8_t* GifAskLocalPaletteBufCallback(void* pModule,
@@ -200,10 +204,25 @@ class CCodec_ProgressiveDecoder {
static void GifReadScanlineCallback(void* pModule,
int32_t row_num,
uint8_t* row_buf);
+ bool GifReadMoreData(CCodec_GifModule* pGifModule,
+ FXCODEC_STATUS& err_status);
+ void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap,
+ double scale_y,
+ int des_row);
+#endif // PDF_ENABLE_XFA_GIF
+
+#ifdef PDF_ENABLE_XFA_BMP
static bool BmpInputImagePositionBufCallback(void* pModule, uint32_t rcd_pos);
static void BmpReadScanlineCallback(void* pModule,
int32_t row_num,
uint8_t* row_buf);
+ void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap,
+ int32_t des_line,
+ uint8_t* src_scan,
+ FXCodec_Format src_format);
+ bool BmpReadMoreData(CCodec_BmpModule* pBmpModule,
+ FXCODEC_STATUS& err_status);
+#endif // PDF_ENABLE_XFA_BMP
bool DetectImageType(FXCODEC_IMAGE_TYPE imageType,
CFX_DIBAttribute* pAttribute);
@@ -220,17 +239,6 @@ class CCodec_ProgressiveDecoder {
void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
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);
- bool GifReadMoreData(CCodec_GifModule* pGifModule,
- FXCODEC_STATUS& err_status);
- void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap,
- double scale_y,
- int des_row);
- bool BmpReadMoreData(CCodec_BmpModule* pBmpModule,
- FXCODEC_STATUS& err_status);
void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
};
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp
index 7818a34ec6..736772892a 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
+
#include <limits>
#include "core/fxcodec/codec/codec_int.h"
diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp
index 3edf8924c3..d9a36a6c5a 100644
--- a/core/fxcodec/codec/fx_codec.cpp
+++ b/core/fxcodec/codec/fx_codec.cpp
@@ -24,12 +24,18 @@ CCodec_ModuleMgr::CCodec_ModuleMgr()
m_pJpxModule(new CCodec_JpxModule),
m_pJbig2Module(new CCodec_Jbig2Module),
m_pIccModule(new CCodec_IccModule),
-#ifdef PDF_ENABLE_XFA
- m_pPngModule(new CCodec_PngModule),
- m_pGifModule(new CCodec_GifModule),
+#ifdef PDF_ENABLE_XFA_BMP
m_pBmpModule(new CCodec_BmpModule),
+#endif // PDF_ENABLE_XFA_BMP
+#ifdef PDF_ENABLE_XFA_GIF
+ m_pGifModule(new CCodec_GifModule),
+#endif // PDF_ENABLE_XFA_GIF
+#ifdef PDF_ENABLE_XFA_PNG
+ m_pPngModule(new CCodec_PngModule),
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_TIFF
m_pTiffModule(new CCodec_TiffModule),
-#endif // PDF_ENABLE_XFA
+#endif // PDF_ENABLE_XFA_TIFF
m_pFlateModule(new CCodec_FlateModule) {
}
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 4a1719f0f7..e4996c887a 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -17,11 +17,13 @@
namespace {
+#ifdef PDF_ENABLE_XFA_PNG
#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
const double kPngGamma = 1.7;
-#else
+#else // _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
const double kPngGamma = 2.2;
-#endif
+#endif // _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
+#endif // PDF_ENABLE_XFA_PNG
void RGB2BGR(uint8_t* buffer, int width = 1) {
if (buffer && width > 0) {
@@ -299,14 +301,22 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
m_pFile = nullptr;
if (m_pJpegContext)
m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext);
- if (m_pPngContext)
- m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
- if (m_pGifContext)
- m_pCodecMgr->GetGifModule()->Finish(m_pGifContext);
+#ifdef PDF_ENABLE_XFA_BMP
if (m_pBmpContext)
m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext);
+#endif // PDF_ENABLE_XFA_BMP
+#ifdef PDF_ENABLE_XFA_GIF
+ if (m_pGifContext)
+ m_pCodecMgr->GetGifModule()->Finish(m_pGifContext);
+#endif // PDF_ENABLE_XFA_GIF
+#ifdef PDF_ENABLE_XFA_PNG
+ if (m_pPngContext)
+ m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_TIFF
if (m_pTiffContext)
m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext);
+#endif // PDF_ENABLE_XFA_TIFF
FX_Free(m_pSrcBuf);
FX_Free(m_pDecodeBuf);
FX_Free(m_pSrcPalette);
@@ -349,6 +359,7 @@ bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule,
return true;
}
+#ifdef PDF_ENABLE_XFA_PNG
bool CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule,
int width,
int height,
@@ -584,7 +595,9 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule,
}
}
}
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
@@ -874,7 +887,9 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y);
}
}
+#endif // PDF_ENABLE_XFA_GIF
+#ifdef PDF_ENABLE_XFA_BMP
bool CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
@@ -954,6 +969,7 @@ void CCodec_ProgressiveDecoder::BmpReadScanlineCallback(void* pModule,
}
pCodec->ResampleVertBT(pDIBitmap, scale_y, des_row);
}
+#endif // PDF_ENABLE_XFA_BMP
void CCodec_ProgressiveDecoder::ResampleVertBT(CFX_DIBitmap* pDeviceBitmap,
double scale_y,
@@ -1051,6 +1067,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
FXSYS_memset(m_pSrcBuf, 0, size);
m_SrcSize = size;
switch (imageType) {
+#ifdef PDF_ENABLE_XFA_BMP
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
if (!pBmpModule) {
@@ -1106,6 +1123,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
}
+#endif // PDF_ENABLE_XFA_BMP
case FXCODEC_IMAGE_JPG: {
CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
if (!pJpegModule) {
@@ -1149,6 +1167,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
}
+#ifdef PDF_ENABLE_XFA_PNG
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
if (!pPngModule) {
@@ -1211,6 +1230,8 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
}
return true;
}
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (!pGifModule) {
@@ -1263,6 +1284,8 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
}
+#endif // PDF_XFA_ENABLE_GIF
+#ifdef PDF_ENABLE_XFA_TIFF
case FXCODEC_IMAGE_TIF: {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (!pTiffModule) {
@@ -1288,6 +1311,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
}
return true;
}
+#endif // PDF_ENABLE_XFA_TIFF
default:
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -1832,13 +1856,20 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
return FXCODEC_STATUS_ERROR;
}
switch (m_imagType) {
- case FXCODEC_IMAGE_BMP:
case FXCODEC_IMAGE_JPG:
+#ifdef PDF_ENABLE_XFA_BMP
+ case FXCODEC_IMAGE_BMP:
+#endif
+#ifdef PDF_ENABLE_XFA_PNG
case FXCODEC_IMAGE_PNG:
+#endif
+#ifdef PDF_ENABLE_XFA_TIFF
case FXCODEC_IMAGE_TIF:
+#endif
frames = m_FrameNumber = 1;
m_status = FXCODEC_STATUS_DECODE_READY;
return m_status;
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (true) {
@@ -1868,6 +1899,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
return m_status;
}
}
+#endif // PDF_ENABLE_XFA_GIF
default:
return FXCODEC_STATUS_ERROR;
}
@@ -1968,6 +2000,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
}
+#ifdef PDF_ENABLE_XFA_PNG
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
if (!pPngModule) {
@@ -2020,6 +2053,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
}
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (!pGifModule) {
@@ -2041,6 +2076,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
}
+#endif // PDF_ENABLE_XFA_GIF
+#ifdef PDF_ENABLE_XFA_BMP
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
if (!pBmpModule) {
@@ -2071,9 +2108,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
}
+#endif // PDF_ENABLE_XFA_BMP
+#ifdef PDF_ENABLE_XFA_TIFF
case FXCODEC_IMAGE_TIF:
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
+#endif // PDF_ENABLE_XFA_TIFF
default:
return FXCODEC_STATUS_ERROR;
}
@@ -2116,6 +2156,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
}
}
+#ifdef PDF_ENABLE_XFA_PNG
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
while (true) {
@@ -2160,6 +2201,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
}
}
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_GIF
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (true) {
@@ -2191,6 +2234,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
return m_status;
}
}
+#endif // PDF_ENABLE_XFA_GIF
+#ifdef PDF_ENABLE_XFA_BMP
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
while (true) {
@@ -2221,6 +2266,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
return m_status;
}
};
+#endif // PDF_ENABLE_XFA_BMP
+#ifdef PDF_ENABLE_XFA_TIFF
case FXCODEC_IMAGE_TIF: {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
bool ret = false;
@@ -2364,6 +2411,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
m_status = FXCODEC_STATUS_DECODE_FINISH;
return m_status;
}
+#endif // PDF_ENABLE_XFA_TIFF
default:
return FXCODEC_STATUS_ERROR;
}
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index bb4766567b..a33e117c7e 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -28,12 +28,23 @@ class CJPX_Decoder;
class CPDF_ColorSpace;
class CPDF_StreamAcc;
-#ifdef PDF_ENABLE_XFA
+#ifdef PDF_ENABLE_XFA_BMP
#include "core/fxcodec/codec/ccodec_bmpmodule.h"
+#endif // PDF_ENABLE_XFA_BMP
+
+#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
+#ifdef PDF_ENABLE_XFA
class CCodec_ProgressiveDecoder;
class CFX_DIBAttribute {
@@ -71,11 +82,23 @@ class CCodec_ModuleMgr {
#ifdef PDF_ENABLE_XFA
CCodec_ProgressiveDecoder* CreateProgressiveDecoder();
- CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
- CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
+#endif // PDF_ENABLE_XFA
+
+#ifdef PDF_ENABLE_XFA_BMP
CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
+#endif // PDF_ENABLE_XFA_BMP
+
+#ifdef PDF_ENABLE_XFA_GIF
+ CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
+#endif // PDF_ENABLE_XFA_GIF
+
+#ifdef PDF_ENABLE_XFA_PNG
+ CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
+#endif // PDF_ENABLE_XFA_PNG
+
+#ifdef PDF_ENABLE_XFA_TIFF
CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
-#endif // PDF_ENABLE_XFA
+#endif // PDF_ENABLE_XFA_TIFF
protected:
std::unique_ptr<CCodec_BasicModule> m_pBasicModule;
@@ -85,12 +108,21 @@ class CCodec_ModuleMgr {
std::unique_ptr<CCodec_Jbig2Module> m_pJbig2Module;
std::unique_ptr<CCodec_IccModule> m_pIccModule;
-#ifdef PDF_ENABLE_XFA
- std::unique_ptr<CCodec_PngModule> m_pPngModule;
- std::unique_ptr<CCodec_GifModule> m_pGifModule;
+#ifdef PDF_ENABLE_XFA_BMP
std::unique_ptr<CCodec_BmpModule> m_pBmpModule;
+#endif // PDF_ENABLE_XFA_BMP
+
+#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
+#endif // PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_FlateModule> m_pFlateModule;
};
diff --git a/pdfium.gni b/pdfium.gni
index 5737224f70..614ab916ec 100644
--- a/pdfium.gni
+++ b/pdfium.gni
@@ -17,6 +17,18 @@ declare_args() {
# Build PDFium either with or without XFA Forms support.
pdf_enable_xfa = pdf_enable_xfa_override
+ # If XFA, also support bmp codec. Ignored if not XFA.
+ pdf_enable_xfa_bmp = false
+
+ # If XFA, also support gif codec. Ignored if not XFA.
+ pdf_enable_xfa_gif = false
+
+ # If XFA, also support png codec. Ignored if not XFA.
+ pdf_enable_xfa_png = false
+
+ # If XFA, also support png codec. Ignored if not XFA.
+ pdf_enable_xfa_tiff = false
+
# Build PDFium against skia (experimental) rather than agg. Use Skia to draw everything.
pdf_use_skia = pdf_use_skia_override