OLD | NEW |
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" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 x *= lamda; | 61 x *= lamda; |
62 y *= lamda; | 62 y *= lamda; |
63 return *this; | 63 return *this; |
64 } | 64 } |
65 FXT_PSV& operator /= (baseType lamda) | 65 FXT_PSV& operator /= (baseType lamda) |
66 { | 66 { |
67 x /= lamda; | 67 x /= lamda; |
68 y /= lamda; | 68 y /= lamda; |
69 return *this; | 69 return *this; |
70 } | 70 } |
71 friend» FX_BOOL»» operator == (const FXT_PSV &obj1, const FXT_PSV
&obj2) | 71 friend» bool» » operator == (const FXT_PSV &obj1, const FXT_PSV
&obj2) |
72 { | 72 { |
73 return obj1.x == obj2.x && obj1.y == obj2.y; | 73 return obj1.x == obj2.x && obj1.y == obj2.y; |
74 } | 74 } |
75 friend» FX_BOOL»» operator != (const FXT_PSV &obj1, const FXT_PSV
&obj2) | 75 friend» bool» » operator != (const FXT_PSV &obj1, const FXT_PSV
&obj2) |
76 { | 76 { |
77 return obj1.x != obj2.x || obj1.y != obj2.y; | 77 return obj1.x != obj2.x || obj1.y != obj2.y; |
78 } | 78 } |
79 friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &
obj2) | 79 friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &
obj2) |
80 { | 80 { |
81 CFX_PSVTemplate obj; | 81 CFX_PSVTemplate obj; |
82 obj.x = obj1.x + obj2.x; | 82 obj.x = obj1.x + obj2.x; |
83 obj.y = obj1.y + obj2.y; | 83 obj.y = obj1.y + obj2.y; |
84 return obj; | 84 return obj; |
85 } | 85 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen; | 167 FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen; |
168 } | 168 } |
169 baseType DotProduct(baseType otherx, baseType othery) const | 169 baseType DotProduct(baseType otherx, baseType othery) const |
170 { | 170 { |
171 return FXT_PSV::x * otherx + FXT_PSV::y * othery; | 171 return FXT_PSV::x * otherx + FXT_PSV::y * othery; |
172 } | 172 } |
173 baseType DotProduct(const FXT_VECTOR &v) const | 173 baseType DotProduct(const FXT_VECTOR &v) const |
174 { | 174 { |
175 return FXT_PSV::x * v.x + FXT_PSV::y * v.y; | 175 return FXT_PSV::x * v.x + FXT_PSV::y * v.y; |
176 } | 176 } |
177 FX_BOOL» » IsParallel(baseType otherx, baseType othery) const | 177 bool» » IsParallel(baseType otherx, baseType othery) const |
178 { | 178 { |
179 baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx; | 179 baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx; |
180 return FXSYS_fabs(t) < 0x0001f; | 180 return FXSYS_fabs(t) < 0x0001f; |
181 } | 181 } |
182 FX_BOOL» » IsParallel(const FXT_VECTOR &v) const | 182 bool» » IsParallel(const FXT_VECTOR &v) const |
183 { | 183 { |
184 return IsParallel(v.x, v.y); | 184 return IsParallel(v.x, v.y); |
185 } | 185 } |
186 FX_BOOL» » IsPerpendicular(baseType otherx, baseType othery) const | 186 bool» » IsPerpendicular(baseType otherx, baseType othery) const |
187 { | 187 { |
188 baseType t = DotProduct(otherx, othery); | 188 baseType t = DotProduct(otherx, othery); |
189 return FXSYS_fabs(t) < 0x0001f; | 189 return FXSYS_fabs(t) < 0x0001f; |
190 } | 190 } |
191 FX_BOOL» » IsPerpendicular(const FXT_VECTOR &v) const | 191 bool» » IsPerpendicular(const FXT_VECTOR &v) const |
192 { | 192 { |
193 return IsPerpendicular(v.x, v.y); | 193 return IsPerpendicular(v.x, v.y); |
194 } | 194 } |
195 void Translate(baseType dx, baseType dy) | 195 void Translate(baseType dx, baseType dy) |
196 { | 196 { |
197 FXT_PSV::x += dx, FXT_PSV::y += dy; | 197 FXT_PSV::x += dx, FXT_PSV::y += dy; |
198 } | 198 } |
199 void Scale(baseType sx, baseType sy) | 199 void Scale(baseType sx, baseType sy) |
200 { | 200 { |
201 FXT_PSV::x *= sx, FXT_PSV::y *= sy; | 201 FXT_PSV::x *= sx, FXT_PSV::y *= sy; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 { | 333 { |
334 FXT_RECT::left += left; | 334 FXT_RECT::left += left; |
335 FXT_RECT::top += top; | 335 FXT_RECT::top += top; |
336 FXT_RECT::width -= left + right; | 336 FXT_RECT::width -= left + right; |
337 FXT_RECT::height -= top + bottom; | 337 FXT_RECT::height -= top + bottom; |
338 } | 338 } |
339 void Deflate(const FXT_RECT &rt) | 339 void Deflate(const FXT_RECT &rt) |
340 { | 340 { |
341 Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); | 341 Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); |
342 } | 342 } |
343 FX_BOOL» » IsEmpty() const | 343 bool» » IsEmpty() const |
344 { | 344 { |
345 return width <= 0 || height <= 0; | 345 return width <= 0 || height <= 0; |
346 } | 346 } |
347 FX_BOOL» » IsEmpty(FX_FLOAT fEpsilon) const | 347 bool» » IsEmpty(FX_FLOAT fEpsilon) const |
348 { | 348 { |
349 return width <= fEpsilon || height <= fEpsilon; | 349 return width <= fEpsilon || height <= fEpsilon; |
350 } | 350 } |
351 void Empty() | 351 void Empty() |
352 { | 352 { |
353 width = height = 0; | 353 width = height = 0; |
354 } | 354 } |
355 FX_BOOL» » Contains(baseType x, baseType y) const | 355 bool» » Contains(baseType x, baseType y) const |
356 { | 356 { |
357 return x >= left && x < left + width && y >= top && y < top + height; | 357 return x >= left && x < left + width && y >= top && y < top + height; |
358 } | 358 } |
359 FX_BOOL» » Contains(const FXT_POINT &p) const | 359 bool» » Contains(const FXT_POINT &p) const |
360 { | 360 { |
361 return Contains(p.x, p.y); | 361 return Contains(p.x, p.y); |
362 } | 362 } |
363 FX_BOOL» » Contains(const FXT_RECT &rt) const | 363 bool» » Contains(const FXT_RECT &rt) const |
364 { | 364 { |
365 return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.b
ottom() <= bottom(); | 365 return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.b
ottom() <= bottom(); |
366 } | 366 } |
367 baseType Width() const | 367 baseType Width() const |
368 { | 368 { |
369 return width; | 369 return width; |
370 } | 370 } |
371 baseType Height() const | 371 baseType Height() const |
372 { | 372 { |
373 return height; | 373 return height; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 494 } |
495 if (top < rt.top) { | 495 if (top < rt.top) { |
496 top = rt.top; | 496 top = rt.top; |
497 } | 497 } |
498 if (b > rt.bottom()) { | 498 if (b > rt.bottom()) { |
499 b = rt.bottom(); | 499 b = rt.bottom(); |
500 } | 500 } |
501 width = r - left; | 501 width = r - left; |
502 height = b - top; | 502 height = b - top; |
503 } | 503 } |
504 FX_BOOL» » IntersectWith(const FXT_RECT &rt) const | 504 bool» » IntersectWith(const FXT_RECT &rt) const |
505 { | 505 { |
506 FXT_RECT rect = rt; | 506 FXT_RECT rect = rt; |
507 rect.Intersect(*this); | 507 rect.Intersect(*this); |
508 return !rect.IsEmpty(); | 508 return !rect.IsEmpty(); |
509 } | 509 } |
510 FX_BOOL» » IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) con
st | 510 bool» » IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) con
st |
511 { | 511 { |
512 FXT_RECT rect = rt; | 512 FXT_RECT rect = rt; |
513 rect.Intersect(*this); | 513 rect.Intersect(*this); |
514 return !rect.IsEmpty(fEpsilon); | 514 return !rect.IsEmpty(fEpsilon); |
515 } | 515 } |
516 friend» FX_BOOL»operator == (const FXT_RECT &rc1, const FXT_RECT &rc2) | 516 friend» bool» operator == (const FXT_RECT &rc1, const FXT_RECT &rc2) |
517 { | 517 { |
518 return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.wi
dth && rc1.height == rc2.height; | 518 return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.wi
dth && rc1.height == rc2.height; |
519 } | 519 } |
520 friend» FX_BOOL»operator != (const FXT_RECT &rc1, const FXT_RECT &rc2) | 520 friend» bool» operator != (const FXT_RECT &rc1, const FXT_RECT &rc2) |
521 { | 521 { |
522 return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.wi
dth || rc1.height != rc2.height; | 522 return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.wi
dth || rc1.height != rc2.height; |
523 } | 523 } |
524 baseType left, top; | 524 baseType left, top; |
525 baseType width, height; | 525 baseType width, height; |
526 }; | 526 }; |
527 typedef CFX_RTemplate<int32_t> CFX_Rect; | 527 typedef CFX_RTemplate<int32_t> CFX_Rect; |
528 typedef CFX_RTemplate<FX_FLOAT> CFX_RectF; | 528 typedef CFX_RTemplate<FX_FLOAT> CFX_RectF; |
529 typedef CFX_RTemplate<int32_t> * FX_LPRECT; | 529 typedef CFX_RTemplate<int32_t> * FX_LPRECT; |
530 typedef CFX_RTemplate<FX_FLOAT> * FX_LPRECTF; | 530 typedef CFX_RTemplate<FX_FLOAT> * FX_LPRECTF; |
(...skipping 23 matching lines...) Expand all Loading... |
554 int Width() const | 554 int Width() const |
555 { | 555 { |
556 return right - left; | 556 return right - left; |
557 } | 557 } |
558 | 558 |
559 int Height() const | 559 int Height() const |
560 { | 560 { |
561 return bottom - top; | 561 return bottom - top; |
562 } | 562 } |
563 | 563 |
564 FX_BOOL» » IsEmpty() const | 564 bool» » IsEmpty() const |
565 { | 565 { |
566 return right <= left || bottom <= top; | 566 return right <= left || bottom <= top; |
567 } | 567 } |
568 | 568 |
569 void Normalize(); | 569 void Normalize(); |
570 | 570 |
571 void Intersect(const FX_RECT& src); | 571 void Intersect(const FX_RECT& src); |
572 | 572 |
573 void Intersect(int left1, int top1, int right1, int bottom1) | 573 void Intersect(int left1, int top1, int right1, int bottom1) |
574 { | 574 { |
575 Intersect(FX_RECT(left1, top1, right1, bottom1)); | 575 Intersect(FX_RECT(left1, top1, right1, bottom1)); |
576 } | 576 } |
577 | 577 |
578 void Union(const FX_RECT& other_rect); | 578 void Union(const FX_RECT& other_rect); |
579 | 579 |
580 FX_BOOL» » operator == (const FX_RECT& src) const | 580 bool» » operator == (const FX_RECT& src) const |
581 { | 581 { |
582 return left == src.left && right == src.right && top == src.top && botto
m == src.bottom; | 582 return left == src.left && right == src.right && top == src.top && botto
m == src.bottom; |
583 } | 583 } |
584 | 584 |
585 void Offset(int dx, int dy) | 585 void Offset(int dx, int dy) |
586 { | 586 { |
587 left += dx; | 587 left += dx; |
588 right += dx; | 588 right += dx; |
589 top += dy; | 589 top += dy; |
590 bottom += dy; | 590 bottom += dy; |
591 } | 591 } |
592 | 592 |
593 FX_BOOL» » Contains(const FX_RECT& other_rect) const | 593 bool» » Contains(const FX_RECT& other_rect) const |
594 { | 594 { |
595 return other_rect.left >= left && other_rect.right <= right && other_rec
t.top >= top && other_rect.bottom <= bottom; | 595 return other_rect.left >= left && other_rect.right <= right && other_rec
t.top >= top && other_rect.bottom <= bottom; |
596 } | 596 } |
597 | 597 |
598 FX_BOOL» » Contains(int x, int y) const | 598 bool» » Contains(int x, int y) const |
599 { | 599 { |
600 return x >= left && x < right && y >= top && y < bottom; | 600 return x >= left && x < right && y >= top && y < bottom; |
601 } | 601 } |
602 }; | 602 }; |
603 struct FX_SMALL_RECT { | 603 struct FX_SMALL_RECT { |
604 | 604 |
605 int16_t Left; | 605 int16_t Left; |
606 | 606 |
607 int16_t Top; | 607 int16_t Top; |
608 | 608 |
(...skipping 21 matching lines...) Expand all Loading... |
630 CFX_FloatRect(const FX_FLOAT* pArray) | 630 CFX_FloatRect(const FX_FLOAT* pArray) |
631 { | 631 { |
632 left = pArray[0]; | 632 left = pArray[0]; |
633 bottom = pArray[1]; | 633 bottom = pArray[1]; |
634 right = pArray[2]; | 634 right = pArray[2]; |
635 top = pArray[3]; | 635 top = pArray[3]; |
636 } | 636 } |
637 | 637 |
638 CFX_FloatRect(const FX_RECT& rect); | 638 CFX_FloatRect(const FX_RECT& rect); |
639 | 639 |
640 FX_BOOL» » » » IsEmpty() const | 640 bool» » » » IsEmpty() const |
641 { | 641 { |
642 return left >= right || bottom >= top; | 642 return left >= right || bottom >= top; |
643 } | 643 } |
644 | 644 |
645 void Normalize(); | 645 void Normalize(); |
646 | 646 |
647 void Reset() | 647 void Reset() |
648 { | 648 { |
649 left = right = bottom = top = 0; | 649 left = right = bottom = top = 0; |
650 } | 650 } |
651 | 651 |
652 FX_BOOL» » » » Contains(const CFX_FloatRect& other_rect
) const; | 652 bool» » » » Contains(const CFX_FloatRect& other_rect
) const; |
653 | 653 |
654 FX_BOOL» » » » Contains(FX_FLOAT x, FX_FLOAT y) const; | 654 bool» » » » Contains(FX_FLOAT x, FX_FLOAT y) const; |
655 | 655 |
656 void Transform(const CFX_Matrix* pMatrix); | 656 void Transform(const CFX_Matrix* pMatrix); |
657 | 657 |
658 void Intersect(const CFX_FloatRect& other_rec
t); | 658 void Intersect(const CFX_FloatRect& other_rec
t); |
659 | 659 |
660 void Union(const CFX_FloatRect& other_rect); | 660 void Union(const CFX_FloatRect& other_rect); |
661 | 661 |
662 FX_RECT GetInnerRect() const; | 662 FX_RECT GetInnerRect() const; |
663 | 663 |
664 FX_RECT GetOutterRect() const; | 664 FX_RECT GetOutterRect() const; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 void Set(const FX_FLOAT n[6]); | 779 void Set(const FX_FLOAT n[6]); |
780 | 780 |
781 void SetIdentity() | 781 void SetIdentity() |
782 { | 782 { |
783 a = d = 1; | 783 a = d = 1; |
784 b = c = e = f = 0; | 784 b = c = e = f = 0; |
785 } | 785 } |
786 | 786 |
787 void SetReverse(const CFX_Matrix &m); | 787 void SetReverse(const CFX_Matrix &m); |
788 | 788 |
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); | 789 void» » » Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FL
OAT d, FX_FLOAT e, FX_FLOAT f, bool bPrepended = false); |
790 | 790 |
791 void» » » Concat(const CFX_Matrix &m, FX_BOOL bPrepended =
FALSE); | 791 void» » » Concat(const CFX_Matrix &m, bool bPrepended = fa
lse); |
792 | 792 |
793 void» » » ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrep
ended = FALSE); | 793 void» » » ConcatInverse(const CFX_Matrix& m, bool bPrepend
ed = false); |
794 void Reset() | 794 void Reset() |
795 { | 795 { |
796 SetIdentity(); | 796 SetIdentity(); |
797 } | 797 } |
798 | 798 |
799 void Copy(const CFX_Matrix& m) | 799 void Copy(const CFX_Matrix& m) |
800 { | 800 { |
801 *this = m; | 801 *this = m; |
802 } | 802 } |
803 | 803 |
804 FX_BOOL» » » IsIdentity() const | 804 bool» » » IsIdentity() const |
805 { | 805 { |
806 return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; | 806 return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; |
807 } | 807 } |
808 FX_BOOL» » » IsInvertible() const; | 808 bool» » » IsInvertible() const; |
809 | 809 |
810 FX_BOOL» » » Is90Rotated() const; | 810 bool» » » Is90Rotated() const; |
811 | 811 |
812 FX_BOOL» » » IsScaled() const; | 812 bool» » » IsScaled() const; |
813 | 813 |
814 void» » » Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepe
nded = FALSE); | 814 void» » » Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepende
d = false); |
815 | 815 |
816 void» » » TranslateI(int32_t x, int32_t y, FX_BOOL bPrepen
ded = FALSE) | 816 void» » » TranslateI(int32_t x, int32_t y, bool bPrepended
= false) |
817 { | 817 { |
818 Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); | 818 Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); |
819 } | 819 } |
820 | 820 |
821 void» » » Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepend
ed = FALSE); | 821 void» » » Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended
= false); |
822 | 822 |
823 void» » » Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FA
LSE); | 823 void» » » Rotate(FX_FLOAT fRadian, bool bPrepended = false
); |
824 | 824 |
825 void» » » RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT
y, FX_BOOL bPrepended = FALSE); | 825 void» » » RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT
y, bool bPrepended = false); |
826 | 826 |
827 void» » » Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadia
n, FX_BOOL bPrepended = FALSE); | 827 void» » » Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadia
n, bool bPrepended = false); |
828 | 828 |
829 void MatchRect(const CFX_FloatRect &dest, const CFX_F
loatRect &src); | 829 void MatchRect(const CFX_FloatRect &dest, const CFX_F
loatRect &src); |
830 | 830 |
831 FX_FLOAT GetXUnit() const; | 831 FX_FLOAT GetXUnit() const; |
832 | 832 |
833 FX_FLOAT GetYUnit() const; | 833 FX_FLOAT GetYUnit() const; |
834 void GetUnitRect(CFX_RectF &rect) const; | 834 void GetUnitRect(CFX_RectF &rect) const; |
835 | 835 |
836 CFX_FloatRect GetUnitRect() const; | 836 CFX_FloatRect GetUnitRect() const; |
837 | 837 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 FX_FLOAT a; | 904 FX_FLOAT a; |
905 FX_FLOAT b; | 905 FX_FLOAT b; |
906 FX_FLOAT c; | 906 FX_FLOAT c; |
907 FX_FLOAT d; | 907 FX_FLOAT d; |
908 FX_FLOAT e; | 908 FX_FLOAT e; |
909 FX_FLOAT f; | 909 FX_FLOAT f; |
910 }; | 910 }; |
911 #define CFX_AffineMatrix CFX_Matrix | 911 #define CFX_AffineMatrix CFX_Matrix |
912 | 912 |
913 #endif // CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ | 913 #endif // CORE_INCLUDE_FXCRT_FX_COORDINATES_H_ |
OLD | NEW |