summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/fx_codec_progress.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-31 16:29:29 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-31 23:43:31 +0000
commitdb9faec3c8fb3ced3d8340b2b6ae252b8f40d135 (patch)
treee345adf7b949322e462c48274dd256410a237f51 /core/fxcodec/codec/fx_codec_progress.cpp
parentfc04f41200e4ba4f47f52f188708547e8a1bee6d (diff)
downloadpdfium-db9faec3c8fb3ced3d8340b2b6ae252b8f40d135.tar.xz
Put all CCodec_PngModule state into its context.
Rename FXPNG_Context and use unowned ptr. Clean up context in its dtor. Then create and destroy using |new|. Change-Id: I7b66e6d0da50a16d3b8d5108ffd931bb01145892 Reviewed-on: https://pdfium-review.googlesource.com/6152 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/fx_codec_progress.cpp')
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp42
1 files changed, 17 insertions, 25 deletions
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 4cadb152d8..638141bc92 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -300,7 +300,7 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
if (m_pBmpContext)
m_pCodecMgr->GetBmpModule()->Finish(m_pBmpContext);
if (m_pPngContext)
- m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
+ m_pCodecMgr->GetPngModule()->Finish(m_pPngContext.Release());
if (m_pTiffContext)
m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext.Release());
FX_Free(m_pSrcBuf);
@@ -1111,8 +1111,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_status = FXCODEC_STATUS_ERR_MEMORY;
return false;
}
- pPngModule->SetDelegate(this);
- m_pPngContext = pPngModule->Start();
+ m_pPngContext = pPngModule->Start(this);
if (!m_pPngContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return false;
@@ -1123,16 +1122,15 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
return false;
}
m_offSet += size;
- bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, size, pAttribute);
+ bResult =
+ pPngModule->Input(m_pPngContext.Get(), m_pSrcBuf, size, pAttribute);
while (bResult) {
uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet;
uint32_t input_size =
remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
if (input_size == 0) {
- if (m_pPngContext) {
- pPngModule->Finish(m_pPngContext);
- }
- m_pPngContext = nullptr;
+ if (m_pPngContext)
+ pPngModule->Finish(m_pPngContext.Release());
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
}
@@ -1148,14 +1146,12 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
return false;
}
m_offSet += input_size;
- bResult =
- pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, pAttribute);
+ bResult = pPngModule->Input(m_pPngContext.Get(), m_pSrcBuf, input_size,
+ pAttribute);
}
ASSERT(!bResult);
- if (m_pPngContext) {
- pPngModule->Finish(m_pPngContext);
- m_pPngContext = nullptr;
- }
+ if (m_pPngContext)
+ pPngModule->Finish(m_pPngContext.Release());
if (m_SrcPassNumber == 0) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -1913,11 +1909,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(
m_status = FXCODEC_STATUS_ERR_MEMORY;
return m_status;
}
- if (m_pPngContext) {
- pPngModule->Finish(m_pPngContext);
- m_pPngContext = nullptr;
- }
- m_pPngContext = pPngModule->Start();
+ if (m_pPngContext)
+ pPngModule->Finish(m_pPngContext.Release());
+ m_pPngContext = pPngModule->Start(this);
if (!m_pPngContext) {
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
@@ -2060,10 +2054,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
uint32_t input_size =
remain_size > FXCODEC_BLOCK_SIZE ? FXCODEC_BLOCK_SIZE : remain_size;
if (input_size == 0) {
- if (m_pPngContext) {
- pPngModule->Finish(m_pPngContext);
- }
- m_pPngContext = nullptr;
+ if (m_pPngContext)
+ pPngModule->Finish(m_pPngContext.Release());
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
m_status = FXCODEC_STATUS_DECODE_FINISH;
@@ -2083,8 +2075,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
return m_status;
}
m_offSet += input_size;
- bResult =
- pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr);
+ bResult = pPngModule->Input(m_pPngContext.Get(), m_pSrcBuf, input_size,
+ nullptr);
if (!bResult) {
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;