| 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 SK_ScalarMin == fTop && | 429 SK_ScalarMin == fTop && |
| 430 SK_ScalarMax == fRight && | 430 SK_ScalarMax == fRight && |
| 431 SK_ScalarMax == fBottom; } | 431 SK_ScalarMax == fBottom; } |
| 432 | 432 |
| 433 /** | 433 /** |
| 434 * Returns true iff all values in the rect are finite. If any are | 434 * Returns true iff all values in the rect are finite. If any are |
| 435 * infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this | 435 * infinite or NaN (or SK_FixedNaN when SkScalar is fixed) then this |
| 436 * returns false. | 436 * returns false. |
| 437 */ | 437 */ |
| 438 bool isFinite() const { | 438 bool isFinite() const { |
| 439 #ifdef SK_SCALAR_IS_FLOAT | |
| 440 float accum = 0; | 439 float accum = 0; |
| 441 accum *= fLeft; | 440 accum *= fLeft; |
| 442 accum *= fTop; | 441 accum *= fTop; |
| 443 accum *= fRight; | 442 accum *= fRight; |
| 444 accum *= fBottom; | 443 accum *= fBottom; |
| 445 | 444 |
| 446 // accum is either NaN or it is finite (zero). | 445 // accum is either NaN or it is finite (zero). |
| 447 SkASSERT(0 == accum || !(accum == accum)); | 446 SkASSERT(0 == accum || !(accum == accum)); |
| 448 | 447 |
| 449 // value==value will be true iff value is not NaN | 448 // value==value will be true iff value is not NaN |
| 450 // TODO: is it faster to say !accum or accum==accum? | 449 // TODO: is it faster to say !accum or accum==accum? |
| 451 return accum == accum; | 450 return accum == accum; |
| 452 #else | |
| 453 // use bit-or for speed, since we don't care about short-circuting the | |
| 454 // tests, and we expect the common case will be that we need to check al
l. | |
| 455 int isNaN = (SK_FixedNaN == fLeft) | (SK_FixedNaN == fTop) | | |
| 456 (SK_FixedNaN == fRight) | (SK_FixedNaN == fBottom); | |
| 457 return !isNaN; | |
| 458 #endif | |
| 459 } | 451 } |
| 460 | 452 |
| 461 SkScalar x() const { return fLeft; } | 453 SkScalar x() const { return fLeft; } |
| 462 SkScalar y() const { return fTop; } | 454 SkScalar y() const { return fTop; } |
| 463 SkScalar left() const { return fLeft; } | 455 SkScalar left() const { return fLeft; } |
| 464 SkScalar top() const { return fTop; } | 456 SkScalar top() const { return fTop; } |
| 465 SkScalar right() const { return fRight; } | 457 SkScalar right() const { return fRight; } |
| 466 SkScalar bottom() const { return fBottom; } | 458 SkScalar bottom() const { return fBottom; } |
| 467 SkScalar width() const { return fRight - fLeft; } | 459 SkScalar width() const { return fRight - fLeft; } |
| 468 SkScalar height() const { return fBottom - fTop; } | 460 SkScalar height() const { return fBottom - fTop; } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 */ | 782 */ |
| 791 void sort(); | 783 void sort(); |
| 792 | 784 |
| 793 /** | 785 /** |
| 794 * cast-safe way to treat the rect as an array of (4) SkScalars. | 786 * cast-safe way to treat the rect as an array of (4) SkScalars. |
| 795 */ | 787 */ |
| 796 const SkScalar* asScalars() const { return &fLeft; } | 788 const SkScalar* asScalars() const { return &fLeft; } |
| 797 }; | 789 }; |
| 798 | 790 |
| 799 #endif | 791 #endif |
| OLD | NEW |