OLD | NEW |
| (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 CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ | |
8 #define CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ | |
9 | |
10 #include "core/include/fxcrt/fx_basic.h" | |
11 | |
12 class CFX_Matrix; | |
13 | |
14 template <class BaseType> | |
15 class CFX_PSTemplate { | |
16 public: | |
17 CFX_PSTemplate() : x(0), y(0) {} | |
18 CFX_PSTemplate(BaseType new_x, BaseType new_y) : x(new_x), y(new_y) {} | |
19 CFX_PSTemplate(const CFX_PSTemplate& other) : x(other.x), y(other.y) {} | |
20 void clear() { | |
21 x = 0; | |
22 y = 0; | |
23 } | |
24 CFX_PSTemplate operator=(const CFX_PSTemplate& other) { | |
25 if (this != &other) { | |
26 x = other.x; | |
27 y = other.y; | |
28 } | |
29 return *this; | |
30 } | |
31 bool operator==(const CFX_PSTemplate& other) const { | |
32 return x == other.x && y == other.y; | |
33 } | |
34 bool operator!=(const CFX_PSTemplate& other) const { | |
35 return !(*this == other); | |
36 } | |
37 CFX_PSTemplate& operator+=(const CFX_PSTemplate<BaseType>& obj) { | |
38 x += obj.x; | |
39 y += obj.y; | |
40 return *this; | |
41 } | |
42 CFX_PSTemplate& operator-=(const CFX_PSTemplate<BaseType>& obj) { | |
43 x -= obj.x; | |
44 y -= obj.y; | |
45 return *this; | |
46 } | |
47 CFX_PSTemplate& operator*=(BaseType factor) { | |
48 x *= factor; | |
49 y *= factor; | |
50 return *this; | |
51 } | |
52 CFX_PSTemplate& operator/=(BaseType divisor) { | |
53 x /= divisor; | |
54 y /= divisor; | |
55 return *this; | |
56 } | |
57 CFX_PSTemplate operator+(const CFX_PSTemplate& other) { | |
58 return CFX_PSTemplate(x + other.x, y + other.y); | |
59 } | |
60 CFX_PSTemplate operator-(const CFX_PSTemplate& other) { | |
61 return CFX_PSTemplate(x - other.x, y - other.y); | |
62 } | |
63 CFX_PSTemplate operator*(BaseType factor) { | |
64 return CFX_PSTemplate(x * factor, y * factor); | |
65 } | |
66 CFX_PSTemplate operator/(BaseType divisor) { | |
67 return CFX_PSTemplate(x / divisor, y / divisor); | |
68 } | |
69 | |
70 BaseType x; | |
71 BaseType y; | |
72 }; | |
73 typedef CFX_PSTemplate<int32_t> CFX_Point; | |
74 typedef CFX_PSTemplate<FX_FLOAT> CFX_PointF; | |
75 typedef CFX_PSTemplate<int32_t> CFX_Size; | |
76 typedef CFX_PSTemplate<FX_FLOAT> CFX_SizeF; | |
77 typedef CFX_ArrayTemplate<CFX_Point> CFX_Points; | |
78 typedef CFX_ArrayTemplate<CFX_PointF> CFX_PointsF; | |
79 | |
80 template <class BaseType> | |
81 class CFX_VTemplate : public CFX_PSTemplate<BaseType> { | |
82 public: | |
83 using CFX_PSTemplate<BaseType>::x; | |
84 using CFX_PSTemplate<BaseType>::y; | |
85 | |
86 CFX_VTemplate() : CFX_PSTemplate<BaseType>() {} | |
87 CFX_VTemplate(BaseType new_x, BaseType new_y) | |
88 : CFX_PSTemplate<BaseType>(new_x, new_y) {} | |
89 | |
90 CFX_VTemplate(const CFX_VTemplate& other) : CFX_PSTemplate<BaseType>(other) {} | |
91 | |
92 CFX_VTemplate(const CFX_PSTemplate<BaseType>& point1, | |
93 const CFX_PSTemplate<BaseType>& point2) | |
94 : CFX_PSTemplate<BaseType>(point2.x - point1.x, point2.y - point1.y) {} | |
95 | |
96 FX_FLOAT Length() const { return FXSYS_sqrt(x * x + y * y); } | |
97 void Normalize() { | |
98 FX_FLOAT fLen = Length(); | |
99 if (fLen < 0.0001f) | |
100 return; | |
101 | |
102 x /= fLen; | |
103 y /= fLen; | |
104 } | |
105 void Translate(BaseType dx, BaseType dy) { | |
106 x += dx; | |
107 y += dy; | |
108 } | |
109 void Scale(BaseType sx, BaseType sy) { | |
110 x *= sx; | |
111 y *= sy; | |
112 } | |
113 void Rotate(FX_FLOAT fRadian) { | |
114 FX_FLOAT cosValue = FXSYS_cos(fRadian); | |
115 FX_FLOAT sinValue = FXSYS_sin(fRadian); | |
116 x = x * cosValue - y * sinValue; | |
117 y = x * sinValue + y * cosValue; | |
118 } | |
119 }; | |
120 typedef CFX_VTemplate<int32_t> CFX_Vector; | |
121 typedef CFX_VTemplate<FX_FLOAT> CFX_VectorF; | |
122 | |
123 // Rectangles. | |
124 // TODO(tsepez): Consolidate all these different rectangle classes. | |
125 | |
126 // LTRB rectangles (y-axis runs downwards). | |
127 struct FX_SMALL_RECT { | |
128 FX_SMALL_RECT() : FX_SMALL_RECT(kInvalid, kInvalid, kInvalid, kInvalid) {} | |
129 | |
130 FX_SMALL_RECT(int16_t l, int16_t t, int16_t r, int16_t b) | |
131 : left(l), top(t), right(r), bottom(b) {} | |
132 | |
133 static const int16_t kInvalid = -1; | |
134 | |
135 int16_t left; | |
136 int16_t top; | |
137 int16_t right; | |
138 int16_t bottom; | |
139 }; | |
140 | |
141 struct FX_RECT { | |
142 FX_RECT() : left(0), top(0), right(0), bottom(0) {} | |
143 | |
144 FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} | |
145 | |
146 explicit FX_RECT(const FX_SMALL_RECT& other) | |
147 : FX_RECT(other.left, other.top, other.right, other.bottom) {} | |
148 | |
149 int Width() const { return right - left; } | |
150 int Height() const { return bottom - top; } | |
151 bool IsEmpty() const { return right <= left || bottom <= top; } | |
152 | |
153 void Normalize(); | |
154 | |
155 void Intersect(const FX_RECT& src); | |
156 void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); } | |
157 | |
158 void Union(const FX_RECT& other_rect); | |
159 void Union(int l, int t, int r, int b) { Union(FX_RECT(l, t, r, b)); } | |
160 | |
161 void Offset(int dx, int dy) { | |
162 left += dx; | |
163 right += dx; | |
164 top += dy; | |
165 bottom += dy; | |
166 } | |
167 | |
168 bool operator==(const FX_RECT& src) const { | |
169 return left == src.left && right == src.right && top == src.top && | |
170 bottom == src.bottom; | |
171 } | |
172 | |
173 FX_BOOL Contains(const FX_RECT& other_rect) const { | |
174 return other_rect.left >= left && other_rect.right <= right && | |
175 other_rect.top >= top && other_rect.bottom <= bottom; | |
176 } | |
177 | |
178 FX_BOOL Contains(int x, int y) const { | |
179 return x >= left && x < right && y >= top && y < bottom; | |
180 } | |
181 | |
182 FX_SMALL_RECT ToSmallRect() const { | |
183 return FX_SMALL_RECT( | |
184 static_cast<uint16_t>(left), static_cast<uint16_t>(top), | |
185 static_cast<uint16_t>(right), static_cast<uint16_t>(bottom)); | |
186 } | |
187 | |
188 int32_t left; | |
189 int32_t top; | |
190 int32_t right; | |
191 int32_t bottom; | |
192 }; | |
193 | |
194 // LBRT rectangles (y-axis runs upwards). | |
195 class CFX_FloatPoint { | |
196 public: | |
197 CFX_FloatPoint(FX_FLOAT xx, FX_FLOAT yy) : x(xx), y(yy) {} | |
198 | |
199 FX_FLOAT x; | |
200 FX_FLOAT y; | |
201 }; | |
202 | |
203 class CFX_FloatRect { | |
204 public: | |
205 CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {} | |
206 CFX_FloatRect(FX_FLOAT l, FX_FLOAT b, FX_FLOAT r, FX_FLOAT t) | |
207 : left(l), bottom(b), right(r), top(t) {} | |
208 | |
209 explicit CFX_FloatRect(const FX_FLOAT* pArray) | |
210 : CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {} | |
211 | |
212 explicit CFX_FloatRect(const FX_RECT& rect); | |
213 | |
214 void Normalize(); | |
215 | |
216 void Reset() { | |
217 left = 0.0f; | |
218 right = 0.0f; | |
219 bottom = 0.0f; | |
220 top = 0.0f; | |
221 } | |
222 | |
223 bool IsEmpty() const { return left >= right || bottom >= top; } | |
224 bool Contains(const CFX_FloatRect& other_rect) const; | |
225 bool Contains(FX_FLOAT x, FX_FLOAT y) const; | |
226 | |
227 void Transform(const CFX_Matrix* pMatrix); | |
228 void Intersect(const CFX_FloatRect& other_rect); | |
229 void Union(const CFX_FloatRect& other_rect); | |
230 | |
231 FX_RECT GetInnerRect() const; | |
232 FX_RECT GetOutterRect() const; | |
233 FX_RECT GetClosestRect() const; | |
234 | |
235 int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects); | |
236 | |
237 void InitRect(FX_FLOAT x, FX_FLOAT y) { | |
238 left = x; | |
239 right = x; | |
240 bottom = y; | |
241 top = y; | |
242 } | |
243 void UpdateRect(FX_FLOAT x, FX_FLOAT y); | |
244 | |
245 FX_FLOAT Width() const { return right - left; } | |
246 FX_FLOAT Height() const { return top - bottom; } | |
247 | |
248 void Inflate(FX_FLOAT x, FX_FLOAT y) { | |
249 Normalize(); | |
250 left -= x; | |
251 right += x; | |
252 bottom -= y; | |
253 top += y; | |
254 } | |
255 | |
256 void Inflate(FX_FLOAT other_left, | |
257 FX_FLOAT other_bottom, | |
258 FX_FLOAT other_right, | |
259 FX_FLOAT other_top) { | |
260 Normalize(); | |
261 left -= other_left; | |
262 bottom -= other_bottom; | |
263 right += other_right; | |
264 top += other_top; | |
265 } | |
266 | |
267 void Inflate(const CFX_FloatRect& rt) { | |
268 Inflate(rt.left, rt.bottom, rt.right, rt.top); | |
269 } | |
270 | |
271 void Deflate(FX_FLOAT x, FX_FLOAT y) { | |
272 Normalize(); | |
273 left += x; | |
274 right -= x; | |
275 bottom += y; | |
276 top -= y; | |
277 } | |
278 | |
279 void Deflate(FX_FLOAT other_left, | |
280 FX_FLOAT other_bottom, | |
281 FX_FLOAT other_right, | |
282 FX_FLOAT other_top) { | |
283 Normalize(); | |
284 left += other_left; | |
285 bottom += other_bottom; | |
286 right -= other_right; | |
287 top -= other_top; | |
288 } | |
289 | |
290 void Deflate(const CFX_FloatRect& rt) { | |
291 Deflate(rt.left, rt.bottom, rt.right, rt.top); | |
292 } | |
293 | |
294 void Translate(FX_FLOAT e, FX_FLOAT f) { | |
295 left += e; | |
296 right += e; | |
297 top += f; | |
298 bottom += f; | |
299 } | |
300 | |
301 static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints); | |
302 | |
303 FX_RECT ToFxRect() const { | |
304 return FX_RECT(static_cast<int32_t>(left), static_cast<int32_t>(top), | |
305 static_cast<int32_t>(right), static_cast<int32_t>(bottom)); | |
306 } | |
307 | |
308 FX_FLOAT left; | |
309 FX_FLOAT bottom; | |
310 FX_FLOAT right; | |
311 FX_FLOAT top; | |
312 }; | |
313 using CFX_RectArray = CFX_ArrayTemplate<CFX_FloatRect>; | |
314 | |
315 // LTWH rectangles (y-axis runs downwards). | |
316 template <class baseType> | |
317 class CFX_RTemplate { | |
318 public: | |
319 typedef CFX_PSTemplate<baseType> FXT_POINT; | |
320 typedef CFX_PSTemplate<baseType> FXT_SIZE; | |
321 typedef CFX_VTemplate<baseType> FXT_VECTOR; | |
322 typedef CFX_RTemplate<baseType> FXT_RECT; | |
323 void Set(baseType left, baseType top, baseType width, baseType height) { | |
324 FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, | |
325 FXT_RECT::height = height; | |
326 } | |
327 void Set(baseType left, baseType top, const FXT_SIZE& size) { | |
328 FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size); | |
329 } | |
330 void Set(const FXT_POINT& p, baseType width, baseType height) { | |
331 TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height; | |
332 } | |
333 void Set(const FXT_POINT& p1, const FXT_POINT& p2) { | |
334 TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, | |
335 FXT_RECT::Normalize(); | |
336 } | |
337 void Set(const FXT_POINT& p, const FXT_VECTOR& v) { | |
338 TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, | |
339 FXT_RECT::Normalize(); | |
340 } | |
341 void Reset() { | |
342 FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0; | |
343 } | |
344 FXT_RECT& operator+=(const FXT_POINT& p) { | |
345 left += p.x, top += p.y; | |
346 return *this; | |
347 } | |
348 FXT_RECT& operator-=(const FXT_POINT& p) { | |
349 left -= p.x, top -= p.y; | |
350 return *this; | |
351 } | |
352 baseType right() const { return left + width; } | |
353 baseType bottom() const { return top + height; } | |
354 void Normalize() { | |
355 if (width < 0) { | |
356 left += width; | |
357 width = -width; | |
358 } | |
359 if (height < 0) { | |
360 top += height; | |
361 height = -height; | |
362 } | |
363 } | |
364 void Offset(baseType dx, baseType dy) { | |
365 left += dx; | |
366 top += dy; | |
367 } | |
368 void Inflate(baseType x, baseType y) { | |
369 left -= x; | |
370 width += x * 2; | |
371 top -= y; | |
372 height += y * 2; | |
373 } | |
374 void Inflate(const FXT_POINT& p) { Inflate(p.x, p.y); } | |
375 void Inflate(baseType left, baseType top, baseType right, baseType bottom) { | |
376 FXT_RECT::left -= left; | |
377 FXT_RECT::top -= top; | |
378 FXT_RECT::width += left + right; | |
379 FXT_RECT::height += top + bottom; | |
380 } | |
381 void Inflate(const FXT_RECT& rt) { | |
382 Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height); | |
383 } | |
384 void Deflate(baseType x, baseType y) { | |
385 left += x; | |
386 width -= x * 2; | |
387 top += y; | |
388 height -= y * 2; | |
389 } | |
390 void Deflate(const FXT_POINT& p) { Deflate(p.x, p.y); } | |
391 void Deflate(baseType left, baseType top, baseType right, baseType bottom) { | |
392 FXT_RECT::left += left; | |
393 FXT_RECT::top += top; | |
394 FXT_RECT::width -= left + right; | |
395 FXT_RECT::height -= top + bottom; | |
396 } | |
397 void Deflate(const FXT_RECT& rt) { | |
398 Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); | |
399 } | |
400 FX_BOOL IsEmpty() const { return width <= 0 || height <= 0; } | |
401 FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const { | |
402 return width <= fEpsilon || height <= fEpsilon; | |
403 } | |
404 void Empty() { width = height = 0; } | |
405 FX_BOOL Contains(baseType x, baseType y) const { | |
406 return x >= left && x < left + width && y >= top && y < top + height; | |
407 } | |
408 FX_BOOL Contains(const FXT_POINT& p) const { return Contains(p.x, p.y); } | |
409 FX_BOOL Contains(const FXT_RECT& rt) const { | |
410 return rt.left >= left && rt.right() <= right() && rt.top >= top && | |
411 rt.bottom() <= bottom(); | |
412 } | |
413 baseType Width() const { return width; } | |
414 baseType Height() const { return height; } | |
415 FXT_SIZE Size() const { | |
416 FXT_SIZE size; | |
417 size.Set(width, height); | |
418 return size; | |
419 } | |
420 void Size(FXT_SIZE s) { width = s.x, height = s.y; } | |
421 FXT_POINT TopLeft() const { | |
422 FXT_POINT p; | |
423 p.x = left; | |
424 p.y = top; | |
425 return p; | |
426 } | |
427 FXT_POINT TopRight() const { | |
428 FXT_POINT p; | |
429 p.x = left + width; | |
430 p.y = top; | |
431 return p; | |
432 } | |
433 FXT_POINT BottomLeft() const { | |
434 FXT_POINT p; | |
435 p.x = left; | |
436 p.y = top + height; | |
437 return p; | |
438 } | |
439 FXT_POINT BottomRight() const { | |
440 FXT_POINT p; | |
441 p.x = left + width; | |
442 p.y = top + height; | |
443 return p; | |
444 } | |
445 void TopLeft(FXT_POINT tl) { | |
446 left = tl.x; | |
447 top = tl.y; | |
448 } | |
449 void TopRight(FXT_POINT tr) { | |
450 width = tr.x - left; | |
451 top = tr.y; | |
452 } | |
453 void BottomLeft(FXT_POINT bl) { | |
454 left = bl.x; | |
455 height = bl.y - top; | |
456 } | |
457 void BottomRight(FXT_POINT br) { | |
458 width = br.x - left; | |
459 height = br.y - top; | |
460 } | |
461 FXT_POINT Center() const { | |
462 FXT_POINT p; | |
463 p.x = left + width / 2; | |
464 p.y = top + height / 2; | |
465 return p; | |
466 } | |
467 void Union(baseType x, baseType y) { | |
468 baseType r = right(), b = bottom(); | |
469 if (left > x) { | |
470 left = x; | |
471 } | |
472 if (r < x) { | |
473 r = x; | |
474 } | |
475 if (top > y) { | |
476 top = y; | |
477 } | |
478 if (b < y) { | |
479 b = y; | |
480 } | |
481 width = r - left; | |
482 height = b - top; | |
483 } | |
484 void Union(const FXT_POINT& p) { Union(p.x, p.y); } | |
485 void Union(const FXT_RECT& rt) { | |
486 baseType r = right(), b = bottom(); | |
487 if (left > rt.left) { | |
488 left = rt.left; | |
489 } | |
490 if (r < rt.right()) { | |
491 r = rt.right(); | |
492 } | |
493 if (top > rt.top) { | |
494 top = rt.top; | |
495 } | |
496 if (b < rt.bottom()) { | |
497 b = rt.bottom(); | |
498 } | |
499 width = r - left; | |
500 height = b - top; | |
501 } | |
502 void Intersect(const FXT_RECT& rt) { | |
503 baseType r = right(), b = bottom(); | |
504 if (left < rt.left) { | |
505 left = rt.left; | |
506 } | |
507 if (r > rt.right()) { | |
508 r = rt.right(); | |
509 } | |
510 if (top < rt.top) { | |
511 top = rt.top; | |
512 } | |
513 if (b > rt.bottom()) { | |
514 b = rt.bottom(); | |
515 } | |
516 width = r - left; | |
517 height = b - top; | |
518 } | |
519 FX_BOOL IntersectWith(const FXT_RECT& rt) const { | |
520 FXT_RECT rect = rt; | |
521 rect.Intersect(*this); | |
522 return !rect.IsEmpty(); | |
523 } | |
524 FX_BOOL IntersectWith(const FXT_RECT& rt, FX_FLOAT fEpsilon) const { | |
525 FXT_RECT rect = rt; | |
526 rect.Intersect(*this); | |
527 return !rect.IsEmpty(fEpsilon); | |
528 } | |
529 friend bool operator==(const FXT_RECT& rc1, const FXT_RECT& rc2) { | |
530 return rc1.left == rc2.left && rc1.top == rc2.top && | |
531 rc1.width == rc2.width && rc1.height == rc2.height; | |
532 } | |
533 friend bool operator!=(const FXT_RECT& rc1, const FXT_RECT& rc2) { | |
534 return !(rc1 == rc2); | |
535 } | |
536 baseType left, top; | |
537 baseType width, height; | |
538 }; | |
539 typedef CFX_RTemplate<int32_t> CFX_Rect; | |
540 typedef CFX_RTemplate<FX_FLOAT> CFX_RectF; | |
541 typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray; | |
542 | |
543 class CFX_Matrix { | |
544 public: | |
545 CFX_Matrix() { SetIdentity(); } | |
546 | |
547 CFX_Matrix(FX_FLOAT a1, | |
548 FX_FLOAT b1, | |
549 FX_FLOAT c1, | |
550 FX_FLOAT d1, | |
551 FX_FLOAT e1, | |
552 FX_FLOAT f1) { | |
553 a = a1; | |
554 b = b1; | |
555 c = c1; | |
556 d = d1; | |
557 e = e1; | |
558 f = f1; | |
559 } | |
560 | |
561 void Set(FX_FLOAT a, | |
562 FX_FLOAT b, | |
563 FX_FLOAT c, | |
564 FX_FLOAT d, | |
565 FX_FLOAT e, | |
566 FX_FLOAT f); | |
567 void Set(const FX_FLOAT n[6]); | |
568 | |
569 void SetIdentity() { | |
570 a = d = 1; | |
571 b = c = e = f = 0; | |
572 } | |
573 | |
574 void SetReverse(const CFX_Matrix& m); | |
575 | |
576 void Concat(FX_FLOAT a, | |
577 FX_FLOAT b, | |
578 FX_FLOAT c, | |
579 FX_FLOAT d, | |
580 FX_FLOAT e, | |
581 FX_FLOAT f, | |
582 FX_BOOL bPrepended = FALSE); | |
583 void Concat(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); | |
584 void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); | |
585 | |
586 void Copy(const CFX_Matrix& m) { *this = m; } | |
587 | |
588 FX_BOOL IsIdentity() const { | |
589 return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; | |
590 } | |
591 FX_BOOL IsInvertible() const; | |
592 | |
593 FX_BOOL Is90Rotated() const; | |
594 | |
595 FX_BOOL IsScaled() const; | |
596 | |
597 void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE); | |
598 | |
599 void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE) { | |
600 Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); | |
601 } | |
602 | |
603 void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE); | |
604 | |
605 void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE); | |
606 | |
607 void RotateAt(FX_FLOAT fRadian, | |
608 FX_FLOAT x, | |
609 FX_FLOAT y, | |
610 FX_BOOL bPrepended = FALSE); | |
611 | |
612 void Shear(FX_FLOAT fAlphaRadian, | |
613 FX_FLOAT fBetaRadian, | |
614 FX_BOOL bPrepended = FALSE); | |
615 | |
616 void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src); | |
617 | |
618 FX_FLOAT GetXUnit() const; | |
619 | |
620 FX_FLOAT GetYUnit() const; | |
621 void GetUnitRect(CFX_RectF& rect) const; | |
622 | |
623 CFX_FloatRect GetUnitRect() const; | |
624 | |
625 FX_FLOAT GetUnitArea() const; | |
626 FX_FLOAT TransformXDistance(FX_FLOAT dx) const; | |
627 int32_t TransformXDistance(int32_t dx) const; | |
628 FX_FLOAT TransformYDistance(FX_FLOAT dy) const; | |
629 int32_t TransformYDistance(int32_t dy) const; | |
630 FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const; | |
631 int32_t TransformDistance(int32_t dx, int32_t dy) const; | |
632 FX_FLOAT TransformDistance(FX_FLOAT distance) const; | |
633 | |
634 void TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const; | |
635 void TransformPoint(int32_t& x, int32_t& y) const; | |
636 | |
637 void Transform(FX_FLOAT& x, FX_FLOAT& y) const { TransformPoint(x, y); } | |
638 void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const { | |
639 x1 = x, y1 = y; | |
640 TransformPoint(x1, y1); | |
641 } | |
642 | |
643 void TransformVector(CFX_VectorF& v) const; | |
644 void TransformVector(CFX_Vector& v) const; | |
645 void TransformRect(CFX_RectF& rect) const; | |
646 void TransformRect(CFX_Rect& rect) const; | |
647 | |
648 void TransformRect(FX_FLOAT& left, | |
649 FX_FLOAT& right, | |
650 FX_FLOAT& top, | |
651 FX_FLOAT& bottom) const; | |
652 void TransformRect(CFX_FloatRect& rect) const { | |
653 TransformRect(rect.left, rect.right, rect.top, rect.bottom); | |
654 } | |
655 | |
656 FX_FLOAT GetA() const { return a; } | |
657 FX_FLOAT GetB() const { return b; } | |
658 FX_FLOAT GetC() const { return c; } | |
659 FX_FLOAT GetD() const { return d; } | |
660 FX_FLOAT GetE() const { return e; } | |
661 FX_FLOAT GetF() const { return f; } | |
662 | |
663 public: | |
664 FX_FLOAT a; | |
665 FX_FLOAT b; | |
666 FX_FLOAT c; | |
667 FX_FLOAT d; | |
668 FX_FLOAT e; | |
669 FX_FLOAT f; | |
670 }; | |
671 | |
672 #endif // CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ | |
OLD | NEW |