Chromium Code Reviews| 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 isValid() const { return (fLeft <= fRight) && (fTop <= fBottom); } | |
|
reed1
2013/09/03 20:25:21
I think we already have the notion of "inverted" f
sugoi1
2013/09/04 18:01:10
Good point, I added a check to make sure width() a
| |
| 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 isValid() const { return SkScalarIsFinite(fLeft) && | |
| 425 SkScalarIsFinite(fTop) && | |
| 426 SkScalarIsFinite(fRight) && | |
| 427 SkScalarIsFinite(fBottom) && | |
| 428 (fLeft <= fRight) && | |
| 429 (fTop <= fBottom); } | |
| 422 /** | 430 /** |
| 423 * Returns true iff all values in the rect are finite. If any are | 431 * 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 | 432 * infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this |
| 425 * returns false. | 433 * returns false. |
| 426 */ | 434 */ |
| 427 bool isFinite() const { | 435 bool isFinite() const { |
| 428 #ifdef SK_SCALAR_IS_FLOAT | 436 #ifdef SK_SCALAR_IS_FLOAT |
| 429 float accum = 0; | 437 float accum = 0; |
| 430 accum *= fLeft; | 438 accum *= fLeft; |
| 431 accum *= fTop; | 439 accum *= fTop; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 */ | 805 */ |
| 798 void sort(); | 806 void sort(); |
| 799 | 807 |
| 800 /** | 808 /** |
| 801 * cast-safe way to treat the rect as an array of (4) SkScalars. | 809 * cast-safe way to treat the rect as an array of (4) SkScalars. |
| 802 */ | 810 */ |
| 803 const SkScalar* asScalars() const { return &fLeft; } | 811 const SkScalar* asScalars() const { return &fLeft; } |
| 804 }; | 812 }; |
| 805 | 813 |
| 806 #endif | 814 #endif |
| OLD | NEW |