• 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_RENDERSTATUS_H_
8 #define CORE_FPDFAPI_RENDER_CPDF_RENDERSTATUS_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "core/fpdfapi/page/cpdf_clippath.h"
14 #include "core/fpdfapi/page/cpdf_graphicstates.h"
15 #include "core/fpdfapi/render/cpdf_renderoptions.h"
16 #include "core/fxge/cfx_renderdevice.h"
17 
18 class CFX_PathData;
19 class CPDF_Color;
20 class CPDF_Dictionary;
21 class CPDF_Font;
22 class CPDF_FormObject;
23 class CPDF_ImageCacheEntry;
24 class CPDF_ImageObject;
25 class CPDF_ImageRenderer;
26 class CPDF_Object;
27 class CPDF_PageObject;
28 class CPDF_PageObjectHolder;
29 class CPDF_PathObject;
30 class CPDF_ShadingObject;
31 class CPDF_ShadingPattern;
32 class CPDF_TilingPattern;
33 class CPDF_TransferFunc;
34 class CPDF_Type3Cache;
35 class CPDF_Type3Char;
36 class CPDF_Type3Font;
37 
38 class CPDF_RenderStatus {
39  public:
40   CPDF_RenderStatus();
41   ~CPDF_RenderStatus();
42 
43   bool Initialize(class CPDF_RenderContext* pContext,
44                   CFX_RenderDevice* pDevice,
45                   const CFX_Matrix* pDeviceMatrix,
46                   const CPDF_PageObject* pStopObj,
47                   const CPDF_RenderStatus* pParentStatus,
48                   const CPDF_GraphicStates* pInitialStates,
49                   const CPDF_RenderOptions* pOptions,
50                   int transparency,
51                   bool bDropObjects,
52                   CPDF_Dictionary* pFormResource = nullptr,
53                   bool bStdCS = false,
54                   CPDF_Type3Char* pType3Char = nullptr,
55                   FX_ARGB fill_color = 0,
56                   uint32_t GroupFamily = 0,
57                   bool bLoadMask = false);
58   void RenderObjectList(const CPDF_PageObjectHolder* pObjectHolder,
59                         const CFX_Matrix* pObj2Device);
60   void RenderSingleObject(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device);
61   bool ContinueSingleObject(CPDF_PageObject* pObj,
62                             const CFX_Matrix* pObj2Device,
63                             IFX_Pause* pPause);
GetContext()64   CPDF_RenderContext* GetContext() { return m_pContext; }
65 
66 #if defined _SKIA_SUPPORT_
67   void DebugVerifyDeviceIsPreMultiplied() const;
68 #endif
69 
70   CPDF_RenderOptions m_Options;
71   CPDF_Dictionary* m_pFormResource;
72   CPDF_Dictionary* m_pPageResource;
73   std::vector<CPDF_Type3Font*> m_Type3FontCache;
74 
75  private:
76   friend class CPDF_ImageRenderer;
77   friend class CPDF_RenderContext;
78 
79   void ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device);
80   bool ProcessTransparency(CPDF_PageObject* PageObj,
81                            const CFX_Matrix* pObj2Device);
82   void ProcessObjectNoClip(CPDF_PageObject* PageObj,
83                            const CFX_Matrix* pObj2Device);
84   void DrawObjWithBackground(CPDF_PageObject* pObj,
85                              const CFX_Matrix* pObj2Device);
86   bool DrawObjWithBlend(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device);
87   bool ProcessPath(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device);
88   void ProcessPathPattern(CPDF_PathObject* pPathObj,
89                           const CFX_Matrix* pObj2Device,
90                           int& filltype,
91                           bool& bStroke);
92   void DrawPathWithPattern(CPDF_PathObject* pPathObj,
93                            const CFX_Matrix* pObj2Device,
94                            const CPDF_Color* pColor,
95                            bool bStroke);
96   void DrawTilingPattern(CPDF_TilingPattern* pPattern,
97                          CPDF_PageObject* pPageObj,
98                          const CFX_Matrix* pObj2Device,
99                          bool bStroke);
100   void DrawShadingPattern(CPDF_ShadingPattern* pPattern,
101                           const CPDF_PageObject* pPageObj,
102                           const CFX_Matrix* pObj2Device,
103                           bool bStroke);
104   bool SelectClipPath(const CPDF_PathObject* pPathObj,
105                       const CFX_Matrix* pObj2Device,
106                       bool bStroke);
107   bool ProcessImage(CPDF_ImageObject* pImageObj, const CFX_Matrix* pObj2Device);
108   void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
109                          int left,
110                          int top,
111                          FX_ARGB mask_argb,
112                          int bitmap_alpha,
113                          int blend_mode,
114                          int bIsolated);
115   void ProcessShading(const CPDF_ShadingObject* pShadingObj,
116                       const CFX_Matrix* pObj2Device);
117   void DrawShading(CPDF_ShadingPattern* pPattern,
118                    CFX_Matrix* pMatrix,
119                    FX_RECT& clip_rect,
120                    int alpha,
121                    bool bAlphaMode);
122   bool ProcessType3Text(CPDF_TextObject* textobj,
123                         const CFX_Matrix* pObj2Device);
124   bool ProcessText(CPDF_TextObject* textobj,
125                    const CFX_Matrix* pObj2Device,
126                    CFX_PathData* pClippingPath);
127   void DrawTextPathWithPattern(const CPDF_TextObject* textobj,
128                                const CFX_Matrix* pObj2Device,
129                                CPDF_Font* pFont,
130                                FX_FLOAT font_size,
131                                const CFX_Matrix* pTextMatrix,
132                                bool bFill,
133                                bool bStroke);
134   bool ProcessForm(const CPDF_FormObject* pFormObj,
135                    const CFX_Matrix* pObj2Device);
136   std::unique_ptr<CFX_DIBitmap> GetBackdrop(const CPDF_PageObject* pObj,
137                                             const FX_RECT& rect,
138                                             int& left,
139                                             int& top,
140                                             bool bBackAlphaRequired);
141   std::unique_ptr<CFX_DIBitmap> LoadSMask(CPDF_Dictionary* pSMaskDict,
142                                           FX_RECT* pClipRect,
143                                           const CFX_Matrix* pMatrix);
144   static CPDF_Type3Cache* GetCachedType3(CPDF_Type3Font* pFont);
145   static CPDF_GraphicStates* CloneObjStates(const CPDF_GraphicStates* pPathObj,
146                                             bool bStroke);
147   CPDF_TransferFunc* GetTransferFunc(CPDF_Object* pObject) const;
148   FX_ARGB GetFillArgb(CPDF_PageObject* pObj, bool bType3 = false) const;
149   FX_ARGB GetStrokeArgb(CPDF_PageObject* pObj) const;
150   bool GetObjectClippedRect(const CPDF_PageObject* pObj,
151                             const CFX_Matrix* pObj2Device,
152                             bool bLogical,
153                             FX_RECT& rect) const;
154   void GetScaledMatrix(CFX_Matrix& matrix) const;
155 
156   static const int kRenderMaxRecursionDepth = 64;
157   static int s_CurrentRecursionDepth;
158 
159   CPDF_RenderContext* m_pContext;
160   bool m_bStopped;
161   CFX_RenderDevice* m_pDevice;
162   CFX_Matrix m_DeviceMatrix;
163   CPDF_ClipPath m_LastClipPath;
164   const CPDF_PageObject* m_pCurObj;
165   const CPDF_PageObject* m_pStopObj;
166   CPDF_GraphicStates m_InitialStates;
167   std::unique_ptr<CPDF_ImageRenderer> m_pImageRenderer;
168   bool m_bPrint;
169   int m_Transparency;
170   bool m_bDropObjects;
171   bool m_bStdCS;
172   uint32_t m_GroupFamily;
173   bool m_bLoadMask;
174   CPDF_Type3Char* m_pType3Char;
175   FX_ARGB m_T3FillColor;
176   int m_curBlend;
177 };
178 
179 #endif  // CORE_FPDFAPI_RENDER_CPDF_RENDERSTATUS_H_
180