summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfview.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-05-11 14:36:10 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-11 19:10:43 +0000
commit830897a1774fb50d04b656d7bf70be321e133cf9 (patch)
treebd5473e87f1246c8bdc9c224342637160d70da55 /fpdfsdk/fpdfview.cpp
parentdbc3d3e1e0b28692c31f08f6b4c606577255078d (diff)
downloadpdfium-830897a1774fb50d04b656d7bf70be321e133cf9.tar.xz
Move map and codec loading into manager
This Cl consolidates the code to load maps and codecs into the CPDF_ModuleMgr class instead of putting it directly into fpdfview. Change-Id: Ia08f212f43a33e51ab1c7832051ee4f28eecb50d Reviewed-on: https://pdfium-review.googlesource.com/5335 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfview.cpp')
-rw-r--r--fpdfsdk/fpdfview.cpp61
1 files changed, 11 insertions, 50 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 616402e564..fea1aba8de 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -49,30 +49,13 @@
#include "public/fpdf_formfill.h"
#endif // PDF_ENABLE_XFA
-#ifdef PDF_ENABLE_XFA_BMP
-#include "core/fxcodec/codec/ccodec_bmpmodule.h"
-#endif
-
-#ifdef PDF_ENABLE_XFA_GIF
-#include "core/fxcodec/codec/ccodec_gifmodule.h"
-#endif
-
-#ifdef PDF_ENABLE_XFA_PNG
-#include "core/fxcodec/codec/ccodec_pngmodule.h"
-#endif
-
-#ifdef PDF_ENABLE_XFA_TIFF
-#include "core/fxcodec/codec/ccodec_tiffmodule.h"
-#endif
-
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#include "core/fxge/cfx_windowsdevice.h"
#endif
namespace {
-// Also indicates whether library is currently initialized.
-CCodec_ModuleMgr* g_pCodecModule = nullptr;
+bool g_bLibraryInitialized = false;
void RenderPageImpl(CPDF_PageRenderContext* pContext,
CPDF_Page* pPage,
@@ -368,42 +351,19 @@ DLLEXPORT void STDCALL FPDF_InitLibrary() {
DLLEXPORT void STDCALL
FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* cfg) {
- if (g_pCodecModule)
+ if (g_bLibraryInitialized)
return;
FXMEM_InitializePartitionAlloc();
- g_pCodecModule = new CCodec_ModuleMgr();
CFX_GEModule* pModule = CFX_GEModule::Get();
- pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule);
+ pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr);
CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get();
- pModuleMgr->SetCodecModule(g_pCodecModule);
+ pModuleMgr->SetCodecModule(pModule->GetCodecModule());
pModuleMgr->InitPageModule();
- pModuleMgr->LoadEmbeddedGB1CMaps();
- pModuleMgr->LoadEmbeddedJapan1CMaps();
- pModuleMgr->LoadEmbeddedCNS1CMaps();
- pModuleMgr->LoadEmbeddedKorea1CMaps();
-
-#ifdef PDF_ENABLE_XFA_BMP
- pModuleMgr->GetCodecModule()->SetBmpModule(
- pdfium::MakeUnique<CCodec_BmpModule>());
-#endif
-
-#ifdef PDF_ENABLE_XFA_GIF
- pModuleMgr->GetCodecModule()->SetGifModule(
- pdfium::MakeUnique<CCodec_GifModule>());
-#endif
-
-#ifdef PDF_ENABLE_XFA_PNG
- pModuleMgr->GetCodecModule()->SetPngModule(
- pdfium::MakeUnique<CCodec_PngModule>());
-#endif
-
-#ifdef PDF_ENABLE_XFA_TIFF
- pModuleMgr->GetCodecModule()->SetTiffModule(
- pdfium::MakeUnique<CCodec_TiffModule>());
-#endif
+ pModuleMgr->LoadEmbeddedMaps();
+ pModuleMgr->LoadCodecModules();
#ifdef PDF_ENABLE_XFA
FXJSE_Initialize();
@@ -411,10 +371,12 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* cfg) {
#endif // PDF_ENABLE_XFA
if (cfg && cfg->version >= 2)
IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate);
+
+ g_bLibraryInitialized = true;
}
DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
- if (!g_pCodecModule)
+ if (!g_bLibraryInitialized)
return;
#ifdef PDF_ENABLE_XFA
@@ -425,10 +387,9 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
CPDF_ModuleMgr::Destroy();
CFX_GEModule::Destroy();
- delete g_pCodecModule;
- g_pCodecModule = nullptr;
-
IJS_Runtime::Destroy();
+
+ g_bLibraryInitialized = false;
}
#ifndef _WIN32