Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: include/core/SkRect.h

Issue 809443002: Rewrite NaN checks in terms of SkScalarIsNaN() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPoint.h ('k') | include/core/SkScalar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « include/core/SkPoint.h ('k') | include/core/SkScalar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698