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

Side by Side Diff: core/include/fxcrt/fx_coordinates.h

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ 7 #ifndef CORE_INCLUDE_FXCRT_FX_COORDINATES_H_
8 #define CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ 8 #define CORE_INCLUDE_FXCRT_FX_COORDINATES_H_
9 9
10 #include "fx_basic.h" 10 #include "fx_basic.h"
11 11
12 template<class baseType> class CFX_PSVTemplate; 12 template <class baseType>
13 template<class baseType> class CFX_VTemplate; 13 class CFX_PSVTemplate;
14 template<class baseType> class CFX_PRLTemplate; 14 template <class baseType>
15 template<class baseType> class CFX_RTemplate; 15 class CFX_VTemplate;
16 template<class baseType> class CFX_ETemplate; 16 template <class baseType>
17 template<class baseType> class CFX_ATemplate; 17 class CFX_PRLTemplate;
18 template<class baseType> class CFX_RRTemplate; 18 template <class baseType>
19 class CFX_RTemplate;
20 template <class baseType>
21 class CFX_ETemplate;
22 template <class baseType>
23 class CFX_ATemplate;
24 template <class baseType>
25 class CFX_RRTemplate;
19 class CFX_Matrix; 26 class CFX_Matrix;
20 template<class baseType> 27 template <class baseType>
21 class CFX_PSVTemplate 28 class CFX_PSVTemplate {
22 { 29 public:
23 public: 30 typedef CFX_PSVTemplate<baseType> FXT_PSV;
24 typedef CFX_PSVTemplate<baseType>» FXT_PSV; 31 typedef CFX_PSVTemplate<baseType> FXT_POINT;
25 typedef CFX_PSVTemplate<baseType>» FXT_POINT; 32 typedef CFX_PSVTemplate<baseType> FXT_SIZE;
26 typedef CFX_PSVTemplate<baseType>» FXT_SIZE; 33 void Set(baseType x, baseType y) { FXT_PSV::x = x, FXT_PSV::y = y; }
27 void» » Set(baseType x, baseType y) 34 void Set(const FXT_PSV& psv) { FXT_PSV::x = psv.x, FXT_PSV::y = psv.y; }
28 { 35 void Add(baseType x, baseType y) { FXT_PSV::x += x, FXT_PSV::y += y; }
29 FXT_PSV::x = x, FXT_PSV::y = y; 36 void Subtract(baseType x, baseType y) { FXT_PSV::x -= x, FXT_PSV::y -= y; }
30 } 37 void Reset() { FXT_PSV::x = FXT_PSV::y = 0; }
31 void» » Set(const FXT_PSV &psv) 38 FXT_PSV& operator+=(const FXT_PSV& obj) {
32 { 39 x += obj.x;
33 FXT_PSV::x = psv.x, FXT_PSV::y = psv.y; 40 y += obj.y;
34 } 41 return *this;
35 void» » Add(baseType x, baseType y) 42 }
36 { 43 FXT_PSV& operator-=(const FXT_PSV& obj) {
37 FXT_PSV::x += x, FXT_PSV::y += y; 44 x -= obj.x;
38 } 45 y -= obj.y;
39 void» » Subtract(baseType x, baseType y) 46 return *this;
40 { 47 }
41 FXT_PSV::x -= x, FXT_PSV::y -= y; 48 FXT_PSV& operator*=(baseType lamda) {
42 } 49 x *= lamda;
43 void» » Reset() 50 y *= lamda;
44 { 51 return *this;
45 FXT_PSV::x = FXT_PSV::y = 0; 52 }
46 } 53 FXT_PSV& operator/=(baseType lamda) {
47 FXT_PSV&» operator += (const FXT_PSV &obj) 54 x /= lamda;
48 { 55 y /= lamda;
49 x += obj.x; 56 return *this;
50 y += obj.y; 57 }
51 return *this; 58 friend FX_BOOL operator==(const FXT_PSV& obj1, const FXT_PSV& obj2) {
52 } 59 return obj1.x == obj2.x && obj1.y == obj2.y;
53 FXT_PSV&» operator -= (const FXT_PSV &obj) 60 }
54 { 61 friend FX_BOOL operator!=(const FXT_PSV& obj1, const FXT_PSV& obj2) {
55 x -= obj.x; 62 return obj1.x != obj2.x || obj1.y != obj2.y;
56 y -= obj.y; 63 }
57 return *this; 64 friend FXT_PSV operator+(const FXT_PSV& obj1, const FXT_PSV& obj2) {
58 } 65 CFX_PSVTemplate obj;
59 FXT_PSV&» operator *= (baseType lamda) 66 obj.x = obj1.x + obj2.x;
60 { 67 obj.y = obj1.y + obj2.y;
61 x *= lamda; 68 return obj;
62 y *= lamda; 69 }
63 return *this; 70 friend FXT_PSV operator-(const FXT_PSV& obj1, const FXT_PSV& obj2) {
64 } 71 CFX_PSVTemplate obj;
65 FXT_PSV&» operator /= (baseType lamda) 72 obj.x = obj1.x - obj2.x;
66 { 73 obj.y = obj1.y - obj2.y;
67 x /= lamda; 74 return obj;
68 y /= lamda; 75 }
69 return *this; 76 friend FXT_PSV operator*(const FXT_PSV& obj, baseType lamda) {
70 } 77 CFX_PSVTemplate t;
71 friend» FX_BOOL»» operator == (const FXT_PSV &obj1, const FXT_PSV &obj2) 78 t.x = obj.x * lamda;
72 { 79 t.y = obj.y * lamda;
73 return obj1.x == obj2.x && obj1.y == obj2.y; 80 return t;
74 } 81 }
75 friend» FX_BOOL»» operator != (const FXT_PSV &obj1, const FXT_PSV &obj2) 82 friend FXT_PSV operator*(baseType lamda, const FXT_PSV& obj) {
76 { 83 CFX_PSVTemplate t;
77 return obj1.x != obj2.x || obj1.y != obj2.y; 84 t.x = lamda * obj.x;
78 } 85 t.y = lamda * obj.y;
79 friend» FXT_PSV»» operator + (const FXT_PSV &obj1, const FXT_PSV & obj2) 86 return t;
80 { 87 }
81 CFX_PSVTemplate obj; 88 friend FXT_PSV operator/(const FXT_PSV& obj, baseType lamda) {
82 obj.x = obj1.x + obj2.x; 89 CFX_PSVTemplate t;
83 obj.y = obj1.y + obj2.y; 90 t.x = obj.x / lamda;
84 return obj; 91 t.y = obj.y / lamda;
85 } 92 return t;
86 friend» FXT_PSV»» operator - (const FXT_PSV &obj1, const FXT_PSV & obj2) 93 }
87 { 94 baseType x, y;
88 CFX_PSVTemplate obj;
89 obj.x = obj1.x - obj2.x;
90 obj.y = obj1.y - obj2.y;
91 return obj;
92 }
93 friend» FXT_PSV»» operator * (const FXT_PSV &obj, baseType lamda)
94 {
95 CFX_PSVTemplate t;
96 t.x = obj.x * lamda;
97 t.y = obj.y * lamda;
98 return t;
99 }
100 friend» FXT_PSV»» operator * (baseType lamda, const FXT_PSV &obj)
101 {
102 CFX_PSVTemplate t;
103 t.x = lamda * obj.x;
104 t.y = lamda * obj.y;
105 return t;
106 }
107 friend» FXT_PSV»» operator / (const FXT_PSV &obj, baseType lamda)
108 {
109 CFX_PSVTemplate t;
110 t.x = obj.x / lamda;
111 t.y = obj.y / lamda;
112 return t;
113 }
114 baseType x, y;
115 }; 95 };
116 typedef CFX_PSVTemplate<int32_t>» » » CFX_Point; 96 typedef CFX_PSVTemplate<int32_t> CFX_Point;
117 typedef CFX_PSVTemplate<FX_FLOAT>» » » CFX_PointF; 97 typedef CFX_PSVTemplate<FX_FLOAT> CFX_PointF;
118 typedef CFX_PSVTemplate<int32_t>» » » CFX_Size; 98 typedef CFX_PSVTemplate<int32_t> CFX_Size;
119 typedef CFX_PSVTemplate<FX_FLOAT>» » » CFX_SizeF; 99 typedef CFX_PSVTemplate<FX_FLOAT> CFX_SizeF;
120 typedef CFX_ArrayTemplate<CFX_Point>» » CFX_Points; 100 typedef CFX_ArrayTemplate<CFX_Point> CFX_Points;
121 typedef CFX_ArrayTemplate<CFX_PointF>» » CFX_PointsF; 101 typedef CFX_ArrayTemplate<CFX_PointF> CFX_PointsF;
122 typedef CFX_PSVTemplate<int32_t> *» » » FX_LPPOINT; 102 typedef CFX_PSVTemplate<int32_t>* FX_LPPOINT;
123 typedef CFX_PSVTemplate<FX_FLOAT> *» » » FX_LPPOINTF; 103 typedef CFX_PSVTemplate<FX_FLOAT>* FX_LPPOINTF;
124 typedef CFX_PSVTemplate<int32_t> const *» FX_LPCPOINT; 104 typedef CFX_PSVTemplate<int32_t> const* FX_LPCPOINT;
125 typedef CFX_PSVTemplate<FX_FLOAT> const *» FX_LPCPOINTF; 105 typedef CFX_PSVTemplate<FX_FLOAT> const* FX_LPCPOINTF;
126 #define CFX_FloatPoint» CFX_PointF 106 #define CFX_FloatPoint CFX_PointF
127 template<class baseType> 107 template <class baseType>
128 class CFX_VTemplate: public CFX_PSVTemplate<baseType> 108 class CFX_VTemplate : public CFX_PSVTemplate<baseType> {
129 { 109 public:
130 public: 110 typedef CFX_PSVTemplate<baseType> FXT_PSV;
131 typedef CFX_PSVTemplate<baseType>» FXT_PSV; 111 typedef CFX_PSVTemplate<baseType> FXT_POINT;
132 typedef CFX_PSVTemplate<baseType>» FXT_POINT; 112 typedef CFX_PSVTemplate<baseType> FXT_SIZE;
133 typedef CFX_PSVTemplate<baseType>» FXT_SIZE; 113 typedef CFX_VTemplate<baseType> FXT_VECTOR;
134 typedef CFX_VTemplate<baseType>» » FXT_VECTOR; 114 void Set(baseType newx, baseType newy) {
135 void» » Set(baseType newx, baseType newy) 115 FXT_PSV::x = newx;
136 { 116 FXT_PSV::y = newy;
137 FXT_PSV::x = newx; 117 }
138 FXT_PSV::y = newy; 118 void Set(const FXT_PSV& psv) { FXT_PSV::x = psv.x, FXT_PSV::y = psv.y; }
139 } 119 void Set(const FXT_POINT& p1, const FXT_POINT& p2) {
140 void» » Set(const FXT_PSV &psv) 120 FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;
141 { 121 }
142 FXT_PSV::x = psv.x, FXT_PSV::y = psv.y; 122 void Reset() { FXT_PSV::x = FXT_PSV::y = 0; }
143 } 123 baseType SquareLength() const {
144 void» » Set(const FXT_POINT &p1, const FXT_POINT &p2) 124 return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;
145 { 125 }
146 FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y; 126 baseType Length() const {
147 } 127 return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
148 void» » Reset() 128 }
149 { 129 void Normalize() {
150 FXT_PSV::x = FXT_PSV::y = 0; 130 FX_FLOAT fLen =
151 } 131 FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
152 baseType» SquareLength() const 132 if (fLen < 0.0001f) {
153 { 133 return;
154 return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y; 134 }
155 } 135 FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
156 baseType» Length() const 136 FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
157 { 137 }
158 return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y); 138 baseType DotProduct(baseType otherx, baseType othery) const {
159 } 139 return FXT_PSV::x * otherx + FXT_PSV::y * othery;
160 void» » Normalize() 140 }
161 { 141 baseType DotProduct(const FXT_VECTOR& v) const {
162 FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PS V::y); 142 return FXT_PSV::x * v.x + FXT_PSV::y * v.y;
163 if (fLen < 0.0001f) { 143 }
164 return; 144 FX_BOOL IsParallel(baseType otherx, baseType othery) const {
165 } 145 baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx;
166 FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen; 146 return FXSYS_fabs(t) < 0x0001f;
167 FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen; 147 }
168 } 148 FX_BOOL IsParallel(const FXT_VECTOR& v) const { return IsParallel(v.x, v.y); }
169 baseType» DotProduct(baseType otherx, baseType othery) const 149 FX_BOOL IsPerpendicular(baseType otherx, baseType othery) const {
170 { 150 baseType t = DotProduct(otherx, othery);
171 return FXT_PSV::x * otherx + FXT_PSV::y * othery; 151 return FXSYS_fabs(t) < 0x0001f;
172 } 152 }
173 baseType» DotProduct(const FXT_VECTOR &v) const 153 FX_BOOL IsPerpendicular(const FXT_VECTOR& v) const {
174 { 154 return IsPerpendicular(v.x, v.y);
175 return FXT_PSV::x * v.x + FXT_PSV::y * v.y; 155 }
176 } 156 void Translate(baseType dx, baseType dy) {
177 FX_BOOL» » IsParallel(baseType otherx, baseType othery) const 157 FXT_PSV::x += dx, FXT_PSV::y += dy;
178 { 158 }
179 baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx; 159 void Scale(baseType sx, baseType sy) { FXT_PSV::x *= sx, FXT_PSV::y *= sy; }
180 return FXSYS_fabs(t) < 0x0001f; 160 void Rotate(FX_FLOAT fRadian) {
181 } 161 FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
182 FX_BOOL» » IsParallel(const FXT_VECTOR &v) const 162 FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
183 { 163 FX_FLOAT cosValue = FXSYS_cos(fRadian);
184 return IsParallel(v.x, v.y); 164 FX_FLOAT sinValue = FXSYS_sin(fRadian);
185 } 165 FXT_PSV::x = xx * cosValue - yy * sinValue;
186 FX_BOOL» » IsPerpendicular(baseType otherx, baseType othery) const 166 FXT_PSV::y = xx * sinValue + yy * cosValue;
187 { 167 }
188 baseType t = DotProduct(otherx, othery); 168 friend FX_FLOAT Cosine(const FXT_VECTOR& v1, const FXT_VECTOR& v2) {
189 return FXSYS_fabs(t) < 0x0001f; 169 FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
190 } 170 FX_FLOAT dotProduct = v1.DotProduct(v2);
191 FX_BOOL» » IsPerpendicular(const FXT_VECTOR &v) const 171 return dotProduct /
192 { 172 (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
193 return IsPerpendicular(v.x, v.y); 173 }
194 } 174 friend FX_FLOAT ArcCosine(const FXT_VECTOR& v1, const FXT_VECTOR& v2) {
195 void» » Translate(baseType dx, baseType dy) 175 return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
196 { 176 }
197 FXT_PSV::x += dx, FXT_PSV::y += dy; 177 friend FX_FLOAT SlopeAngle(const FXT_VECTOR& v) {
198 } 178 CFX_VTemplate vx;
199 void» » Scale(baseType sx, baseType sy) 179 vx.Set(1, 0);
200 { 180 FX_FLOAT fSlope = ArcCosine(v, vx);
201 FXT_PSV::x *= sx, FXT_PSV::y *= sy; 181 return v.y < 0 ? -fSlope : fSlope;
202 } 182 }
203 void» » Rotate(FX_FLOAT fRadian)
204 {
205 FX_FLOAT xx = (FX_FLOAT)FXT_PSV::x;
206 FX_FLOAT yy = (FX_FLOAT)FXT_PSV::y;
207 FX_FLOAT cosValue = FXSYS_cos(fRadian);
208 FX_FLOAT sinValue = FXSYS_sin(fRadian);
209 FXT_PSV::x = xx * cosValue - yy * sinValue;
210 FXT_PSV::y = xx * sinValue + yy * cosValue;
211 }
212 friend» FX_FLOAT» Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v 2)
213 {
214 FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
215 FX_FLOAT dotProduct = v1.DotProduct(v2);
216 return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLe ngth());
217 }
218 friend» FX_FLOAT» ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
219 {
220 return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
221 }
222 friend» FX_FLOAT» SlopeAngle(const FXT_VECTOR &v)
223 {
224 CFX_VTemplate vx;
225 vx.Set(1, 0);
226 FX_FLOAT fSlope = ArcCosine(v, vx);
227 return v.y < 0 ? -fSlope : fSlope;
228 }
229 }; 183 };
230 typedef CFX_VTemplate<int32_t> CFX_Vector; 184 typedef CFX_VTemplate<int32_t> CFX_Vector;
231 typedef CFX_VTemplate<FX_FLOAT> CFX_VectorF; 185 typedef CFX_VTemplate<FX_FLOAT> CFX_VectorF;
232 template<class baseType> 186 template <class baseType>
233 class CFX_RTemplate 187 class CFX_RTemplate {
234 { 188 public:
235 public: 189 typedef CFX_PSVTemplate<baseType> FXT_POINT;
236 typedef CFX_PSVTemplate<baseType> FXT_POINT; 190 typedef CFX_PSVTemplate<baseType> FXT_SIZE;
237 typedef CFX_PSVTemplate<baseType> FXT_SIZE; 191 typedef CFX_VTemplate<baseType> FXT_VECTOR;
238 typedef CFX_VTemplate<baseType> FXT_VECTOR; 192 typedef CFX_PRLTemplate<baseType> FXT_PARAL;
239 typedef CFX_PRLTemplate<baseType> FXT_PARAL; 193 typedef CFX_RTemplate<baseType> FXT_RECT;
240 typedef CFX_RTemplate<baseType> FXT_RECT; 194 void Set(baseType left, baseType top, baseType width, baseType height) {
241 void Set(baseType left, baseType top, baseType width, baseTyp e height) 195 FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width,
242 { 196 FXT_RECT::height = height;
243 FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT _RECT::height = height; 197 }
244 } 198 void Set(baseType left, baseType top, const FXT_SIZE& size) {
245 void Set(baseType left, baseType top, const FXT_SIZE &size) 199 FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);
246 { 200 }
247 FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size); 201 void Set(const FXT_POINT& p, baseType width, baseType height) {
248 } 202 TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;
249 void Set(const FXT_POINT &p, baseType width, baseType height) 203 }
250 { 204 void Set(const FXT_POINT& p1, const FXT_POINT& p2) {
251 TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height; 205 TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y,
252 } 206 FXT_RECT::Normalize();
253 void Set(const FXT_POINT &p1, const FXT_POINT &p2) 207 }
254 { 208 void Set(const FXT_POINT& p, const FXT_VECTOR& v) {
255 TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1 .y, FXT_RECT::Normalize(); 209 TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y,
256 } 210 FXT_RECT::Normalize();
257 void Set(const FXT_POINT &p, const FXT_VECTOR &v) 211 }
258 { 212 void Reset() {
259 TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Nor malize(); 213 FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;
260 } 214 }
261 void Reset() 215 FXT_RECT& operator+=(const FXT_POINT& p) {
262 { 216 left += p.x, top += p.y;
263 FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0; 217 return *this;
264 } 218 }
265 FXT_RECT& operator += (const FXT_POINT &p) 219 FXT_RECT& operator-=(const FXT_POINT& p) {
266 { 220 left -= p.x, top -= p.y;
267 left += p.x, top += p.y; 221 return *this;
268 return *this; 222 }
269 } 223 baseType right() const { return left + width; }
270 FXT_RECT& operator -= (const FXT_POINT &p) 224 baseType bottom() const { return top + height; }
271 { 225 void Normalize() {
272 left -= p.x, top -= p.y; 226 if (width < 0) {
273 return *this; 227 left += width;
274 } 228 width = -width;
275 baseType right() const 229 }
276 { 230 if (height < 0) {
277 return left + width; 231 top += height;
278 } 232 height = -height;
279 baseType bottom() const 233 }
280 { 234 }
281 return top + height; 235 void Offset(baseType dx, baseType dy) {
282 } 236 left += dx;
283 void Normalize() 237 top += dy;
284 { 238 }
285 if (width < 0) { 239 void Inflate(baseType x, baseType y) {
286 left += width; 240 left -= x;
287 width = -width; 241 width += x * 2;
288 } 242 top -= y;
289 if (height < 0) { 243 height += y * 2;
290 top += height; 244 }
291 height = -height; 245 void Inflate(const FXT_POINT& p) { Inflate(p.x, p.y); }
292 } 246 void Inflate(baseType left, baseType top, baseType right, baseType bottom) {
293 } 247 FXT_RECT::left -= left;
294 void Offset(baseType dx, baseType dy) 248 FXT_RECT::top -= top;
295 { 249 FXT_RECT::width += left + right;
296 left += dx; 250 FXT_RECT::height += top + bottom;
297 top += dy; 251 }
298 } 252 void Inflate(const FXT_RECT& rt) {
299 void Inflate(baseType x, baseType y) 253 Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);
300 { 254 }
301 left -= x; 255 void Deflate(baseType x, baseType y) {
302 width += x * 2; 256 left += x;
303 top -= y; 257 width -= x * 2;
304 height += y * 2; 258 top += y;
305 } 259 height -= y * 2;
306 void Inflate(const FXT_POINT &p) 260 }
307 { 261 void Deflate(const FXT_POINT& p) { Deflate(p.x, p.y); }
308 Inflate(p.x, p.y); 262 void Deflate(baseType left, baseType top, baseType right, baseType bottom) {
309 } 263 FXT_RECT::left += left;
310 void Inflate(baseType left, baseType top, baseType right, bas eType bottom) 264 FXT_RECT::top += top;
311 { 265 FXT_RECT::width -= left + right;
312 FXT_RECT::left -= left; 266 FXT_RECT::height -= top + bottom;
313 FXT_RECT::top -= top; 267 }
314 FXT_RECT::width += left + right; 268 void Deflate(const FXT_RECT& rt) {
315 FXT_RECT::height += top + bottom; 269 Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);
316 } 270 }
317 void Inflate(const FXT_RECT &rt) 271 FX_BOOL IsEmpty() const { return width <= 0 || height <= 0; }
318 { 272 FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const {
319 Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height); 273 return width <= fEpsilon || height <= fEpsilon;
320 } 274 }
321 void Deflate(baseType x, baseType y) 275 void Empty() { width = height = 0; }
322 { 276 FX_BOOL Contains(baseType x, baseType y) const {
323 left += x; 277 return x >= left && x < left + width && y >= top && y < top + height;
324 width -= x * 2; 278 }
325 top += y; 279 FX_BOOL Contains(const FXT_POINT& p) const { return Contains(p.x, p.y); }
326 height -= y * 2; 280 FX_BOOL Contains(const FXT_RECT& rt) const {
327 } 281 return rt.left >= left && rt.right() <= right() && rt.top >= top &&
328 void Deflate(const FXT_POINT &p) 282 rt.bottom() <= bottom();
329 { 283 }
330 Deflate(p.x, p.y); 284 baseType Width() const { return width; }
331 } 285 baseType Height() const { return height; }
332 void Deflate(baseType left, baseType top, baseType right, bas eType bottom) 286 FXT_SIZE Size() const {
333 { 287 FXT_SIZE size;
334 FXT_RECT::left += left; 288 size.Set(width, height);
335 FXT_RECT::top += top; 289 return size;
336 FXT_RECT::width -= left + right; 290 }
337 FXT_RECT::height -= top + bottom; 291 void Size(FXT_SIZE s) { width = s.x, height = s.y; }
338 } 292 FXT_POINT TopLeft() const {
339 void Deflate(const FXT_RECT &rt) 293 FXT_POINT p;
340 { 294 p.x = left;
341 Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); 295 p.y = top;
342 } 296 return p;
343 FX_BOOL IsEmpty() const 297 }
344 { 298 FXT_POINT TopRight() const {
345 return width <= 0 || height <= 0; 299 FXT_POINT p;
346 } 300 p.x = left + width;
347 FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const 301 p.y = top;
348 { 302 return p;
349 return width <= fEpsilon || height <= fEpsilon; 303 }
350 } 304 FXT_POINT BottomLeft() const {
351 void Empty() 305 FXT_POINT p;
352 { 306 p.x = left;
353 width = height = 0; 307 p.y = top + height;
354 } 308 return p;
355 FX_BOOL Contains(baseType x, baseType y) const 309 }
356 { 310 FXT_POINT BottomRight() const {
357 return x >= left && x < left + width && y >= top && y < top + height; 311 FXT_POINT p;
358 } 312 p.x = left + width;
359 FX_BOOL Contains(const FXT_POINT &p) const 313 p.y = top + height;
360 { 314 return p;
361 return Contains(p.x, p.y); 315 }
362 } 316 void TopLeft(FXT_POINT tl) {
363 FX_BOOL Contains(const FXT_RECT &rt) const 317 left = tl.x;
364 { 318 top = tl.y;
365 return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.b ottom() <= bottom(); 319 }
366 } 320 void TopRight(FXT_POINT tr) {
367 baseType Width() const 321 width = tr.x - left;
368 { 322 top = tr.y;
369 return width; 323 }
370 } 324 void BottomLeft(FXT_POINT bl) {
371 baseType Height() const 325 left = bl.x;
372 { 326 height = bl.y - top;
373 return height; 327 }
374 } 328 void BottomRight(FXT_POINT br) {
375 FXT_SIZE Size() const 329 width = br.x - left;
376 { 330 height = br.y - top;
377 FXT_SIZE size; 331 }
378 size.Set(width, height); 332 FXT_POINT Center() const {
379 return size; 333 FXT_POINT p;
380 } 334 p.x = left + width / 2;
381 void Size(FXT_SIZE s) 335 p.y = top + height / 2;
382 { 336 return p;
383 width = s.x, height = s.y; 337 }
384 } 338 void GetParallelogram(FXT_PARAL& pg) const {
385 FXT_POINT TopLeft() const 339 pg.x = left, pg.y = top;
386 { 340 pg.x1 = width, pg.y1 = 0;
387 FXT_POINT p; 341 pg.x2 = 0, pg.y2 = height;
388 p.x = left; 342 }
389 p.y = top; 343 void Union(baseType x, baseType y) {
390 return p; 344 baseType r = right(), b = bottom();
391 } 345 if (left > x) {
392 FXT_POINT TopRight() const 346 left = x;
393 { 347 }
394 FXT_POINT p; 348 if (r < x) {
395 p.x = left + width; 349 r = x;
396 p.y = top; 350 }
397 return p; 351 if (top > y) {
398 } 352 top = y;
399 FXT_POINT BottomLeft() const 353 }
400 { 354 if (b < y) {
401 FXT_POINT p; 355 b = y;
402 p.x = left; 356 }
403 p.y = top + height; 357 width = r - left;
404 return p; 358 height = b - top;
405 } 359 }
406 FXT_POINT BottomRight() const 360 void Union(const FXT_POINT& p) { Union(p.x, p.y); }
407 { 361 void Union(const FXT_RECT& rt) {
408 FXT_POINT p; 362 baseType r = right(), b = bottom();
409 p.x = left + width; 363 if (left > rt.left) {
410 p.y = top + height; 364 left = rt.left;
411 return p; 365 }
412 } 366 if (r < rt.right()) {
413 void TopLeft(FXT_POINT tl) 367 r = rt.right();
414 { 368 }
415 left = tl.x; 369 if (top > rt.top) {
416 top = tl.y; 370 top = rt.top;
417 } 371 }
418 void TopRight(FXT_POINT tr) 372 if (b < rt.bottom()) {
419 { 373 b = rt.bottom();
420 width = tr.x - left; 374 }
421 top = tr.y; 375 width = r - left;
422 } 376 height = b - top;
423 void BottomLeft(FXT_POINT bl) 377 }
424 { 378 void Intersect(const FXT_RECT& rt) {
425 left = bl.x; 379 baseType r = right(), b = bottom();
426 height = bl.y - top; 380 if (left < rt.left) {
427 } 381 left = rt.left;
428 void BottomRight(FXT_POINT br) 382 }
429 { 383 if (r > rt.right()) {
430 width = br.x - left; 384 r = rt.right();
431 height = br.y - top; 385 }
432 } 386 if (top < rt.top) {
433 FXT_POINT Center() const 387 top = rt.top;
434 { 388 }
435 FXT_POINT p; 389 if (b > rt.bottom()) {
436 p.x = left + width / 2; 390 b = rt.bottom();
437 p.y = top + height / 2; 391 }
438 return p; 392 width = r - left;
439 } 393 height = b - top;
440 void GetParallelogram(FXT_PARAL &pg) const 394 }
441 { 395 FX_BOOL IntersectWith(const FXT_RECT& rt) const {
442 pg.x = left, pg.y = top; 396 FXT_RECT rect = rt;
443 pg.x1 = width, pg.y1 = 0; 397 rect.Intersect(*this);
444 pg.x2 = 0, pg.y2 = height; 398 return !rect.IsEmpty();
445 } 399 }
446 void Union(baseType x, baseType y) 400 FX_BOOL IntersectWith(const FXT_RECT& rt, FX_FLOAT fEpsilon) const {
447 { 401 FXT_RECT rect = rt;
448 baseType r = right(), b = bottom(); 402 rect.Intersect(*this);
449 if (left > x) { 403 return !rect.IsEmpty(fEpsilon);
450 left = x; 404 }
451 } 405 friend FX_BOOL operator==(const FXT_RECT& rc1, const FXT_RECT& rc2) {
452 if (r < x) { 406 return rc1.left == rc2.left && rc1.top == rc2.top &&
453 r = x; 407 rc1.width == rc2.width && rc1.height == rc2.height;
454 } 408 }
455 if (top > y) { 409 friend FX_BOOL operator!=(const FXT_RECT& rc1, const FXT_RECT& rc2) {
456 top = y; 410 return rc1.left != rc2.left || rc1.top != rc2.top ||
457 } 411 rc1.width != rc2.width || rc1.height != rc2.height;
458 if (b < y) { 412 }
459 b = y; 413 baseType left, top;
460 } 414 baseType width, height;
461 width = r - left;
462 height = b - top;
463 }
464 void Union(const FXT_POINT &p)
465 {
466 Union(p.x, p.y);
467 }
468 void Union(const FXT_RECT &rt)
469 {
470 baseType r = right(), b = bottom();
471 if (left > rt.left) {
472 left = rt.left;
473 }
474 if (r < rt.right()) {
475 r = rt.right();
476 }
477 if (top > rt.top) {
478 top = rt.top;
479 }
480 if (b < rt.bottom()) {
481 b = rt.bottom();
482 }
483 width = r - left;
484 height = b - top;
485 }
486 void Intersect(const FXT_RECT &rt)
487 {
488 baseType r = right(), b = bottom();
489 if (left < rt.left) {
490 left = rt.left;
491 }
492 if (r > rt.right()) {
493 r = rt.right();
494 }
495 if (top < rt.top) {
496 top = rt.top;
497 }
498 if (b > rt.bottom()) {
499 b = rt.bottom();
500 }
501 width = r - left;
502 height = b - top;
503 }
504 FX_BOOL IntersectWith(const FXT_RECT &rt) const
505 {
506 FXT_RECT rect = rt;
507 rect.Intersect(*this);
508 return !rect.IsEmpty();
509 }
510 FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) con st
511 {
512 FXT_RECT rect = rt;
513 rect.Intersect(*this);
514 return !rect.IsEmpty(fEpsilon);
515 }
516 friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2)
517 {
518 return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.wi dth && rc1.height == rc2.height;
519 }
520 friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2)
521 {
522 return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.wi dth || rc1.height != rc2.height;
523 }
524 baseType left, top;
525 baseType width, height;
526 }; 415 };
527 typedef CFX_RTemplate<int32_t>» » » CFX_Rect; 416 typedef CFX_RTemplate<int32_t> CFX_Rect;
528 typedef CFX_RTemplate<FX_FLOAT>»» » CFX_RectF; 417 typedef CFX_RTemplate<FX_FLOAT> CFX_RectF;
529 typedef CFX_RTemplate<int32_t> *» » FX_LPRECT; 418 typedef CFX_RTemplate<int32_t>* FX_LPRECT;
530 typedef CFX_RTemplate<FX_FLOAT> *» » FX_LPRECTF; 419 typedef CFX_RTemplate<FX_FLOAT>* FX_LPRECTF;
531 typedef CFX_RTemplate<int32_t> const *» FX_LPCRECT; 420 typedef CFX_RTemplate<int32_t> const* FX_LPCRECT;
532 typedef CFX_RTemplate<FX_FLOAT> const *»FX_LPCRECTF; 421 typedef CFX_RTemplate<FX_FLOAT> const* FX_LPCRECTF;
533 typedef CFX_ArrayTemplate<CFX_RectF>» CFX_RectFArray; 422 typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray;
534 struct FX_RECT { 423 struct FX_RECT {
535 424 int left;
536 int»» » left; 425
537 426 int top;
538 int»» » top; 427
539 428 int right;
540 int»» » right; 429
541 430 int bottom;
542 int»» » bottom; 431
543 432 FX_RECT() : left(0), top(0), right(0), bottom(0) {}
544 FX_RECT(): left(0), top(0), right(0), bottom(0) { } 433
545 434 FX_RECT(int left1, int top1, int right1, int bottom1) {
546 FX_RECT(int left1, int top1, int right1, int bottom1) 435 left = left1;
547 { 436 top = top1;
548 left = left1; 437 right = right1;
549 top = top1; 438 bottom = bottom1;
550 right = right1; 439 }
551 bottom = bottom1; 440
552 } 441 int Width() const { return right - left; }
553 442
554 int»» » Width() const 443 int Height() const { return bottom - top; }
555 { 444
556 return right - left; 445 FX_BOOL IsEmpty() const { return right <= left || bottom <= top; }
557 } 446
558 447 void Normalize();
559 int»» » Height() const 448
560 { 449 void Intersect(const FX_RECT& src);
561 return bottom - top; 450
562 } 451 void Intersect(int left1, int top1, int right1, int bottom1) {
563 452 Intersect(FX_RECT(left1, top1, right1, bottom1));
564 FX_BOOL» » IsEmpty() const 453 }
565 { 454
566 return right <= left || bottom <= top; 455 void Union(const FX_RECT& other_rect);
567 } 456
568 457 FX_BOOL operator==(const FX_RECT& src) const {
569 void» » Normalize(); 458 return left == src.left && right == src.right && top == src.top &&
570 459 bottom == src.bottom;
571 void» » Intersect(const FX_RECT& src); 460 }
572 461
573 void» » Intersect(int left1, int top1, int right1, int bottom1) 462 void Offset(int dx, int dy) {
574 { 463 left += dx;
575 Intersect(FX_RECT(left1, top1, right1, bottom1)); 464 right += dx;
576 } 465 top += dy;
577 466 bottom += dy;
578 void» » Union(const FX_RECT& other_rect); 467 }
579 468
580 FX_BOOL» » operator == (const FX_RECT& src) const 469 FX_BOOL Contains(const FX_RECT& other_rect) const {
581 { 470 return other_rect.left >= left && other_rect.right <= right &&
582 return left == src.left && right == src.right && top == src.top && botto m == src.bottom; 471 other_rect.top >= top && other_rect.bottom <= bottom;
583 } 472 }
584 473
585 void» » Offset(int dx, int dy) 474 FX_BOOL Contains(int x, int y) const {
586 { 475 return x >= left && x < right && y >= top && y < bottom;
587 left += dx; 476 }
588 right += dx;
589 top += dy;
590 bottom += dy;
591 }
592
593 FX_BOOL» » Contains(const FX_RECT& other_rect) const
594 {
595 return other_rect.left >= left && other_rect.right <= right && other_rec t.top >= top && other_rect.bottom <= bottom;
596 }
597
598 FX_BOOL» » Contains(int x, int y) const
599 {
600 return x >= left && x < right && y >= top && y < bottom;
601 }
602 }; 477 };
603 struct FX_SMALL_RECT { 478 struct FX_SMALL_RECT {
604 479 int16_t Left;
605 int16_t» Left; 480
606 481 int16_t Top;
607 int16_t» Top; 482
608 483 int16_t Right;
609 int16_t» Right; 484
610 485 int16_t Bottom;
611 int16_t» Bottom;
612 }; 486 };
613 class CFX_FloatRect 487 class CFX_FloatRect {
614 { 488 public:
615 public: 489 CFX_FloatRect() { left = right = bottom = top = 0; }
616 490
617 CFX_FloatRect() 491 CFX_FloatRect(FX_FLOAT left1,
618 { 492 FX_FLOAT bottom1,
619 left = right = bottom = top = 0; 493 FX_FLOAT right1,
620 } 494 FX_FLOAT top1) {
621 495 left = left1;
622 CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT to p1) 496 bottom = bottom1;
623 { 497 right = right1;
624 left = left1; 498 top = top1;
625 bottom = bottom1; 499 }
626 right = right1; 500
627 top = top1; 501 CFX_FloatRect(const FX_FLOAT* pArray) {
628 } 502 left = pArray[0];
629 503 bottom = pArray[1];
630 CFX_FloatRect(const FX_FLOAT* pArray) 504 right = pArray[2];
631 { 505 top = pArray[3];
632 left = pArray[0]; 506 }
633 bottom = pArray[1]; 507
634 right = pArray[2]; 508 CFX_FloatRect(const FX_RECT& rect);
635 top = pArray[3]; 509
636 } 510 FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
637 511
638 CFX_FloatRect(const FX_RECT& rect); 512 void Normalize();
639 513
640 FX_BOOL» » » » IsEmpty() const 514 void Reset() { left = right = bottom = top = 0; }
641 { 515
642 return left >= right || bottom >= top; 516 FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
643 } 517
644 518 FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
645 void» » » » Normalize(); 519
646 520 void Transform(const CFX_Matrix* pMatrix);
647 void» » » » Reset() 521
648 { 522 void Intersect(const CFX_FloatRect& other_rect);
649 left = right = bottom = top = 0; 523
650 } 524 void Union(const CFX_FloatRect& other_rect);
651 525
652 FX_BOOL» » » » Contains(const CFX_FloatRect& other_rect ) const; 526 FX_RECT GetInnerRect() const;
653 527
654 FX_BOOL» » » » Contains(FX_FLOAT x, FX_FLOAT y) const; 528 FX_RECT GetOutterRect() const;
655 529
656 void» » » » Transform(const CFX_Matrix* pMatrix); 530 FX_RECT GetClosestRect() const;
657 531
658 void» » » » Intersect(const CFX_FloatRect& other_rec t); 532 int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
659 533
660 void» » » » Union(const CFX_FloatRect& other_rect); 534 void InitRect(FX_FLOAT x, FX_FLOAT y) {
661 535 left = right = x;
662 FX_RECT» » » » GetInnerRect() const; 536 bottom = top = y;
663 537 }
664 FX_RECT» » » » GetOutterRect() const; 538
665 539 void UpdateRect(FX_FLOAT x, FX_FLOAT y);
666 FX_RECT» » » » GetClosestRect() const; 540
667 541 FX_FLOAT Width() const { return right - left; }
668 int»» » » » Substract4(CFX_FloatRect& substract_rect , CFX_FloatRect* pRects); 542
669 543 FX_FLOAT Height() const { return top - bottom; }
670 void» » » » InitRect(FX_FLOAT x, FX_FLOAT y) 544
671 { 545 void Inflate(FX_FLOAT x, FX_FLOAT y) {
672 left = right = x; 546 Normalize();
673 bottom = top = y; 547 left -= x;
674 } 548 right += x;
675 549 bottom -= y;
676 void» » » » UpdateRect(FX_FLOAT x, FX_FLOAT y); 550 top += y;
677 551 }
678 FX_FLOAT» » » Width() const 552
679 { 553 void Inflate(FX_FLOAT other_left,
680 return right - left; 554 FX_FLOAT other_bottom,
681 } 555 FX_FLOAT other_right,
682 556 FX_FLOAT other_top) {
683 FX_FLOAT» » » Height() const 557 Normalize();
684 { 558 left -= other_left;
685 return top - bottom; 559 bottom -= other_bottom;
686 } 560 right += other_right;
687 561 top += other_top;
688 void» » » » Inflate(FX_FLOAT x, FX_FLOAT y) 562 }
689 { 563
690 Normalize(); 564 void Inflate(const CFX_FloatRect& rt) {
691 left -= x; 565 Inflate(rt.left, rt.bottom, rt.right, rt.top);
692 right += x; 566 }
693 bottom -= y; 567
694 top += y; 568 void Deflate(FX_FLOAT x, FX_FLOAT y) {
695 } 569 Normalize();
696 570 left += x;
697 void Inflate(FX_FLOAT other_left, 571 right -= x;
698 FX_FLOAT other_bottom, 572 bottom += y;
699 FX_FLOAT other_right, 573 top -= y;
700 FX_FLOAT other_top) 574 }
701 { 575
702 Normalize(); 576 void Deflate(FX_FLOAT other_left,
703 left -= other_left; 577 FX_FLOAT other_bottom,
704 bottom -= other_bottom; 578 FX_FLOAT other_right,
705 right += other_right; 579 FX_FLOAT other_top) {
706 top += other_top; 580 Normalize();
707 } 581 left += other_left;
708 582 bottom += other_bottom;
709 void Inflate(const CFX_FloatRect &rt) 583 right -= other_right;
710 { 584 top -= other_top;
711 Inflate(rt.left, rt.bottom, rt.right, rt.top); 585 }
712 } 586
713 587 void Deflate(const CFX_FloatRect& rt) {
714 void Deflate(FX_FLOAT x, FX_FLOAT y) 588 Deflate(rt.left, rt.bottom, rt.right, rt.top);
715 { 589 }
716 Normalize(); 590
717 left += x; 591 void Translate(FX_FLOAT e, FX_FLOAT f) {
718 right -= x; 592 left += e;
719 bottom += y; 593 right += e;
720 top -= y; 594 top += f;
721 } 595 bottom += f;
722 596 }
723 void Deflate(FX_FLOAT other_left, 597
724 FX_FLOAT other_bottom, 598 static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
725 FX_FLOAT other_right, 599
726 FX_FLOAT other_top) 600 FX_FLOAT left;
727 { 601
728 Normalize(); 602 FX_FLOAT right;
729 left += other_left; 603
730 bottom += other_bottom; 604 FX_FLOAT bottom;
731 right -= other_right; 605
732 top -= other_top; 606 FX_FLOAT top;
733 }
734
735 void Deflate(const CFX_FloatRect &rt)
736 {
737 Deflate(rt.left, rt.bottom, rt.right, rt.top);
738 }
739
740 void Translate(FX_FLOAT e, FX_FLOAT f)
741 {
742 left += e;
743 right += e;
744 top += f;
745 bottom += f;
746 }
747
748 static CFX_FloatRect» GetBBox(const CFX_FloatPoint* pPoints, int nPoin ts);
749
750 FX_FLOAT» » » left;
751
752 FX_FLOAT» » » right;
753
754 FX_FLOAT» » » bottom;
755
756 FX_FLOAT» » » top;
757 }; 607 };
758 class CFX_Matrix 608 class CFX_Matrix {
759 { 609 public:
760 public: 610 CFX_Matrix() {
761 611 a = d = 1;
762 CFX_Matrix() 612 b = c = e = f = 0;
763 { 613 }
764 a = d = 1; 614
765 b = c = e = f = 0; 615 CFX_Matrix(FX_FLOAT a1,
766 } 616 FX_FLOAT b1,
767 617 FX_FLOAT c1,
768 CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1) 618 FX_FLOAT d1,
769 { 619 FX_FLOAT e1,
770 a = a1; 620 FX_FLOAT f1) {
771 b = b1; 621 a = a1;
772 c = c1; 622 b = b1;
773 d = d1; 623 c = c1;
774 e = e1; 624 d = d1;
775 f = f1; 625 e = e1;
776 } 626 f = f1;
777 627 }
778 void» » » Set(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f); 628
779 void» » » Set(const FX_FLOAT n[6]); 629 void Set(FX_FLOAT a,
780 630 FX_FLOAT b,
781 void» » » SetIdentity() 631 FX_FLOAT c,
782 { 632 FX_FLOAT d,
783 a = d = 1; 633 FX_FLOAT e,
784 b = c = e = f = 0; 634 FX_FLOAT f);
785 } 635 void Set(const FX_FLOAT n[6]);
786 636
787 void» » » SetReverse(const CFX_Matrix &m); 637 void SetIdentity() {
788 638 a = d = 1;
789 void» » » Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FL OAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = FALSE); 639 b = c = e = f = 0;
790 640 }
791 void» » » Concat(const CFX_Matrix &m, FX_BOOL bPrepended = FALSE); 641
792 642 void SetReverse(const CFX_Matrix& m);
793 void» » » ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrep ended = FALSE); 643
794 void» » » Reset() 644 void Concat(FX_FLOAT a,
795 { 645 FX_FLOAT b,
796 SetIdentity(); 646 FX_FLOAT c,
797 } 647 FX_FLOAT d,
798 648 FX_FLOAT e,
799 void» » » Copy(const CFX_Matrix& m) 649 FX_FLOAT f,
800 { 650 FX_BOOL bPrepended = FALSE);
801 *this = m; 651
802 } 652 void Concat(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
803 653
804 FX_BOOL» » » IsIdentity() const 654 void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE);
805 { 655 void Reset() { SetIdentity(); }
806 return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; 656
807 } 657 void Copy(const CFX_Matrix& m) { *this = m; }
808 FX_BOOL» » » IsInvertible() const; 658
809 659 FX_BOOL IsIdentity() const {
810 FX_BOOL» » » Is90Rotated() const; 660 return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;
811 661 }
812 FX_BOOL» » » IsScaled() const; 662 FX_BOOL IsInvertible() const;
813 663
814 void» » » Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepe nded = FALSE); 664 FX_BOOL Is90Rotated() const;
815 665
816 void» » » TranslateI(int32_t x, int32_t y, FX_BOOL bPrepen ded = FALSE) 666 FX_BOOL IsScaled() const;
817 { 667
818 Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); 668 void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE);
819 } 669
820 670 void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE) {
821 void» » » Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepend ed = FALSE); 671 Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);
822 672 }
823 void» » » Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FA LSE); 673
824 674 void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE);
825 void» » » RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE); 675
826 676 void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE);
827 void» » » Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadia n, FX_BOOL bPrepended = FALSE); 677
828 678 void RotateAt(FX_FLOAT fRadian,
829 void» » » MatchRect(const CFX_FloatRect &dest, const CFX_F loatRect &src); 679 FX_FLOAT x,
830 680 FX_FLOAT y,
831 FX_FLOAT» » GetXUnit() const; 681 FX_BOOL bPrepended = FALSE);
832 682
833 FX_FLOAT» » GetYUnit() const; 683 void Shear(FX_FLOAT fAlphaRadian,
834 void» » » GetUnitRect(CFX_RectF &rect) const; 684 FX_FLOAT fBetaRadian,
835 685 FX_BOOL bPrepended = FALSE);
836 CFX_FloatRect» GetUnitRect() const; 686
837 687 void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src);
838 FX_FLOAT» » GetUnitArea() const; 688
839 FX_FLOAT» » TransformXDistance(FX_FLOAT dx) const; 689 FX_FLOAT GetXUnit() const;
840 int32_t» » TransformXDistance(int32_t dx) const; 690
841 FX_FLOAT» » TransformYDistance(FX_FLOAT dy) const; 691 FX_FLOAT GetYUnit() const;
842 int32_t» » TransformYDistance(int32_t dy) const; 692 void GetUnitRect(CFX_RectF& rect) const;
843 FX_FLOAT» » TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const; 693
844 int32_t» » TransformDistance(int32_t dx, int32_t dy) const; 694 CFX_FloatRect GetUnitRect() const;
845 695
846 FX_FLOAT» » TransformDistance(FX_FLOAT distance) const; 696 FX_FLOAT GetUnitArea() const;
847 void» » » TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const; 697 FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
848 void» » » TransformPoint(int32_t &x, int32_t &y) const; 698 int32_t TransformXDistance(int32_t dx) const;
849 void» » » TransformPoints(CFX_PointF *points, int32_t iCou nt) const; 699 FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
850 void» » » TransformPoints(CFX_Point *points, int32_t iCoun t) const; 700 int32_t TransformYDistance(int32_t dy) const;
851 701 FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
852 void» » » Transform(FX_FLOAT& x, FX_FLOAT& y) const 702 int32_t TransformDistance(int32_t dx, int32_t dy) const;
853 { 703
854 TransformPoint(x, y); 704 FX_FLOAT TransformDistance(FX_FLOAT distance) const;
855 } 705 void TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const;
856 706 void TransformPoint(int32_t& x, int32_t& y) const;
857 void» » » Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const 707 void TransformPoints(CFX_PointF* points, int32_t iCount) const;
858 { 708 void TransformPoints(CFX_Point* points, int32_t iCount) const;
859 x1 = x, y1 = y; 709
860 TransformPoint(x1, y1); 710 void Transform(FX_FLOAT& x, FX_FLOAT& y) const { TransformPoint(x, y); }
861 } 711
862 void» » » TransformVector(CFX_VectorF &v) const; 712 void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const {
863 void» » » TransformVector(CFX_Vector &v) const; 713 x1 = x, y1 = y;
864 void» » » TransformRect(CFX_RectF &rect) const; 714 TransformPoint(x1, y1);
865 void» » » TransformRect(CFX_Rect &rect) const; 715 }
866 716 void TransformVector(CFX_VectorF& v) const;
867 void» » » TransformRect(FX_FLOAT& left, FX_FLOAT& right, F X_FLOAT& top, FX_FLOAT& bottom) const; 717 void TransformVector(CFX_Vector& v) const;
868 718 void TransformRect(CFX_RectF& rect) const;
869 void» » » TransformRect(CFX_FloatRect& rect) const 719 void TransformRect(CFX_Rect& rect) const;
870 { 720
871 TransformRect(rect.left, rect.right, rect.top, rect.bottom); 721 void TransformRect(FX_FLOAT& left,
872 } 722 FX_FLOAT& right,
873 723 FX_FLOAT& top,
874 FX_FLOAT» » GetA() const 724 FX_FLOAT& bottom) const;
875 { 725
876 return a; 726 void TransformRect(CFX_FloatRect& rect) const {
877 } 727 TransformRect(rect.left, rect.right, rect.top, rect.bottom);
878 728 }
879 FX_FLOAT» » GetB() const 729
880 { 730 FX_FLOAT GetA() const { return a; }
881 return b; 731
882 } 732 FX_FLOAT GetB() const { return b; }
883 733
884 FX_FLOAT» » GetC() const 734 FX_FLOAT GetC() const { return c; }
885 { 735
886 return c; 736 FX_FLOAT GetD() const { return d; }
887 } 737
888 738 FX_FLOAT GetE() const { return e; }
889 FX_FLOAT» » GetD() const 739
890 { 740 FX_FLOAT GetF() const { return f; }
891 return d; 741
892 } 742 public:
893 743 FX_FLOAT a;
894 FX_FLOAT» » GetE() const 744 FX_FLOAT b;
895 { 745 FX_FLOAT c;
896 return e; 746 FX_FLOAT d;
897 } 747 FX_FLOAT e;
898 748 FX_FLOAT f;
899 FX_FLOAT» » GetF() const
900 {
901 return f;
902 }
903 public:
904 FX_FLOAT a;
905 FX_FLOAT b;
906 FX_FLOAT c;
907 FX_FLOAT d;
908 FX_FLOAT e;
909 FX_FLOAT f;
910 }; 749 };
911 #define CFX_AffineMatrix» CFX_Matrix 750 #define CFX_AffineMatrix CFX_Matrix
912 751
913 #endif // CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ 752 #endif // CORE_INCLUDE_FXCRT_FX_COORDINATES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698