xref: /aosp_15_r20/external/pdfium/core/fpdfapi/page/cpdf_imageloader.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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_IMAGELOADER_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_IMAGELOADER_H_
9 
10 #include "core/fpdfapi/page/cpdf_colorspace.h"
11 #include "core/fxcrt/retain_ptr.h"
12 #include "core/fxcrt/unowned_ptr.h"
13 
14 class CFX_DIBBase;
15 class CPDF_Dictionary;
16 class CPDF_ImageObject;
17 class CPDF_PageImageCache;
18 class CPDF_TransferFunc;
19 class PauseIndicatorIface;
20 
21 class CPDF_ImageLoader {
22  public:
23   CPDF_ImageLoader();
24   ~CPDF_ImageLoader();
25 
26   bool Start(const CPDF_ImageObject* pImage,
27              CPDF_PageImageCache* pPageImageCache,
28              const CPDF_Dictionary* pFormResource,
29              const CPDF_Dictionary* pPageResource,
30              bool bStdCS,
31              CPDF_ColorSpace::Family eFamily,
32              bool bLoadMask,
33              const CFX_Size& max_size_required);
34   bool Continue(PauseIndicatorIface* pPause);
35 
36   RetainPtr<CFX_DIBBase> TranslateImage(
37       RetainPtr<CPDF_TransferFunc> pTransferFunc);
38 
GetBitmap()39   const RetainPtr<CFX_DIBBase>& GetBitmap() const { return m_pBitmap; }
GetMask()40   const RetainPtr<CFX_DIBBase>& GetMask() const { return m_pMask; }
MatteColor()41   uint32_t MatteColor() const { return m_MatteColor; }
42 
43  private:
44   void HandleFailure();
45 
46   uint32_t m_MatteColor = 0;
47   bool m_bCached = false;
48   RetainPtr<CFX_DIBBase> m_pBitmap;
49   RetainPtr<CFX_DIBBase> m_pMask;
50   UnownedPtr<CPDF_PageImageCache> m_pCache;
51   UnownedPtr<const CPDF_ImageObject> m_pImageObject;
52 };
53 
54 #endif  // CORE_FPDFAPI_PAGE_CPDF_IMAGELOADER_H_
55