summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-04 14:37:18 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-04 21:48:48 +0000
commitafd0d1f488ea55da545b3310fd8f22e45522a695 (patch)
tree89136eba4669421b6f828edb9f3d69ee558110d0 /core/fpdfapi/render
parent4f8b044b95dc282959dfe41453e2a9c1ec7e9354 (diff)
downloadpdfium-afd0d1f488ea55da545b3310fd8f22e45522a695.tar.xz
RefCount CPDF_StreamAcc all the time.
Pass stream argument to constructor; it feels like a stream accessor should always be made from a stream rather than passing one in after the fact. Change-Id: Iaa46cb37677b81f0170f5d39bab76ad38ea4af44 Reviewed-on: https://pdfium-review.googlesource.com/3620 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp20
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.h4
2 files changed, 12 insertions, 12 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index 12bfadb19d..e60d0329d0 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -165,8 +165,8 @@ bool CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream) {
if (!src_size.IsValid())
return false;
- m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
- m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
+ m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
+ m_pStreamAcc->LoadAllData(false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData())
return false;
@@ -278,8 +278,8 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return 0;
}
- m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
- m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
+ m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
+ m_pStreamAcc->LoadAllData(false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return 0;
}
@@ -325,17 +325,17 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
CPDF_Stream* pGlobals =
m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals");
if (pGlobals) {
- m_pGlobalStream = pdfium::MakeUnique<CPDF_StreamAcc>();
- m_pGlobalStream->LoadAllData(pGlobals, false);
+ m_pGlobalStream = pdfium::MakeRetain<CPDF_StreamAcc>(pGlobals);
+ m_pGlobalStream->LoadAllData(false);
}
}
ret = pJbig2Module->StartDecode(
m_pJbig2Context.get(), m_pDocument->CodecContext(), m_Width, m_Height,
- m_pStreamAcc.get(), m_pGlobalStream.get(),
- m_pCachedBitmap->GetBuffer(), m_pCachedBitmap->GetPitch(), pPause);
+ m_pStreamAcc, m_pGlobalStream, m_pCachedBitmap->GetBuffer(),
+ m_pCachedBitmap->GetPitch(), pPause);
if (ret < 0) {
m_pCachedBitmap.Reset();
- m_pGlobalStream.reset();
+ m_pGlobalStream.Reset();
m_pJbig2Context.reset();
return 0;
}
@@ -358,7 +358,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
ret = pJbig2Module->ContinueDecode(m_pJbig2Context.get(), pPause);
if (ret < 0) {
m_pCachedBitmap.Reset();
- m_pGlobalStream.reset();
+ m_pGlobalStream.Reset();
m_pJbig2Context.reset();
return 0;
}
diff --git a/core/fpdfapi/render/cpdf_dibsource.h b/core/fpdfapi/render/cpdf_dibsource.h
index c77aac1776..f484f57d75 100644
--- a/core/fpdfapi/render/cpdf_dibsource.h
+++ b/core/fpdfapi/render/cpdf_dibsource.h
@@ -118,7 +118,7 @@ class CPDF_DIBSource : public CFX_DIBSource {
CPDF_Document* m_pDocument;
const CPDF_Stream* m_pStream;
- std::unique_ptr<CPDF_StreamAcc> m_pStreamAcc;
+ CFX_RetainPtr<CPDF_StreamAcc> m_pStreamAcc;
const CPDF_Dictionary* m_pDict;
CPDF_ColorSpace* m_pColorSpace;
uint32_t m_Family;
@@ -139,8 +139,8 @@ class CPDF_DIBSource : public CFX_DIBSource {
uint8_t* m_pMaskedLine;
CFX_RetainPtr<CFX_DIBitmap> m_pCachedBitmap;
CFX_RetainPtr<CPDF_DIBSource> m_pMask;
+ CFX_RetainPtr<CPDF_StreamAcc> m_pGlobalStream;
std::unique_ptr<CCodec_ScanlineDecoder> m_pDecoder;
- std::unique_ptr<CPDF_StreamAcc> m_pGlobalStream;
std::unique_ptr<CCodec_Jbig2Context> m_pJbig2Context;
CPDF_Stream* m_pMaskStream;
int m_Status;