Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: core/fpdfapi/render/fpdf_render_cache.cpp

Issue 2518063005: Avoid cloning in CPDF_ImageCacheEntry::ContinueGetCachedBitmap (Closed)
Patch Set: Comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/render/cpdf_pagerendercache.h" 7 #include "core/fpdfapi/render/cpdf_pagerendercache.h"
8 8
9 #include "core/fpdfapi/page/cpdf_page.h" 9 #include "core/fpdfapi/page/cpdf_page.h"
10 #include "core/fpdfapi/page/pageint.h" 10 #include "core/fpdfapi/page/pageint.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return ret; 285 return ret;
286 } 286 }
287 if (!ret) { 287 if (!ret) {
288 delete m_pCurBitmap; 288 delete m_pCurBitmap;
289 m_pCurBitmap = nullptr; 289 m_pCurBitmap = nullptr;
290 return 0; 290 return 0;
291 } 291 }
292 ContinueGetCachedBitmap(); 292 ContinueGetCachedBitmap();
293 return 0; 293 return 0;
294 } 294 }
295
295 void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() { 296 void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() {
296 m_MatteColor = ((CPDF_DIBSource*)m_pCurBitmap)->GetMatteColor(); 297 m_MatteColor = ((CPDF_DIBSource*)m_pCurBitmap)->GetMatteColor();
297 m_pCurMask = ((CPDF_DIBSource*)m_pCurBitmap)->DetachMask(); 298 m_pCurMask = ((CPDF_DIBSource*)m_pCurBitmap)->DetachMask();
298 CPDF_RenderContext* pContext = m_pRenderStatus->GetContext(); 299 CPDF_RenderContext* pContext = m_pRenderStatus->GetContext();
299 CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache(); 300 CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
300 m_dwTimeCount = pPageRenderCache->GetTimeCount(); 301 m_dwTimeCount = pPageRenderCache->GetTimeCount();
301 if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() < 302 m_pCachedBitmap = m_pCurBitmap;
302 FPDF_HUGE_IMAGE_SIZE) { 303 if (m_pCurMask)
303 m_pCachedBitmap = m_pCurBitmap->Clone(); 304 m_pCachedMask = m_pCurMask;
304 delete m_pCurBitmap; 305 else
305 m_pCurBitmap = nullptr; 306 m_pCurMask = m_pCachedMask;
306 } else {
307 m_pCachedBitmap = m_pCurBitmap;
308 }
309 if (m_pCurMask) {
310 m_pCachedMask = m_pCurMask->Clone();
311 delete m_pCurMask;
312 m_pCurMask = nullptr;
313 }
314 m_pCurBitmap = m_pCachedBitmap;
315 m_pCurMask = m_pCachedMask;
316 CalcSize(); 307 CalcSize();
317 } 308 }
309
318 int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause) { 310 int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause) {
319 int ret = ((CPDF_DIBSource*)m_pCurBitmap)->ContinueLoadDIBSource(pPause); 311 int ret = ((CPDF_DIBSource*)m_pCurBitmap)->ContinueLoadDIBSource(pPause);
320 if (ret == 2) { 312 if (ret == 2) {
321 return ret; 313 return ret;
322 } 314 }
323 if (!ret) { 315 if (!ret) {
324 delete m_pCurBitmap; 316 delete m_pCurBitmap;
325 m_pCurBitmap = nullptr; 317 m_pCurBitmap = nullptr;
326 return 0; 318 return 0;
327 } 319 }
328 ContinueGetCachedBitmap(); 320 ContinueGetCachedBitmap();
329 return 0; 321 return 0;
330 } 322 }
331 void CPDF_ImageCacheEntry::CalcSize() { 323 void CPDF_ImageCacheEntry::CalcSize() {
332 m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap) + 324 m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap) +
333 FPDF_ImageCache_EstimateImageSize(m_pCachedMask); 325 FPDF_ImageCache_EstimateImageSize(m_pCachedMask);
334 } 326 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698