OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRect_DEFINED | 8 #ifndef SkRect_DEFINED |
9 #define SkRect_DEFINED | 9 #define SkRect_DEFINED |
10 | 10 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 * returns false. | 448 * returns false. |
449 */ | 449 */ |
450 bool isFinite() const { | 450 bool isFinite() const { |
451 float accum = 0; | 451 float accum = 0; |
452 accum *= fLeft; | 452 accum *= fLeft; |
453 accum *= fTop; | 453 accum *= fTop; |
454 accum *= fRight; | 454 accum *= fRight; |
455 accum *= fBottom; | 455 accum *= fBottom; |
456 | 456 |
457 // accum is either NaN or it is finite (zero). | 457 // accum is either NaN or it is finite (zero). |
458 SkASSERT(0 == accum || !(accum == accum)); | 458 SkASSERT(0 == accum || SkScalarIsNaN(accum)); |
459 | 459 |
460 // value==value will be true iff value is not NaN | 460 // value==value will be true iff value is not NaN |
461 // TODO: is it faster to say !accum or accum==accum? | 461 // TODO: is it faster to say !accum or accum==accum? |
462 return accum == accum; | 462 return !SkScalarIsNaN(accum); |
463 } | 463 } |
464 | 464 |
465 SkScalar x() const { return fLeft; } | 465 SkScalar x() const { return fLeft; } |
466 SkScalar y() const { return fTop; } | 466 SkScalar y() const { return fTop; } |
467 SkScalar left() const { return fLeft; } | 467 SkScalar left() const { return fLeft; } |
468 SkScalar top() const { return fTop; } | 468 SkScalar top() const { return fTop; } |
469 SkScalar right() const { return fRight; } | 469 SkScalar right() const { return fRight; } |
470 SkScalar bottom() const { return fBottom; } | 470 SkScalar bottom() const { return fBottom; } |
471 SkScalar width() const { return fRight - fLeft; } | 471 SkScalar width() const { return fRight - fLeft; } |
472 SkScalar height() const { return fBottom - fTop; } | 472 SkScalar height() const { return fBottom - fTop; } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 * cast-safe way to treat the rect as an array of (4) SkScalars. | 861 * cast-safe way to treat the rect as an array of (4) SkScalars. |
862 */ | 862 */ |
863 const SkScalar* asScalars() const { return &fLeft; } | 863 const SkScalar* asScalars() const { return &fLeft; } |
864 | 864 |
865 void dump(bool asHex) const; | 865 void dump(bool asHex) const; |
866 void dump() const { this->dump(false); } | 866 void dump() const { this->dump(false); } |
867 void dumpHex() const { this->dump(true); } | 867 void dumpHex() const { this->dump(true); } |
868 }; | 868 }; |
869 | 869 |
870 #endif | 870 #endif |
OLD | NEW |