summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_basic_module.cpp
blob: efa93d6f762c9043d4352871deb70269540d5539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2014 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/fpdfapi/include/cpdf_modulemgr.h"

#include "core/fpdfapi/ipdf_rendermodule.h"
#include "core/fxcodec/include/fx_codec.h"

namespace {

CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = nullptr;

}  // namespace

// static
CPDF_ModuleMgr* CPDF_ModuleMgr::Get() {
  return g_FPDFAPI_pDefaultMgr;
}

// static
void CPDF_ModuleMgr::Create() {
  ASSERT(!g_FPDFAPI_pDefaultMgr);
  g_FPDFAPI_pDefaultMgr = new CPDF_ModuleMgr;
}

// static
void CPDF_ModuleMgr::Destroy() {
  delete g_FPDFAPI_pDefaultMgr;
  g_FPDFAPI_pDefaultMgr = nullptr;
}

CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {}

CPDF_ModuleMgr::~CPDF_ModuleMgr() {}

void CPDF_ModuleMgr::SetPrivateData(void* module_id,
                                    void* pData,
                                    PD_CALLBACK_FREEDATA callback) {
  m_privateData.SetPrivateData(module_id, pData, callback);
}

void* CPDF_ModuleMgr::GetPrivateData(void* module_id) {
  return m_privateData.GetPrivateData(module_id);
}

CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
  return m_pCodecModule ? m_pCodecModule->GetFaxModule() : nullptr;
}

CCodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() {
  return m_pCodecModule ? m_pCodecModule->GetJpegModule() : nullptr;
}

CCodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() {
  return m_pCodecModule ? m_pCodecModule->GetJpxModule() : nullptr;
}

CCodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() {
  return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : nullptr;
}

CCodec_IccModule* CPDF_ModuleMgr::GetIccModule() {
  return m_pCodecModule ? m_pCodecModule->GetIccModule() : nullptr;
}

CCodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() {
  return m_pCodecModule ? m_pCodecModule->GetFlateModule() : nullptr;
}