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

Side by Side Diff: xfa/src/fde/fde_object.h

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master 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/src/fde/fde_iterator.cpp ('k') | xfa/src/fde/fde_object.cpp » ('j') | 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_SRC_FDE_FDE_OBJECT_H_
8 #define XFA_SRC_FDE_FDE_OBJECT_H_
9
10 #include <cstdint>
11
12 #include "core/include/fxge/fx_dib.h"
13 #include "xfa/src/fde/fde_brush.h"
14 #include "xfa/src/fde/fde_pen.h"
15 #include "xfa/src/fgas/crt/fgas_memory.h"
16
17 class CFDE_Pen : public IFDE_Pen, public CFX_Target {
18 public:
19 CFDE_Pen()
20 : m_Color(0),
21 m_iLineCap(0),
22 m_iLineJoin(0),
23 m_iDashStyle(0),
24 m_fDashPhase(0),
25 m_fMiterLimit(10),
26 m_bAutoRelease(FALSE),
27 m_pBrush(NULL) {}
28
29 ~CFDE_Pen() {
30 if (m_pBrush && m_bAutoRelease) {
31 m_pBrush->Release();
32 }
33 }
34 virtual void Release() { delete this; }
35
36 virtual int32_t GetType() const {
37 return m_pBrush ? m_pBrush->GetType() : FDE_PENTYPE_SolidColor;
38 }
39
40 virtual FX_ARGB GetColor() const { return m_Color; }
41 virtual void SetColor(FX_ARGB color) { m_Color = color; }
42 virtual IFDE_Brush* GetBrush() const { return m_pBrush; }
43 virtual void SetBrush(IFDE_Brush* pBrush, FX_BOOL bAutoRelease) {
44 m_bAutoRelease = bAutoRelease;
45 m_pBrush = pBrush;
46 if (m_pBrush && m_pBrush->GetType() == FDE_BRUSHTYPE_Solid) {
47 m_Color = ((IFDE_SolidBrush*)m_pBrush)->GetColor();
48 }
49 }
50 virtual int32_t GetLineCap() const { return m_iLineCap; }
51 virtual void SetLineCap(int32_t iLineCap) { m_iLineCap = iLineCap; }
52 virtual int32_t GetDashStyle() const { return m_iDashStyle; }
53 virtual void SetDashStyle(int32_t iDashStyle) { m_iDashStyle = iDashStyle; }
54 virtual FX_FLOAT GetDashPhase() const { return m_fDashPhase; }
55 virtual void SetDashPhase(FX_FLOAT fPhase) { m_fDashPhase = fPhase; }
56 virtual int32_t CountDashArray() const { return m_DashArray.GetSize(); }
57 virtual int32_t GetDashArray(CFX_FloatArray& dashArray) const {
58 dashArray.Copy(m_DashArray);
59 return dashArray.GetSize();
60 }
61 virtual void SetDashArray(const CFX_FloatArray& dashArray) {
62 m_DashArray.Copy(dashArray);
63 }
64 virtual int32_t GetLineJoin() const { return m_iLineJoin; }
65 virtual void SetLineJoin(int32_t iLineJoin) { m_iLineJoin = iLineJoin; }
66 virtual FX_FLOAT GetMiterLimit() const { return m_fMiterLimit; }
67 virtual void SetMiterLimit(FX_FLOAT fMiterLimit) {
68 m_fMiterLimit = fMiterLimit;
69 }
70 virtual int32_t CountCompoundPatterns() const {
71 return m_CompoundPatterns.GetSize();
72 }
73 virtual FX_BOOL GetCompoundPatterns(
74 CFDE_CompoundPatterns& compoundPatterns) const {
75 return compoundPatterns.Copy(m_CompoundPatterns), TRUE;
76 }
77 virtual FX_BOOL SetCompoundPatterns(
78 const CFDE_CompoundPatterns& compoundPatterns) {
79 return m_CompoundPatterns.Copy(compoundPatterns), TRUE;
80 }
81
82 FX_ARGB m_Color;
83 int32_t m_iLineCap;
84 int32_t m_iLineJoin;
85 int32_t m_iDashStyle;
86 FX_FLOAT m_fDashPhase;
87 FX_FLOAT m_fMiterLimit;
88 FX_BOOL m_bAutoRelease;
89 IFDE_Brush* m_pBrush;
90 CFX_FloatArray m_DashArray;
91 CFDE_CompoundPatterns m_CompoundPatterns;
92 };
93 class CFDE_SolidBrush : public IFDE_SolidBrush, public CFX_Target {
94 public:
95 CFDE_SolidBrush() : m_Color(0xFF000000) { m_Matrix.SetIdentity(); }
96
97 virtual void Release() { delete this; }
98 virtual int32_t GetType() const { return FDE_BRUSHTYPE_Solid; }
99 virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
100 virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
101 virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
102 m_Matrix.Translate(dx, dy);
103 }
104 virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
105 virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
106 virtual void ConcatMatrix(const CFX_Matrix& matrix) {
107 m_Matrix.Concat(matrix);
108 }
109 virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
110 virtual FX_ARGB GetColor() const { return m_Color; }
111 virtual void SetColor(FX_ARGB color) { m_Color = color; }
112
113 FX_ARGB m_Color;
114 CFX_Matrix m_Matrix;
115 };
116 class CFDE_HatchBrush : public IFDE_HatchBrush, public CFX_Target {
117 public:
118 CFDE_HatchBrush() : m_iStyle(-1), m_BackColor(0), m_ForeColor(0) {
119 m_Matrix.SetIdentity();
120 }
121
122 virtual void Release() { delete this; }
123 virtual int32_t GetType() const { return FDE_BRUSHTYPE_Hatch; }
124 virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
125 virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
126 virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
127 m_Matrix.Translate(dx, dy);
128 }
129 virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
130 virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
131 virtual void ConcatMatrix(const CFX_Matrix& matrix) {
132 m_Matrix.Concat(matrix);
133 }
134 virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
135 virtual FX_ARGB GetColor(FX_BOOL bForegroundColor) const {
136 return bForegroundColor ? m_ForeColor : m_BackColor;
137 }
138 virtual void SetColor(FX_ARGB color, FX_BOOL bForegroundColor) {
139 if (bForegroundColor) {
140 m_ForeColor = color;
141 } else {
142 m_BackColor = color;
143 }
144 }
145
146 virtual int32_t GetHatchStyle() const { return m_iStyle; }
147 virtual FX_BOOL SetHatchStyle(int32_t iHatchStyle) {
148 m_iStyle = iHatchStyle;
149 return m_iStyle >= FDE_HATCHSTYLE_Min && m_iStyle <= FDE_HATCHSTYLE_Max;
150 }
151 int32_t m_iStyle;
152 FX_ARGB m_BackColor;
153 FX_ARGB m_ForeColor;
154 CFX_Matrix m_Matrix;
155 };
156 class CFDE_TextureBrush : public IFDE_TextureBrush, public CFX_Target {
157 public:
158 CFDE_TextureBrush() : m_iWrap(0), m_pImage(NULL), m_bAutoRelease(FALSE) {
159 m_Matrix.SetIdentity();
160 }
161
162 virtual void Release() { delete this; }
163 virtual int32_t GetType() const { return FDE_BRUSHTYPE_Texture; }
164 virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
165 virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
166 virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
167 m_Matrix.Translate(dx, dy);
168 }
169 virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
170 virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
171 virtual void ConcatMatrix(const CFX_Matrix& matrix) {
172 m_Matrix.Concat(matrix);
173 }
174 virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
175 virtual IFDE_Image* GetImage() const { return m_pImage; }
176 virtual void SetImage(IFDE_Image* pImage, FX_BOOL bAutoRelease) {
177 m_pImage = pImage;
178 m_bAutoRelease = bAutoRelease;
179 }
180 virtual int32_t GetWrapMode() const { return m_iWrap; }
181 virtual void SetWrapMode(int32_t iWrapMode) { m_iWrap = iWrapMode; }
182 int32_t m_iWrap;
183 IFDE_Image* m_pImage;
184 FX_BOOL m_bAutoRelease;
185 CFX_Matrix m_Matrix;
186 };
187 class CFDE_LinearBrush : public IFDE_LinearGradientBrush, public CFX_Target {
188 public:
189 CFDE_LinearBrush() : m_EndColor(0), m_StartColor(0), m_iWrapMode(0) {
190 m_StartPoint.x = m_StartPoint.y = m_EndPoint.x = m_EndPoint.y = 0;
191 m_Matrix.SetIdentity();
192 }
193
194 virtual void Release() { delete this; }
195 virtual int32_t GetType() const { return FDE_BRUSHTYPE_LinearGradient; }
196 virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
197 virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
198 virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
199 m_Matrix.Translate(dx, dy);
200 }
201 virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
202 virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
203 virtual void ConcatMatrix(const CFX_Matrix& matrix) {
204 m_Matrix.Concat(matrix);
205 }
206 virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
207 virtual void GetLinearPoints(CFX_PointF& startingPoint,
208 CFX_PointF& endingPoint) const {
209 startingPoint = m_StartPoint;
210 endingPoint = m_EndPoint;
211 }
212 virtual void SetLinearPoints(const CFX_PointF& startingPoint,
213 const CFX_PointF& endingPoint) {
214 m_StartPoint = startingPoint;
215 m_EndPoint = endingPoint;
216 }
217 virtual void GetLinearColors(FX_ARGB& startingColor,
218 FX_ARGB& endingColor) const {
219 startingColor = m_StartColor;
220 endingColor = m_EndColor;
221 }
222 virtual void SetLinearColors(const FX_ARGB& startingColor,
223 const FX_ARGB& endingColor) {
224 m_StartColor = startingColor;
225 m_EndColor = endingColor;
226 }
227 virtual int32_t CountGradientColors() const { return m_GradColors.GetSize(); }
228 virtual FX_BOOL GetGradientColors(CFDE_GradientColors& colors) const {
229 return colors.Copy(m_GradColors), TRUE;
230 }
231 virtual FX_BOOL SetGradientColors(const CFDE_GradientColors& colors) {
232 return m_GradColors.Copy(colors), TRUE;
233 }
234
235 virtual int32_t GetWrapMode() const { return m_iWrapMode; }
236 virtual void SetWrapMode(int32_t iWrapMode) { m_iWrapMode = iWrapMode; }
237 CFX_PointF m_EndPoint;
238 CFX_PointF m_StartPoint;
239 FX_ARGB m_EndColor;
240 FX_ARGB m_StartColor;
241 CFDE_GradientColors m_GradColors;
242 int32_t m_iWrapMode;
243 CFX_Matrix m_Matrix;
244 };
245
246 #endif // XFA_SRC_FDE_FDE_OBJECT_H_
OLDNEW
« no previous file with comments | « xfa/src/fde/fde_iterator.cpp ('k') | xfa/src/fde/fde_object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698