• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_IMAGECACHEENTRY_H_
8 #define CORE_FPDFAPI_RENDER_CPDF_IMAGECACHEENTRY_H_
9 
10 #include "core/fpdfapi/page/cpdf_dib.h"
11 #include "core/fxcrt/fx_system.h"
12 #include "core/fxcrt/retain_ptr.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 
15 class CPDF_Dictionary;
16 class CPDF_Document;
17 class CPDF_Image;
18 class CPDF_RenderStatus;
19 class PauseIndicatorIface;
20 
21 class CPDF_ImageCacheEntry {
22  public:
23   CPDF_ImageCacheEntry(CPDF_Document* pDoc,
24                        const RetainPtr<CPDF_Image>& pImage);
25   ~CPDF_ImageCacheEntry();
26 
27   void Reset();
EstimateSize()28   uint32_t EstimateSize() const { return m_dwCacheSize; }
GetTimeCount()29   uint32_t GetTimeCount() const { return m_dwTimeCount; }
GetImage()30   CPDF_Image* GetImage() const { return m_pImage.Get(); }
31 
32   CPDF_DIB::LoadState StartGetCachedBitmap(
33       const CPDF_Dictionary* pFormResources,
34       CPDF_Dictionary* pPageResources,
35       bool bStdCS,
36       uint32_t GroupFamily,
37       bool bLoadMask,
38       CPDF_RenderStatus* pRenderStatus);
39 
40   // Returns whether to Continue() or not.
41   bool Continue(PauseIndicatorIface* pPause, CPDF_RenderStatus* pRenderStatus);
42 
43   RetainPtr<CFX_DIBBase> DetachBitmap();
44   RetainPtr<CFX_DIBBase> DetachMask();
45 
46   int m_dwTimeCount = 0;
47   uint32_t m_MatteColor = 0;
48 
49  private:
50   void ContinueGetCachedBitmap(CPDF_RenderStatus* pRenderStatus);
51   void CalcSize();
52 
53   UnownedPtr<CPDF_Document> const m_pDocument;
54   RetainPtr<CPDF_Image> const m_pImage;
55   RetainPtr<CFX_DIBBase> m_pCurBitmap;
56   RetainPtr<CFX_DIBBase> m_pCurMask;
57   RetainPtr<CFX_DIBBase> m_pCachedBitmap;
58   RetainPtr<CFX_DIBBase> m_pCachedMask;
59   uint32_t m_dwCacheSize = 0;
60 };
61 
62 #endif  // CORE_FPDFAPI_RENDER_CPDF_IMAGECACHEENTRY_H_
63