From f605c24fa76c9034184ed6a5054200962a0b6c07 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 18 May 2017 13:48:33 -0700 Subject: Add more CFX_UnownedPtr usage. One lifetime issue was fixed by passing CPDF_RenderStatus into Continue() methods rather than holidng a pointer which was going stale. Bug: Change-Id: I63b9dce4c1a0d1377cc407b5460535f7c916a040 Reviewed-on: https://pdfium-review.googlesource.com/5659 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- core/fpdfapi/render/cpdf_imagecacheentry.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi/render/cpdf_imagecacheentry.cpp') diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.cpp b/core/fpdfapi/render/cpdf_imagecacheentry.cpp index 392eaba914..74e0bf16d7 100644 --- a/core/fpdfapi/render/cpdf_imagecacheentry.cpp +++ b/core/fpdfapi/render/cpdf_imagecacheentry.cpp @@ -22,11 +22,8 @@ CPDF_ImageCacheEntry::CPDF_ImageCacheEntry(CPDF_Document* pDoc, CPDF_Stream* pStream) : m_dwTimeCount(0), m_MatteColor(0), - m_pRenderStatus(nullptr), m_pDocument(pDoc), m_pStream(pStream), - m_pCurBitmap(nullptr), - m_pCurMask(nullptr), m_dwCacheSize(0) {} CPDF_ImageCacheEntry::~CPDF_ImageCacheEntry() {} @@ -70,11 +67,10 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources, if (!pRenderStatus) return 0; - m_pRenderStatus = pRenderStatus; m_pCurBitmap = pdfium::MakeRetain(); int ret = m_pCurBitmap.As()->StartLoadDIBSource( - m_pDocument, m_pStream, true, pFormResources, pPageResources, bStdCS, - GroupFamily, bLoadMask); + m_pDocument.Get(), m_pStream.Get(), true, pFormResources, pPageResources, + bStdCS, GroupFamily, bLoadMask); if (ret == 2) return ret; @@ -82,14 +78,15 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources, m_pCurBitmap.Reset(); return 0; } - ContinueGetCachedBitmap(); + ContinueGetCachedBitmap(pRenderStatus); return 0; } -void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() { +void CPDF_ImageCacheEntry::ContinueGetCachedBitmap( + CPDF_RenderStatus* pRenderStatus) { m_MatteColor = m_pCurBitmap.As()->GetMatteColor(); m_pCurMask = m_pCurBitmap.As()->DetachMask(); - CPDF_RenderContext* pContext = m_pRenderStatus->GetContext(); + CPDF_RenderContext* pContext = pRenderStatus->GetContext(); CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache(); m_dwTimeCount = pPageRenderCache->GetTimeCount(); if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() < @@ -108,7 +105,8 @@ void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() { CalcSize(); } -int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause) { +int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause, + CPDF_RenderStatus* pRenderStatus) { int ret = m_pCurBitmap.As()->ContinueLoadDIBSource(pPause); if (!ret) { m_pCurBitmap.Reset(); @@ -117,7 +115,7 @@ int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause) { if (ret == 2) return ret; - ContinueGetCachedBitmap(); + ContinueGetCachedBitmap(pRenderStatus); return 0; } -- cgit v1.2.3