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
cfx_renderdevice.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_FXGE_CFX_RENDERDEVICE_H_
8#define CORE_FXGE_CFX_RENDERDEVICE_H_
9
10#include <memory>
11#include <vector>
12
13#include "build/build_config.h"
14#include "core/fxcrt/fx_coordinates.h"
15#include "core/fxcrt/retain_ptr.h"
16#include "core/fxcrt/unowned_ptr.h"
17#include "core/fxge/cfx_path.h"
18#include "core/fxge/dib/fx_dib.h"
19#include "core/fxge/render_defines.h"
20#include "core/fxge/renderdevicedriver_iface.h"
21#include "third_party/base/containers/span.h"
22
23class CFX_DIBBase;
24class CFX_DIBitmap;
25class CFX_Font;
29class TextCharPos;
30struct CFX_Color;
33
35
36// Base class for all render devices. Derived classes must call
37// SetDeviceDriver() to fully initialize the class. Until then, class methods
38// are not safe to call, or may return invalid results.
40 public:
42 public:
43 explicit StateRestorer(CFX_RenderDevice* pDevice);
45
46 private:
48 };
49
50 virtual ~CFX_RenderDevice();
51
52 static CFX_Matrix GetFlipMatrix(float width,
53 float height,
54 float left,
55 float top);
56
57 void SaveState();
58 void RestoreState(bool bKeepSaved);
59
60 int GetWidth() const { return m_Width; }
61 int GetHeight() const { return m_Height; }
62 DeviceType GetDeviceType() const { return m_DeviceType; }
63 int GetRenderCaps() const { return m_RenderCaps; }
64 int GetDeviceCaps(int id) const;
65 RetainPtr<CFX_DIBitmap> GetBitmap();
66 RetainPtr<const CFX_DIBitmap> GetBitmap() const;
67 [[nodiscard]] bool CreateCompatibleBitmap(const RetainPtr<CFX_DIBitmap>& pDIB,
68 int width,
69 int height) const;
70 const FX_RECT& GetClipBox() const { return m_ClipBox; }
71 void SetBaseClip(const FX_RECT& rect);
72 bool SetClip_PathFill(const CFX_Path& path,
73 const CFX_Matrix* pObject2Device,
74 const CFX_FillRenderOptions& fill_options);
75 bool SetClip_PathStroke(const CFX_Path& path,
76 const CFX_Matrix* pObject2Device,
77 const CFX_GraphStateData* pGraphState);
78 bool SetClip_Rect(const FX_RECT& pRect);
79 bool DrawPath(const CFX_Path& path,
80 const CFX_Matrix* pObject2Device,
81 const CFX_GraphStateData* pGraphState,
82 uint32_t fill_color,
83 uint32_t stroke_color,
84 const CFX_FillRenderOptions& fill_options);
85 bool DrawPathWithBlend(const CFX_Path& path,
86 const CFX_Matrix* pObject2Device,
87 const CFX_GraphStateData* pGraphState,
88 uint32_t fill_color,
89 uint32_t stroke_color,
90 const CFX_FillRenderOptions& fill_options,
91 BlendMode blend_type);
92 bool FillRect(const FX_RECT& rect, uint32_t color) {
93 return FillRectWithBlend(rect, color, BlendMode::kNormal);
94 }
95
96 RetainPtr<CFX_DIBitmap> GetBackDrop();
97 bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, int left, int top);
98 bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
99 int left,
100 int top) {
101 return SetDIBitsWithBlend(pBitmap, left, top, BlendMode::kNormal);
102 }
103 bool SetDIBitsWithBlend(const RetainPtr<const CFX_DIBBase>& pBitmap,
104 int left,
105 int top,
106 BlendMode blend_mode);
107 bool StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
108 int left,
109 int top,
110 int dest_width,
111 int dest_height);
113 int left,
114 int top,
115 int dest_width,
116 int dest_height,
117 const FXDIB_ResampleOptions& options,
118 BlendMode blend_mode);
119 bool SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
120 int left,
121 int top,
122 uint32_t argb);
124 int left,
125 int top,
126 int dest_width,
127 int dest_height,
128 uint32_t color);
130 int left,
131 int top,
132 int dest_width,
133 int dest_height,
134 uint32_t argb,
135 const FXDIB_ResampleOptions& options);
136 bool StartDIBits(RetainPtr<const CFX_DIBBase> bitmap,
137 float alpha,
138 uint32_t argb,
139 const CFX_Matrix& matrix,
140 const FXDIB_ResampleOptions& options,
141 std::unique_ptr<CFX_ImageRenderer>* handle);
142 bool StartDIBitsWithBlend(RetainPtr<const CFX_DIBBase> bitmap,
143 float alpha,
144 uint32_t argb,
145 const CFX_Matrix& matrix,
146 const FXDIB_ResampleOptions& options,
147 std::unique_ptr<CFX_ImageRenderer>* handle,
148 BlendMode blend_mode);
150
151 bool DrawNormalText(pdfium::span<const TextCharPos> pCharPos,
152 CFX_Font* pFont,
153 float font_size,
154 const CFX_Matrix& mtText2Device,
155 uint32_t fill_color,
156 const CFX_TextRenderOptions& options);
157 bool DrawTextPath(pdfium::span<const TextCharPos> pCharPos,
158 CFX_Font* pFont,
159 float font_size,
160 const CFX_Matrix& mtText2User,
161 const CFX_Matrix* pUser2Device,
162 const CFX_GraphStateData* pGraphState,
163 uint32_t fill_color,
164 uint32_t stroke_color,
165 CFX_Path* pClippingPath,
166 const CFX_FillRenderOptions& fill_options);
167
168 void DrawFillRect(const CFX_Matrix* pUser2Device,
169 const CFX_FloatRect& rect,
170 const CFX_Color& color,
171 int32_t nTransparency);
172 void DrawFillRect(const CFX_Matrix* pUser2Device,
173 const CFX_FloatRect& rect,
174 const FX_COLORREF& color);
175 void DrawStrokeRect(const CFX_Matrix& mtUser2Device,
176 const CFX_FloatRect& rect,
177 const FX_COLORREF& color,
178 float fWidth);
179 void DrawStrokeLine(const CFX_Matrix* pUser2Device,
180 const CFX_PointF& ptMoveTo,
181 const CFX_PointF& ptLineTo,
182 const FX_COLORREF& color,
183 float fWidth);
184 void DrawBorder(const CFX_Matrix* pUser2Device,
185 const CFX_FloatRect& rect,
186 float fWidth,
187 const CFX_Color& color,
188 const CFX_Color& crLeftTop,
189 const CFX_Color& crRightBottom,
190 BorderStyle nStyle,
191 int32_t nTransparency);
192 void DrawFillArea(const CFX_Matrix& mtUser2Device,
193 const std::vector<CFX_PointF>& points,
194 const FX_COLORREF& color);
195 void DrawShadow(const CFX_Matrix& mtUser2Device,
196 const CFX_FloatRect& rect,
197 int32_t nTransparency,
198 int32_t nStartGray,
199 int32_t nEndGray);
200 bool DrawShading(const CPDF_ShadingPattern* pPattern,
201 const CFX_Matrix* pMatrix,
202 const FX_RECT& clip_rect,
203 int alpha,
204 bool bAlphaMode);
205
206 // Multiplies the device by a constant alpha, returning `true` on success.
207 bool MultiplyAlpha(float alpha);
208
209 // Multiplies the device by an alpha mask, returning `true` on success.
210 bool MultiplyAlphaMask(const RetainPtr<const CFX_DIBBase>& mask);
211
212#if defined(PDF_USE_SKIA)
215 int left,
216 int top,
217 float alpha,
219 bool SyncInternalBitmaps();
220#endif
221
222 protected:
224
225 void SetBitmap(RetainPtr<CFX_DIBitmap> bitmap);
226
227 void SetDeviceDriver(std::unique_ptr<RenderDeviceDriverIface> pDriver);
229 return m_pDeviceDriver.get();
230 }
231
232 private:
233 void InitDeviceInfo();
234 void UpdateClipBox();
235 bool DrawFillStrokePath(const CFX_Path& path,
236 const CFX_Matrix* pObject2Device,
237 const CFX_GraphStateData* pGraphState,
238 uint32_t fill_color,
239 uint32_t stroke_color,
240 const CFX_FillRenderOptions& fill_options,
241 BlendMode blend_type);
242 bool DrawCosmeticLine(const CFX_PointF& ptMoveTo,
243 const CFX_PointF& ptLineTo,
244 uint32_t color,
245 const CFX_FillRenderOptions& fill_options,
246 BlendMode blend_type);
247 void DrawZeroAreaPath(const std::vector<CFX_Path::Point>& path,
248 const CFX_Matrix* matrix,
249 bool adjust,
250 bool aliased_path,
251 uint32_t fill_color,
252 uint8_t fill_alpha,
253 BlendMode blend_type);
254 bool FillRectWithBlend(const FX_RECT& rect,
255 uint32_t color,
256 BlendMode blend_type);
257
258 RetainPtr<CFX_DIBitmap> m_pBitmap;
259 int m_Width = 0;
260 int m_Height = 0;
261 int m_bpp = 0;
262 int m_RenderCaps = 0;
263 DeviceType m_DeviceType = DeviceType::kDisplay;
264 FX_RECT m_ClipBox;
265 std::unique_ptr<RenderDeviceDriverIface> m_pDeviceDriver;
266};
267
268#endif // CORE_FXGE_CFX_RENDERDEVICE_H_
BorderStyle
bool Create(int width, int height, FXDIB_Format format, RetainPtr< CFX_DIBitmap > pBackdropBitmap)
bool Attach(RetainPtr< CFX_DIBitmap > pBitmap)
~CFX_DefaultRenderDevice() override
bool AttachWithBackdropAndGroupKnockout(RetainPtr< CFX_DIBitmap > pBitmap, RetainPtr< CFX_DIBitmap > pBackdropBitmap, bool bGroupKnockout)
bool AttachWithRgbByteOrder(RetainPtr< CFX_DIBitmap > pBitmap, bool bRgbByteOrder)
StateRestorer(CFX_RenderDevice *pDevice)
void DrawBorder(const CFX_Matrix *pUser2Device, const CFX_FloatRect &rect, float fWidth, const CFX_Color &color, const CFX_Color &crLeftTop, const CFX_Color &crRightBottom, BorderStyle nStyle, int32_t nTransparency)
bool StretchBitMask(RetainPtr< CFX_DIBBase > bitmap, int left, int top, int dest_width, int dest_height, uint32_t color)
bool MultiplyAlpha(float alpha)
bool DrawTextPath(pdfium::span< const TextCharPos > pCharPos, CFX_Font *pFont, float font_size, const CFX_Matrix &mtText2User, const CFX_Matrix *pUser2Device, const CFX_GraphStateData *pGraphState, uint32_t fill_color, uint32_t stroke_color, CFX_Path *pClippingPath, const CFX_FillRenderOptions &fill_options)
bool SetClip_Rect(const FX_RECT &pRect)
bool SetClip_PathFill(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_FillRenderOptions &fill_options)
bool StretchDIBits(RetainPtr< const CFX_DIBBase > bitmap, int left, int top, int dest_width, int dest_height)
bool SetClip_PathStroke(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState)
RenderDeviceDriverIface * GetDeviceDriver() const
void SetBaseClip(const FX_RECT &rect)
bool GetDIBits(const RetainPtr< CFX_DIBitmap > &pBitmap, int left, int top)
bool FillRect(const FX_RECT &rect, uint32_t color)
bool StretchDIBitsWithFlagsAndBlend(RetainPtr< const CFX_DIBBase > bitmap, int left, int top, int dest_width, int dest_height, const FXDIB_ResampleOptions &options, BlendMode blend_mode)
bool MultiplyAlphaMask(const RetainPtr< const CFX_DIBBase > &mask)
bool ContinueDIBits(CFX_ImageRenderer *handle, PauseIndicatorIface *pPause)
void DrawFillRect(const CFX_Matrix *pUser2Device, const CFX_FloatRect &rect, const FX_COLORREF &color)
RetainPtr< const CFX_DIBitmap > GetBitmap() const
void SetDeviceDriver(std::unique_ptr< RenderDeviceDriverIface > pDriver)
bool DrawShading(const CPDF_ShadingPattern *pPattern, const CFX_Matrix *pMatrix, const FX_RECT &clip_rect, int alpha, bool bAlphaMode)
static CFX_Matrix GetFlipMatrix(float width, float height, float left, float top)
void DrawFillArea(const CFX_Matrix &mtUser2Device, const std::vector< CFX_PointF > &points, const FX_COLORREF &color)
bool StartDIBits(RetainPtr< const CFX_DIBBase > bitmap, float alpha, uint32_t argb, const CFX_Matrix &matrix, const FXDIB_ResampleOptions &options, std::unique_ptr< CFX_ImageRenderer > *handle)
bool StretchBitMaskWithFlags(RetainPtr< CFX_DIBBase > bitmap, int left, int top, int dest_width, int dest_height, uint32_t argb, const FXDIB_ResampleOptions &options)
bool DrawPath(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions &fill_options)
RetainPtr< CFX_DIBitmap > GetBackDrop()
void SetBitmap(RetainPtr< CFX_DIBitmap > bitmap)
void DrawShadow(const CFX_Matrix &mtUser2Device, const CFX_FloatRect &rect, int32_t nTransparency, int32_t nStartGray, int32_t nEndGray)
bool SetDIBitsWithBlend(const RetainPtr< const CFX_DIBBase > &pBitmap, int left, int top, BlendMode blend_mode)
void DrawStrokeLine(const CFX_Matrix *pUser2Device, const CFX_PointF &ptMoveTo, const CFX_PointF &ptLineTo, const FX_COLORREF &color, float fWidth)
bool StartDIBitsWithBlend(RetainPtr< const CFX_DIBBase > bitmap, float alpha, uint32_t argb, const CFX_Matrix &matrix, const FXDIB_ResampleOptions &options, std::unique_ptr< CFX_ImageRenderer > *handle, BlendMode blend_mode)
int GetRenderCaps() const
bool DrawNormalText(pdfium::span< const TextCharPos > pCharPos, CFX_Font *pFont, float font_size, const CFX_Matrix &mtText2Device, uint32_t fill_color, const CFX_TextRenderOptions &options)
bool DrawPathWithBlend(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions &fill_options, BlendMode blend_type)
void DrawStrokeRect(const CFX_Matrix &mtUser2Device, const CFX_FloatRect &rect, const FX_COLORREF &color, float fWidth)
RetainPtr< CFX_DIBitmap > GetBitmap()
int GetHeight() const
const FX_RECT & GetClipBox() const
int GetDeviceCaps(int id) const
void RestoreState(bool bKeepSaved)
bool SetDIBits(const RetainPtr< const CFX_DIBBase > &pBitmap, int left, int top)
bool CreateCompatibleBitmap(const RetainPtr< CFX_DIBitmap > &pDIB, int width, int height) const
DeviceType GetDeviceType() const
bool SetBitMask(const RetainPtr< CFX_DIBBase > &pBitmap, int left, int top, uint32_t argb)
void DrawFillRect(const CFX_Matrix *pUser2Device, const CFX_FloatRect &rect, const CFX_Color &color, int32_t nTransparency)
void VerifySavedHelloWorldDocumentWithPassword(const char *password)
void VerifySavedModifiedHelloWorldDocumentWithPassword(const char *password)
void OpenAndVerifyHelloWorldDocumentWithPassword(const char *filename, const char *password)
RetainPtr< CPDF_Object > RemoveFor(ByteStringView key)
CPDF_Parser * GetParser() const
CPDF_Dictionary * GetMutableTrailerForTesting()
FPDF_DOCUMENT OpenSavedDocumentWithPassword(const char *password)
void CloseSavedDocument()
static void CompareBitmap(FPDF_BITMAP bitmap, int expected_width, int expected_height, const char *expected_md5sum)
void UnloadPage(FPDF_PAGE page)
FPDF_DOCUMENT document() const
void CloseSavedPage(FPDF_PAGE page)
FPDF_PAGE LoadPage(int page_number)
FPDF_PAGE LoadSavedPage(int page_number)
TEST_F(CPDFSecurityHandlerEmbedderTest, Unencrypted)
#define FPDF_FILLMODE_ALTERNATE
Definition fpdf_edit.h:52
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, int fillmode, FPDF_BOOL stroke)
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_object)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object, unsigned int R, unsigned int G, unsigned int B, unsigned int A)
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x, float y, float w, float h)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page)
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_LoadCustomDocument(FPDF_FILEACCESS *pFileAccess, FPDF_BYTESTRING password)
BlendMode
Definition fx_dib.h:49
FXDIB_Format
Definition fx_dib.h:19
const char * HelloWorldChecksum()
const char * HelloWorldRemovedChecksum()