summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-11-23 07:49:00 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-23 07:49:00 -0800
commit9e4fca796e2711fcd311b1203b75fdd7f737c9b5 (patch)
tree1397248f2bdb0f522401437a4750f635e0c30b2b /core/fpdfapi/render
parente36430e530e48d4145f34a554f9891b1989b590d (diff)
downloadpdfium-9e4fca796e2711fcd311b1203b75fdd7f737c9b5.tar.xz
Avoid cloning in CPDF_ImageCacheEntry::ContinueGetCachedBitmap
We are always cloning when the bitmap size is bounded by some constant, and we are always cloning the mask. Instead, just assign pointers. BUG=pdfium:633 Review-Url: https://codereview.chromium.org/2518063005
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/fpdf_render_cache.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/core/fpdfapi/render/fpdf_render_cache.cpp b/core/fpdfapi/render/fpdf_render_cache.cpp
index a91d2ba8d0..9f663525ec 100644
--- a/core/fpdfapi/render/fpdf_render_cache.cpp
+++ b/core/fpdfapi/render/fpdf_render_cache.cpp
@@ -292,29 +292,21 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources,
ContinueGetCachedBitmap();
return 0;
}
+
void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() {
m_MatteColor = ((CPDF_DIBSource*)m_pCurBitmap)->GetMatteColor();
m_pCurMask = ((CPDF_DIBSource*)m_pCurBitmap)->DetachMask();
CPDF_RenderContext* pContext = m_pRenderStatus->GetContext();
CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
m_dwTimeCount = pPageRenderCache->GetTimeCount();
- if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() <
- FPDF_HUGE_IMAGE_SIZE) {
- m_pCachedBitmap = m_pCurBitmap->Clone();
- delete m_pCurBitmap;
- m_pCurBitmap = nullptr;
- } else {
- m_pCachedBitmap = m_pCurBitmap;
- }
- if (m_pCurMask) {
- m_pCachedMask = m_pCurMask->Clone();
- delete m_pCurMask;
- m_pCurMask = nullptr;
- }
- m_pCurBitmap = m_pCachedBitmap;
- m_pCurMask = m_pCachedMask;
+ m_pCachedBitmap = m_pCurBitmap;
+ if (m_pCurMask)
+ m_pCachedMask = m_pCurMask;
+ else
+ m_pCurMask = m_pCachedMask;
CalcSize();
}
+
int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause) {
int ret = ((CPDF_DIBSource*)m_pCurBitmap)->ContinueLoadDIBSource(pPause);
if (ret == 2) {