summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.cpp42
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.h21
-rw-r--r--core/fpdfapi/render/cpdf_pagerendercache.cpp13
3 files changed, 39 insertions, 37 deletions
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.cpp b/core/fpdfapi/render/cpdf_imagecacheentry.cpp
index f69bfdae68..f4be2af12c 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.cpp
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.cpp
@@ -52,7 +52,7 @@ RetainPtr<CFX_DIBSource> CPDF_ImageCacheEntry::DetachMask() {
return std::move(m_pCurMask);
}
-int CPDF_ImageCacheEntry::StartGetCachedBitmap(
+CPDF_DIBSource::LoadState CPDF_ImageCacheEntry::StartGetCachedBitmap(
CPDF_Dictionary* pFormResources,
CPDF_Dictionary* pPageResources,
bool bStdCS,
@@ -64,7 +64,7 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(
if (m_pCachedBitmap) {
m_pCurBitmap = m_pCachedBitmap;
m_pCurMask = m_pCachedMask;
- return 1;
+ return CPDF_DIBSource::LoadState::kSuccess;
}
m_pCurBitmap = pdfium::MakeRetain<CPDF_DIBSource>();
@@ -72,14 +72,26 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(
m_pDocument.Get(), m_pImage->GetStream(), true, pFormResources,
pPageResources, bStdCS, GroupFamily, bLoadMask);
if (ret == 2)
- return ret;
+ return CPDF_DIBSource::LoadState::kContinue;
- if (!ret) {
+ if (ret == 1)
+ ContinueGetCachedBitmap(pRenderStatus);
+ else
m_pCurBitmap.Reset();
- return 0;
- }
- ContinueGetCachedBitmap(pRenderStatus);
- return 0;
+ return CPDF_DIBSource::LoadState::kFail;
+}
+
+bool CPDF_ImageCacheEntry::Continue(IFX_PauseIndicator* pPause,
+ CPDF_RenderStatus* pRenderStatus) {
+ int ret = m_pCurBitmap.As<CPDF_DIBSource>()->ContinueLoadDIBSource(pPause);
+ if (ret == 2)
+ return true;
+
+ if (ret == 1)
+ ContinueGetCachedBitmap(pRenderStatus);
+ else
+ m_pCurBitmap.Reset();
+ return false;
}
void CPDF_ImageCacheEntry::ContinueGetCachedBitmap(
@@ -105,20 +117,6 @@ void CPDF_ImageCacheEntry::ContinueGetCachedBitmap(
CalcSize();
}
-int CPDF_ImageCacheEntry::Continue(IFX_PauseIndicator* pPause,
- CPDF_RenderStatus* pRenderStatus) {
- int ret = m_pCurBitmap.As<CPDF_DIBSource>()->ContinueLoadDIBSource(pPause);
- if (!ret) {
- m_pCurBitmap.Reset();
- return 0;
- }
- if (ret == 2)
- return ret;
-
- ContinueGetCachedBitmap(pRenderStatus);
- return 0;
-}
-
void CPDF_ImageCacheEntry::CalcSize() {
m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap) +
FPDF_ImageCache_EstimateImageSize(m_pCachedMask);
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.h b/core/fpdfapi/render/cpdf_imagecacheentry.h
index 2bede23e62..dfeeddf408 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.h
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.h
@@ -9,11 +9,11 @@
#include <memory>
+#include "core/fpdfapi/render/cpdf_dibsource.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
-class CFX_DIBSource;
class CFX_DIBitmap;
class CPDF_Dictionary;
class CPDF_Document;
@@ -31,13 +31,18 @@ class CPDF_ImageCacheEntry {
uint32_t EstimateSize() const { return m_dwCacheSize; }
uint32_t GetTimeCount() const { return m_dwTimeCount; }
CPDF_Image* GetImage() const { return m_pImage.Get(); }
- int StartGetCachedBitmap(CPDF_Dictionary* pFormResources,
- CPDF_Dictionary* pPageResources,
- bool bStdCS,
- uint32_t GroupFamily,
- bool bLoadMask,
- CPDF_RenderStatus* pRenderStatus);
- int Continue(IFX_PauseIndicator* pPause, CPDF_RenderStatus* pRenderStatus);
+
+ CPDF_DIBSource::LoadState StartGetCachedBitmap(
+ CPDF_Dictionary* pFormResources,
+ CPDF_Dictionary* pPageResources,
+ bool bStdCS,
+ uint32_t GroupFamily,
+ bool bLoadMask,
+ CPDF_RenderStatus* pRenderStatus);
+
+ // Returns whether to Continue() or not.
+ bool Continue(IFX_PauseIndicator* pPause, CPDF_RenderStatus* pRenderStatus);
+
RetainPtr<CFX_DIBSource> DetachBitmap();
RetainPtr<CFX_DIBSource> DetachMask();
diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp
index 0d01589af3..781f18f0e0 100644
--- a/core/fpdfapi/render/cpdf_pagerendercache.cpp
+++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp
@@ -94,17 +94,17 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap(
m_pCurImageCacheEntry =
new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pImage);
}
- int ret = m_pCurImageCacheEntry->StartGetCachedBitmap(
+ CPDF_DIBSource::LoadState ret = m_pCurImageCacheEntry->StartGetCachedBitmap(
pRenderStatus->GetFormResource(), m_pPage->m_pPageResources.Get(), bStdCS,
GroupFamily, bLoadMask, pRenderStatus);
- if (ret == 2)
+ if (ret == CPDF_DIBSource::LoadState::kContinue)
return true;
m_nTimeCount++;
if (!m_bCurFindCache)
m_ImageCache[pStream] = m_pCurImageCacheEntry;
- if (!ret)
+ if (ret == CPDF_DIBSource::LoadState::kFail)
m_nCacheSize += m_pCurImageCacheEntry->EstimateSize();
return false;
@@ -112,8 +112,8 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap(
bool CPDF_PageRenderCache::Continue(IFX_PauseIndicator* pPause,
CPDF_RenderStatus* pRenderStatus) {
- int ret = m_pCurImageCacheEntry->Continue(pPause, pRenderStatus);
- if (ret == 2)
+ bool ret = m_pCurImageCacheEntry->Continue(pPause, pRenderStatus);
+ if (ret)
return true;
m_nTimeCount++;
@@ -121,8 +121,7 @@ bool CPDF_PageRenderCache::Continue(IFX_PauseIndicator* pPause,
m_ImageCache[m_pCurImageCacheEntry->GetImage()->GetStream()] =
m_pCurImageCacheEntry;
}
- if (!ret)
- m_nCacheSize += m_pCurImageCacheEntry->EstimateSize();
+ m_nCacheSize += m_pCurImageCacheEntry->EstimateSize();
return false;
}