From 5ce09684216ed6b74836de9bd056b8f15bd66a4e Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 25 May 2016 16:16:32 -0700 Subject: 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 --- core/fxcodec/codec/fx_codec_jbig.cpp | 37 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'core/fxcodec/codec/fx_codec_jbig.cpp') 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 m_SymbolDictCache; }; -JBig2DocumentContext* GetJBig2DocumentContext(CCodec_Jbig2Module* pModule, - CFX_PrivateData* pPrivateData) { - void* pModulePrivateData = pPrivateData->GetPrivateData(pModule); - if (pModulePrivateData) { - CFX_Deletable* pDeletable = - reinterpret_cast(pModulePrivateData); - return static_cast(pDeletable); - } - JBig2DocumentContext* pJBig2DocumentContext = new JBig2DocumentContext(); - pPrivateData->SetPrivateObj(pModule, pJBig2DocumentContext); - return pJBig2DocumentContext; +JBig2DocumentContext* GetJBig2DocumentContext( + std::unique_ptr* pContextHolder) { + if (!pContextHolder->get()) + pContextHolder->reset(new JBig2DocumentContext()); + return static_cast(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* 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; -- cgit v1.2.3