OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkRect_DEFINED | 10 #ifndef SkRect_DEFINED |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 * This is a specific "truncation" of the average, which is different than | 93 * This is a specific "truncation" of the average, which is different than |
94 * (bottom + top) / 2 when the sum is negative. | 94 * (bottom + top) / 2 when the sum is negative. |
95 */ | 95 */ |
96 int centerY() const { return (fBottom + fTop) >> 1; } | 96 int centerY() const { return (fBottom + fTop) >> 1; } |
97 | 97 |
98 /** | 98 /** |
99 * Return true if the rectangle's width or height are <= 0 | 99 * Return true if the rectangle's width or height are <= 0 |
100 */ | 100 */ |
101 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } | 101 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } |
102 | 102 |
103 bool isInverted() const { return fLeft > fRight || fTop > fBottom; } | |
mtklein
2013/09/24 22:52:18
Is there any performance lost by implementing this
sugoi1
2013/09/25 21:15:27
It's just that I'm using this functionality in SkV
| |
104 | |
103 bool isLargest() const { return SK_MinS32 == fLeft && | 105 bool isLargest() const { return SK_MinS32 == fLeft && |
104 SK_MinS32 == fTop && | 106 SK_MinS32 == fTop && |
105 SK_MaxS32 == fRight && | 107 SK_MaxS32 == fRight && |
106 SK_MaxS32 == fBottom; } | 108 SK_MaxS32 == fBottom; } |
107 | 109 |
108 friend bool operator==(const SkIRect& a, const SkIRect& b) { | 110 friend bool operator==(const SkIRect& a, const SkIRect& b) { |
109 return !memcmp(&a, &b, sizeof(a)); | 111 return !memcmp(&a, &b, sizeof(a)); |
110 } | 112 } |
111 | 113 |
112 friend bool operator!=(const SkIRect& a, const SkIRect& b) { | 114 friend bool operator!=(const SkIRect& a, const SkIRect& b) { |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 SkIntToScalar(irect.fRight), | 414 SkIntToScalar(irect.fRight), |
413 SkIntToScalar(irect.fBottom)); | 415 SkIntToScalar(irect.fBottom)); |
414 return r; | 416 return r; |
415 } | 417 } |
416 | 418 |
417 /** | 419 /** |
418 * Return true if the rectangle's width or height are <= 0 | 420 * Return true if the rectangle's width or height are <= 0 |
419 */ | 421 */ |
420 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } | 422 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } |
421 | 423 |
424 bool isInverted() const { return fLeft > fRight || fTop > fBottom; } | |
425 | |
422 /** | 426 /** |
423 * Returns true iff all values in the rect are finite. If any are | 427 * Returns true iff all values in the rect are finite. If any are |
424 * infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this | 428 * infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this |
425 * returns false. | 429 * returns false. |
426 */ | 430 */ |
427 bool isFinite() const { | 431 bool isFinite() const { |
428 #ifdef SK_SCALAR_IS_FLOAT | 432 #ifdef SK_SCALAR_IS_FLOAT |
429 float accum = 0; | 433 float accum = 0; |
430 accum *= fLeft; | 434 accum *= fLeft; |
431 accum *= fTop; | 435 accum *= fTop; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 */ | 801 */ |
798 void sort(); | 802 void sort(); |
799 | 803 |
800 /** | 804 /** |
801 * cast-safe way to treat the rect as an array of (4) SkScalars. | 805 * cast-safe way to treat the rect as an array of (4) SkScalars. |
802 */ | 806 */ |
803 const SkScalar* asScalars() const { return &fLeft; } | 807 const SkScalar* asScalars() const { return &fLeft; } |
804 }; | 808 }; |
805 | 809 |
806 #endif | 810 #endif |
OLD | NEW |