From 1704350a92234b1e38f0a84010ddf9ecdfce48f8 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Mon, 6 Mar 2017 15:54:38 -0500 Subject: Manual revert of: Avoid cloning in CPDF_ImageCacheEntry::ContinueGetCachedBitmap Not cloning is causing issues when printing to XPS printer. I have no idea why. CL being reverted: https://codereview.chromium.org/2518063005/ BUG=698350 Change-Id: I7c814c712f9959d10d0b6502a28e15ecd752f94a Reviewed-on: https://pdfium-review.googlesource.com/2930 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fpdfapi/render/cpdf_imagecacheentry.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.cpp b/core/fpdfapi/render/cpdf_imagecacheentry.cpp index f11cae888d..82b6117f86 100644 --- a/core/fpdfapi/render/cpdf_imagecacheentry.cpp +++ b/core/fpdfapi/render/cpdf_imagecacheentry.cpp @@ -97,11 +97,21 @@ void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() { CPDF_RenderContext* pContext = m_pRenderStatus->GetContext(); CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache(); m_dwTimeCount = pPageRenderCache->GetTimeCount(); - m_pCachedBitmap = pdfium::WrapUnique(m_pCurBitmap); - if (m_pCurMask) - m_pCachedMask = pdfium::WrapUnique(m_pCurMask); - else - m_pCurMask = m_pCachedMask.get(); + 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 = pdfium::WrapUnique(m_pCurBitmap); + } + if (m_pCurMask) { + m_pCachedMask = m_pCurMask->Clone(); + delete m_pCurMask; + m_pCurMask = nullptr; + } + m_pCurBitmap = m_pCachedBitmap.get(); + m_pCurMask = m_pCachedMask.get(); CalcSize(); } -- cgit v1.2.3