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_FXCRT_INCLUDE_FX_COORDINATES_H_ | |
8 #define CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | |
9 | |
10 #include "core/fxcrt/include/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_RECT { | |
128 FX_RECT() : left(0), top(0), right(0), bottom(0) {} | |
129 | |
130 FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} | |
131 | |
132 int Width() const { return right - left; } | |
133 int Height() const { return bottom - top; } | |
134 bool IsEmpty() const { return right <= left || bottom <= top; } | |
135 | |
136 bool Valid() const { | |
137 pdfium::base::CheckedNumeric<int> w = right; | |
138 pdfium::base::CheckedNumeric<int> h = bottom; | |
139 w -= left; | |
140 h -= top; | |
141 return w.IsValid() && h.IsValid(); | |
142 } | |
143 | |
144 void Normalize(); | |
145 | |
146 void Intersect(const FX_RECT& src); | |
147 void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); } | |
148 | |
149 void Union(const FX_RECT& other_rect); | |
150 void Union(int l, int t, int r, int b) { Union(FX_RECT(l, t, r, b)); } | |
151 | |
152 void Offset(int dx, int dy) { | |
153 left += dx; | |
154 right += dx; | |
155 top += dy; | |
156 bottom += dy; | |
157 } | |
158 | |
159 bool operator==(const FX_RECT& src) const { | |
160 return left == src.left && right == src.right && top == src.top && | |
161 bottom == src.bottom; | |
162 } | |
163 | |
164 bool Contains(const FX_RECT& other_rect) const { | |
165 return other_rect.left >= left && other_rect.right <= right && | |
166 other_rect.top >= top && other_rect.bottom <= bottom; | |
167 } | |
168 | |
169 bool Contains(int x, int y) const { | |
170 return x >= left && x < right && y >= top && y < bottom; | |
171 } | |
172 | |
173 int32_t left; | |
174 int32_t top; | |
175 int32_t right; | |
176 int32_t bottom; | |
177 }; | |
178 | |
179 // LBRT rectangles (y-axis runs upwards). | |
180 class CFX_FloatPoint { | |
181 public: | |
182 CFX_FloatPoint() : x(0.0f), y(0.0f) {} | |
183 CFX_FloatPoint(FX_FLOAT xx, FX_FLOAT yy) : x(xx), y(yy) {} | |
184 | |
185 bool operator==(const CFX_FloatPoint& that) const { | |
186 return x == that.x && y == that.y; | |
187 } | |
188 bool operator!=(const CFX_FloatPoint& that) const { return !(*this == that); } | |
189 | |
190 FX_FLOAT x; | |
191 FX_FLOAT y; | |
192 }; | |
193 | |
194 // LTWH rectangles (y-axis runs downwards). | |
195 template <class baseType> | |
196 class CFX_RTemplate { | |
197 public: | |
198 typedef CFX_PSTemplate<baseType> FXT_POINT; | |
199 typedef CFX_PSTemplate<baseType> FXT_SIZE; | |
200 typedef CFX_VTemplate<baseType> FXT_VECTOR; | |
201 typedef CFX_RTemplate<baseType> FXT_RECT; | |
202 void Set(baseType dst_left, | |
203 baseType dst_top, | |
204 baseType dst_width, | |
205 baseType dst_height) { | |
206 left = dst_left; | |
207 top = dst_top; | |
208 width = dst_width; | |
209 height = dst_height; | |
210 } | |
211 void Set(baseType dst_left, baseType dst_top, const FXT_SIZE& dst_size) { | |
212 left = dst_left; | |
213 top = dst_top; | |
214 Size(dst_size); | |
215 } | |
216 void Set(const FXT_POINT& p, baseType dst_width, baseType dst_height) { | |
217 TopLeft(p); | |
218 width = dst_width; | |
219 height = dst_height; | |
220 } | |
221 void Set(const FXT_POINT& p1, const FXT_POINT& p2) { | |
222 TopLeft(p1); | |
223 width = p2.x - p1.x; | |
224 height = p2.y - p1.y; | |
225 Normalize(); | |
226 } | |
227 void Set(const FXT_POINT& p, const FXT_VECTOR& v) { | |
228 TopLeft(p); | |
229 width = v.x; | |
230 height = v.y; | |
231 Normalize(); | |
232 } | |
233 void Reset() { | |
234 left = 0; | |
235 top = 0; | |
236 width = 0; | |
237 height = 0; | |
238 } | |
239 FXT_RECT& operator+=(const FXT_POINT& p) { | |
240 left += p.x; | |
241 top += p.y; | |
242 return *this; | |
243 } | |
244 FXT_RECT& operator-=(const FXT_POINT& p) { | |
245 left -= p.x; | |
246 top -= p.y; | |
247 return *this; | |
248 } | |
249 baseType right() const { return left + width; } | |
250 baseType bottom() const { return top + height; } | |
251 void Normalize() { | |
252 if (width < 0) { | |
253 left += width; | |
254 width = -width; | |
255 } | |
256 if (height < 0) { | |
257 top += height; | |
258 height = -height; | |
259 } | |
260 } | |
261 void Offset(baseType dx, baseType dy) { | |
262 left += dx; | |
263 top += dy; | |
264 } | |
265 void Inflate(baseType x, baseType y) { | |
266 left -= x; | |
267 width += x * 2; | |
268 top -= y; | |
269 height += y * 2; | |
270 } | |
271 void Inflate(const FXT_POINT& p) { Inflate(p.x, p.y); } | |
272 void Inflate(baseType off_left, | |
273 baseType off_top, | |
274 baseType off_right, | |
275 baseType off_bottom) { | |
276 left -= off_left; | |
277 top -= off_top; | |
278 width += off_left + off_right; | |
279 height += off_top + off_bottom; | |
280 } | |
281 void Inflate(const FXT_RECT& rt) { | |
282 Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height); | |
283 } | |
284 void Deflate(baseType x, baseType y) { | |
285 left += x; | |
286 width -= x * 2; | |
287 top += y; | |
288 height -= y * 2; | |
289 } | |
290 void Deflate(const FXT_POINT& p) { Deflate(p.x, p.y); } | |
291 void Deflate(baseType off_left, | |
292 baseType off_top, | |
293 baseType off_right, | |
294 baseType off_bottom) { | |
295 left += off_left; | |
296 top += off_top; | |
297 width -= off_left + off_right; | |
298 height -= off_top + off_bottom; | |
299 } | |
300 void Deflate(const FXT_RECT& rt) { | |
301 Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); | |
302 } | |
303 FX_BOOL IsEmpty() const { return width <= 0 || height <= 0; } | |
304 FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const { | |
305 return width <= fEpsilon || height <= fEpsilon; | |
306 } | |
307 void Empty() { width = height = 0; } | |
308 bool Contains(baseType x, baseType y) const { | |
309 return x >= left && x < left + width && y >= top && y < top + height; | |
310 } | |
311 bool Contains(const FXT_POINT& p) const { return Contains(p.x, p.y); } | |
312 bool Contains(const FXT_RECT& rt) const { | |
313 return rt.left >= left && rt.right() <= right() && rt.top >= top && | |
314 rt.bottom() <= bottom(); | |
315 } | |
316 baseType Width() const { return width; } | |
317 baseType Height() const { return height; } | |
318 FXT_SIZE Size() const { | |
319 FXT_SIZE size; | |
320 size.Set(width, height); | |
321 return size; | |
322 } | |
323 void Size(FXT_SIZE s) { width = s.x, height = s.y; } | |
324 FXT_POINT TopLeft() const { | |
325 FXT_POINT p; | |
326 p.x = left; | |
327 p.y = top; | |
328 return p; | |
329 } | |
330 FXT_POINT TopRight() const { | |
331 FXT_POINT p; | |
332 p.x = left + width; | |
333 p.y = top; | |
334 return p; | |
335 } | |
336 FXT_POINT BottomLeft() const { | |
337 FXT_POINT p; | |
338 p.x = left; | |
339 p.y = top + height; | |
340 return p; | |
341 } | |
342 FXT_POINT BottomRight() const { | |
343 FXT_POINT p; | |
344 p.x = left + width; | |
345 p.y = top + height; | |
346 return p; | |
347 } | |
348 void TopLeft(FXT_POINT tl) { | |
349 left = tl.x; | |
350 top = tl.y; | |
351 } | |
352 void TopRight(FXT_POINT tr) { | |
353 width = tr.x - left; | |
354 top = tr.y; | |
355 } | |
356 void BottomLeft(FXT_POINT bl) { | |
357 left = bl.x; | |
358 height = bl.y - top; | |
359 } | |
360 void BottomRight(FXT_POINT br) { | |
361 width = br.x - left; | |
362 height = br.y - top; | |
363 } | |
364 FXT_POINT Center() const { | |
365 FXT_POINT p; | |
366 p.x = left + width / 2; | |
367 p.y = top + height / 2; | |
368 return p; | |
369 } | |
370 void Union(baseType x, baseType y) { | |
371 baseType r = right(); | |
372 baseType b = bottom(); | |
373 if (left > x) | |
374 left = x; | |
375 if (r < x) | |
376 r = x; | |
377 if (top > y) | |
378 top = y; | |
379 if (b < y) | |
380 b = y; | |
381 width = r - left; | |
382 height = b - top; | |
383 } | |
384 void Union(const FXT_POINT& p) { Union(p.x, p.y); } | |
385 void Union(const FXT_RECT& rt) { | |
386 baseType r = right(); | |
387 baseType b = bottom(); | |
388 if (left > rt.left) | |
389 left = rt.left; | |
390 if (r < rt.right()) | |
391 r = rt.right(); | |
392 if (top > rt.top) | |
393 top = rt.top; | |
394 if (b < rt.bottom()) | |
395 b = rt.bottom(); | |
396 width = r - left; | |
397 height = b - top; | |
398 } | |
399 void Intersect(const FXT_RECT& rt) { | |
400 baseType r = right(); | |
401 baseType b = bottom(); | |
402 if (left < rt.left) | |
403 left = rt.left; | |
404 if (r > rt.right()) | |
405 r = rt.right(); | |
406 if (top < rt.top) | |
407 top = rt.top; | |
408 if (b > rt.bottom()) | |
409 b = rt.bottom(); | |
410 width = r - left; | |
411 height = b - top; | |
412 } | |
413 FX_BOOL IntersectWith(const FXT_RECT& rt) const { | |
414 FXT_RECT rect = rt; | |
415 rect.Intersect(*this); | |
416 return !rect.IsEmpty(); | |
417 } | |
418 FX_BOOL IntersectWith(const FXT_RECT& rt, FX_FLOAT fEpsilon) const { | |
419 FXT_RECT rect = rt; | |
420 rect.Intersect(*this); | |
421 return !rect.IsEmpty(fEpsilon); | |
422 } | |
423 friend bool operator==(const FXT_RECT& rc1, const FXT_RECT& rc2) { | |
424 return rc1.left == rc2.left && rc1.top == rc2.top && | |
425 rc1.width == rc2.width && rc1.height == rc2.height; | |
426 } | |
427 friend bool operator!=(const FXT_RECT& rc1, const FXT_RECT& rc2) { | |
428 return !(rc1 == rc2); | |
429 } | |
430 baseType left, top; | |
431 baseType width, height; | |
432 }; | |
433 typedef CFX_RTemplate<int32_t> CFX_Rect; | |
434 typedef CFX_RTemplate<FX_FLOAT> CFX_RectF; | |
435 typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray; | |
436 | |
437 class CFX_FloatRect { | |
438 public: | |
439 CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {} | |
440 CFX_FloatRect(FX_FLOAT l, FX_FLOAT b, FX_FLOAT r, FX_FLOAT t) | |
441 : left(l), bottom(b), right(r), top(t) {} | |
442 | |
443 explicit CFX_FloatRect(const FX_FLOAT* pArray) | |
444 : CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {} | |
445 | |
446 explicit CFX_FloatRect(const FX_RECT& rect); | |
447 | |
448 void Normalize(); | |
449 | |
450 void Reset() { | |
451 left = 0.0f; | |
452 right = 0.0f; | |
453 bottom = 0.0f; | |
454 top = 0.0f; | |
455 } | |
456 | |
457 bool IsEmpty() const { return left >= right || bottom >= top; } | |
458 bool Contains(const CFX_FloatRect& other_rect) const; | |
459 bool Contains(FX_FLOAT x, FX_FLOAT y) const; | |
460 | |
461 void Transform(const CFX_Matrix* pMatrix); | |
462 void Intersect(const CFX_FloatRect& other_rect); | |
463 void Union(const CFX_FloatRect& other_rect); | |
464 | |
465 FX_RECT GetInnerRect() const; | |
466 FX_RECT GetOuterRect() const; | |
467 FX_RECT GetClosestRect() const; | |
468 | |
469 int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects); | |
470 | |
471 void InitRect(FX_FLOAT x, FX_FLOAT y) { | |
472 left = x; | |
473 right = x; | |
474 bottom = y; | |
475 top = y; | |
476 } | |
477 void UpdateRect(FX_FLOAT x, FX_FLOAT y); | |
478 | |
479 FX_FLOAT Width() const { return right - left; } | |
480 FX_FLOAT Height() const { return top - bottom; } | |
481 | |
482 void Inflate(FX_FLOAT x, FX_FLOAT y) { | |
483 Normalize(); | |
484 left -= x; | |
485 right += x; | |
486 bottom -= y; | |
487 top += y; | |
488 } | |
489 | |
490 void Inflate(FX_FLOAT other_left, | |
491 FX_FLOAT other_bottom, | |
492 FX_FLOAT other_right, | |
493 FX_FLOAT other_top) { | |
494 Normalize(); | |
495 left -= other_left; | |
496 bottom -= other_bottom; | |
497 right += other_right; | |
498 top += other_top; | |
499 } | |
500 | |
501 void Inflate(const CFX_FloatRect& rt) { | |
502 Inflate(rt.left, rt.bottom, rt.right, rt.top); | |
503 } | |
504 | |
505 void Deflate(FX_FLOAT x, FX_FLOAT y) { | |
506 Normalize(); | |
507 left += x; | |
508 right -= x; | |
509 bottom += y; | |
510 top -= y; | |
511 } | |
512 | |
513 void Deflate(FX_FLOAT other_left, | |
514 FX_FLOAT other_bottom, | |
515 FX_FLOAT other_right, | |
516 FX_FLOAT other_top) { | |
517 Normalize(); | |
518 left += other_left; | |
519 bottom += other_bottom; | |
520 right -= other_right; | |
521 top -= other_top; | |
522 } | |
523 | |
524 void Deflate(const CFX_FloatRect& rt) { | |
525 Deflate(rt.left, rt.bottom, rt.right, rt.top); | |
526 } | |
527 | |
528 void Translate(FX_FLOAT e, FX_FLOAT f) { | |
529 left += e; | |
530 right += e; | |
531 top += f; | |
532 bottom += f; | |
533 } | |
534 | |
535 static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints); | |
536 | |
537 FX_RECT ToFxRect() const { | |
538 return FX_RECT(static_cast<int32_t>(left), static_cast<int32_t>(top), | |
539 static_cast<int32_t>(right), static_cast<int32_t>(bottom)); | |
540 } | |
541 | |
542 static CFX_FloatRect FromCFXRectF(const CFX_RectF& rect) { | |
543 return CFX_FloatRect(rect.left, rect.top, rect.right(), rect.bottom()); | |
544 } | |
545 | |
546 FX_FLOAT left; | |
547 FX_FLOAT bottom; | |
548 FX_FLOAT right; | |
549 FX_FLOAT top; | |
550 }; | |
551 | |
552 class CFX_Matrix { | |
553 public: | |
554 CFX_Matrix() { SetIdentity(); } | |
555 | |
556 CFX_Matrix(FX_FLOAT a1, | |
557 FX_FLOAT b1, | |
558 FX_FLOAT c1, | |
559 FX_FLOAT d1, | |
560 FX_FLOAT e1, | |
561 FX_FLOAT f1) { | |
562 a = a1; | |
563 b = b1; | |
564 c = c1; | |
565 d = d1; | |
566 e = e1; | |
567 f = f1; | |
568 } | |
569 | |
570 void Set(FX_FLOAT a, | |
571 FX_FLOAT b, | |
572 FX_FLOAT c, | |
573 FX_FLOAT d, | |
574 FX_FLOAT e, | |
575 FX_FLOAT f); | |
576 void Set(const FX_FLOAT n[6]); | |
577 | |
578 void SetIdentity() { | |
579 a = d = 1; | |
580 b = c = e = f = 0; | |
581 } | |
582 | |
583 void SetReverse(const CFX_Matrix& m); | |
584 | |
585 void Concat(FX_FLOAT a, | |
586 FX_FLOAT b, | |
587 FX_FLOAT c, | |
588 FX_FLOAT d, | |
589 FX_FLOAT e, | |
590 FX_FLOAT f, | |
591 FX_BOOL bPrepended = FALSE); | |
592 void Concat(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); | |
593 void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); | |
594 | |
595 FX_BOOL IsIdentity() const { | |
596 return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; | |
597 } | |
598 | |
599 FX_BOOL IsInvertible() const; | |
600 FX_BOOL Is90Rotated() const; | |
601 FX_BOOL IsScaled() const; | |
602 | |
603 void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE); | |
604 void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE) { | |
605 Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); | |
606 } | |
607 | |
608 void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE); | |
609 void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE); | |
610 void RotateAt(FX_FLOAT fRadian, | |
611 FX_FLOAT x, | |
612 FX_FLOAT y, | |
613 FX_BOOL bPrepended = FALSE); | |
614 | |
615 void Shear(FX_FLOAT fAlphaRadian, | |
616 FX_FLOAT fBetaRadian, | |
617 FX_BOOL bPrepended = FALSE); | |
618 | |
619 void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src); | |
620 FX_FLOAT GetXUnit() const; | |
621 FX_FLOAT GetYUnit() const; | |
622 void GetUnitRect(CFX_RectF& rect) const; | |
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 void TransformRect(FX_FLOAT& left, | |
648 FX_FLOAT& right, | |
649 FX_FLOAT& top, | |
650 FX_FLOAT& bottom) const; | |
651 void TransformRect(CFX_FloatRect& rect) const { | |
652 TransformRect(rect.left, rect.right, rect.top, rect.bottom); | |
653 } | |
654 | |
655 FX_FLOAT GetA() const { return a; } | |
656 FX_FLOAT GetB() const { return b; } | |
657 FX_FLOAT GetC() const { return c; } | |
658 FX_FLOAT GetD() const { return d; } | |
659 FX_FLOAT GetE() const { return e; } | |
660 FX_FLOAT GetF() const { return f; } | |
661 | |
662 public: | |
663 FX_FLOAT a; | |
664 FX_FLOAT b; | |
665 FX_FLOAT c; | |
666 FX_FLOAT d; | |
667 FX_FLOAT e; | |
668 FX_FLOAT f; | |
669 }; | |
670 | |
671 #endif // CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | |
OLD | NEW |