Separate BmpModule from ModuleMgr and remove ModuleMgr.
ModuleMgr is no longer useful, so delete it. Then make BmpModule methods
static, and separate out the non-static part into BmpProgressiveDecoder.
Change-Id: Ib13518c62a8d22118d52a1bad236eb1463cc3678
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69951
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_pagemodule.cpp b/core/fpdfapi/page/cpdf_pagemodule.cpp
index 705d313..3c6c751 100644
--- a/core/fpdfapi/page/cpdf_pagemodule.cpp
+++ b/core/fpdfapi/page/cpdf_pagemodule.cpp
@@ -10,7 +10,6 @@
#include "core/fpdfapi/page/cpdf_colorspace.h"
#include "core/fpdfapi/page/cpdf_devicecs.h"
#include "core/fpdfapi/page/cpdf_patterncs.h"
-#include "core/fxcodec/fx_codec.h"
namespace {
@@ -21,7 +20,6 @@
// static
void CPDF_PageModule::Create() {
ASSERT(!g_PageModule);
- fxcodec::ModuleMgr::Create();
g_PageModule = new CPDF_PageModule();
}
@@ -30,7 +28,6 @@
ASSERT(g_PageModule);
delete g_PageModule;
g_PageModule = nullptr;
- fxcodec::ModuleMgr::Destroy();
}
// static
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index 136d77c..d380db8 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -90,6 +90,8 @@
]
if (pdf_enable_xfa_bmp) {
sources += [
+ "bmp/bmp_progressive_decoder.cpp",
+ "bmp/bmp_progressive_decoder.h",
"bmp/bmpmodule.cpp",
"bmp/bmpmodule.h",
"bmp/cfx_bmpcontext.cpp",
diff --git a/core/fxcodec/bmp/bmp_progressive_decoder.cpp b/core/fxcodec/bmp/bmp_progressive_decoder.cpp
new file mode 100644
index 0000000..6af9d64
--- /dev/null
+++ b/core/fxcodec/bmp/bmp_progressive_decoder.cpp
@@ -0,0 +1,34 @@
+// Copyright 2020 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxcodec/bmp/bmp_progressive_decoder.h"
+
+#include "core/fxcodec/bmp/bmpmodule.h"
+#include "core/fxcodec/cfx_codec_memory.h"
+
+namespace fxcodec {
+
+// static
+BmpProgressiveDecoder* BmpProgressiveDecoder::GetInstance() {
+ static pdfium::base::NoDestructor<BmpProgressiveDecoder> s;
+ return s.get();
+}
+
+BmpProgressiveDecoder::BmpProgressiveDecoder() = default;
+
+BmpProgressiveDecoder::~BmpProgressiveDecoder() = default;
+
+FX_FILESIZE BmpProgressiveDecoder::GetAvailInput(Context* context) const {
+ return BmpModule::GetAvailInput(context);
+}
+
+bool BmpProgressiveDecoder::Input(Context* context,
+ RetainPtr<CFX_CodecMemory> codec_memory,
+ CFX_DIBAttribute* pAttribute) {
+ return BmpModule::Input(context, codec_memory, pAttribute);
+}
+
+} // namespace fxcodec
diff --git a/core/fxcodec/bmp/bmp_progressive_decoder.h b/core/fxcodec/bmp/bmp_progressive_decoder.h
new file mode 100644
index 0000000..26a354c
--- /dev/null
+++ b/core/fxcodec/bmp/bmp_progressive_decoder.h
@@ -0,0 +1,40 @@
+// Copyright 2020 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_BMP_BMP_PROGRESSIVE_DECODER_H_
+#define CORE_FXCODEC_BMP_BMP_PROGRESSIVE_DECODER_H_
+
+#include "core/fxcodec/progressive_decoder_iface.h"
+#include "third_party/base/no_destructor.h"
+
+#ifndef PDF_ENABLE_XFA_BMP
+#error "BMP must be enabled"
+#endif
+
+namespace fxcodec {
+
+class BmpProgressiveDecoder final : public ProgressiveDecoderIface {
+ public:
+ static BmpProgressiveDecoder* GetInstance();
+
+ // ProgressiveDecoderIface:
+ FX_FILESIZE GetAvailInput(Context* context) const override;
+ bool Input(Context* context,
+ RetainPtr<CFX_CodecMemory> codec_memory,
+ CFX_DIBAttribute* pAttribute) override;
+
+ private:
+ friend pdfium::base::NoDestructor<BmpProgressiveDecoder>;
+
+ BmpProgressiveDecoder();
+ ~BmpProgressiveDecoder() override;
+};
+
+} // namespace fxcodec
+
+using BmpProgressiveDecoder = fxcodec::BmpProgressiveDecoder;
+
+#endif // CORE_FXCODEC_BMP_BMP_PROGRESSIVE_DECODER_H_
diff --git a/core/fxcodec/bmp/bmpmodule.cpp b/core/fxcodec/bmp/bmpmodule.cpp
index 56ffad1..68275ac 100644
--- a/core/fxcodec/bmp/bmpmodule.cpp
+++ b/core/fxcodec/bmp/bmpmodule.cpp
@@ -11,28 +11,28 @@
#include "core/fxcodec/bmp/cfx_bmpcontext.h"
#include "core/fxcodec/cfx_codec_memory.h"
#include "core/fxcodec/fx_codec.h"
+#include "core/fxcodec/fx_codec_def.h"
#include "core/fxge/fx_dib.h"
#include "third_party/base/ptr_util.h"
namespace fxcodec {
-BmpModule::BmpModule() = default;
-
-BmpModule::~BmpModule() = default;
-
-std::unique_ptr<ProgressiveDecoderIface::Context> BmpModule::Start(
+// static
+std::unique_ptr<ProgressiveDecoderIface::Context> BmpModule::StartDecode(
Delegate* pDelegate) {
- return pdfium::MakeUnique<CFX_BmpContext>(this, pDelegate);
+ return pdfium::MakeUnique<CFX_BmpContext>(pDelegate);
}
-BmpModule::Status BmpModule::ReadHeader(Context* pContext,
- int32_t* width,
- int32_t* height,
- bool* tb_flag,
- int32_t* components,
- int32_t* pal_num,
- const std::vector<uint32_t>** palette,
- CFX_DIBAttribute* pAttribute) {
+// static
+BmpModule::Status BmpModule::ReadHeader(
+ ProgressiveDecoderIface::Context* pContext,
+ int32_t* width,
+ int32_t* height,
+ bool* tb_flag,
+ int32_t* components,
+ int32_t* pal_num,
+ const std::vector<uint32_t>** palette,
+ CFX_DIBAttribute* pAttribute) {
ASSERT(pAttribute);
auto* ctx = static_cast<CFX_BmpContext*>(pContext);
@@ -52,15 +52,20 @@
return Status::kSuccess;
}
-BmpModule::Status BmpModule::LoadImage(Context* pContext) {
+// static
+BmpModule::Status BmpModule::LoadImage(
+ ProgressiveDecoderIface::Context* pContext) {
return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.DecodeImage();
}
-FX_FILESIZE BmpModule::GetAvailInput(Context* pContext) const {
+// static
+FX_FILESIZE BmpModule::GetAvailInput(
+ ProgressiveDecoderIface::Context* pContext) {
return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.GetAvailInput();
}
-bool BmpModule::Input(Context* pContext,
+// static
+bool BmpModule::Input(ProgressiveDecoderIface::Context* pContext,
RetainPtr<CFX_CodecMemory> codec_memory,
CFX_DIBAttribute*) {
auto* ctx = static_cast<CFX_BmpContext*>(pContext);
diff --git a/core/fxcodec/bmp/bmpmodule.h b/core/fxcodec/bmp/bmpmodule.h
index a180ceb..08d2c7a 100644
--- a/core/fxcodec/bmp/bmpmodule.h
+++ b/core/fxcodec/bmp/bmpmodule.h
@@ -13,11 +13,15 @@
#include "core/fxcodec/progressive_decoder_iface.h"
#include "third_party/base/span.h"
+#ifndef PDF_ENABLE_XFA_BMP
+#error "BMP must be enabled"
+#endif
+
namespace fxcodec {
class CFX_DIBAttribute;
-class BmpModule final : public ProgressiveDecoderIface {
+class BmpModule {
public:
class Delegate {
public:
@@ -28,25 +32,25 @@
enum class Status : uint8_t { kFail, kSuccess, kContinue };
- BmpModule();
- ~BmpModule() override;
-
- // ProgressiveDecoderIface:
- FX_FILESIZE GetAvailInput(Context* pContext) const override;
- bool Input(Context* pContext,
- RetainPtr<CFX_CodecMemory> codec_memory,
- CFX_DIBAttribute* pAttribute) override;
-
- std::unique_ptr<Context> Start(Delegate* pDelegate);
- Status ReadHeader(Context* pContext,
- int32_t* width,
- int32_t* height,
- bool* tb_flag,
- int32_t* components,
- int32_t* pal_num,
- const std::vector<uint32_t>** palette,
+ static std::unique_ptr<ProgressiveDecoderIface::Context> StartDecode(
+ Delegate* pDelegate);
+ static Status ReadHeader(ProgressiveDecoderIface::Context* pContext,
+ int32_t* width,
+ int32_t* height,
+ bool* tb_flag,
+ int32_t* components,
+ int32_t* pal_num,
+ const std::vector<uint32_t>** palette,
+ CFX_DIBAttribute* pAttribute);
+ static Status LoadImage(ProgressiveDecoderIface::Context* pContext);
+ static FX_FILESIZE GetAvailInput(ProgressiveDecoderIface::Context* pContext);
+ static bool Input(ProgressiveDecoderIface::Context* pContext,
+ RetainPtr<CFX_CodecMemory> codec_memory,
CFX_DIBAttribute* pAttribute);
- Status LoadImage(Context* pContext);
+
+ BmpModule() = delete;
+ BmpModule(const BmpModule&) = delete;
+ BmpModule& operator=(const BmpModule&) = delete;
};
} // namespace fxcodec
diff --git a/core/fxcodec/bmp/cfx_bmpcontext.cpp b/core/fxcodec/bmp/cfx_bmpcontext.cpp
index a35a585..494dfac 100644
--- a/core/fxcodec/bmp/cfx_bmpcontext.cpp
+++ b/core/fxcodec/bmp/cfx_bmpcontext.cpp
@@ -8,9 +8,8 @@
namespace fxcodec {
-CFX_BmpContext::CFX_BmpContext(BmpModule* pModule,
- BmpModule::Delegate* pDelegate)
- : m_Bmp(this), m_pModule(pModule), m_pDelegate(pDelegate) {}
+CFX_BmpContext::CFX_BmpContext(BmpModule::Delegate* pDelegate)
+ : m_Bmp(this), m_pDelegate(pDelegate) {}
CFX_BmpContext::~CFX_BmpContext() = default;
diff --git a/core/fxcodec/bmp/cfx_bmpcontext.h b/core/fxcodec/bmp/cfx_bmpcontext.h
index aea65df..0e21d31 100644
--- a/core/fxcodec/bmp/cfx_bmpcontext.h
+++ b/core/fxcodec/bmp/cfx_bmpcontext.h
@@ -16,11 +16,10 @@
class CFX_BmpContext final : public ProgressiveDecoderIface::Context {
public:
- CFX_BmpContext(BmpModule* pModule, BmpModule::Delegate* pDelegate);
+ explicit CFX_BmpContext(BmpModule::Delegate* pDelegate);
~CFX_BmpContext() override;
CFX_BmpDecompressor m_Bmp;
- UnownedPtr<BmpModule> const m_pModule;
UnownedPtr<BmpModule::Delegate> const m_pDelegate;
};
diff --git a/core/fxcodec/fx_codec.cpp b/core/fxcodec/fx_codec.cpp
index b3cd13d..300a0a5 100644
--- a/core/fxcodec/fx_codec.cpp
+++ b/core/fxcodec/fx_codec.cpp
@@ -6,52 +6,10 @@
#include "core/fxcodec/fx_codec.h"
-#include <algorithm>
-#include <cmath>
-#include <memory>
-#include <utility>
-
-#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_memory.h"
-#include "core/fxcrt/fx_safe_types.h"
-#include "third_party/base/logging.h"
-#include "third_party/base/ptr_util.h"
namespace fxcodec {
-namespace {
-
-ModuleMgr* g_ModuleMgr = nullptr;
-
-} // namespace
-
-// static
-void ModuleMgr::Create() {
- ASSERT(!g_ModuleMgr);
- g_ModuleMgr = new ModuleMgr();
-}
-
-// static
-void ModuleMgr::Destroy() {
- ASSERT(g_ModuleMgr);
- delete g_ModuleMgr;
- g_ModuleMgr = nullptr;
-}
-
-// static
-ModuleMgr* ModuleMgr::GetInstance() {
- ASSERT(g_ModuleMgr);
- return g_ModuleMgr;
-}
-
-ModuleMgr::ModuleMgr() {
-#ifdef PDF_ENABLE_XFA_BMP
- SetBmpModule(pdfium::MakeUnique<BmpModule>());
-#endif
-}
-
-ModuleMgr::~ModuleMgr() = default;
-
#ifdef PDF_ENABLE_XFA
CFX_DIBAttribute::CFX_DIBAttribute() = default;
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index f730def..f84e752 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -8,19 +8,9 @@
#define CORE_FXCODEC_FX_CODEC_H_
#include <map>
-#include <memory>
-#include <utility>
-#include "core/fxcodec/fx_codec_def.h"
-#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_safe_types.h"
-#ifdef PDF_ENABLE_XFA
-#ifdef PDF_ENABLE_XFA_BMP
-#include "core/fxcodec/bmp/bmpmodule.h"
-#endif // PDF_ENABLE_XFA_BMP
-#endif
-
namespace fxcodec {
#ifdef PDF_ENABLE_XFA
@@ -36,37 +26,6 @@
};
#endif // PDF_ENABLE_XFA
-class ProgressiveDecoder;
-
-class ModuleMgr {
- public:
- // Per-process singleton managed by callers.
- static void Create();
- static void Destroy();
- static ModuleMgr* GetInstance();
-
-#ifdef PDF_ENABLE_XFA
- std::unique_ptr<ProgressiveDecoder> CreateProgressiveDecoder();
-
-#ifdef PDF_ENABLE_XFA_BMP
- BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
- void SetBmpModule(std::unique_ptr<BmpModule> module) {
- m_pBmpModule = std::move(module);
- }
-#endif // PDF_ENABLE_XFA_BMP
-#endif // PDF_ENABLE_XFA
-
- private:
- ModuleMgr();
- ~ModuleMgr();
-
-#ifdef PDF_ENABLE_XFA
-#ifdef PDF_ENABLE_XFA_BMP
- std::unique_ptr<BmpModule> m_pBmpModule;
-#endif // PDF_ENABLE_XFA_BMP
-#endif // PDF_ENABLE_XFA
-};
-
void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels);
FX_SAFE_UINT32 CalculatePitch8(uint32_t bpc, uint32_t components, int width);
diff --git a/core/fxcodec/progressivedecoder.cpp b/core/fxcodec/progressivedecoder.cpp
index 96e1466..bbc5c35 100644
--- a/core/fxcodec/progressivedecoder.cpp
+++ b/core/fxcodec/progressivedecoder.cpp
@@ -13,7 +13,6 @@
#include "build/build_config.h"
#include "core/fxcodec/cfx_codec_memory.h"
-#include "core/fxcodec/fx_codec.h"
#include "core/fxcodec/jpeg/jpeg_progressive_decoder.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_stream.h"
@@ -23,6 +22,10 @@
#include "third_party/base/logging.h"
#include "third_party/base/ptr_util.h"
+#ifdef PDF_ENABLE_XFA_BMP
+#include "core/fxcodec/bmp/bmp_progressive_decoder.h"
+#endif // PDF_ENABLE_XFA_BMP
+
#ifdef PDF_ENABLE_XFA_GIF
#include "core/fxcodec/gif/gif_progressive_decoder.h"
#endif // PDF_ENABLE_XFA_GIF
@@ -243,8 +246,7 @@
}
}
-ProgressiveDecoder::ProgressiveDecoder(ModuleMgr* pCodecMgr)
- : m_pCodecMgr(pCodecMgr) {}
+ProgressiveDecoder::ProgressiveDecoder() = default;
ProgressiveDecoder::~ProgressiveDecoder() = default;
@@ -568,8 +570,7 @@
bool ProgressiveDecoder::BmpInputImagePositionBuf(uint32_t rcd_pos) {
m_offSet = rcd_pos;
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
- return BmpReadMoreData(m_pCodecMgr->GetBmpModule(), m_pBmpContext.get(),
- &error_status);
+ return BmpReadMoreData(m_pBmpContext.get(), &error_status);
}
void ProgressiveDecoder::BmpReadScanline(uint32_t row_num,
@@ -700,22 +701,21 @@
bool ProgressiveDecoder::BmpDetectImageTypeInBuffer(
CFX_DIBAttribute* pAttribute) {
- BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
std::unique_ptr<ProgressiveDecoderIface::Context> pBmpContext =
- pBmpModule->Start(this);
- pBmpModule->Input(pBmpContext.get(), m_pCodecMemory, nullptr);
+ BmpModule::StartDecode(this);
+ BmpModule::Input(pBmpContext.get(), m_pCodecMemory, nullptr);
const std::vector<uint32_t>* palette;
- BmpModule::Status read_result = pBmpModule->ReadHeader(
+ BmpModule::Status read_result = BmpModule::ReadHeader(
pBmpContext.get(), &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
&m_SrcComponents, &m_SrcPaletteNumber, &palette, pAttribute);
while (read_result == BmpModule::Status::kContinue) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
- if (!BmpReadMoreData(pBmpModule, pBmpContext.get(), &error_status)) {
+ if (!BmpReadMoreData(pBmpContext.get(), &error_status)) {
m_status = error_status;
return false;
}
- read_result = pBmpModule->ReadHeader(
+ read_result = BmpModule::ReadHeader(
pBmpContext.get(), &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
&m_SrcComponents, &m_SrcPaletteNumber, &palette, pAttribute);
}
@@ -753,7 +753,7 @@
}
uint32_t availableData = m_pFile->GetSize() - m_offSet +
- pBmpModule->GetAvailInput(pBmpContext.get());
+ BmpModule::GetAvailInput(pBmpContext.get());
if (neededData > availableData) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -773,10 +773,10 @@
}
bool ProgressiveDecoder::BmpReadMoreData(
- BmpModule* pBmpModule,
ProgressiveDecoderIface::Context* pContext,
FXCODEC_STATUS* err_status) {
- return ReadMoreData(pBmpModule, pContext, false, err_status);
+ return ReadMoreData(BmpProgressiveDecoder::GetInstance(), pContext, false,
+ err_status);
}
FXCODEC_STATUS ProgressiveDecoder::BmpStartDecode(
@@ -791,17 +791,16 @@
}
FXCODEC_STATUS ProgressiveDecoder::BmpContinueDecode() {
- BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
- BmpModule::Status read_res = pBmpModule->LoadImage(m_pBmpContext.get());
+ BmpModule::Status read_res = BmpModule::LoadImage(m_pBmpContext.get());
while (read_res == BmpModule::Status::kContinue) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
- if (!BmpReadMoreData(pBmpModule, m_pBmpContext.get(), &error_status)) {
+ if (!BmpReadMoreData(m_pBmpContext.get(), &error_status)) {
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
m_status = error_status;
return m_status;
}
- read_res = pBmpModule->LoadImage(m_pBmpContext.get());
+ read_res = BmpModule::LoadImage(m_pBmpContext.get());
}
m_pDeviceBitmap = nullptr;
@@ -2246,8 +2245,4 @@
}
}
-std::unique_ptr<ProgressiveDecoder> ModuleMgr::CreateProgressiveDecoder() {
- return pdfium::MakeUnique<ProgressiveDecoder>(this);
-}
-
} // namespace fxcodec
diff --git a/core/fxcodec/progressivedecoder.h b/core/fxcodec/progressivedecoder.h
index 6c76754..87e3d1c 100644
--- a/core/fxcodec/progressivedecoder.h
+++ b/core/fxcodec/progressivedecoder.h
@@ -37,7 +37,6 @@
namespace fxcodec {
class CFX_DIBAttribute;
-class ModuleMgr;
class Dummy {}; // Placeholder to work around C++ syntax issues
@@ -65,7 +64,7 @@
FXCodec_Cmyk = 0x120
};
- explicit ProgressiveDecoder(ModuleMgr* pCodecMgr);
+ ProgressiveDecoder();
virtual ~ProgressiveDecoder();
FXCODEC_STATUS LoadImageInfo(const RetainPtr<IFX_SeekableReadStream>& pFile,
@@ -176,8 +175,7 @@
private:
#ifdef PDF_ENABLE_XFA_BMP
- bool BmpReadMoreData(BmpModule* pBmpModule,
- ProgressiveDecoderIface::Context* pBmpContext,
+ bool BmpReadMoreData(ProgressiveDecoderIface::Context* pBmpContext,
FXCODEC_STATUS* err_status);
bool BmpDetectImageTypeInBuffer(CFX_DIBAttribute* pAttribute);
FXCODEC_STATUS BmpStartDecode(const RetainPtr<CFX_DIBitmap>& pDIBitmap);
@@ -243,7 +241,6 @@
FXCODEC_IMAGE_TYPE m_imageType = FXCODEC_IMAGE_UNKNOWN;
RetainPtr<IFX_SeekableReadStream> m_pFile;
RetainPtr<CFX_DIBitmap> m_pDeviceBitmap;
- 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;
diff --git a/core/fxcodec/progressivedecoder_unittest.cpp b/core/fxcodec/progressivedecoder_unittest.cpp
index 0c4b30a..f756f5e 100644
--- a/core/fxcodec/progressivedecoder_unittest.cpp
+++ b/core/fxcodec/progressivedecoder_unittest.cpp
@@ -370,10 +370,8 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- ModuleMgr::Create();
{
- std::unique_ptr<ProgressiveDecoder> decoder =
- ModuleMgr::GetInstance()->CreateProgressiveDecoder();
+ auto decoder = pdfium::MakeUnique<ProgressiveDecoder>();
auto source = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(kInput);
CFX_DIBAttribute attr;
@@ -398,7 +396,6 @@
status = decoder->ContinueDecode();
EXPECT_EQ(FXCODEC_STATUS_DECODE_FINISH, status);
}
- ModuleMgr::Destroy();
}
#endif // PDF_ENABLE_XFA_GIF
diff --git a/core/fxcodec/tiff/tiff_decoder.cpp b/core/fxcodec/tiff/tiff_decoder.cpp
index f2b86fa..1776c26 100644
--- a/core/fxcodec/tiff/tiff_decoder.cpp
+++ b/core/fxcodec/tiff/tiff_decoder.cpp
@@ -11,6 +11,7 @@
#include "core/fxcodec/cfx_codec_memory.h"
#include "core/fxcodec/fx_codec.h"
+#include "core/fxcodec/fx_codec_def.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/retain_ptr.h"
diff --git a/testing/fuzzers/xfa_codec_fuzzer.h b/testing/fuzzers/xfa_codec_fuzzer.h
index 427a0c1..ef9ce69 100644
--- a/testing/fuzzers/xfa_codec_fuzzer.h
+++ b/testing/fuzzers/xfa_codec_fuzzer.h
@@ -12,6 +12,7 @@
#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/cfx_dibitmap.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/span.h"
// Support up to 64 MB. This prevents trivial OOM when MSAN is on and
@@ -21,9 +22,7 @@
class XFACodecFuzzer {
public:
static int Fuzz(const uint8_t* data, size_t size, FXCODEC_IMAGE_TYPE type) {
- auto* mgr = fxcodec::ModuleMgr::GetInstance();
- std::unique_ptr<ProgressiveDecoder> decoder =
- mgr->CreateProgressiveDecoder();
+ auto decoder = pdfium::MakeUnique<ProgressiveDecoder>();
auto source = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, size));
CFX_DIBAttribute attr;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 13e7aa6..2515454 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -18,6 +18,7 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/cfx_dibitmap.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fwl/fwl_widgethit.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffapp.h"
@@ -155,9 +156,7 @@
FXCODEC_IMAGE_TYPE type,
int32_t& iImageXDpi,
int32_t& iImageYDpi) {
- auto* pCodecMgr = fxcodec::ModuleMgr::GetInstance();
- std::unique_ptr<ProgressiveDecoder> pProgressiveDecoder =
- pCodecMgr->CreateProgressiveDecoder();
+ auto pProgressiveDecoder = pdfium::MakeUnique<ProgressiveDecoder>();
CFX_DIBAttribute dibAttr;
pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false);