Put more fxcodec classes into namespace fxcodec.
BUG=pdfium:1311
Change-Id: I612c8a308a9e55cb5bb873b29f65cfa549cc7f35
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/56292
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/cpdf_modulemgr.cpp b/core/fpdfapi/cpdf_modulemgr.cpp
index ebe7758..3987f69 100644
--- a/core/fpdfapi/cpdf_modulemgr.cpp
+++ b/core/fpdfapi/cpdf_modulemgr.cpp
@@ -25,7 +25,7 @@
void CPDF_ModuleMgr::Create() {
ASSERT(!g_pDefaultMgr);
g_pDefaultMgr = new CPDF_ModuleMgr;
- CCodec_ModuleMgr::Create();
+ fxcodec::ModuleMgr::Create();
CPDF_PageModule::Create();
g_pDefaultMgr->LoadEmbeddedMaps();
}
@@ -34,7 +34,7 @@
void CPDF_ModuleMgr::Destroy() {
ASSERT(g_pDefaultMgr);
CPDF_PageModule::Destroy();
- CCodec_ModuleMgr::Destroy();
+ fxcodec::ModuleMgr::Destroy();
delete g_pDefaultMgr;
g_pDefaultMgr = nullptr;
}
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 156872b..e3d46c2 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -88,7 +88,7 @@
int32_t num_comps;
int32_t bits;
bool color_trans;
- if (!CCodec_ModuleMgr::GetInstance()->GetJpegModule()->LoadInfo(
+ if (!fxcodec::ModuleMgr::GetInstance()->GetJpegModule()->LoadInfo(
src_span, &width, &height, &num_comps, &bits, &color_trans)) {
return nullptr;
}
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index 44b3785..6e8aaaf 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -92,7 +92,7 @@
}
if (decoder == "DCTDecode") {
std::unique_ptr<ScanlineDecoder> pDecoder =
- CCodec_ModuleMgr::GetInstance()->GetJpegModule()->CreateDecoder(
+ fxcodec::ModuleMgr::GetInstance()->GetJpegModule()->CreateDecoder(
src_span, width, height, 0,
!pParam || pParam->GetIntegerFor("ColorTransform", 1));
return DecodeAllScanlines(std::move(pDecoder));
diff --git a/core/fpdfapi/render/cpdf_dibbase.cpp b/core/fpdfapi/render/cpdf_dibbase.cpp
index 67ef464..efbade6 100644
--- a/core/fpdfapi/render/cpdf_dibbase.cpp
+++ b/core/fpdfapi/render/cpdf_dibbase.cpp
@@ -282,7 +282,8 @@
return LoadState::kFail;
FXCODEC_STATUS iDecodeStatus;
- Jbig2Module* pJbig2Module = CCodec_ModuleMgr::GetInstance()->GetJbig2Module();
+ Jbig2Module* pJbig2Module =
+ fxcodec::ModuleMgr::GetInstance()->GetJbig2Module();
if (!m_pJbig2Context) {
m_pJbig2Context = pdfium::MakeUnique<Jbig2Context>();
if (m_pStreamAcc->GetImageParam()) {
@@ -511,7 +512,7 @@
bool CPDF_DIBBase::CreateDCTDecoder(pdfium::span<const uint8_t> src_span,
const CPDF_Dictionary* pParams) {
- JpegModule* pJpegModule = CCodec_ModuleMgr::GetInstance()->GetJpegModule();
+ JpegModule* pJpegModule = fxcodec::ModuleMgr::GetInstance()->GetJpegModule();
m_pDecoder = pJpegModule->CreateDecoder(
src_span, m_Width, m_Height, m_nComponents,
!pParams || pParams->GetIntegerFor("ColorTransform", 1));
diff --git a/core/fxcodec/bmp/cfx_bmpcontext.h b/core/fxcodec/bmp/cfx_bmpcontext.h
index e368a9b..993afdd 100644
--- a/core/fxcodec/bmp/cfx_bmpcontext.h
+++ b/core/fxcodec/bmp/cfx_bmpcontext.h
@@ -14,7 +14,7 @@
namespace fxcodec {
-class CFX_BmpContext final : public CodecModuleIface::Context {
+class CFX_BmpContext final : public ModuleIface::Context {
public:
CFX_BmpContext(BmpModule* pModule, BmpModule::Delegate* pDelegate);
~CFX_BmpContext() override;
diff --git a/core/fxcodec/codec/bmpmodule.cpp b/core/fxcodec/codec/bmpmodule.cpp
index d052413..d9919ce 100644
--- a/core/fxcodec/codec/bmpmodule.cpp
+++ b/core/fxcodec/codec/bmpmodule.cpp
@@ -21,8 +21,7 @@
BmpModule::~BmpModule() = default;
-std::unique_ptr<CodecModuleIface::Context> BmpModule::Start(
- Delegate* pDelegate) {
+std::unique_ptr<ModuleIface::Context> BmpModule::Start(Delegate* pDelegate) {
return pdfium::MakeUnique<CFX_BmpContext>(this, pDelegate);
}
diff --git a/core/fxcodec/codec/bmpmodule.h b/core/fxcodec/codec/bmpmodule.h
index 3a8b257..eb33c37 100644
--- a/core/fxcodec/codec/bmpmodule.h
+++ b/core/fxcodec/codec/bmpmodule.h
@@ -12,11 +12,11 @@
#include "core/fxcodec/codec/codec_module_iface.h"
-class CFX_DIBAttribute;
-
namespace fxcodec {
-class BmpModule final : public CodecModuleIface {
+class CFX_DIBAttribute;
+
+class BmpModule final : public ModuleIface {
public:
class Delegate {
public:
@@ -30,7 +30,7 @@
BmpModule();
~BmpModule() override;
- // CodecModuleIface:
+ // ModuleIface:
FX_FILESIZE GetAvailInput(Context* pContext) const override;
bool Input(Context* pContext,
RetainPtr<CFX_CodecMemory> codec_memory,
diff --git a/core/fxcodec/codec/codec_module_iface.h b/core/fxcodec/codec/codec_module_iface.h
index 12a119e..4c6f961 100644
--- a/core/fxcodec/codec/codec_module_iface.h
+++ b/core/fxcodec/codec/codec_module_iface.h
@@ -11,16 +11,19 @@
#include "core/fxcrt/retain_ptr.h"
class CFX_CodecMemory;
+
+namespace fxcodec {
+
class CFX_DIBAttribute;
-class CodecModuleIface {
+class ModuleIface {
public:
class Context {
public:
virtual ~Context() = default;
};
- virtual ~CodecModuleIface() = default;
+ virtual ~ModuleIface() = default;
// Returns the number of unprocessed bytes remaining in the input buffer.
virtual FX_FILESIZE GetAvailInput(Context* pContext) const = 0;
@@ -33,4 +36,8 @@
CFX_DIBAttribute* pAttribute) = 0;
};
+} // namespace fxcodec
+
+using fxcodec::ModuleIface;
+
#endif // CORE_FXCODEC_CODEC_CODEC_MODULE_IFACE_H_
diff --git a/core/fxcodec/codec/gifmodule.cpp b/core/fxcodec/codec/gifmodule.cpp
index 1c4733f..0e33f64 100644
--- a/core/fxcodec/codec/gifmodule.cpp
+++ b/core/fxcodec/codec/gifmodule.cpp
@@ -20,8 +20,7 @@
GifModule::~GifModule() = default;
-std::unique_ptr<CodecModuleIface::Context> GifModule::Start(
- Delegate* pDelegate) {
+std::unique_ptr<ModuleIface::Context> GifModule::Start(Delegate* pDelegate) {
return pdfium::MakeUnique<CFX_GifContext>(this, pDelegate);
}
diff --git a/core/fxcodec/codec/gifmodule.h b/core/fxcodec/codec/gifmodule.h
index 70bfb28..9d4d8ed 100644
--- a/core/fxcodec/codec/gifmodule.h
+++ b/core/fxcodec/codec/gifmodule.h
@@ -14,11 +14,11 @@
#include "core/fxcodec/gif/cfx_gif.h"
#include "core/fxcrt/fx_coordinates.h"
-class CFX_DIBAttribute;
-
namespace fxcodec {
-class GifModule final : public CodecModuleIface {
+class CFX_DIBAttribute;
+
+class GifModule final : public ModuleIface {
public:
class Delegate {
public:
@@ -38,7 +38,7 @@
GifModule();
~GifModule() override;
- // CodecModuleIface:
+ // ModuleIface:
FX_FILESIZE GetAvailInput(Context* context) const override;
bool Input(Context* context,
RetainPtr<CFX_CodecMemory> codec_memory,
diff --git a/core/fxcodec/codec/jpegmodule.cpp b/core/fxcodec/codec/jpegmodule.cpp
index 414f795..c1b0025 100644
--- a/core/fxcodec/codec/jpegmodule.cpp
+++ b/core/fxcodec/codec/jpegmodule.cpp
@@ -36,7 +36,7 @@
#endif
} // extern "C"
-class CJpegContext final : public CodecModuleIface::Context {
+class CJpegContext final : public ModuleIface::Context {
public:
CJpegContext();
~CJpegContext() override;
@@ -481,7 +481,7 @@
bits_per_components, color_transform);
}
-std::unique_ptr<CodecModuleIface::Context> JpegModule::Start() {
+std::unique_ptr<ModuleIface::Context> JpegModule::Start() {
// Use ordinary pointer until past the possibility of a longjump.
auto* pContext = new CJpegContext();
if (setjmp(pContext->m_JumpMark) == -1) {
diff --git a/core/fxcodec/codec/jpegmodule.h b/core/fxcodec/codec/jpegmodule.h
index 31bfeee..243f869 100644
--- a/core/fxcodec/codec/jpegmodule.h
+++ b/core/fxcodec/codec/jpegmodule.h
@@ -14,14 +14,14 @@
#include "core/fxcodec/codec/codec_module_iface.h"
#include "third_party/base/span.h"
-class CFX_DIBAttribute;
class CFX_DIBBase;
namespace fxcodec {
+class CFX_DIBAttribute;
class ScanlineDecoder;
-class JpegModule final : public CodecModuleIface {
+class JpegModule final : public ModuleIface {
public:
std::unique_ptr<ScanlineDecoder> CreateDecoder(
pdfium::span<const uint8_t> src_buf,
@@ -30,7 +30,7 @@
int nComps,
bool ColorTransform);
- // CodecModuleIface:
+ // ModuleIface:
FX_FILESIZE GetAvailInput(Context* pContext) const override;
bool Input(Context* pContext,
RetainPtr<CFX_CodecMemory> codec_memory,
diff --git a/core/fxcodec/codec/pngmodule.cpp b/core/fxcodec/codec/pngmodule.cpp
index 19fa62c..8999508 100644
--- a/core/fxcodec/codec/pngmodule.cpp
+++ b/core/fxcodec/codec/pngmodule.cpp
@@ -24,7 +24,7 @@
#define PNG_ERROR_SIZE 256
-class CPngContext final : public CodecModuleIface::Context {
+class CPngContext final : public ModuleIface::Context {
public:
explicit CPngContext(PngModule::Delegate* pDelegate);
~CPngContext() override;
@@ -189,8 +189,7 @@
PngModule::~PngModule() = default;
-std::unique_ptr<CodecModuleIface::Context> PngModule::Start(
- Delegate* pDelegate) {
+std::unique_ptr<ModuleIface::Context> PngModule::Start(Delegate* pDelegate) {
auto p = pdfium::MakeUnique<CPngContext>(pDelegate);
p->m_pPng =
png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
diff --git a/core/fxcodec/codec/pngmodule.h b/core/fxcodec/codec/pngmodule.h
index 946ad07..c5f1980 100644
--- a/core/fxcodec/codec/pngmodule.h
+++ b/core/fxcodec/codec/pngmodule.h
@@ -13,7 +13,7 @@
namespace fxcodec {
-class PngModule final : public CodecModuleIface {
+class PngModule final : public ModuleIface {
public:
class Delegate {
public:
@@ -34,7 +34,7 @@
PngModule();
~PngModule() override;
- // CodecModuleIface:
+ // ModuleIface:
FX_FILESIZE GetAvailInput(Context* pContext) const override;
bool Input(Context* pContext,
RetainPtr<CFX_CodecMemory> codec_memory,
diff --git a/core/fxcodec/codec/progressivedecoder.cpp b/core/fxcodec/codec/progressivedecoder.cpp
index 2987ea3..85052f0 100644
--- a/core/fxcodec/codec/progressivedecoder.cpp
+++ b/core/fxcodec/codec/progressivedecoder.cpp
@@ -253,7 +253,7 @@
}
}
-ProgressiveDecoder::ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr)
+ProgressiveDecoder::ProgressiveDecoder(ModuleMgr* pCodecMgr)
: m_pCodecMgr(pCodecMgr) {}
ProgressiveDecoder::~ProgressiveDecoder() = default;
@@ -715,8 +715,7 @@
return false;
}
- std::unique_ptr<CodecModuleIface::Context> pBmpContext =
- pBmpModule->Start(this);
+ std::unique_ptr<ModuleIface::Context> pBmpContext = pBmpModule->Start(this);
pBmpModule->Input(pBmpContext.get(), m_pCodecMemory, nullptr);
const std::vector<uint32_t>* palette;
@@ -788,7 +787,7 @@
}
bool ProgressiveDecoder::BmpReadMoreData(BmpModule* pBmpModule,
- CodecModuleIface::Context* pContext,
+ ModuleIface::Context* pContext,
FXCODEC_STATUS& err_status) {
return ReadMoreData(pBmpModule, pContext, false, err_status);
}
@@ -1579,8 +1578,8 @@
return false;
}
-bool ProgressiveDecoder::ReadMoreData(CodecModuleIface* pModule,
- CodecModuleIface::Context* pContext,
+bool ProgressiveDecoder::ReadMoreData(ModuleIface* pModule,
+ ModuleIface::Context* pContext,
bool invalidate_buffer,
FXCODEC_STATUS& err_status) {
// Check for EOF.
@@ -2333,9 +2332,8 @@
}
}
-} // namespace fxcodec
-
-std::unique_ptr<ProgressiveDecoder>
-CCodec_ModuleMgr::CreateProgressiveDecoder() {
+std::unique_ptr<ProgressiveDecoder> ModuleMgr::CreateProgressiveDecoder() {
return pdfium::MakeUnique<ProgressiveDecoder>(this);
}
+
+} // namespace fxcodec
diff --git a/core/fxcodec/codec/progressivedecoder.h b/core/fxcodec/codec/progressivedecoder.h
index 149efd3..b2eac13 100644
--- a/core/fxcodec/codec/progressivedecoder.h
+++ b/core/fxcodec/codec/progressivedecoder.h
@@ -34,13 +34,14 @@
#include "core/fxcodec/codec/tiffmodule.h"
#endif // PDF_ENABLE_XFA_TIFF
-class CCodec_ModuleMgr;
-class CFX_DIBAttribute;
class CFX_DIBitmap;
class IFX_SeekableReadStream;
namespace fxcodec {
+class CFX_DIBAttribute;
+class ModuleMgr;
+
class Dummy {}; // Placeholder to work around C++ syntax issues
class ProgressiveDecoder :
@@ -67,7 +68,7 @@
FXCodec_Cmyk = 0x120
};
- explicit ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr);
+ explicit ProgressiveDecoder(ModuleMgr* pCodecMgr);
virtual ~ProgressiveDecoder();
FXCODEC_STATUS LoadImageInfo(const RetainPtr<IFX_SeekableReadStream>& pFile,
@@ -184,7 +185,7 @@
private:
#ifdef PDF_ENABLE_XFA_BMP
bool BmpReadMoreData(BmpModule* pBmpModule,
- CodecModuleIface::Context* pBmpContext,
+ ModuleIface::Context* pBmpContext,
FXCODEC_STATUS& err_status);
bool BmpDetectImageTypeInBuffer(CFX_DIBAttribute* pAttribute);
FXCODEC_STATUS BmpStartDecode(const RetainPtr<CFX_DIBitmap>& pDIBitmap);
@@ -223,8 +224,8 @@
bool DetectImageType(FXCODEC_IMAGE_TYPE imageType,
CFX_DIBAttribute* pAttribute);
- bool ReadMoreData(CodecModuleIface* pModule,
- CodecModuleIface::Context* pContext,
+ bool ReadMoreData(ModuleIface* pModule,
+ ModuleIface::Context* pContext,
bool invalidate_buffer,
FXCODEC_STATUS& err_status);
@@ -250,22 +251,22 @@
FXCODEC_IMAGE_TYPE m_imageType = FXCODEC_IMAGE_UNKNOWN;
RetainPtr<IFX_SeekableReadStream> m_pFile;
RetainPtr<CFX_DIBitmap> m_pDeviceBitmap;
- UnownedPtr<CCodec_ModuleMgr> m_pCodecMgr;
+ UnownedPtr<ModuleMgr> m_pCodecMgr;
RetainPtr<CFX_CodecMemory> m_pCodecMemory;
std::unique_ptr<uint8_t, FxFreeDeleter> m_pDecodeBuf;
std::unique_ptr<FX_ARGB, FxFreeDeleter> m_pSrcPalette;
- std::unique_ptr<CodecModuleIface::Context> m_pJpegContext;
+ std::unique_ptr<ModuleIface::Context> m_pJpegContext;
#ifdef PDF_ENABLE_XFA_BMP
- std::unique_ptr<CodecModuleIface::Context> m_pBmpContext;
+ std::unique_ptr<ModuleIface::Context> m_pBmpContext;
#endif // PDF_ENABLE_XFA_BMP
#ifdef PDF_ENABLE_XFA_GIF
- std::unique_ptr<CodecModuleIface::Context> m_pGifContext;
+ std::unique_ptr<ModuleIface::Context> m_pGifContext;
#endif // PDF_ENABLE_XFA_GIF
#ifdef PDF_ENABLE_XFA_PNG
- std::unique_ptr<CodecModuleIface::Context> m_pPngContext;
+ std::unique_ptr<ModuleIface::Context> m_pPngContext;
#endif // PDF_ENABLE_XFA_PNG
#ifdef PDF_ENABLE_XFA_TIFF
- std::unique_ptr<CodecModuleIface::Context> m_pTiffContext;
+ std::unique_ptr<ModuleIface::Context> m_pTiffContext;
#endif // PDF_ENABLE_XFA_TIFF
uint32_t m_offSet = 0;
int m_ScanlineSize = 0;
diff --git a/core/fxcodec/codec/progressivedecoder_unittest.cpp b/core/fxcodec/codec/progressivedecoder_unittest.cpp
index 6489f3d..9a2a7e6 100644
--- a/core/fxcodec/codec/progressivedecoder_unittest.cpp
+++ b/core/fxcodec/codec/progressivedecoder_unittest.cpp
@@ -370,12 +370,11 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- CCodec_ModuleMgr::Create();
- CCodec_ModuleMgr::GetInstance()->SetGifModule(
- pdfium::MakeUnique<GifModule>());
+ ModuleMgr::Create();
+ ModuleMgr::GetInstance()->SetGifModule(pdfium::MakeUnique<GifModule>());
{
std::unique_ptr<ProgressiveDecoder> decoder =
- CCodec_ModuleMgr::GetInstance()->CreateProgressiveDecoder();
+ ModuleMgr::GetInstance()->CreateProgressiveDecoder();
auto source = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(kInput);
CFX_DIBAttribute attr;
@@ -400,7 +399,7 @@
status = decoder->ContinueDecode();
EXPECT_EQ(FXCODEC_STATUS_DECODE_FINISH, status);
}
- CCodec_ModuleMgr::Destroy();
+ ModuleMgr::Destroy();
}
#endif // PDF_ENABLE_XFA_GIF
diff --git a/core/fxcodec/codec/tiffmodule.cpp b/core/fxcodec/codec/tiffmodule.cpp
index d23ef7d..08567f6 100644
--- a/core/fxcodec/codec/tiffmodule.cpp
+++ b/core/fxcodec/codec/tiffmodule.cpp
@@ -33,7 +33,7 @@
} // namespace
-class CTiffContext final : public CodecModuleIface::Context {
+class CTiffContext final : public ModuleIface::Context {
public:
CTiffContext() = default;
~CTiffContext() override = default;
@@ -488,7 +488,7 @@
namespace fxcodec {
-std::unique_ptr<CodecModuleIface::Context> TiffModule::CreateDecoder(
+std::unique_ptr<ModuleIface::Context> TiffModule::CreateDecoder(
const RetainPtr<IFX_SeekableReadStream>& file_ptr) {
auto pDecoder = pdfium::MakeUnique<CTiffContext>();
if (!pDecoder->InitDecoder(file_ptr))
diff --git a/core/fxcodec/codec/tiffmodule.h b/core/fxcodec/codec/tiffmodule.h
index 71d69c5..cc957f2 100644
--- a/core/fxcodec/codec/tiffmodule.h
+++ b/core/fxcodec/codec/tiffmodule.h
@@ -11,18 +11,19 @@
#include "core/fxcodec/codec/codec_module_iface.h"
-class CFX_DIBAttribute;
class CFX_DIBitmap;
class IFX_SeekableReadStream;
namespace fxcodec {
-class TiffModule final : public CodecModuleIface {
+class CFX_DIBAttribute;
+
+class TiffModule final : public ModuleIface {
public:
std::unique_ptr<Context> CreateDecoder(
const RetainPtr<IFX_SeekableReadStream>& file_ptr);
- // CodecModuleIface:
+ // ModuleIface:
FX_FILESIZE GetAvailInput(Context* pContext) const override;
bool Input(Context* pContext,
RetainPtr<CFX_CodecMemory> codec_memory,
diff --git a/core/fxcodec/fx_codec.cpp b/core/fxcodec/fx_codec.cpp
index 567f8c3..5ed6f01 100644
--- a/core/fxcodec/fx_codec.cpp
+++ b/core/fxcodec/fx_codec.cpp
@@ -19,32 +19,34 @@
#include "third_party/base/logging.h"
#include "third_party/base/ptr_util.h"
+namespace fxcodec {
+
namespace {
-CCodec_ModuleMgr* g_CCodecModuleMgr = nullptr;
+ModuleMgr* g_ModuleMgr = nullptr;
} // namespace
// static
-void CCodec_ModuleMgr::Create() {
- ASSERT(!g_CCodecModuleMgr);
- g_CCodecModuleMgr = new CCodec_ModuleMgr();
+void ModuleMgr::Create() {
+ ASSERT(!g_ModuleMgr);
+ g_ModuleMgr = new ModuleMgr();
}
// static
-void CCodec_ModuleMgr::Destroy() {
- ASSERT(g_CCodecModuleMgr);
- delete g_CCodecModuleMgr;
- g_CCodecModuleMgr = nullptr;
+void ModuleMgr::Destroy() {
+ ASSERT(g_ModuleMgr);
+ delete g_ModuleMgr;
+ g_ModuleMgr = nullptr;
}
// static
-CCodec_ModuleMgr* CCodec_ModuleMgr::GetInstance() {
- ASSERT(g_CCodecModuleMgr);
- return g_CCodecModuleMgr;
+ModuleMgr* ModuleMgr::GetInstance() {
+ ASSERT(g_ModuleMgr);
+ return g_ModuleMgr;
}
-CCodec_ModuleMgr::CCodec_ModuleMgr()
+ModuleMgr::ModuleMgr()
: m_pJpegModule(pdfium::MakeUnique<JpegModule>()),
m_pJbig2Module(pdfium::MakeUnique<Jbig2Module>()) {
#ifdef PDF_ENABLE_XFA_BMP
@@ -64,7 +66,7 @@
#endif
}
-CCodec_ModuleMgr::~CCodec_ModuleMgr() = default;
+ModuleMgr::~ModuleMgr() = default;
#ifdef PDF_ENABLE_XFA
CFX_DIBAttribute::CFX_DIBAttribute() = default;
@@ -75,8 +77,6 @@
}
#endif // PDF_ENABLE_XFA
-namespace fxcodec {
-
void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) {
if (pDestBuf == pSrcBuf) {
for (int i = 0; i < pixels; i++) {
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index 7b26a8e..4c6b94d 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -34,6 +34,8 @@
#endif // PDF_ENABLE_XFA_TIFF
#endif // PDF_ENABLE_XFA
+namespace fxcodec {
+
#ifdef PDF_ENABLE_XFA
class CFX_DIBAttribute {
public:
@@ -47,24 +49,22 @@
};
#endif // PDF_ENABLE_XFA
-namespace fxcodec {
class Jbig2Module;
class JpegModule;
class ProgressiveDecoder;
-}
-class CCodec_ModuleMgr {
+class ModuleMgr {
public:
// Per-process singleton managed by callers.
static void Create();
static void Destroy();
- static CCodec_ModuleMgr* GetInstance();
+ static ModuleMgr* GetInstance();
- fxcodec::JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
- fxcodec::Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
+ JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
+ Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
#ifdef PDF_ENABLE_XFA
- std::unique_ptr<fxcodec::ProgressiveDecoder> CreateProgressiveDecoder();
+ std::unique_ptr<ProgressiveDecoder> CreateProgressiveDecoder();
#ifdef PDF_ENABLE_XFA_BMP
BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
@@ -96,11 +96,11 @@
#endif // PDF_ENABLE_XFA
private:
- CCodec_ModuleMgr();
- ~CCodec_ModuleMgr();
+ ModuleMgr();
+ ~ModuleMgr();
- std::unique_ptr<fxcodec::JpegModule> m_pJpegModule;
- std::unique_ptr<fxcodec::Jbig2Module> m_pJbig2Module;
+ std::unique_ptr<JpegModule> m_pJpegModule;
+ std::unique_ptr<Jbig2Module> m_pJbig2Module;
#ifdef PDF_ENABLE_XFA
#ifdef PDF_ENABLE_XFA_BMP
@@ -121,8 +121,6 @@
#endif // PDF_ENABLE_XFA
};
-namespace fxcodec {
-
void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels);
FX_SAFE_UINT32 CalculatePitch8(uint32_t bpc, uint32_t components, int width);
@@ -130,4 +128,8 @@
} // namespace fxcodec
+#ifdef PDF_ENABLE_XFA
+using CFX_DIBAttribute = fxcodec::CFX_DIBAttribute;
+#endif
+
#endif // CORE_FXCODEC_FX_CODEC_H_
diff --git a/core/fxcodec/gif/cfx_gifcontext.cpp b/core/fxcodec/gif/cfx_gifcontext.cpp
index 3b212a5..9f7bf67 100644
--- a/core/fxcodec/gif/cfx_gifcontext.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext.cpp
@@ -15,6 +15,8 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
+namespace fxcodec {
+
namespace {
constexpr int32_t kGifInterlaceStep[4] = {8, 8, 4, 2};
@@ -547,3 +549,5 @@
return true;
}
+
+} // namespace fxcodec
diff --git a/core/fxcodec/gif/cfx_gifcontext.h b/core/fxcodec/gif/cfx_gifcontext.h
index ce5e9d4..7e813a6 100644
--- a/core/fxcodec/gif/cfx_gifcontext.h
+++ b/core/fxcodec/gif/cfx_gifcontext.h
@@ -18,7 +18,9 @@
class CFX_CodecMemory;
-class CFX_GifContext : public CodecModuleIface::Context {
+namespace fxcodec {
+
+class CFX_GifContext : public ModuleIface::Context {
public:
CFX_GifContext(GifModule* gif_module, GifModule::Delegate* delegate);
~CFX_GifContext() override;
@@ -76,4 +78,6 @@
bool ScanForTerminalMarker();
};
+} // namespace fxcodec
+
#endif // CORE_FXCODEC_GIF_CFX_GIFCONTEXT_H_
diff --git a/core/fxcodec/gif/cfx_gifcontext_unittest.cpp b/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
index eaa8c09..925beed 100644
--- a/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
@@ -9,6 +9,8 @@
#include "core/fxcodec/codec/cfx_codec_memory.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace fxcodec {
+
class CFX_GifContextForTest final : public CFX_GifContext {
public:
CFX_GifContextForTest(GifModule* gif_module, GifModule::Delegate* delegate)
@@ -301,3 +303,5 @@
context.SetTestInputBuffer({});
}
}
+
+} // namespace fxcodec
diff --git a/testing/fuzzers/xfa_codec_fuzzer.h b/testing/fuzzers/xfa_codec_fuzzer.h
index d237ecd..c1cae50 100644
--- a/testing/fuzzers/xfa_codec_fuzzer.h
+++ b/testing/fuzzers/xfa_codec_fuzzer.h
@@ -21,7 +21,7 @@
class XFACodecFuzzer {
public:
static int Fuzz(const uint8_t* data, size_t size, FXCODEC_IMAGE_TYPE type) {
- auto* mgr = CCodec_ModuleMgr::GetInstance();
+ auto* mgr = fxcodec::ModuleMgr::GetInstance();
std::unique_ptr<ProgressiveDecoder> decoder =
mgr->CreateProgressiveDecoder();
auto source = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 427dd2c..91f0690 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -154,7 +154,7 @@
FXCODEC_IMAGE_TYPE type,
int32_t& iImageXDpi,
int32_t& iImageYDpi) {
- auto* pCodecMgr = CCodec_ModuleMgr::GetInstance();
+ auto* pCodecMgr = fxcodec::ModuleMgr::GetInstance();
std::unique_ptr<ProgressiveDecoder> pProgressiveDecoder =
pCodecMgr->CreateProgressiveDecoder();