summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_document.h9
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp6
-rw-r--r--core/fxcodec/codec/ccodec_jbig2module.h6
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp37
4 files changed, 30 insertions, 28 deletions
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index f7a7f9f183..e1d1c77a12 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -11,6 +11,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_basic.h"
class CFX_Font;
@@ -35,7 +36,7 @@ class CPDF_StreamAcc;
#define FPDFPERM_PRINT_HIGH 0x0800
#define FPDF_PAGE_MAX_NUM 0xFFFFF
-class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
+class CPDF_Document : public CPDF_IndirectObjectHolder {
public:
explicit CPDF_Document(CPDF_Parser* pParser);
~CPDF_Document();
@@ -57,6 +58,9 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
void ClearPageData();
void RemoveColorSpaceFromPageData(CPDF_Object* pObject);
+ std::unique_ptr<CFX_Deletable>* CodecContext() { return &m_pCodecContext; }
+ std::unique_ptr<CPDF_LinkList>* LinksContext() { return &m_pLinksContext; }
+
CPDF_DocRenderData* GetRenderData() const { return m_pDocRender.get(); }
void ClearRenderData();
void ClearRenderFont();
@@ -107,7 +111,6 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
friend class CPDF_OCContext;
// Retrieve page count information by getting count value from the tree nodes
- // or walking through the tree nodes to calculate it.
int RetrievePageCount() const;
CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages,
int iPage,
@@ -131,6 +134,8 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
// TODO(thestig): Figure out why this cannot be a std::unique_ptr.
CPDF_DocPageData* m_pDocPage;
std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
+ std::unique_ptr<CFX_Deletable> m_pCodecContext;
+ std::unique_ptr<CPDF_LinkList> m_pLinksContext;
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 19aeb71e9a..75f6a231a4 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -355,9 +355,9 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
}
}
ret = pJbig2Module->StartDecode(
- m_pJbig2Context, m_pDocument, m_Width, m_Height, m_pStreamAcc.get(),
- m_pGlobalStream.get(), m_pCachedBitmap->GetBuffer(),
- m_pCachedBitmap->GetPitch(), pPause);
+ m_pJbig2Context, m_pDocument->CodecContext(), m_Width, m_Height,
+ m_pStreamAcc.get(), m_pGlobalStream.get(),
+ m_pCachedBitmap->GetBuffer(), m_pCachedBitmap->GetPitch(), pPause);
if (ret < 0) {
m_pCachedBitmap.reset();
m_pGlobalStream.reset();
diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h
index 20578c8cdb..a967e0b997 100644
--- a/core/fxcodec/codec/ccodec_jbig2module.h
+++ b/core/fxcodec/codec/ccodec_jbig2module.h
@@ -7,7 +7,9 @@
#ifndef CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
#define CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
-#include "core/fxcrt/include/fx_system.h"
+#include <memory>
+
+#include "core/fxcrt/include/fx_basic.h"
class CPDF_StreamAcc;
class IFX_Pause;
@@ -19,7 +21,7 @@ class CCodec_Jbig2Module {
void* CreateJbig2Context();
FXCODEC_STATUS StartDecode(void* pJbig2Context,
- CFX_PrivateData* pPrivateData,
+ std::unique_ptr<CFX_Deletable>* pContextHolder,
uint32_t width,
uint32_t height,
CPDF_StreamAcc* src_stream,
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index 99cf2ec82f..2b0be1070e 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -46,17 +46,11 @@ class JBig2DocumentContext : public CFX_Deletable {
std::list<CJBig2_CachePair> m_SymbolDictCache;
};
-JBig2DocumentContext* GetJBig2DocumentContext(CCodec_Jbig2Module* pModule,
- CFX_PrivateData* pPrivateData) {
- void* pModulePrivateData = pPrivateData->GetPrivateData(pModule);
- if (pModulePrivateData) {
- CFX_Deletable* pDeletable =
- reinterpret_cast<CFX_Deletable*>(pModulePrivateData);
- return static_cast<JBig2DocumentContext*>(pDeletable);
- }
- JBig2DocumentContext* pJBig2DocumentContext = new JBig2DocumentContext();
- pPrivateData->SetPrivateObj(pModule, pJBig2DocumentContext);
- return pJBig2DocumentContext;
+JBig2DocumentContext* GetJBig2DocumentContext(
+ std::unique_ptr<CFX_Deletable>* pContextHolder) {
+ if (!pContextHolder->get())
+ pContextHolder->reset(new JBig2DocumentContext());
+ return static_cast<JBig2DocumentContext*>(pContextHolder->get());
}
CCodec_Jbig2Context::CCodec_Jbig2Context() {
@@ -76,20 +70,21 @@ void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) {
}
pJbig2Content = NULL;
}
-FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context,
- CFX_PrivateData* pPrivateData,
- uint32_t width,
- uint32_t height,
- CPDF_StreamAcc* src_stream,
- CPDF_StreamAcc* global_stream,
- uint8_t* dest_buf,
- uint32_t dest_pitch,
- IFX_Pause* pPause) {
+FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
+ void* pJbig2Context,
+ std::unique_ptr<CFX_Deletable>* pContextHolder,
+ uint32_t width,
+ uint32_t height,
+ CPDF_StreamAcc* src_stream,
+ CPDF_StreamAcc* global_stream,
+ uint8_t* dest_buf,
+ uint32_t dest_pitch,
+ IFX_Pause* pPause) {
if (!pJbig2Context) {
return FXCODEC_STATUS_ERR_PARAMS;
}
JBig2DocumentContext* pJBig2DocumentContext =
- GetJBig2DocumentContext(this, pPrivateData);
+ GetJBig2DocumentContext(pContextHolder);
CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
m_pJbig2Context->m_width = width;
m_pJbig2Context->m_height = height;