summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorkcwu <kcwu@chromium.org>2016-09-19 09:49:13 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-19 09:49:13 -0700
commita5b37f6b916f1a35d3fbb3f0b41e9e4b4d265370 (patch)
treeb3beba72bff050114f7741c7c21b379868ea9124 /core
parentc48089977dc4d2a63d37e6668382c10b42e22a72 (diff)
downloadpdfium-a5b37f6b916f1a35d3fbb3f0b41e9e4b4d265370.tar.xz
Remove dead code in CCodec_IccModule
TEST=build pdfium and chromium BUG=pdfium:599 Review-Url: https://codereview.chromium.org/2355523002
Diffstat (limited to 'core')
-rw-r--r--core/fxcodec/codec/ccodec_iccmodule.h59
-rw-r--r--core/fxcodec/codec/fx_codec_icc.cpp317
2 files changed, 0 insertions, 376 deletions
diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h
index fd2f456654..8d4d0e9ca0 100644
--- a/core/fxcodec/codec/ccodec_iccmodule.h
+++ b/core/fxcodec/codec/ccodec_iccmodule.h
@@ -11,63 +11,16 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-class CFX_BinaryBuf;
-class CFX_IccProfileCache;
-class CFX_IccTransformCache;
-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();
~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,
@@ -77,19 +30,7 @@ class CCodec_IccModule {
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/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp
index 8ffbffe985..b5060a9fb6 100644
--- a/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/fxcodec/codec/fx_codec_icc.cpp
@@ -14,20 +14,12 @@ const uint32_t N_COMPONENT_RGB = 3;
const uint32_t N_COMPONENT_CMYK = 4;
const uint32_t N_COMPONENT_DEFAULT = 3;
-FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]) {
- return cmsMD5computeIDExt(buf, dwSize, ID);
-}
struct CLcmsCmm {
cmsHTRANSFORM m_hTransform;
int m_nSrcComponents;
int m_nDstComponents;
FX_BOOL m_bLab;
};
-extern "C" {
-int ourHandler(int ErrorCode, const char* ErrorText) {
- return TRUE;
-}
-};
FX_BOOL CheckComponents(cmsColorSpaceSignature cs,
int nComponents,
FX_BOOL bDst) {
@@ -238,306 +230,10 @@ void IccLib_TranslateImage(void* pTransform,
cmsDoTransform(((CLcmsCmm*)pTransform)->m_hTransform, (void*)pSrc, pDest,
pixels);
}
-void* CreateProfile_Gray(double gamma) {
- cmsCIExyY* D50 = (cmsCIExyY*)cmsD50_xyY();
- if (!cmsWhitePointFromTemp(D50, 6504)) {
- return nullptr;
- }
- cmsToneCurve* curve = cmsBuildGamma(nullptr, gamma);
- if (!curve) {
- return nullptr;
- }
- void* profile = cmsCreateGrayProfile(D50, curve);
- cmsFreeToneCurve(curve);
- return profile;
-}
-CCodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
- if (!pProfile) {
- return CCodec_IccModule::IccCS_Unknown;
- }
- switch (cmsGetColorSpace(pProfile)) {
- case cmsSigXYZData:
- return CCodec_IccModule::IccCS_XYZ;
- case cmsSigLabData:
- return CCodec_IccModule::IccCS_Lab;
- case cmsSigLuvData:
- return CCodec_IccModule::IccCS_Luv;
- case cmsSigYCbCrData:
- return CCodec_IccModule::IccCS_YCbCr;
- case cmsSigYxyData:
- return CCodec_IccModule::IccCS_Yxy;
- case cmsSigRgbData:
- return CCodec_IccModule::IccCS_Rgb;
- case cmsSigGrayData:
- return CCodec_IccModule::IccCS_Gray;
- case cmsSigHsvData:
- return CCodec_IccModule::IccCS_Hsv;
- case cmsSigHlsData:
- return CCodec_IccModule::IccCS_Hls;
- case cmsSigCmykData:
- return CCodec_IccModule::IccCS_Cmyk;
- case cmsSigCmyData:
- return CCodec_IccModule::IccCS_Cmy;
- default:
- return CCodec_IccModule::IccCS_Unknown;
- }
-}
-CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
- const uint8_t* pProfileData,
- uint32_t dwProfileSize) {
- CCodec_IccModule::IccCS cs;
- cmsHPROFILE hProfile =
- cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
- if (!hProfile) {
- return IccCS_Unknown;
- }
- cs = GetProfileCSFromHandle(hProfile);
- if (hProfile) {
- cmsCloseProfile(hProfile);
- }
- return cs;
-}
-CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
- if (!pFile) {
- return IccCS_Unknown;
- }
- CCodec_IccModule::IccCS cs;
- uint32_t dwSize = (uint32_t)pFile->GetSize();
- uint8_t* pBuf = FX_Alloc(uint8_t, dwSize);
- pFile->ReadBlock(pBuf, 0, dwSize);
- cs = GetProfileCS(pBuf, dwSize);
- FX_Free(pBuf);
- return cs;
-}
-uint32_t TransferProfileType(void* pProfile, uint32_t dwFormat) {
- cmsColorSpaceSignature cs = cmsGetColorSpace(pProfile);
- switch (cs) {
- case cmsSigXYZData:
- return TYPE_XYZ_16;
- case cmsSigLabData:
- return TYPE_Lab_DBL;
- case cmsSigLuvData:
- return TYPE_YUV_8;
- case cmsSigYCbCrData:
- return TYPE_YCbCr_8;
- case cmsSigYxyData:
- return TYPE_Yxy_16;
- case cmsSigRgbData:
- return T_DOSWAP(dwFormat) ? TYPE_RGB_8 : TYPE_BGR_8;
- case cmsSigGrayData:
- return TYPE_GRAY_8;
- case cmsSigHsvData:
- return TYPE_HSV_8;
- case cmsSigHlsData:
- return TYPE_HLS_8;
- case cmsSigCmykData:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC_8 : TYPE_CMYK_8;
- case cmsSigCmyData:
- return TYPE_CMY_8;
- case cmsSigMCH5Data:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC5_8 : TYPE_CMYK5_8;
- case cmsSigMCH6Data:
- return TYPE_CMYK6_8;
- case cmsSigMCH7Data:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC7_8 : TYPE_CMYK7_8;
- case cmsSigMCH8Data:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC8_8 : TYPE_CMYK8_8;
- case cmsSigMCH9Data:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC9_8 : TYPE_CMYK9_8;
- case cmsSigMCHAData:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC10_8 : TYPE_CMYK10_8;
- case cmsSigMCHBData:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC11_8 : TYPE_CMYK11_8;
- case cmsSigMCHCData:
- return T_DOSWAP(dwFormat) ? TYPE_KYMC12_8 : TYPE_CMYK12_8;
- default:
- return 0;
- }
-}
-class CFX_IccProfileCache {
- public:
- CFX_IccProfileCache();
- ~CFX_IccProfileCache();
- void* m_pProfile;
- uint32_t m_dwRate;
-
- protected:
- void Purge();
-};
-CFX_IccProfileCache::CFX_IccProfileCache() {
- m_pProfile = nullptr;
- m_dwRate = 1;
-}
-CFX_IccProfileCache::~CFX_IccProfileCache() {
- if (m_pProfile) {
- cmsCloseProfile(m_pProfile);
- }
-}
-void CFX_IccProfileCache::Purge() {}
-class CFX_IccTransformCache {
- public:
- CFX_IccTransformCache(CLcmsCmm* pCmm = nullptr);
- ~CFX_IccTransformCache();
- void* m_pIccTransform;
- uint32_t m_dwRate;
- CLcmsCmm* m_pCmm;
-
- protected:
- void Purge();
-};
-CFX_IccTransformCache::CFX_IccTransformCache(CLcmsCmm* pCmm) {
- m_pIccTransform = nullptr;
- m_dwRate = 1;
- m_pCmm = pCmm;
-}
-CFX_IccTransformCache::~CFX_IccTransformCache() {
- if (m_pIccTransform) {
- cmsDeleteTransform(m_pIccTransform);
- }
- FX_Free(m_pCmm);
-}
-void CFX_IccTransformCache::Purge() {}
-class CFX_ByteStringKey : public CFX_BinaryBuf {
- public:
- CFX_ByteStringKey() : CFX_BinaryBuf() {}
- CFX_ByteStringKey& operator<<(uint32_t i);
-};
-CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) {
- AppendBlock(&i, sizeof(uint32_t));
- return *this;
-}
-void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam,
- Icc_CLASS ic,
- CFX_BinaryBuf* pTransformKey) {
- CFX_IccProfileCache* pCache = nullptr;
- CFX_ByteStringKey key;
- CFX_ByteString text;
- key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8);
- uint8_t ID[16];
- switch (pIccParam->dwProfileType) {
- case Icc_PARAMTYPE_NONE:
- return nullptr;
- case Icc_PARAMTYPE_BUFFER:
- MD5ComputeID(pIccParam->pProfileData, pIccParam->dwProfileSize, ID);
- break;
- case Icc_PARAMTYPE_PARAM:
- FXSYS_memset(ID, 0, 16);
- switch (pIccParam->ColorSpace) {
- case IccCS_Gray:
- text.Format("%lf", pIccParam->Gamma);
- break;
- default:
- break;
- }
- MD5ComputeID(text.GetBuffer(0), text.GetLength(), ID);
- break;
- default:
- break;
- }
- key.AppendBlock(ID, 16);
- CFX_ByteString ProfileKey(key.GetBuffer(), key.GetSize());
- ASSERT(pTransformKey);
- pTransformKey->AppendBlock(ProfileKey.GetBuffer(0), ProfileKey.GetLength());
- auto it = m_MapProfile.find(ProfileKey);
- if (it == m_MapProfile.end()) {
- pCache = new CFX_IccProfileCache;
- switch (pIccParam->dwProfileType) {
- case Icc_PARAMTYPE_BUFFER:
- pCache->m_pProfile = cmsOpenProfileFromMem(pIccParam->pProfileData,
- pIccParam->dwProfileSize);
- break;
- case Icc_PARAMTYPE_PARAM:
- switch (pIccParam->ColorSpace) {
- case IccCS_Rgb:
- pCache->m_pProfile = cmsCreate_sRGBProfile();
- break;
- case IccCS_Gray:
- pCache->m_pProfile = CreateProfile_Gray(pIccParam->Gamma);
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- m_MapProfile[ProfileKey] = pCache;
- } else {
- pCache = it->second;
- pCache->m_dwRate++;
- }
- return pCache->m_pProfile;
-}
-void* CCodec_IccModule::CreateTransform(
- CCodec_IccModule::IccParam* pInputParam,
- CCodec_IccModule::IccParam* pOutputParam,
- CCodec_IccModule::IccParam* pProofParam,
- uint32_t dwIntent,
- uint32_t dwFlag,
- uint32_t dwPrfIntent,
- uint32_t dwPrfFlag) {
- CLcmsCmm* pCmm = nullptr;
- ASSERT(pInputParam && pOutputParam);
- CFX_ByteStringKey key;
- void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key);
- if (!pInputProfile) {
- return nullptr;
- }
- void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key);
- if (!pOutputProfile) {
- return nullptr;
- }
- uint32_t dwInputProfileType =
- TransferProfileType(pInputProfile, pInputParam->dwFormat);
- uint32_t dwOutputProfileType =
- TransferProfileType(pOutputProfile, pOutputParam->dwFormat);
- if (dwInputProfileType == 0 || dwOutputProfileType == 0) {
- return nullptr;
- }
- void* pProofProfile = nullptr;
- if (pProofParam) {
- pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key);
- }
- key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag
- << !!pProofProfile << dwPrfIntent << dwPrfFlag;
- CFX_ByteString TransformKey(key.GetBuffer(), key.GetSize());
- CFX_IccTransformCache* pTransformCache;
- auto it = m_MapTranform.find(TransformKey);
- if (it == m_MapTranform.end()) {
- pCmm = FX_Alloc(CLcmsCmm, 1);
- pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType);
- pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType);
- pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab;
- pTransformCache = new CFX_IccTransformCache(pCmm);
- if (pProofProfile) {
- pTransformCache->m_pIccTransform = cmsCreateProofingTransform(
- pInputProfile, dwInputProfileType, pOutputProfile,
- dwOutputProfileType, pProofProfile, dwIntent, dwPrfIntent, dwPrfFlag);
- } else {
- pTransformCache->m_pIccTransform =
- cmsCreateTransform(pInputProfile, dwInputProfileType, pOutputProfile,
- dwOutputProfileType, dwIntent, dwFlag);
- }
- pCmm->m_hTransform = pTransformCache->m_pIccTransform;
- m_MapTranform[TransformKey] = pTransformCache;
- } else {
- pTransformCache = it->second;
- pTransformCache->m_dwRate++;
- }
- return pTransformCache->m_pCmm;
-}
CCodec_IccModule::CCodec_IccModule() : m_nComponents(0) {}
CCodec_IccModule::~CCodec_IccModule() {
- for (const auto& pair : m_MapProfile) {
- delete pair.second;
- }
- m_MapProfile.clear();
- for (const auto& pair : m_MapTranform) {
- delete pair.second;
- }
- m_MapTranform.clear();
}
void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData,
uint32_t dwProfileSize,
@@ -548,19 +244,6 @@ void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData,
intent, dwSrcFormat);
}
-void* CCodec_IccModule::CreateTransform_CMYK(const uint8_t* pSrcProfileData,
- uint32_t dwSrcProfileSize,
- uint32_t& nSrcComponents,
- const uint8_t* pDstProfileData,
- uint32_t dwDstProfileSize,
- int32_t intent,
- uint32_t dwSrcFormat,
- uint32_t dwDstFormat) {
- return IccLib_CreateTransform(
- pSrcProfileData, dwSrcProfileSize, nSrcComponents, pDstProfileData,
- dwDstProfileSize, 4, intent, dwSrcFormat, dwDstFormat);
-}
-
void CCodec_IccModule::DestroyTransform(void* pTransform) {
IccLib_DestroyTransform(pTransform);
}