Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_pageimagecache.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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_PAGE_CPDF_PAGEIMAGECACHE_H_
8#define CORE_FPDFAPI_PAGE_CPDF_PAGEIMAGECACHE_H_
9
10#include <stdint.h>
11
12#include <functional>
13#include <map>
14#include <memory>
15
16#include "core/fpdfapi/page/cpdf_dib.h"
17#include "core/fxcrt/maybe_owned.h"
18#include "core/fxcrt/retain_ptr.h"
19#include "core/fxcrt/unowned_ptr.h"
20
21class CPDF_Dictionary;
22class CPDF_Image;
23class CPDF_Page;
24class CPDF_Stream;
26
28 public:
29 explicit CPDF_PageImageCache(CPDF_Page* pPage);
31
32 void ResetBitmapForImage(RetainPtr<CPDF_Image> pImage);
33 void CacheOptimization(int32_t dwLimitCacheSize);
34 uint32_t GetTimeCount() const { return m_nTimeCount; }
35 CPDF_Page* GetPage() const { return m_pPage; }
36
37 bool StartGetCachedBitmap(RetainPtr<CPDF_Image> pImage,
38 const CPDF_Dictionary* pFormResources,
39 const CPDF_Dictionary* pPageResources,
40 bool bStdCS,
41 CPDF_ColorSpace::Family eFamily,
42 bool bLoadMask,
43 const CFX_Size& max_size_required);
44
45 bool Continue(PauseIndicatorIface* pPause);
46
47 uint32_t GetCurMatteColor() const;
50
51 private:
52 class Entry {
53 public:
54 explicit Entry(RetainPtr<CPDF_Image> pImage);
55 ~Entry();
56
57 void Reset();
58 uint32_t EstimateSize() const { return m_dwCacheSize; }
59 uint32_t GetMatteColor() const { return m_MatteColor; }
60 uint32_t GetTimeCount() const { return m_dwTimeCount; }
61 void SetTimeCount(uint32_t count) { m_dwTimeCount = count; }
62 CPDF_Image* GetImage() const { return m_pImage.Get(); }
63
64 CPDF_DIB::LoadState StartGetCachedBitmap(
65 CPDF_PageImageCache* pPageImageCache,
66 const CPDF_Dictionary* pFormResources,
67 const CPDF_Dictionary* pPageResources,
68 bool bStdCS,
69 CPDF_ColorSpace::Family eFamily,
70 bool bLoadMask,
71 const CFX_Size& max_size_required);
72
73 // Returns whether to Continue() or not.
74 bool Continue(PauseIndicatorIface* pPause,
75 CPDF_PageImageCache* pPageImageCache);
76
77 RetainPtr<CFX_DIBBase> DetachBitmap();
78 RetainPtr<CFX_DIBBase> DetachMask();
79
80 private:
81 void ContinueGetCachedBitmap(CPDF_PageImageCache* pPageImageCache);
82 void CalcSize();
83 bool IsCacheValid(const CFX_Size& max_size_required) const;
84
85 uint32_t m_dwTimeCount = 0;
86 uint32_t m_MatteColor = 0;
87 uint32_t m_dwCacheSize = 0;
88 RetainPtr<CPDF_Image> const m_pImage;
89 RetainPtr<CFX_DIBBase> m_pCurBitmap;
90 RetainPtr<CFX_DIBBase> m_pCurMask;
91 RetainPtr<CFX_DIBBase> m_pCachedBitmap;
92 RetainPtr<CFX_DIBBase> m_pCachedMask;
93 bool m_bCachedSetMaxSizeRequired = false;
94 };
95
96 void ClearImageCacheEntry(const CPDF_Stream* pStream);
97
98 UnownedPtr<CPDF_Page> const m_pPage;
101 MaybeOwned<Entry> m_pCurImageCacheEntry;
102 uint32_t m_nTimeCount = 0;
103 uint32_t m_nCacheSize = 0;
104 bool m_bCurFindCache = false;
105};
106
107#endif // CORE_FPDFAPI_PAGE_CPDF_PAGEIMAGECACHE_H_
void SetJpegImage(RetainPtr< IFX_SeekableReadStream > pFile)
bool Continue(PauseIndicatorIface *pPause)
RetainPtr< CFX_DIBBase > LoadDIBBase() const
void ResetCache(CPDF_Page *pPage)
RetainPtr< const CPDF_Dictionary > GetOC() const
RetainPtr< const CPDF_Stream > GetStream() const
~CPDF_Image() override
bool StartLoadDIBBase(const CPDF_Dictionary *pFormResource, const CPDF_Dictionary *pPageResource, bool bStdCS, CPDF_ColorSpace::Family GroupFamily, bool bLoadMask, const CFX_Size &max_size_required)
RetainPtr< const CPDF_Dictionary > GetDict() const
void SetJpegImageInline(RetainPtr< IFX_SeekableReadStream > pFile)
RetainPtr< CFX_DIBBase > DetachBitmap()
static bool IsValidJpegBitsPerComponent(int32_t bpc)
void SetImage(const RetainPtr< CFX_DIBitmap > &pBitmap)
RetainPtr< CPDF_DIB > CreateNewDIB() const
static bool IsValidJpegComponent(int32_t comps)
RetainPtr< CFX_DIBBase > DetachMask()
void ConvertStreamToIndirectObject()
CPDF_Page * GetPage() const
void ResetBitmapForImage(RetainPtr< CPDF_Image > pImage)
RetainPtr< CFX_DIBBase > DetachCurBitmap()
bool StartGetCachedBitmap(RetainPtr< CPDF_Image > pImage, const CPDF_Dictionary *pFormResources, const CPDF_Dictionary *pPageResources, bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size &max_size_required)
bool Continue(PauseIndicatorIface *pPause)
uint32_t GetCurMatteColor() const
void CacheOptimization(int32_t dwLimitCacheSize)
CPDF_PageImageCache(CPDF_Page *pPage)
RetainPtr< CFX_DIBBase > DetachCurMask()
uint32_t GetTimeCount() const
CPDF_PageImageCache * GetPageImageCache()
Definition cpdf_page.h:83
#define FXARGB_B(argb)
Definition fx_dib.h:127
#define FXARGB_G(argb)
Definition fx_dib.h:126
#define FXARGB_R(argb)
Definition fx_dib.h:125
FXDIB_Format
Definition fx_dib.h:19
const char kDecodeParms[]