Rename CCodec_IccModule to fxcodec::IccModule.
BUG=pdfium:1311
Change-Id: I3334956e7b1fefea1ab9b51349c574a83cbae7d6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55773
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index a1497bd..afe84cb 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -28,7 +28,7 @@
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
-#include "core/fxcodec/codec/ccodec_iccmodule.h"
+#include "core/fxcodec/codec/iccmodule.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_safe_types.h"
@@ -915,8 +915,7 @@
}
if (m_pProfile->transform()) {
float rgb[3];
- CCodec_IccModule::Translate(m_pProfile->transform(), CountComponents(),
- pBuf, rgb);
+ IccModule::Translate(m_pProfile->transform(), CountComponents(), pBuf, rgb);
*R = rgb[0];
*G = rgb[1];
*B = rgb[2];
@@ -971,8 +970,8 @@
bTranslate = nPixelCount.ValueOrDie() < nMaxColors * 3 / 2;
}
if (bTranslate) {
- CCodec_IccModule::TranslateScanline(m_pProfile->transform(), pDestBuf,
- pSrcBuf, pixels);
+ IccModule::TranslateScanline(m_pProfile->transform(), pDestBuf, pSrcBuf,
+ pixels);
return;
}
@@ -989,8 +988,8 @@
order /= 52;
}
}
- CCodec_IccModule::TranslateScanline(
- m_pProfile->transform(), m_pCache.data(), temp_src.data(), nMaxColors);
+ IccModule::TranslateScanline(m_pProfile->transform(), m_pCache.data(),
+ temp_src.data(), nMaxColors);
}
for (int i = 0; i < pixels; i++) {
int index = 0;
diff --git a/core/fpdfapi/page/cpdf_iccprofile.cpp b/core/fpdfapi/page/cpdf_iccprofile.cpp
index 811ef35..12590ff 100644
--- a/core/fpdfapi/page/cpdf_iccprofile.cpp
+++ b/core/fpdfapi/page/cpdf_iccprofile.cpp
@@ -7,7 +7,7 @@
#include "core/fpdfapi/page/cpdf_iccprofile.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
-#include "core/fxcodec/codec/ccodec_iccmodule.h"
+#include "core/fxcodec/codec/iccmodule.h"
namespace {
@@ -26,7 +26,7 @@
return;
}
- m_Transform = CCodec_IccModule::CreateTransform_sRGB(span);
+ m_Transform = IccModule::CreateTransform_sRGB(span);
if (m_Transform)
m_nSrcComponents = m_Transform->components();
}
diff --git a/core/fpdfapi/page/cpdf_iccprofile.h b/core/fpdfapi/page/cpdf_iccprofile.h
index 0f13b0b..ffac22f 100644
--- a/core/fpdfapi/page/cpdf_iccprofile.h
+++ b/core/fpdfapi/page/cpdf_iccprofile.h
@@ -13,9 +13,12 @@
#include "core/fxcrt/unowned_ptr.h"
#include "third_party/base/span.h"
-class CLcmsCmm;
class CPDF_Stream;
+namespace fxcodec {
+class CLcmsCmm;
+}
+
class CPDF_IccProfile final : public Retainable {
public:
template <typename T, typename... Args>
@@ -25,7 +28,7 @@
bool IsValid() const { return IsSRGB() || IsSupported(); }
bool IsSRGB() const { return m_bsRGB; }
bool IsSupported() const { return !!m_Transform; }
- CLcmsCmm* transform() { return m_Transform.get(); }
+ fxcodec::CLcmsCmm* transform() { return m_Transform.get(); }
uint32_t GetComponents() const { return m_nSrcComponents; }
private:
@@ -34,7 +37,7 @@
const bool m_bsRGB;
UnownedPtr<const CPDF_Stream> const m_pStream;
- std::unique_ptr<CLcmsCmm> m_Transform;
+ std::unique_ptr<fxcodec::CLcmsCmm> m_Transform;
uint32_t m_nSrcComponents = 0;
};
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index 479a7f5..8ccc29d 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -15,8 +15,6 @@
"codec/ccodec_faxmodule.h",
"codec/ccodec_flatemodule.cpp",
"codec/ccodec_flatemodule.h",
- "codec/ccodec_iccmodule.cpp",
- "codec/ccodec_iccmodule.h",
"codec/ccodec_jbig2module.cpp",
"codec/ccodec_jbig2module.h",
"codec/ccodec_jpegmodule.cpp",
@@ -32,6 +30,8 @@
"codec/codec_int.h",
"codec/codec_module_iface.h",
"codec/fx_codec.cpp",
+ "codec/iccmodule.cpp",
+ "codec/iccmodule.h",
"fx_codec.h",
"fx_codec_def.h",
"jbig2/JBig2_ArithDecoder.cpp",
diff --git a/core/fxcodec/codec/ccodec_iccmodule.cpp b/core/fxcodec/codec/iccmodule.cpp
similarity index 87%
rename from core/fxcodec/codec/ccodec_iccmodule.cpp
rename to core/fxcodec/codec/iccmodule.cpp
index 2448a10..d27f200 100644
--- a/core/fxcodec/codec/ccodec_iccmodule.cpp
+++ b/core/fxcodec/codec/iccmodule.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcodec/codec/ccodec_iccmodule.h"
+#include "core/fxcodec/codec/iccmodule.h"
#include <algorithm>
#include <memory>
@@ -14,6 +14,8 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
+namespace fxcodec {
+
namespace {
// For use with std::unique_ptr<cmsHPROFILE>.
@@ -49,7 +51,7 @@
}
// static
-std::unique_ptr<CLcmsCmm> CCodec_IccModule::CreateTransform_sRGB(
+std::unique_ptr<CLcmsCmm> IccModule::CreateTransform_sRGB(
pdfium::span<const uint8_t> span) {
ScopedCmsProfile srcProfile(cmsOpenProfileFromMem(span.data(), span.size()));
if (!srcProfile)
@@ -108,10 +110,10 @@
}
// static
-void CCodec_IccModule::Translate(CLcmsCmm* pTransform,
- uint32_t nSrcComponents,
- const float* pSrcValues,
- float* pDestValues) {
+void IccModule::Translate(CLcmsCmm* pTransform,
+ uint32_t nSrcComponents,
+ const float* pSrcValues,
+ float* pDestValues) {
if (!pTransform)
return;
@@ -138,10 +140,12 @@
}
// static
-void CCodec_IccModule::TranslateScanline(CLcmsCmm* pTransform,
- unsigned char* pDest,
- const unsigned char* pSrc,
- int32_t pixels) {
+void IccModule::TranslateScanline(CLcmsCmm* pTransform,
+ unsigned char* pDest,
+ const unsigned char* pSrc,
+ int32_t pixels) {
if (pTransform)
cmsDoTransform(pTransform->transform(), pSrc, pDest, pixels);
}
+
+} // namespace fxcodec
diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/iccmodule.h
similarity index 79%
rename from core/fxcodec/codec/ccodec_iccmodule.h
rename to core/fxcodec/codec/iccmodule.h
index a9db38a..7270f45 100644
--- a/core/fxcodec/codec/ccodec_iccmodule.h
+++ b/core/fxcodec/codec/iccmodule.h
@@ -4,8 +4,8 @@
// 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_
+#ifndef CORE_FXCODEC_CODEC_ICCMODULE_H_
+#define CORE_FXCODEC_CODEC_ICCMODULE_H_
#include <memory>
@@ -20,6 +20,8 @@
#include "third_party/lcms/include/lcms2.h"
#endif
+namespace fxcodec {
+
class CLcmsCmm {
public:
CLcmsCmm(cmsHTRANSFORM transform,
@@ -40,7 +42,7 @@
const bool m_bNormal;
};
-class CCodec_IccModule {
+class IccModule {
public:
static std::unique_ptr<CLcmsCmm> CreateTransform_sRGB(
pdfium::span<const uint8_t> span);
@@ -53,9 +55,14 @@
const uint8_t* pSrc,
int pixels);
- CCodec_IccModule() = delete;
- CCodec_IccModule(const CCodec_IccModule&) = delete;
- CCodec_IccModule& operator=(const CCodec_IccModule&) = delete;
+ IccModule() = delete;
+ IccModule(const IccModule&) = delete;
+ IccModule& operator=(const IccModule&) = delete;
};
-#endif // CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
+} // namespace fxcodec
+
+using CLcmsCmm = fxcodec::CLcmsCmm;
+using IccModule = fxcodec::IccModule;
+
+#endif // CORE_FXCODEC_CODEC_ICCMODULE_H_
diff --git a/testing/fuzzers/pdf_codec_icc_fuzzer.cc b/testing/fuzzers/pdf_codec_icc_fuzzer.cc
index 6d06a90..06936b8 100644
--- a/testing/fuzzers/pdf_codec_icc_fuzzer.cc
+++ b/testing/fuzzers/pdf_codec_icc_fuzzer.cc
@@ -4,20 +4,19 @@
#include <cstdint>
-#include "core/fxcodec/codec/ccodec_iccmodule.h"
+#include "core/fxcodec/codec/iccmodule.h"
#include "third_party/base/span.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
std::unique_ptr<CLcmsCmm> transform =
- CCodec_IccModule::CreateTransform_sRGB(pdfium::make_span(data, size));
+ IccModule::CreateTransform_sRGB(pdfium::make_span(data, size));
if (transform) {
float src[4];
float dst[4];
for (int i = 0; i < 4; i++)
src[i] = 0.5f;
- CCodec_IccModule::Translate(transform.get(), transform->components(), src,
- dst);
+ IccModule::Translate(transform.get(), transform->components(), src, dst);
}
return 0;