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/span.h"
17#include "core/fxcrt/unowned_ptr.h"
18#include "core/fxge/cfx_path.h"
19#include "core/fxge/dib/fx_dib.h"
20#include "core/fxge/render_defines.h"
21#include "core/fxge/renderdevicedriver_iface.h"
22
24class CFX_DIBBase;
25class CFX_DIBitmap;
26class 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 FillRect(const FX_RECT& rect, uint32_t color);
86
87 RetainPtr<const CFX_DIBitmap> GetBackDrop() const;
88 bool GetDIBits(RetainPtr<CFX_DIBitmap> bitmap, int left, int top) const;
89 bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap, int left, int top);
90 bool SetDIBitsWithBlend(RetainPtr<const CFX_DIBBase> bitmap,
91 int left,
92 int top,
93 BlendMode blend_mode);
94 bool StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
95 int left,
96 int top,
97 int dest_width,
98 int dest_height);
100 int left,
101 int top,
102 int dest_width,
103 int dest_height,
104 const FXDIB_ResampleOptions& options,
105 BlendMode blend_mode);
106 bool SetBitMask(RetainPtr<const CFX_DIBBase> bitmap,
107 int left,
108 int top,
109 uint32_t argb);
111 int left,
112 int top,
113 int dest_width,
114 int dest_height,
115 uint32_t color);
117 int left,
118 int top,
119 int dest_width,
120 int dest_height,
121 uint32_t argb,
122 const FXDIB_ResampleOptions& options);
124 RetainPtr<const CFX_DIBBase> bitmap,
125 float alpha,
126 uint32_t argb,
127 const CFX_Matrix& matrix,
128 const FXDIB_ResampleOptions& options);
130 RetainPtr<const CFX_DIBBase> bitmap,
131 float alpha,
132 uint32_t argb,
133 const CFX_Matrix& matrix,
134 const FXDIB_ResampleOptions& options,
135 BlendMode blend_mode);
137 PauseIndicatorIface* pPause);
138
139 bool DrawNormalText(pdfium::span<const TextCharPos> pCharPos,
140 CFX_Font* pFont,
141 float font_size,
142 const CFX_Matrix& mtText2Device,
143 uint32_t fill_color,
144 const CFX_TextRenderOptions& options);
145 bool DrawTextPath(pdfium::span<const TextCharPos> pCharPos,
146 CFX_Font* pFont,
147 float font_size,
148 const CFX_Matrix& mtText2User,
149 const CFX_Matrix* pUser2Device,
150 const CFX_GraphStateData* pGraphState,
151 uint32_t fill_color,
152 uint32_t stroke_color,
153 CFX_Path* pClippingPath,
154 const CFX_FillRenderOptions& fill_options);
155
156 void DrawFillRect(const CFX_Matrix* pUser2Device,
157 const CFX_FloatRect& rect,
158 const CFX_Color& color,
159 int32_t nTransparency);
160 void DrawFillRect(const CFX_Matrix* pUser2Device,
161 const CFX_FloatRect& rect,
162 const FX_COLORREF& color);
163 void DrawStrokeRect(const CFX_Matrix& mtUser2Device,
164 const CFX_FloatRect& rect,
165 const FX_COLORREF& color,
166 float fWidth);
167 void DrawStrokeLine(const CFX_Matrix* pUser2Device,
168 const CFX_PointF& ptMoveTo,
169 const CFX_PointF& ptLineTo,
170 const FX_COLORREF& color,
171 float fWidth);
172 void DrawBorder(const CFX_Matrix* pUser2Device,
173 const CFX_FloatRect& rect,
174 float fWidth,
175 const CFX_Color& color,
176 const CFX_Color& crLeftTop,
177 const CFX_Color& crRightBottom,
178 BorderStyle nStyle,
179 int32_t nTransparency);
180 void DrawFillArea(const CFX_Matrix& mtUser2Device,
181 const std::vector<CFX_PointF>& points,
182 const FX_COLORREF& color);
183 void DrawShadow(const CFX_Matrix& mtUser2Device,
184 const CFX_FloatRect& rect,
185 int32_t nTransparency,
186 int32_t nStartGray,
187 int32_t nEndGray);
188
189 // See RenderDeviceDriverIface methods of the same name.
190 bool MultiplyAlpha(float alpha);
191 bool MultiplyAlphaMask(RetainPtr<const CFX_DIBitmap> mask);
192
193#if defined(PDF_USE_SKIA)
195 const CFX_Matrix& matrix,
196 const FX_RECT& clip_rect,
197 int alpha);
200 int left,
201 int top,
202 float alpha,
204 void SyncInternalBitmaps();
205#endif // defined(PDF_USE_SKIA)
206
207 protected:
209
210 void SetBitmap(RetainPtr<CFX_DIBitmap> bitmap);
211
212 void SetDeviceDriver(std::unique_ptr<RenderDeviceDriverIface> pDriver);
214 return m_pDeviceDriver.get();
215 }
216
217 private:
218 void InitDeviceInfo();
219 void UpdateClipBox();
220 bool DrawFillStrokePath(const CFX_Path& path,
221 const CFX_Matrix* pObject2Device,
222 const CFX_GraphStateData* pGraphState,
223 uint32_t fill_color,
224 uint32_t stroke_color,
225 const CFX_FillRenderOptions& fill_options);
226 bool DrawCosmeticLine(const CFX_PointF& ptMoveTo,
227 const CFX_PointF& ptLineTo,
228 uint32_t color,
229 const CFX_FillRenderOptions& fill_options);
230 void DrawZeroAreaPath(const std::vector<CFX_Path::Point>& path,
231 const CFX_Matrix* matrix,
232 bool adjust,
233 bool aliased_path,
234 uint32_t fill_color,
235 uint8_t fill_alpha);
236
237 RetainPtr<CFX_DIBitmap> m_pBitmap;
238 int m_Width = 0;
239 int m_Height = 0;
240 int m_bpp = 0;
241 int m_RenderCaps = 0;
242 DeviceType m_DeviceType = DeviceType::kDisplay;
243 FX_RECT m_ClipBox;
244 std::unique_ptr<RenderDeviceDriverIface> m_pDeviceDriver;
245};
246
247#endif // CORE_FXGE_CFX_RENDERDEVICE_H_
BorderStyle
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)
bool CreateWithBackdrop(int width, int height, FXDIB_Format format, RetainPtr< CFX_DIBitmap > backdrop)
bool Create(int width, int height, FXDIB_Format format)
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
RetainPtr< const CFX_DIBitmap > GetBackDrop() const
void SetBaseClip(const FX_RECT &rect)
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(RetainPtr< const CFX_DIBitmap > mask)
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 SetDIBits(RetainPtr< const CFX_DIBBase > bitmap, int left, int top)
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 SetDIBitsWithBlend(RetainPtr< const CFX_DIBBase > bitmap, int left, int top, BlendMode blend_mode)
bool SetBitMask(RetainPtr< const CFX_DIBBase > bitmap, int left, int top, uint32_t argb)
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)
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)
RenderDeviceDriverIface::StartResult StartDIBits(RetainPtr< const CFX_DIBBase > bitmap, float alpha, uint32_t argb, const CFX_Matrix &matrix, const FXDIB_ResampleOptions &options)
void DrawStrokeLine(const CFX_Matrix *pUser2Device, const CFX_PointF &ptMoveTo, const CFX_PointF &ptLineTo, const FX_COLORREF &color, float fWidth)
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)
RenderDeviceDriverIface::StartResult StartDIBitsWithBlend(RetainPtr< const CFX_DIBBase > bitmap, float alpha, uint32_t argb, const CFX_Matrix &matrix, const FXDIB_ResampleOptions &options, BlendMode blend_mode)
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 CreateCompatibleBitmap(const RetainPtr< CFX_DIBitmap > &pDIB, int width, int height) const
DeviceType GetDeviceType() const
bool ContinueDIBits(CFX_AggImageRenderer *handle, PauseIndicatorIface *pPause)
void DrawFillRect(const CFX_Matrix *pUser2Device, const CFX_FloatRect &rect, const CFX_Color &color, int32_t nTransparency)
bool GetDIBits(RetainPtr< CFX_DIBitmap > bitmap, int left, int top) const
void VerifySavedHelloWorldDocumentWithPassword(const char *password)
void VerifySavedModifiedHelloWorldDocumentWithPassword(const char *password)
void OpenAndVerifyHelloWorldDocumentWithPassword(const char *filename, const char *password)
RetainPtr< CPDF_Object > RemoveFor(ByteStringView key)
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
CPDF_Parser * GetParser() const
CPDF_Dictionary * GetMutableTrailerForTesting()
FPDF_DOCUMENT OpenSavedDocumentWithPassword(const char *password)
void CloseSavedDocument()
FPDF_PAGE LoadPage(int page_index)
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 LoadSavedPage(int page_index)
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_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page, int index)
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)
CFX_PTemplate< float > CFX_PointF
BlendMode
Definition fx_dib.h:119
uint32_t FX_COLORREF
Definition fx_dib.h:42
FXDIB_Format
Definition fx_dib.h:21
const char * HelloWorldChecksum()
const char * HelloWorldRemovedChecksum()