summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-25 16:16:32 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-25 16:16:32 -0700
commit5ce09684216ed6b74836de9bd056b8f15bd66a4e (patch)
tree841e23498e3684f4b83062c958169bb05573af7d /core/fxcodec
parent65be4b1818ab99df2bf5b6265604fc25456db49d (diff)
downloadpdfium-5ce09684216ed6b74836de9bd056b8f15bd66a4e.tar.xz
Remove CFX_PrivateData from CPDF_Document
Replace it with two generic slots for Links and Codec usage. Since the codec is at a lower layer than the document, we don't provide separate get/set methods, since having a document upon which to call these would be a layering violation. Do the same for the Links for simplicity. Review-Url: https://codereview.chromium.org/2005193003
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/ccodec_jbig2module.h6
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp37
2 files changed, 20 insertions, 23 deletions
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;