Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: core/fxcodec/codec/fx_codec_jbig.cpp

Issue 2149903002: Use smart pointers for various Jbig2 decoding contexts (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxcodec/codec/ccodec_jbig2module.h ('k') | core/fxcodec/jbig2/JBig2_Context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 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 4876cef53d5125748d1deffe2e8d48a9b4a73a03..8f2d07f49099579bb5ce5867a22162d06ad8f6c2 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;
« no previous file with comments | « core/fxcodec/codec/ccodec_jbig2module.h ('k') | core/fxcodec/jbig2/JBig2_Context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698