summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-05-09 14:42:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-09 14:42:42 +0000
commit27924e6c9d43f0eba57d14004853d5a8ba47de26 (patch)
treefcc6639b62cf2fee783123b1858c618ba773da2e /core/fxcodec
parent5f7c5be8b7072d46e8d8088a1ec14370ecfad44c (diff)
downloadpdfium-27924e6c9d43f0eba57d14004853d5a8ba47de26.tar.xz
Do not build TIFF when codec is disabled
Currently all of the TIFF related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the TIFF codec code if support for TIFF is turned off. It also fixes cases in the code base where tif was being used instead of tiff. BUG=pdfium:1080 Change-Id: If6aaa8af5160fdd5b261e63bab7d5984196efcc9 Reviewed-on: https://pdfium-review.googlesource.com/32193 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h16
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp35
-rw-r--r--core/fxcodec/fx_codec_def.h4
3 files changed, 38 insertions, 17 deletions
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index a14ec0db29..9a0136c872 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -15,13 +15,17 @@
#include "core/fxcodec/codec/ccodec_gifmodule.h"
#include "core/fxcodec/codec/ccodec_jpegmodule.h"
#include "core/fxcodec/codec/ccodec_pngmodule.h"
-#include "core/fxcodec/codec/ccodec_tiffmodule.h"
#include "core/fxcodec/fx_codec_def.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
+#ifdef PDF_ENABLE_XFA_TIFF
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
+#endif // PDF_ENABLE_XFA_TIFF
+
class CCodec_ModuleMgr;
class CFX_DIBAttribute;
class IFX_SeekableReadStream;
@@ -167,7 +171,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
bool JpegDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
bool PngDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
bool GifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
- bool TifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
+#ifdef PDF_ENABLE_XFA_TIFF
+ bool TiffDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
+#endif // PDF_ENABLE_XFA_TIFF
void GetDownScale(int& down_scale);
void GetTransMethod(FXDIB_Format dest_format, FXCodec_Format src_format);
@@ -199,7 +205,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
FXCODEC_STATUS PngContinueDecode();
FXCODEC_STATUS GifContinueDecode();
FXCODEC_STATUS BmpContinueDecode();
- FXCODEC_STATUS TifContinueDecode();
+#ifdef PDF_ENABLE_XFA_TIFF
+ FXCODEC_STATUS TiffContinueDecode();
+#endif // PDF_ENABLE_XFA_TIFF
RetainPtr<IFX_SeekableReadStream> m_pFile;
RetainPtr<CFX_DIBitmap> m_pDeviceBitmap;
@@ -208,7 +216,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
std::unique_ptr<CCodec_PngModule::Context> m_pPngContext;
std::unique_ptr<CCodec_GifModule::Context> m_pGifContext;
std::unique_ptr<CCodec_BmpModule::Context> m_pBmpContext;
+#ifdef PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_TiffModule::Context> m_pTiffContext;
+#endif // PDF_ENABLE_XFA_TIFF
FXCODEC_IMAGE_TYPE m_imagType;
uint32_t m_offSet;
uint8_t* m_pSrcBuf;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index e1aec22150..e606c414bb 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -250,10 +250,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder(
CCodec_ModuleMgr* pCodecMgr) {
m_pFile = nullptr;
- m_pJpegContext = nullptr;
- m_pPngContext = nullptr;
- m_pBmpContext = nullptr;
- m_pTiffContext = nullptr;
m_pCodecMgr = nullptr;
m_pSrcBuf = nullptr;
m_pDecodeBuf = nullptr;
@@ -1045,8 +1041,10 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
return PngDetectImageType(pAttribute, size);
case FXCODEC_IMAGE_GIF:
return GifDetectImageType(pAttribute, size);
- case FXCODEC_IMAGE_TIF:
- return TifDetectImageType(pAttribute, size);
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+ return TiffDetectImageType(pAttribute, size);
+#endif // PDF_ENABLE_XFA_TIFF
default:
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -1282,8 +1280,10 @@ bool CCodec_ProgressiveDecoder::GifDetectImageType(CFX_DIBAttribute* pAttribute,
return false;
}
-bool CCodec_ProgressiveDecoder::TifDetectImageType(CFX_DIBAttribute* pAttribute,
- uint32_t size) {
+#ifdef PDF_ENABLE_XFA_TIFF
+bool CCodec_ProgressiveDecoder::TiffDetectImageType(
+ CFX_DIBAttribute* pAttribute,
+ uint32_t size) {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (!pTiffModule) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
@@ -1307,6 +1307,7 @@ bool CCodec_ProgressiveDecoder::TifDetectImageType(CFX_DIBAttribute* pAttribute,
}
return true;
}
+#endif // PDF_ENABLE_XFA_TIFF
FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
const RetainPtr<IFX_SeekableReadStream>& pFile,
@@ -1862,7 +1863,9 @@ std::pair<FXCODEC_STATUS, size_t> CCodec_ProgressiveDecoder::GetFrames() {
case FXCODEC_IMAGE_JPG:
case FXCODEC_IMAGE_BMP:
case FXCODEC_IMAGE_PNG:
- case FXCODEC_IMAGE_TIF:
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+#endif // PDF_ENABLE_XFA_TIFF
m_FrameNumber = 1;
m_status = FXCODEC_STATUS_DECODE_READY;
return {m_status, 1};
@@ -1960,9 +1963,11 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(
return GifStartDecode(pDIBitmap);
case FXCODEC_IMAGE_BMP:
return BmpStartDecode(pDIBitmap);
- case FXCODEC_IMAGE_TIF:
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
+#endif // PDF_ENABLE_XFA_TIFF
default:
return FXCODEC_STATUS_ERROR;
}
@@ -2125,8 +2130,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
return GifContinueDecode();
case FXCODEC_IMAGE_BMP:
return BmpContinueDecode();
- case FXCODEC_IMAGE_TIF:
- return TifContinueDecode();
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+ return TiffContinueDecode();
+#endif // PDF_ENABLE_XFA_TIFF
default:
return FXCODEC_STATUS_ERROR;
}
@@ -2278,7 +2285,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::BmpContinueDecode() {
}
}
-FXCODEC_STATUS CCodec_ProgressiveDecoder::TifContinueDecode() {
+#ifdef PDF_ENABLE_XFA_TIFF
+FXCODEC_STATUS CCodec_ProgressiveDecoder::TiffContinueDecode() {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (!pTiffModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -2416,6 +2424,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TifContinueDecode() {
m_status = FXCODEC_STATUS_DECODE_FINISH;
return m_status;
}
+#endif // PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_ProgressiveDecoder>
CCodec_ModuleMgr::CreateProgressiveDecoder() {
diff --git a/core/fxcodec/fx_codec_def.h b/core/fxcodec/fx_codec_def.h
index 3983285d6d..e4ac0437eb 100644
--- a/core/fxcodec/fx_codec_def.h
+++ b/core/fxcodec/fx_codec_def.h
@@ -30,7 +30,9 @@ enum FXCODEC_IMAGE_TYPE {
FXCODEC_IMAGE_JPG,
FXCODEC_IMAGE_PNG,
FXCODEC_IMAGE_GIF,
- FXCODEC_IMAGE_TIF,
+#ifdef PDF_ENABLE_XFA_TIFF
+ FXCODEC_IMAGE_TIFF,
+#endif // PDF_ENABLE_XFA_TIFF
FXCODEC_IMAGE_MAX
};
enum FXCODEC_RESUNIT {