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 SkPoint_DEFINED | 8 #ifndef SkPoint_DEFINED |
9 #define SkPoint_DEFINED | 9 #define SkPoint_DEFINED |
10 | 10 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 350 |
351 /** | 351 /** |
352 * Returns true if both X and Y are finite (not infinity or NaN) | 352 * Returns true if both X and Y are finite (not infinity or NaN) |
353 */ | 353 */ |
354 bool isFinite() const { | 354 bool isFinite() const { |
355 SkScalar accum = 0; | 355 SkScalar accum = 0; |
356 accum *= fX; | 356 accum *= fX; |
357 accum *= fY; | 357 accum *= fY; |
358 | 358 |
359 // accum is either NaN or it is finite (zero). | 359 // accum is either NaN or it is finite (zero). |
360 SkASSERT(0 == accum || !(accum == accum)); | 360 SkASSERT(0 == accum || SkScalarIsNaN(accum)); |
361 | 361 |
362 // value==value will be true iff value is not NaN | 362 // value==value will be true iff value is not NaN |
363 // TODO: is it faster to say !accum or accum==accum? | 363 // TODO: is it faster to say !accum or accum==accum? |
364 return accum == accum; | 364 return !SkScalarIsNaN(accum); |
365 } | 365 } |
366 | 366 |
367 /** | 367 /** |
368 * Returns true if the point's coordinates equal (x,y) | 368 * Returns true if the point's coordinates equal (x,y) |
369 */ | 369 */ |
370 bool equals(SkScalar x, SkScalar y) const { | 370 bool equals(SkScalar x, SkScalar y) const { |
371 return fX == x && fY == y; | 371 return fX == x && fY == y; |
372 } | 372 } |
373 | 373 |
374 friend bool operator==(const SkPoint& a, const SkPoint& b) { | 374 friend bool operator==(const SkPoint& a, const SkPoint& b) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 533 |
534 /** | 534 /** |
535 * cast-safe way to treat the point as an array of (2) SkScalars. | 535 * cast-safe way to treat the point as an array of (2) SkScalars. |
536 */ | 536 */ |
537 const SkScalar* asScalars() const { return &fX; } | 537 const SkScalar* asScalars() const { return &fX; } |
538 }; | 538 }; |
539 | 539 |
540 typedef SkPoint SkVector; | 540 typedef SkPoint SkVector; |
541 | 541 |
542 #endif | 542 #endif |
OLD | NEW |