xref: /aosp_15_r20/external/pdfium/core/fpdfapi/render/cpdf_docrenderdata.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_RENDER_CPDF_DOCRENDERDATA_H_
8 #define CORE_FPDFAPI_RENDER_CPDF_DOCRENDERDATA_H_
9 
10 #include <functional>
11 #include <map>
12 
13 #include "build/build_config.h"
14 #include "core/fpdfapi/parser/cpdf_document.h"
15 #include "core/fxcrt/observed_ptr.h"
16 #include "core/fxcrt/retain_ptr.h"
17 
18 #if BUILDFLAG(IS_WIN)
19 #include <memory>
20 #endif
21 
22 class CPDF_Font;
23 class CPDF_Object;
24 class CPDF_TransferFunc;
25 class CPDF_Type3Cache;
26 class CPDF_Type3Font;
27 
28 #if BUILDFLAG(IS_WIN)
29 class CFX_PSFontTracker;
30 #endif
31 
32 class CPDF_DocRenderData : public CPDF_Document::RenderDataIface {
33  public:
34   static CPDF_DocRenderData* FromDocument(const CPDF_Document* pDoc);
35 
36   CPDF_DocRenderData();
37   ~CPDF_DocRenderData() override;
38 
39   CPDF_DocRenderData(const CPDF_DocRenderData&) = delete;
40   CPDF_DocRenderData& operator=(const CPDF_DocRenderData&) = delete;
41 
42   RetainPtr<CPDF_Type3Cache> GetCachedType3(CPDF_Type3Font* pFont);
43   RetainPtr<CPDF_TransferFunc> GetTransferFunc(
44       RetainPtr<const CPDF_Object> pObj);
45 
46 #if BUILDFLAG(IS_WIN)
47   CFX_PSFontTracker* GetPSFontTracker();
48 #endif
49 
50  protected:
51   // protected for use by test subclasses.
52   RetainPtr<CPDF_TransferFunc> CreateTransferFunc(
53       RetainPtr<const CPDF_Object> pObj) const;
54 
55  private:
56   // TODO(tsepez): investigate this map outliving its font keys.
57   std::map<CPDF_Font*, ObservedPtr<CPDF_Type3Cache>> m_Type3FaceMap;
58   std::map<RetainPtr<const CPDF_Object>,
59            ObservedPtr<CPDF_TransferFunc>,
60            std::less<>>
61       m_TransferFuncMap;
62 
63 #if BUILDFLAG(IS_WIN)
64   std::unique_ptr<CFX_PSFontTracker> m_PSFontTracker;
65 #endif
66 };
67 
68 #endif  // CORE_FPDFAPI_RENDER_CPDF_DOCRENDERDATA_H_
69