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

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

Issue 2534953004: Return unique_ptrs from CFX_DIBitmap::Clone(). (Closed)
Patch Set: nits 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 | « core/fpdfapi/font/cpdf_type3char.cpp ('k') | core/fpdfapi/render/cpdf_imagerenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_imagecacheentry.h" 7 #include "core/fpdfapi/render/cpdf_imagecacheentry.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 16 matching lines...) Expand all
27 m_pStream(pStream), 27 m_pStream(pStream),
28 m_pCurBitmap(nullptr), 28 m_pCurBitmap(nullptr),
29 m_pCurMask(nullptr), 29 m_pCurMask(nullptr),
30 m_dwCacheSize(0) {} 30 m_dwCacheSize(0) {}
31 31
32 CPDF_ImageCacheEntry::~CPDF_ImageCacheEntry() {} 32 CPDF_ImageCacheEntry::~CPDF_ImageCacheEntry() {}
33 33
34 void CPDF_ImageCacheEntry::Reset(const CFX_DIBitmap* pBitmap) { 34 void CPDF_ImageCacheEntry::Reset(const CFX_DIBitmap* pBitmap) {
35 m_pCachedBitmap.reset(); 35 m_pCachedBitmap.reset();
36 if (pBitmap) 36 if (pBitmap)
37 m_pCachedBitmap = pdfium::WrapUnique<CFX_DIBSource>(pBitmap->Clone()); 37 m_pCachedBitmap = pBitmap->Clone();
38 CalcSize(); 38 CalcSize();
39 } 39 }
40 40
41 static uint32_t FPDF_ImageCache_EstimateImageSize(const CFX_DIBSource* pDIB) { 41 static uint32_t FPDF_ImageCache_EstimateImageSize(const CFX_DIBSource* pDIB) {
42 return pDIB && pDIB->GetBuffer() 42 return pDIB && pDIB->GetBuffer()
43 ? (uint32_t)pDIB->GetHeight() * pDIB->GetPitch() + 43 ? (uint32_t)pDIB->GetHeight() * pDIB->GetPitch() +
44 (uint32_t)pDIB->GetPaletteSize() * 4 44 (uint32_t)pDIB->GetPaletteSize() * 4
45 : 0; 45 : 0;
46 } 46 }
47 47
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return 0; 157 return 0;
158 } 158 }
159 ContinueGetCachedBitmap(); 159 ContinueGetCachedBitmap();
160 return 0; 160 return 0;
161 } 161 }
162 162
163 void CPDF_ImageCacheEntry::CalcSize() { 163 void CPDF_ImageCacheEntry::CalcSize() {
164 m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap.get()) + 164 m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap.get()) +
165 FPDF_ImageCache_EstimateImageSize(m_pCachedMask.get()); 165 FPDF_ImageCache_EstimateImageSize(m_pCachedMask.get());
166 } 166 }
OLDNEW
« no previous file with comments | « core/fpdfapi/font/cpdf_type3char.cpp ('k') | core/fpdfapi/render/cpdf_imagerenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698