1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FPDFAPI_RENDER_CPDF_PAGERENDERCACHE_H_ 8 #define CORE_FPDFAPI_RENDER_CPDF_PAGERENDERCACHE_H_ 9 10 #include <map> 11 #include <memory> 12 13 #include "core/fpdfapi/page/cpdf_page.h" 14 #include "core/fxcrt/fx_system.h" 15 #include "core/fxcrt/maybe_owned.h" 16 #include "core/fxcrt/retain_ptr.h" 17 #include "core/fxcrt/unowned_ptr.h" 18 19 class CPDF_Image; 20 class CPDF_ImageCacheEntry; 21 class CPDF_Page; 22 class CPDF_RenderStatus; 23 class CPDF_Stream; 24 class PauseIndicatorIface; 25 26 class CPDF_PageRenderCache : public CPDF_Page::RenderCacheIface { 27 public: 28 explicit CPDF_PageRenderCache(CPDF_Page* pPage); 29 ~CPDF_PageRenderCache() override; 30 31 // CPDF_Page::RenderCacheIface: 32 void ResetBitmapForImage(const RetainPtr<CPDF_Image>& pImage) override; 33 34 void CacheOptimization(int32_t dwLimitCacheSize); GetTimeCount()35 uint32_t GetTimeCount() const { return m_nTimeCount; } GetPage()36 CPDF_Page* GetPage() const { return m_pPage.Get(); } GetCurImageCacheEntry()37 CPDF_ImageCacheEntry* GetCurImageCacheEntry() const { 38 return m_pCurImageCacheEntry.Get(); 39 } 40 41 bool StartGetCachedBitmap(const RetainPtr<CPDF_Image>& pImage, 42 bool bStdCS, 43 uint32_t GroupFamily, 44 bool bLoadMask, 45 CPDF_RenderStatus* pRenderStatus); 46 47 bool Continue(PauseIndicatorIface* pPause, CPDF_RenderStatus* pRenderStatus); 48 49 private: 50 void ClearImageCacheEntry(CPDF_Stream* pStream); 51 52 UnownedPtr<CPDF_Page> const m_pPage; 53 std::map<CPDF_Stream*, std::unique_ptr<CPDF_ImageCacheEntry>> m_ImageCache; 54 MaybeOwned<CPDF_ImageCacheEntry> m_pCurImageCacheEntry; 55 uint32_t m_nTimeCount = 0; 56 uint32_t m_nCacheSize = 0; 57 bool m_bCurFindCache = false; 58 }; 59 60 #endif // CORE_FPDFAPI_RENDER_CPDF_PAGERENDERCACHE_H_ 61