Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: xfa/include/fxgraphics/fx_graphics.h

Issue 1810563002: Move xfa/include/fxgraphics/fx_graphics.h to xfa/fxgraphics. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/include/fwl/lightwidget/theme.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 XFA_INCLUDE_FXGRAPHICS_FX_GRAPHICS_H_
8 #define XFA_INCLUDE_FXGRAPHICS_FX_GRAPHICS_H_
9
10 #include "core/include/fpdfapi/fpdf_pageobj.h"
11
12 typedef int FX_ERR;
13 #define FX_ERR_Succeeded 0
14 #define FX_ERR_Indefinite -1
15 #define FX_ERR_Parameter_Invalid -100
16 #define FX_ERR_Property_Invalid -200
17 #define FX_ERR_Intermediate_Value_Invalid -300
18 #define FX_ERR_Method_Not_Supported -400
19 #define FX_ERR_Out_Of_Memory -500
20
21 #define FX_SHADING_Steps 256
22 typedef int32_t FX_DashStyle;
23 enum {
24 FX_DASHSTYLE_Solid = 0,
25 FX_DASHSTYLE_Dash = 1,
26 FX_DASHSTYLE_Dot = 2,
27 FX_DASHSTYLE_DashDot = 3,
28 FX_DASHSTYLE_DashDotDot = 4
29 };
30 typedef int32_t FX_StrokeAlignment;
31 enum {
32 FX_STROKEALIGNMENT_Center = 0,
33 FX_STROKEALIGNMENT_Inset = 1,
34 FX_STROKEALIGNMENT_Outset = 2,
35 FX_STROKEALIGNMENT_Left = 3,
36 FX_STROKEALIGNMENT_Right = 4
37 };
38 typedef int32_t FX_HatchStyle;
39 enum {
40 FX_HATCHSTYLE_Horizontal = 0,
41 FX_HATCHSTYLE_Vertical = 1,
42 FX_HATCHSTYLE_ForwardDiagonal = 2,
43 FX_HATCHSTYLE_BackwardDiagonal = 3,
44 FX_HATCHSTYLE_Cross = 4,
45 FX_HATCHSTYLE_DiagonalCross = 5,
46 FX_HATCHSTYLE_05Percent = 6,
47 FX_HATCHSTYLE_10Percent = 7,
48 FX_HATCHSTYLE_20Percent = 8,
49 FX_HATCHSTYLE_25Percent = 9,
50 FX_HATCHSTYLE_30Percent = 10,
51 FX_HATCHSTYLE_40Percent = 11,
52 FX_HATCHSTYLE_50Percent = 12,
53 FX_HATCHSTYLE_60Percent = 13,
54 FX_HATCHSTYLE_70Percent = 14,
55 FX_HATCHSTYLE_75Percent = 15,
56 FX_HATCHSTYLE_80Percent = 16,
57 FX_HATCHSTYLE_90Percent = 17,
58 FX_HATCHSTYLE_LightDownwardDiagonal = 18,
59 FX_HATCHSTYLE_LightUpwardDiagonal = 19,
60 FX_HATCHSTYLE_DarkDownwardDiagonal = 20,
61 FX_HATCHSTYLE_DarkUpwardDiagonal = 21,
62 FX_HATCHSTYLE_WideDownwardDiagonal = 22,
63 FX_HATCHSTYLE_WideUpwardDiagonal = 23,
64 FX_HATCHSTYLE_LightVertical = 24,
65 FX_HATCHSTYLE_LightHorizontal = 25,
66 FX_HATCHSTYLE_NarrowVertical = 26,
67 FX_HATCHSTYLE_NarrowHorizontal = 27,
68 FX_HATCHSTYLE_DarkVertical = 28,
69 FX_HATCHSTYLE_DarkHorizontal = 29,
70 FX_HATCHSTYLE_DashedDownwardDiagonal = 30,
71 FX_HATCHSTYLE_DashedUpwardDiagonal = 31,
72 FX_HATCHSTYLE_DashedHorizontal = 32,
73 FX_HATCHSTYLE_DashedVertical = 33,
74 FX_HATCHSTYLE_SmallConfetti = 34,
75 FX_HATCHSTYLE_LargeConfetti = 35,
76 FX_HATCHSTYLE_ZigZag = 36,
77 FX_HATCHSTYLE_Wave = 37,
78 FX_HATCHSTYLE_DiagonalBrick = 38,
79 FX_HATCHSTYLE_HorizontalBrick = 39,
80 FX_HATCHSTYLE_Weave = 40,
81 FX_HATCHSTYLE_Plaid = 41,
82 FX_HATCHSTYLE_Divot = 42,
83 FX_HATCHSTYLE_DottedGrid = 43,
84 FX_HATCHSTYLE_DottedDiamond = 44,
85 FX_HATCHSTYLE_Shingle = 45,
86 FX_HATCHSTYLE_Trellis = 46,
87 FX_HATCHSTYLE_Sphere = 47,
88 FX_HATCHSTYLE_SmallGrid = 48,
89 FX_HATCHSTYLE_SmallCheckerBoard = 49,
90 FX_HATCHSTYLE_LargeCheckerBoard = 50,
91 FX_HATCHSTYLE_OutlinedDiamond = 51,
92 FX_HATCHSTYLE_SolidDiamond = 52
93 };
94 typedef int32_t FX_DeviceCap;
95 typedef int32_t FX_FillMode;
96 class CFX_RenderDevice;
97 class CFX_GraphStateData;
98 class CFX_Matrix;
99 class CFX_DIBSource;
100 class CFX_DIBitmap;
101 class CFX_Font;
102 class CFX_WideString;
103 class CFX_PathGenerator;
104 class CFX_Graphics;
105 class CFX_Color;
106 class CFX_Path;
107 class CFX_Pattern;
108 class CFX_Shading;
109
110 class CAGG_Graphics {
111 public:
112 CAGG_Graphics();
113 virtual ~CAGG_Graphics();
114
115 FX_ERR Create(CFX_Graphics* owner,
116 int32_t width,
117 int32_t height,
118 FXDIB_Format format);
119
120 private:
121 CFX_Graphics* m_owner;
122 };
123
124 class CFX_Graphics {
125 public:
126 CFX_Graphics();
127 virtual ~CFX_Graphics();
128
129 FX_ERR Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing = TRUE);
130 FX_ERR Create(int32_t width,
131 int32_t height,
132 FXDIB_Format format,
133 FX_BOOL isNative = TRUE,
134 FX_BOOL isAntialiasing = TRUE);
135
136 FX_ERR GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal);
137 FX_ERR IsPrinterDevice(FX_BOOL& isPrinter);
138 FX_ERR EnableAntialiasing(FX_BOOL isAntialiasing);
139
140 FX_ERR SaveGraphState();
141 FX_ERR RestoreGraphState();
142
143 FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap) const;
144 FX_ERR GetDashCount(int32_t& dashCount) const;
145 FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const;
146 FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const;
147 FX_ERR GetMiterLimit(FX_FLOAT& miterLimit) const;
148 FX_ERR GetLineWidth(FX_FLOAT& lineWidth) const;
149 FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const;
150 FX_ERR GetClipRect(CFX_RectF& rect) const;
151 CFX_Matrix* GetMatrix();
152 CFX_RenderDevice* GetRenderDevice();
153
154 FX_ERR SetLineCap(CFX_GraphStateData::LineCap lineCap);
155 FX_ERR SetLineDash(FX_FLOAT dashPhase,
156 FX_FLOAT* dashArray,
157 int32_t dashCount);
158 FX_ERR SetLineDash(FX_DashStyle dashStyle);
159 FX_ERR SetLineJoin(CFX_GraphStateData::LineJoin lineJoin);
160 FX_ERR SetMiterLimit(FX_FLOAT miterLimit);
161 FX_ERR SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE);
162 FX_ERR SetStrokeAlignment(FX_StrokeAlignment strokeAlignment);
163 FX_ERR SetStrokeColor(CFX_Color* color);
164 FX_ERR SetFillColor(CFX_Color* color);
165 FX_ERR SetClipRect(const CFX_RectF& rect);
166 FX_ERR SetFont(CFX_Font* font);
167 FX_ERR SetFontSize(const FX_FLOAT size);
168 FX_ERR SetFontHScale(const FX_FLOAT scale);
169 FX_ERR SetCharSpacing(const FX_FLOAT spacing);
170 FX_ERR SetTextDrawingMode(const int32_t mode);
171
172 FX_ERR StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL);
173 FX_ERR FillPath(CFX_Path* path,
174 FX_FillMode fillMode = FXFILL_WINDING,
175 CFX_Matrix* matrix = NULL);
176 FX_ERR ClipPath(CFX_Path* path,
177 FX_FillMode fillMode = FXFILL_WINDING,
178 CFX_Matrix* matrix = NULL);
179 FX_ERR DrawImage(CFX_DIBSource* source,
180 const CFX_PointF& point,
181 CFX_Matrix* matrix = NULL);
182 FX_ERR StretchImage(CFX_DIBSource* source,
183 const CFX_RectF& rect,
184 CFX_Matrix* matrix = NULL);
185 FX_ERR ConcatMatrix(const CFX_Matrix* matrix);
186 FX_ERR ClearClip();
187 FX_ERR ShowText(const CFX_PointF& point,
188 const CFX_WideString& text,
189 CFX_Matrix* matrix = NULL);
190 FX_ERR CalcTextRect(CFX_RectF& rect,
191 const CFX_WideString& text,
192 FX_BOOL isMultiline = FALSE,
193 CFX_Matrix* matrix = NULL);
194 FX_ERR Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix);
195 FX_ERR Transfer(CFX_Graphics* graphics,
196 FX_FLOAT srcLeft,
197 FX_FLOAT srcTop,
198 const CFX_RectF& dstRect,
199 const CFX_Matrix* matrix);
200
201 FX_ERR InverseRect(const CFX_RectF& rect);
202 FX_ERR XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
203 FX_ERR EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
204
205 private:
206 FX_ERR RenderDeviceSetLineDash(FX_DashStyle dashStyle);
207 FX_ERR RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix);
208 FX_ERR RenderDeviceFillPath(CFX_Path* path,
209 FX_FillMode fillMode,
210 CFX_Matrix* matrix);
211 FX_ERR RenderDeviceDrawImage(CFX_DIBSource* source,
212 const CFX_PointF& point,
213 CFX_Matrix* matrix);
214 FX_ERR RenderDeviceStretchImage(CFX_DIBSource* source,
215 const CFX_RectF& rect,
216 CFX_Matrix* matrix);
217 FX_ERR RenderDeviceShowText(const CFX_PointF& point,
218 const CFX_WideString& text,
219 CFX_Matrix* matrix);
220
221 FX_ERR StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix);
222 FX_ERR StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix);
223
224 FX_ERR FillPathWithPattern(CFX_Path* path,
225 FX_FillMode fillMode,
226 CFX_Matrix* matrix);
227 FX_ERR FillPathWithShading(CFX_Path* path,
228 FX_FillMode fillMode,
229 CFX_Matrix* matrix);
230
231 FX_ERR SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix);
232 FX_ERR CalcTextInfo(const CFX_WideString& text,
233 FX_DWORD* charCodes,
234 FXTEXT_CHARPOS* charPos,
235 CFX_RectF& rect);
236
237 protected:
238 int32_t m_type;
239
240 private:
241 struct TInfo {
242 TInfo()
243 : isAntialiasing(TRUE),
244 strokeAlignment(FX_STROKEALIGNMENT_Center),
245 isActOnDash(FALSE),
246 strokeColor(nullptr),
247 fillColor(nullptr),
248 font(nullptr),
249 fontSize(40.0),
250 fontHScale(1.0),
251 fontSpacing(0.0) {}
252 explicit TInfo(const TInfo& info);
253 TInfo& operator=(const TInfo& other);
254
255 CFX_GraphStateData graphState;
256 FX_BOOL isAntialiasing;
257 FX_StrokeAlignment strokeAlignment;
258 CFX_Matrix CTM;
259 FX_BOOL isActOnDash;
260 CFX_Color* strokeColor;
261 CFX_Color* fillColor;
262 CFX_Font* font;
263 FX_FLOAT fontSize;
264 FX_FLOAT fontHScale;
265 FX_FLOAT fontSpacing;
266 } m_info;
267 CFX_RenderDevice* m_renderDevice;
268 CFX_PtrArray m_infoStack;
269 CAGG_Graphics* m_aggGraphics;
270 friend class CAGG_Graphics;
271 };
272
273 class CFX_Path {
274 public:
275 CFX_Path();
276 virtual ~CFX_Path();
277
278 FX_ERR Create();
279 FX_ERR MoveTo(FX_FLOAT x, FX_FLOAT y);
280 FX_ERR LineTo(FX_FLOAT x, FX_FLOAT y);
281 FX_ERR BezierTo(FX_FLOAT ctrlX1,
282 FX_FLOAT ctrlY1,
283 FX_FLOAT ctrlX2,
284 FX_FLOAT ctrlY2,
285 FX_FLOAT toX,
286 FX_FLOAT toY);
287 FX_ERR ArcTo(FX_FLOAT left,
288 FX_FLOAT top,
289 FX_FLOAT width,
290 FX_FLOAT height,
291 FX_FLOAT startAngle,
292 FX_FLOAT sweepAngle);
293 FX_ERR Close();
294
295 FX_ERR AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
296 FX_ERR AddBezier(FX_FLOAT startX,
297 FX_FLOAT startY,
298 FX_FLOAT ctrlX1,
299 FX_FLOAT ctrlY1,
300 FX_FLOAT ctrlX2,
301 FX_FLOAT ctrlY2,
302 FX_FLOAT endX,
303 FX_FLOAT endY);
304 FX_ERR AddRectangle(FX_FLOAT left,
305 FX_FLOAT top,
306 FX_FLOAT width,
307 FX_FLOAT height);
308 FX_ERR AddEllipse(FX_FLOAT left,
309 FX_FLOAT top,
310 FX_FLOAT width,
311 FX_FLOAT height);
312 FX_ERR AddEllipse(const CFX_RectF& rect);
313 FX_ERR AddArc(FX_FLOAT left,
314 FX_FLOAT top,
315 FX_FLOAT width,
316 FX_FLOAT height,
317 FX_FLOAT startAngle,
318 FX_FLOAT sweepAngle);
319 FX_ERR AddPie(FX_FLOAT left,
320 FX_FLOAT top,
321 FX_FLOAT width,
322 FX_FLOAT height,
323 FX_FLOAT startAngle,
324 FX_FLOAT sweepAngle);
325 FX_ERR AddSubpath(CFX_Path* path);
326 FX_ERR Clear();
327
328 FX_BOOL IsEmpty();
329 CFX_PathData* GetPathData();
330
331 private:
332 CFX_PathGenerator* m_generator;
333 };
334
335 class CFX_Color {
336 public:
337 CFX_Color();
338 // TODO(weili): Remove implicit conversions. Make this explicit.
339 CFX_Color(const FX_ARGB argb);
340 explicit CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
341 explicit CFX_Color(CFX_Shading* shading);
342 virtual ~CFX_Color();
343
344 FX_ERR Set(const FX_ARGB argb);
345 FX_ERR Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
346 FX_ERR Set(CFX_Shading* shading);
347
348 private:
349 int32_t m_type;
350 union {
351 struct {
352 FX_ARGB argb;
353 CFX_Pattern* pattern;
354 } m_info;
355 CFX_Shading* m_shading;
356 };
357
358 friend class CFX_Graphics;
359 };
360
361 class CFX_Pattern {
362 public:
363 CFX_Pattern();
364 virtual ~CFX_Pattern();
365
366 FX_ERR Create(CFX_DIBitmap* bitmap,
367 const FX_FLOAT xStep,
368 const FX_FLOAT yStep,
369 CFX_Matrix* matrix = NULL);
370 FX_ERR Create(FX_HatchStyle hatchStyle,
371 const FX_ARGB foreArgb,
372 const FX_ARGB backArgb,
373 CFX_Matrix* matrix = NULL);
374
375 private:
376 int32_t m_type;
377 CFX_Matrix m_matrix;
378 union {
379 struct {
380 CFX_RectF rect;
381 FX_FLOAT xStep;
382 FX_FLOAT yStep;
383 FX_BOOL isColored;
384 } m_rectInfo;
385 struct {
386 CFX_DIBitmap* bitmap;
387 FX_FLOAT x1Step;
388 FX_FLOAT y1Step;
389 } m_bitmapInfo;
390 struct {
391 FX_HatchStyle hatchStyle;
392 FX_ARGB foreArgb;
393 FX_ARGB backArgb;
394 } m_hatchInfo;
395 };
396 friend class CFX_Graphics;
397 };
398
399 class CFX_Shading {
400 public:
401 CFX_Shading();
402 virtual ~CFX_Shading();
403
404 FX_ERR CreateAxial(const CFX_PointF& beginPoint,
405 const CFX_PointF& endPoint,
406 FX_BOOL isExtendedBegin,
407 FX_BOOL isExtendedEnd,
408 const FX_ARGB beginArgb,
409 const FX_ARGB endArgb);
410 FX_ERR CreateRadial(const CFX_PointF& beginPoint,
411 const CFX_PointF& endPoint,
412 const FX_FLOAT beginRadius,
413 const FX_FLOAT endRadius,
414 FX_BOOL isExtendedBegin,
415 FX_BOOL isExtendedEnd,
416 const FX_ARGB beginArgb,
417 const FX_ARGB endArgb);
418
419 private:
420 FX_ERR InitArgbArray();
421
422 int32_t m_type;
423 CFX_PointF m_beginPoint;
424 CFX_PointF m_endPoint;
425 FX_FLOAT m_beginRadius;
426 FX_FLOAT m_endRadius;
427 FX_BOOL m_isExtendedBegin;
428 FX_BOOL m_isExtendedEnd;
429 FX_ARGB m_beginArgb;
430 FX_ARGB m_endArgb;
431 FX_ARGB m_argbArray[FX_SHADING_Steps];
432 friend class CFX_Graphics;
433 };
434
435 #endif // XFA_INCLUDE_FXGRAPHICS_FX_GRAPHICS_H_
OLDNEW
« no previous file with comments | « xfa/include/fwl/lightwidget/theme.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698