| OLD | NEW |
| 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/fpdf_render/cpdf_pagerendercache.h" | 7 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 10 #include "core/fpdfapi/fpdf_page/pageint.h" | 10 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 12 #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" | 12 #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" |
| 13 #include "core/fpdfapi/fpdf_render/render_int.h" | 13 #include "core/fpdfapi/fpdf_render/render_int.h" |
| 14 #include "core/fxge/include/fx_ge.h" | 14 #include "core/fxge/include/fx_ge.h" |
| 15 | 15 |
| 16 struct CACHEINFO { | 16 struct CACHEINFO { |
| 17 uint32_t time; | 17 uint32_t time; |
| 18 CPDF_Stream* pStream; | 18 CPDF_Stream* pStream; |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 extern "C" { | 21 extern "C" { |
| 22 static int compare(const void* data1, const void* data2) { | 22 static int compare(const void* data1, const void* data2) { |
| 23 return ((CACHEINFO*)data1)->time - ((CACHEINFO*)data2)->time; | 23 return ((CACHEINFO*)data1)->time - ((CACHEINFO*)data2)->time; |
| 24 } | 24 } |
| 25 } // extern "C" | 25 } // extern "C" |
| 26 | 26 |
| 27 CPDF_PageRenderCache::CPDF_PageRenderCache(CPDF_Page* pPage) |
| 28 : m_pPage(pPage), |
| 29 m_pCurImageCacheEntry(nullptr), |
| 30 m_nTimeCount(0), |
| 31 m_nCacheSize(0), |
| 32 m_bCurFindCache(FALSE) {} |
| 33 |
| 27 CPDF_PageRenderCache::~CPDF_PageRenderCache() { | 34 CPDF_PageRenderCache::~CPDF_PageRenderCache() { |
| 28 for (const auto& it : m_ImageCache) | 35 for (const auto& it : m_ImageCache) |
| 29 delete it.second; | 36 delete it.second; |
| 30 } | 37 } |
| 31 void CPDF_PageRenderCache::CacheOptimization(int32_t dwLimitCacheSize) { | 38 void CPDF_PageRenderCache::CacheOptimization(int32_t dwLimitCacheSize) { |
| 32 if (m_nCacheSize <= (uint32_t)dwLimitCacheSize) | 39 if (m_nCacheSize <= (uint32_t)dwLimitCacheSize) |
| 33 return; | 40 return; |
| 34 | 41 |
| 35 size_t nCount = m_ImageCache.size(); | 42 size_t nCount = m_ImageCache.size(); |
| 36 CACHEINFO* pCACHEINFO = FX_Alloc(CACHEINFO, nCount); | 43 CACHEINFO* pCACHEINFO = FX_Alloc(CACHEINFO, nCount); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 m_pCurBitmap = nullptr; | 325 m_pCurBitmap = nullptr; |
| 319 return 0; | 326 return 0; |
| 320 } | 327 } |
| 321 ContinueGetCachedBitmap(); | 328 ContinueGetCachedBitmap(); |
| 322 return 0; | 329 return 0; |
| 323 } | 330 } |
| 324 void CPDF_ImageCacheEntry::CalcSize() { | 331 void CPDF_ImageCacheEntry::CalcSize() { |
| 325 m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap) + | 332 m_dwCacheSize = FPDF_ImageCache_EstimateImageSize(m_pCachedBitmap) + |
| 326 FPDF_ImageCache_EstimateImageSize(m_pCachedMask); | 333 FPDF_ImageCache_EstimateImageSize(m_pCachedMask); |
| 327 } | 334 } |
| OLD | NEW |