summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-18 13:48:33 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-18 21:21:59 +0000
commitf605c24fa76c9034184ed6a5054200962a0b6c07 (patch)
treeac9e02f447e0d3ca07155082eb84ea546fc73762 /core/fpdfapi/render
parent940967de0b588d3abb9cba5822ae5f5c5fe05017 (diff)
downloadpdfium-f605c24fa76c9034184ed6a5054200962a0b6c07.tar.xz
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 <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.cpp20
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.h12
-rw-r--r--core/fpdfapi/render/cpdf_imageloader.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_imageloader.h2
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_pagerendercache.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_pagerendercache.h2
7 files changed, 24 insertions, 24 deletions
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<CPDF_DIBSource>();
int ret = m_pCurBitmap.As<CPDF_DIBSource>()->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<CPDF_DIBSource>()->GetMatteColor();
m_pCurMask = m_pCurBitmap.As<CPDF_DIBSource>()->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<CPDF_DIBSource>()->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;
}
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.h b/core/fpdfapi/render/cpdf_imagecacheentry.h
index b17d3fdda2..b908fb78d0 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.h
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.h
@@ -10,6 +10,7 @@
#include <memory>
#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
class CFX_DIBitmap;
@@ -28,7 +29,7 @@ class CPDF_ImageCacheEntry {
void Reset(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap);
uint32_t EstimateSize() const { return m_dwCacheSize; }
uint32_t GetTimeCount() const { return m_dwTimeCount; }
- CPDF_Stream* GetStream() const { return m_pStream; }
+ CPDF_Stream* GetStream() const { return m_pStream.Get(); }
int StartGetCachedBitmap(CPDF_Dictionary* pFormResources,
CPDF_Dictionary* pPageResources,
@@ -38,7 +39,7 @@ class CPDF_ImageCacheEntry {
CPDF_RenderStatus* pRenderStatus,
int32_t downsampleWidth,
int32_t downsampleHeight);
- int Continue(IFX_Pause* pPause);
+ int Continue(IFX_Pause* pPause, CPDF_RenderStatus* pRenderStatus);
CFX_RetainPtr<CFX_DIBSource> DetachBitmap();
CFX_RetainPtr<CFX_DIBSource> DetachMask();
@@ -46,12 +47,11 @@ class CPDF_ImageCacheEntry {
uint32_t m_MatteColor;
private:
- void ContinueGetCachedBitmap();
+ void ContinueGetCachedBitmap(CPDF_RenderStatus* pRenderStatus);
void CalcSize();
- CPDF_RenderStatus* m_pRenderStatus;
- CPDF_Document* m_pDocument;
- CPDF_Stream* m_pStream;
+ CFX_UnownedPtr<CPDF_Document> const m_pDocument;
+ CFX_UnownedPtr<CPDF_Stream> const m_pStream;
CFX_RetainPtr<CFX_DIBSource> m_pCurBitmap;
CFX_RetainPtr<CFX_DIBSource> m_pCurMask;
CFX_RetainPtr<CFX_DIBSource> m_pCachedBitmap;
diff --git a/core/fpdfapi/render/cpdf_imageloader.cpp b/core/fpdfapi/render/cpdf_imageloader.cpp
index 230dc02fe5..af441a5b00 100644
--- a/core/fpdfapi/render/cpdf_imageloader.cpp
+++ b/core/fpdfapi/render/cpdf_imageloader.cpp
@@ -51,8 +51,9 @@ bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage,
return ret;
}
-bool CPDF_ImageLoader::Continue(IFX_Pause* pPause) {
- bool ret = m_pCache ? m_pCache->Continue(pPause)
+bool CPDF_ImageLoader::Continue(IFX_Pause* pPause,
+ CPDF_RenderStatus* pRenderStatus) {
+ bool ret = m_pCache ? m_pCache->Continue(pPause, pRenderStatus)
: m_pImage->GetImage()->Continue(pPause);
if (!ret)
HandleFailure();
diff --git a/core/fpdfapi/render/cpdf_imageloader.h b/core/fpdfapi/render/cpdf_imageloader.h
index c7161c3486..4b2119455e 100644
--- a/core/fpdfapi/render/cpdf_imageloader.h
+++ b/core/fpdfapi/render/cpdf_imageloader.h
@@ -29,7 +29,7 @@ class CPDF_ImageLoader {
CPDF_RenderStatus* pRenderStatus,
int32_t nDownsampleWidth,
int32_t nDownsampleHeight);
- bool Continue(IFX_Pause* pPause);
+ bool Continue(IFX_Pause* pPause, CPDF_RenderStatus* pRenderStatus);
CFX_RetainPtr<CFX_DIBSource> m_pBitmap;
CFX_RetainPtr<CFX_DIBSource> m_pMask;
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 28548121b9..12c354076b 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -541,7 +541,7 @@ bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) {
pPause);
if (m_Status == 4) {
- if (m_Loader.Continue(pPause))
+ if (m_Loader.Continue(pPause, m_pRenderStatus))
return true;
if (StartRenderDIBSource())
diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp
index 549f466527..2fa7220409 100644
--- a/core/fpdfapi/render/cpdf_pagerendercache.cpp
+++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp
@@ -111,8 +111,9 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap(
return false;
}
-bool CPDF_PageRenderCache::Continue(IFX_Pause* pPause) {
- int ret = m_pCurImageCacheEntry->Continue(pPause);
+bool CPDF_PageRenderCache::Continue(IFX_Pause* pPause,
+ CPDF_RenderStatus* pRenderStatus) {
+ int ret = m_pCurImageCacheEntry->Continue(pPause, pRenderStatus);
if (ret == 2)
return true;
diff --git a/core/fpdfapi/render/cpdf_pagerendercache.h b/core/fpdfapi/render/cpdf_pagerendercache.h
index affd55bbfe..e6528ddeea 100644
--- a/core/fpdfapi/render/cpdf_pagerendercache.h
+++ b/core/fpdfapi/render/cpdf_pagerendercache.h
@@ -43,7 +43,7 @@ class CPDF_PageRenderCache {
int32_t downsampleWidth,
int32_t downsampleHeight);
- bool Continue(IFX_Pause* pPause);
+ bool Continue(IFX_Pause* pPause, CPDF_RenderStatus* pRenderStatus);
private:
void ClearImageCacheEntry(CPDF_Stream* pStream);