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_renderstatus.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_RENDER_CPDF_RENDERSTATUS_H_
8#define CORE_FPDFAPI_RENDER_CPDF_RENDERSTATUS_H_
9
10#include <memory>
11#include <utility>
12#include <vector>
13
14#include "build/build_config.h"
15#include "core/fpdfapi/page/cpdf_clippath.h"
16#include "core/fpdfapi/page/cpdf_colorspace.h"
17#include "core/fpdfapi/page/cpdf_graphicstates.h"
18#include "core/fpdfapi/page/cpdf_transparency.h"
19#include "core/fpdfapi/parser/cpdf_dictionary.h"
20#include "core/fpdfapi/render/cpdf_renderoptions.h"
21#include "core/fxcrt/retain_ptr.h"
22#include "core/fxcrt/unowned_ptr.h"
23#include "core/fxge/dib/fx_dib.h"
24
25class CFX_DIBitmap;
26class CFX_Path;
28class CPDF_Color;
29class CPDF_Font;
30class CPDF_FormObject;
31class CPDF_ImageObject;
33class CPDF_Object;
34class CPDF_PageObject;
36class CPDF_PathObject;
38class CPDF_ShadingObject;
39class CPDF_ShadingPattern;
40class CPDF_TilingPattern;
41class CPDF_TransferFunc;
42class CPDF_Type3Char;
43class CPDF_Type3Font;
45
47 public:
50
51 // Called prior to Initialize().
52 void SetOptions(const CPDF_RenderOptions& options) { m_Options = options; }
53 void SetDeviceMatrix(const CFX_Matrix& matrix) { m_DeviceMatrix = matrix; }
54 void SetStopObject(const CPDF_PageObject* pStopObj) { m_pStopObj = pStopObj; }
56 m_pFormResource = std::move(pRes);
57 }
58 void SetType3Char(CPDF_Type3Char* pType3Char) { m_pType3Char = pType3Char; }
59 void SetFillColor(FX_ARGB color) { m_T3FillColor = color; }
60 void SetDropObjects(bool bDropObjects) { m_bDropObjects = bDropObjects; }
61 void SetLoadMask(bool bLoadMask) { m_bLoadMask = bLoadMask; }
62 void SetStdCS(bool bStdCS) { m_bStdCS = bStdCS; }
64 m_GroupFamily = family;
65 }
66 void SetTransparency(const CPDF_Transparency& transparency) {
67 m_Transparency = transparency;
68 }
69 void SetInGroup(bool bInGroup) { m_bInGroup = bInGroup; }
70
71 void Initialize(const CPDF_RenderStatus* pParentStatus,
72 const CPDF_GraphicStates* pInitialStates);
73
74 void RenderObjectList(const CPDF_PageObjectHolder* pObjectHolder,
75 const CFX_Matrix& mtObj2Device);
77 const CFX_Matrix& mtObj2Device);
79 const CFX_Matrix& mtObj2Device,
80 PauseIndicatorIface* pPause);
81 void ProcessClipPath(const CPDF_ClipPath& ClipPath,
82 const CFX_Matrix& mtObj2Device);
83
84 CPDF_ColorSpace::Family GetGroupFamily() const { return m_GroupFamily; }
85 bool GetLoadMask() const { return m_bLoadMask; }
86 bool GetDropObjects() const { return m_bDropObjects; }
87 bool IsPrint() const {
88#if BUILDFLAG(IS_WIN)
89 return m_bPrint;
90#else
91 return false;
92#endif
93 }
94 bool IsStopped() const { return m_bStopped; }
95 CPDF_RenderContext* GetContext() const { return m_pContext; }
97 return m_pFormResource.Get();
98 }
100 return m_pPageResource.Get();
101 }
102 CFX_RenderDevice* GetRenderDevice() const { return m_pDevice; }
103 const CPDF_RenderOptions& GetRenderOptions() const { return m_Options; }
104
105 RetainPtr<CPDF_TransferFunc> GetTransferFunc(
106 RetainPtr<const CPDF_Object> pObject) const;
107
110
111 void DrawTilingPattern(CPDF_TilingPattern* pattern,
112 CPDF_PageObject* pPageObj,
113 const CFX_Matrix& mtObj2Device,
114 bool stroke);
115 void DrawShadingPattern(CPDF_ShadingPattern* pattern,
116 const CPDF_PageObject* pPageObj,
117 const CFX_Matrix& mtObj2Device,
118 bool stroke);
119 // `pDIBitmap` must be non-null.
120 void CompositeDIBitmap(RetainPtr<CFX_DIBitmap> bitmap,
121 int left,
122 int top,
123 FX_ARGB mask_argb,
124 float alpha,
125 BlendMode blend_mode,
126 const CPDF_Transparency& transparency);
127
129 const CPDF_GraphicStates* pSrcStates,
130 bool stroke);
131
132 private:
133 bool ProcessTransparency(CPDF_PageObject* PageObj,
134 const CFX_Matrix& mtObj2Device);
135 void ProcessObjectNoClip(CPDF_PageObject* pObj,
136 const CFX_Matrix& mtObj2Device);
137 void DrawObjWithBackground(CPDF_PageObject* pObj,
138 const CFX_Matrix& mtObj2Device);
139 void DrawObjWithBackgroundToDevice(CPDF_PageObject* obj,
140 const CFX_Matrix& object_to_device,
141 CFX_RenderDevice* device,
142 const CFX_Matrix& device_matrix);
143 bool DrawObjWithBlend(CPDF_PageObject* pObj, const CFX_Matrix& mtObj2Device);
144 bool ProcessPath(CPDF_PathObject* path_obj, const CFX_Matrix& mtObj2Device);
145 void ProcessPathPattern(CPDF_PathObject* path_obj,
146 const CFX_Matrix& mtObj2Device,
148 bool* stroke);
149 void DrawPathWithPattern(CPDF_PathObject* path_obj,
150 const CFX_Matrix& mtObj2Device,
151 const CPDF_Color* pColor,
152 bool stroke);
153 bool ClipPattern(const CPDF_PageObject* page_obj,
154 const CFX_Matrix& mtObj2Device,
155 bool stroke);
156 bool SelectClipPath(const CPDF_PathObject* path_obj,
157 const CFX_Matrix& mtObj2Device,
158 bool stroke);
159 bool ProcessImage(CPDF_ImageObject* pImageObj,
160 const CFX_Matrix& mtObj2Device);
161 void ProcessShading(const CPDF_ShadingObject* pShadingObj,
162 const CFX_Matrix& mtObj2Device);
163 bool ProcessType3Text(CPDF_TextObject* textobj,
164 const CFX_Matrix& mtObj2Device);
165 bool ProcessText(CPDF_TextObject* textobj,
166 const CFX_Matrix& mtObj2Device,
167 CFX_Path* clipping_path);
168 void DrawTextPathWithPattern(const CPDF_TextObject* textobj,
169 const CFX_Matrix& mtObj2Device,
170 CPDF_Font* pFont,
171 float font_size,
172 const CFX_Matrix& mtTextMatrix,
173 bool fill,
174 bool stroke);
175 bool ProcessForm(const CPDF_FormObject* pFormObj,
176 const CFX_Matrix& mtObj2Device);
177 FX_RECT GetClippedBBox(const FX_RECT& rect) const;
178 RetainPtr<CFX_DIBitmap> GetBackdrop(const CPDF_PageObject* pObj,
179 const FX_RECT& bbox,
180 bool bBackAlphaRequired);
181 RetainPtr<CFX_DIBitmap> LoadSMask(CPDF_Dictionary* smask_dict,
182 const FX_RECT& clip_rect,
183 const CFX_Matrix& smask_matrix);
184 // Optionally write the colorspace family value into |pCSFamily|.
185 FX_ARGB GetBackgroundColor(const CPDF_Dictionary* pSMaskDict,
186 const CPDF_Dictionary* pGroupDict,
187 CPDF_ColorSpace::Family* pCSFamily);
188 FX_ARGB GetStrokeArgb(CPDF_PageObject* pObj) const;
189 FX_RECT GetObjectClippedRect(const CPDF_PageObject* pObj,
190 const CFX_Matrix& mtObj2Device) const;
191 // Returns the format that is compatible with `m_pDevice`.
192 FXDIB_Format GetCompatibleArgbFormat() const;
193
194 CPDF_RenderOptions m_Options;
195 RetainPtr<const CPDF_Dictionary> m_pFormResource;
196 RetainPtr<const CPDF_Dictionary> m_pPageResource;
197 std::vector<UnownedPtr<const CPDF_Type3Font>> m_Type3FontCache;
198 UnownedPtr<CPDF_RenderContext> const m_pContext;
199 UnownedPtr<CFX_RenderDevice> const m_pDevice;
200 CFX_Matrix m_DeviceMatrix;
201 CPDF_ClipPath m_LastClipPath;
202 UnownedPtr<const CPDF_PageObject> m_pCurObj;
203 UnownedPtr<const CPDF_PageObject> m_pStopObj;
204 CPDF_GraphicStates m_InitialStates;
205 std::unique_ptr<CPDF_ImageRenderer> m_pImageRenderer;
206 UnownedPtr<const CPDF_Type3Char> m_pType3Char;
207 CPDF_Transparency m_Transparency;
208 bool m_bStopped = false;
209#if BUILDFLAG(IS_WIN)
210 bool m_bPrint = false;
211#endif
212 bool m_bDropObjects = false;
213 bool m_bStdCS = false;
214 bool m_bLoadMask = false;
215 bool m_bInGroup = false;
217 FX_ARGB m_T3FillColor = 0;
218};
219
220#endif // CORE_FPDFAPI_RENDER_CPDF_RENDERSTATUS_H_
#define DCHECK
Definition check.h:33
#define CHECK_EQ(x, y)
Definition check_op.h:10
bool Attach(RetainPtr< CFX_DIBitmap > pBitmap)
bool Create(int width, int height, FXDIB_Format format)
FX_RECT GetOuterRect() const
CFX_Matrix & operator=(const CFX_Matrix &other)=default
void Translate(int32_t x, int32_t y)
CFX_FloatRect GetUnitRect() const
void Transform(const CFX_Matrix &matrix)
Definition cfx_path.cpp:393
void AppendRect(float left, float bottom, float right, float top)
Definition cfx_path.cpp:310
bool IsPattern() const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
static CPDF_DocPageData * FromDocument(const CPDF_Document *pDoc)
float GetStrokeAlpha() const
BlendMode GetBlendType() const
CPDF_ImageRenderer(CPDF_RenderStatus *pStatus)
bool Start(RetainPtr< CFX_DIBBase > pDIBBase, FX_ARGB bitmap_argb, const CFX_Matrix &mtImage2Device, const FXDIB_ResampleOptions &options, bool bStdCS)
bool Start(CPDF_ImageObject *pImageObject, const CFX_Matrix &mtObj2Device, bool bStdCS)
bool Continue(PauseIndicatorIface *pPause)
CPDF_Document * GetDocument() const override
Definition cpdf_page.cpp:51
const CFX_Matrix & GetMatrix() const
Layer(const Layer &that)
CPDF_PageObjectHolder * GetObjectHolder()
Layer(CPDF_PageObjectHolder *pHolder, const CFX_Matrix &matrix)
void AppendLayer(CPDF_PageObjectHolder *pObjectHolder, const CFX_Matrix &mtObject2Device)
CPDF_PageImageCache * GetPageCache() const
const CPDF_Dictionary * GetPageResources() const
CPDF_RenderContext(CPDF_Document *pDoc, RetainPtr< CPDF_Dictionary > pPageResources, CPDF_PageImageCache *pPageCache)
void GetBackgroundToDevice(CFX_RenderDevice *device, const CPDF_PageObject *object, const CPDF_RenderOptions *options, const CFX_Matrix &matrix)
CPDF_Document * GetDocument() const
Layer * GetLayer(uint32_t index)
RetainPtr< CPDF_Dictionary > GetMutablePageResources()
size_t CountLayers() const
void Render(CFX_RenderDevice *pDevice, const CPDF_PageObject *pStopObj, const CPDF_RenderOptions *pOptions, const CFX_Matrix *pLastMatrix)
const Options & GetOptions() const
bool CheckOCGDictVisible(const CPDF_Dictionary *pOC) const
bool ColorModeIs(Type mode) const
bool GetLoadMask() const
void SetDropObjects(bool bDropObjects)
const CPDF_RenderOptions & GetRenderOptions() const
void SetType3Char(CPDF_Type3Char *pType3Char)
RetainPtr< CPDF_TransferFunc > GetTransferFunc(RetainPtr< const CPDF_Object > pObject) const
void SetDeviceMatrix(const CFX_Matrix &matrix)
CPDF_RenderStatus(CPDF_RenderContext *pContext, CFX_RenderDevice *pDevice)
void SetFillColor(FX_ARGB color)
CPDF_RenderContext * GetContext() const
void SetOptions(const CPDF_RenderOptions &options)
void RenderSingleObject(CPDF_PageObject *pObj, const CFX_Matrix &mtObj2Device)
const CPDF_Dictionary * GetPageResource() const
bool ContinueSingleObject(CPDF_PageObject *pObj, const CFX_Matrix &mtObj2Device, PauseIndicatorIface *pPause)
CPDF_ColorSpace::Family GetGroupFamily() const
void SetTransparency(const CPDF_Transparency &transparency)
void RenderObjectList(const CPDF_PageObjectHolder *pObjectHolder, const CFX_Matrix &mtObj2Device)
void SetStdCS(bool bStdCS)
FX_ARGB GetFillArgbForType3(CPDF_PageObject *pObj) const
CFX_RenderDevice * GetRenderDevice() const
void SetGroupFamily(CPDF_ColorSpace::Family family)
void DrawShadingPattern(CPDF_ShadingPattern *pattern, const CPDF_PageObject *pPageObj, const CFX_Matrix &mtObj2Device, bool stroke)
void Initialize(const CPDF_RenderStatus *pParentStatus, const CPDF_GraphicStates *pInitialStates)
void DrawTilingPattern(CPDF_TilingPattern *pattern, CPDF_PageObject *pPageObj, const CFX_Matrix &mtObj2Device, bool stroke)
void SetInGroup(bool bInGroup)
static std::unique_ptr< CPDF_GraphicStates > CloneObjStates(const CPDF_GraphicStates *pSrcStates, bool stroke)
void SetFormResource(RetainPtr< const CPDF_Dictionary > pRes)
FX_ARGB GetFillArgb(CPDF_PageObject *pObj) const
void CompositeDIBitmap(RetainPtr< CFX_DIBitmap > bitmap, int left, int top, FX_ARGB mask_argb, float alpha, BlendMode blend_mode, const CPDF_Transparency &transparency)
void SetLoadMask(bool bLoadMask)
bool GetDropObjects() const
const CPDF_Dictionary * GetFormResource() const
void SetStopObject(const CPDF_PageObject *pStopObj)
void ProcessClipPath(const CPDF_ClipPath &ClipPath, const CFX_Matrix &mtObj2Device)
CPDF_Transparency & operator=(const CPDF_Transparency &other)
uint32_t FX_ARGB
Definition fx_dib.h:36
BlendMode
Definition fx_dib.h:119
@ kNormal
Definition fx_dib.h:120
@ kDarken
Definition fx_dib.h:124
#define FXARGB_B(argb)
Definition fx_dib.h:199
#define FXARGB_G(argb)
Definition fx_dib.h:198
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:188
#define FXARGB_R(argb)
Definition fx_dib.h:197
FXDIB_Format
Definition fx_dib.h:21
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
int FXSYS_roundf(float f)
#define CHECK(cvref)
int Height() const
int32_t bottom
bool Valid() const
int32_t right
int Width() const
int32_t top
int32_t left
bool IsEmpty() const