summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-07-19 16:06:10 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-19 16:06:10 -0700
commit8ca60b2cda3efc112c987c1d57d1eb8568667da9 (patch)
treeb9170a729249b4f4aa8751e2f713afed77fca15b /core/fxcodec/codec
parent5b36f0a0eff7f3666a0e642640db3c89e4bb6748 (diff)
downloadpdfium-8ca60b2cda3efc112c987c1d57d1eb8568667da9.tar.xz
Use smart pointers for various Jbig2 decoding contexts
Use unique_ptr for class owned member variables, and remove unnecessary or unused functions and member variable. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2149903002
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r--core/fxcodec/codec/ccodec_jbig2module.h7
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp36
2 files changed, 16 insertions, 27 deletions
diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h
index 63e63afcfa..5d77d53619 100644
--- a/core/fxcodec/codec/ccodec_jbig2module.h
+++ b/core/fxcodec/codec/ccodec_jbig2module.h
@@ -20,7 +20,7 @@ class IFX_Pause;
class CCodec_Jbig2Context {
public:
CCodec_Jbig2Context();
- ~CCodec_Jbig2Context() {}
+ ~CCodec_Jbig2Context();
uint32_t m_width;
uint32_t m_height;
@@ -29,8 +29,7 @@ class CCodec_Jbig2Context {
uint8_t* m_dest_buf;
uint32_t m_dest_pitch;
IFX_Pause* m_pPause;
- CJBig2_Context* m_pContext;
- CJBig2_Image* m_dest_image;
+ std::unique_ptr<CJBig2_Context> m_pContext;
};
class CCodec_Jbig2Module {
@@ -38,7 +37,6 @@ class CCodec_Jbig2Module {
CCodec_Jbig2Module() {}
~CCodec_Jbig2Module();
- CCodec_Jbig2Context* CreateJbig2Context();
FXCODEC_STATUS StartDecode(CCodec_Jbig2Context* pJbig2Context,
std::unique_ptr<CFX_Deletable>* pContextHolder,
uint32_t width,
@@ -50,7 +48,6 @@ class CCodec_Jbig2Module {
IFX_Pause* pPause);
FXCODEC_STATUS ContinueDecode(CCodec_Jbig2Context* pJbig2Context,
IFX_Pause* pPause);
- void DestroyJbig2Context(CCodec_Jbig2Context* pJbig2Context);
};
#endif // CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index 4876cef53d..8f2d07f490 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -37,24 +37,18 @@ JBig2DocumentContext* GetJBig2DocumentContext(
return static_cast<JBig2DocumentContext*>(pContextHolder->get());
}
-CCodec_Jbig2Context::CCodec_Jbig2Context() {
- FXSYS_memset(this, 0, sizeof(CCodec_Jbig2Context));
-}
-
-CCodec_Jbig2Module::~CCodec_Jbig2Module() {}
+CCodec_Jbig2Context::CCodec_Jbig2Context()
+ : m_width(0),
+ m_height(0),
+ m_pGlobalStream(nullptr),
+ m_pSrcStream(nullptr),
+ m_dest_buf(0),
+ m_dest_pitch(0),
+ m_pPause(nullptr) {}
-CCodec_Jbig2Context* CCodec_Jbig2Module::CreateJbig2Context() {
- return new CCodec_Jbig2Context();
-}
+CCodec_Jbig2Context::~CCodec_Jbig2Context() {}
-void CCodec_Jbig2Module::DestroyJbig2Context(
- CCodec_Jbig2Context* pJbig2Context) {
- if (pJbig2Context) {
- CJBig2_Context::DestroyContext(pJbig2Context->m_pContext);
- delete pJbig2Context;
- }
- pJbig2Context = nullptr;
-}
+CCodec_Jbig2Module::~CCodec_Jbig2Module() {}
FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
CCodec_Jbig2Context* pJbig2Context,
@@ -79,9 +73,9 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
pJbig2Context->m_dest_pitch = dest_pitch;
pJbig2Context->m_pPause = pPause;
FXSYS_memset(dest_buf, 0, height * dest_pitch);
- pJbig2Context->m_pContext = CJBig2_Context::CreateContext(
+ pJbig2Context->m_pContext.reset(new CJBig2_Context(
global_stream, src_stream, pJBig2DocumentContext->GetSymbolDictCache(),
- pPause);
+ pPause, false));
if (!pJbig2Context->m_pContext)
return FXCODEC_STATUS_ERROR;
@@ -89,8 +83,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
dest_pitch, pPause);
if (pJbig2Context->m_pContext->GetProcessingStatus() ==
FXCODEC_STATUS_DECODE_FINISH) {
- CJBig2_Context::DestroyContext(pJbig2Context->m_pContext);
- pJbig2Context->m_pContext = nullptr;
+ pJbig2Context->m_pContext.reset();
if (ret != JBIG2_SUCCESS)
return FXCODEC_STATUS_ERROR;
@@ -111,8 +104,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(
FXCODEC_STATUS_DECODE_FINISH) {
return pJbig2Context->m_pContext->GetProcessingStatus();
}
- CJBig2_Context::DestroyContext(pJbig2Context->m_pContext);
- pJbig2Context->m_pContext = nullptr;
+ pJbig2Context->m_pContext.reset();
if (ret != JBIG2_SUCCESS)
return FXCODEC_STATUS_ERROR;