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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 */ | 364 */ |
365 struct SK_API SkRect { | 365 struct SK_API SkRect { |
366 SkScalar fLeft, fTop, fRight, fBottom; | 366 SkScalar fLeft, fTop, fRight, fBottom; |
367 | 367 |
368 static SkRect SK_WARN_UNUSED_RESULT MakeEmpty() { | 368 static SkRect SK_WARN_UNUSED_RESULT MakeEmpty() { |
369 SkRect r; | 369 SkRect r; |
370 r.setEmpty(); | 370 r.setEmpty(); |
371 return r; | 371 return r; |
372 } | 372 } |
373 | 373 |
| 374 static SkRect SK_WARN_UNUSED_RESULT MakeLargest() { |
| 375 SkRect r; |
| 376 r.setLargest(); |
| 377 return r; |
| 378 } |
| 379 |
374 static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) { | 380 static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) { |
375 SkRect r; | 381 SkRect r; |
376 r.set(0, 0, w, h); | 382 r.set(0, 0, w, h); |
377 return r; | 383 return r; |
378 } | 384 } |
379 | 385 |
380 static SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) { | 386 static SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) { |
381 SkRect r; | 387 SkRect r; |
382 r.set(0, 0, size.width(), size.height()); | 388 r.set(0, 0, size.width(), size.height()); |
383 return r; | 389 return r; |
(...skipping 28 matching lines...) Expand all Loading... |
412 SkIntToScalar(irect.fRight), | 418 SkIntToScalar(irect.fRight), |
413 SkIntToScalar(irect.fBottom)); | 419 SkIntToScalar(irect.fBottom)); |
414 return r; | 420 return r; |
415 } | 421 } |
416 | 422 |
417 /** | 423 /** |
418 * Return true if the rectangle's width or height are <= 0 | 424 * Return true if the rectangle's width or height are <= 0 |
419 */ | 425 */ |
420 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } | 426 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } |
421 | 427 |
| 428 bool isLargest() const { return SK_ScalarMin == fLeft && |
| 429 SK_ScalarMin == fTop && |
| 430 SK_ScalarMax == fRight && |
| 431 SK_ScalarMax == fBottom; } |
| 432 |
422 /** | 433 /** |
423 * 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 |
424 * 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 |
425 * returns false. | 436 * returns false. |
426 */ | 437 */ |
427 bool isFinite() const { | 438 bool isFinite() const { |
428 #ifdef SK_SCALAR_IS_FLOAT | 439 #ifdef SK_SCALAR_IS_FLOAT |
429 float accum = 0; | 440 float accum = 0; |
430 accum *= fLeft; | 441 accum *= fLeft; |
431 accum *= fTop; | 442 accum *= fTop; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 */ | 808 */ |
798 void sort(); | 809 void sort(); |
799 | 810 |
800 /** | 811 /** |
801 * cast-safe way to treat the rect as an array of (4) SkScalars. | 812 * cast-safe way to treat the rect as an array of (4) SkScalars. |
802 */ | 813 */ |
803 const SkScalar* asScalars() const { return &fLeft; } | 814 const SkScalar* asScalars() const { return &fLeft; } |
804 }; | 815 }; |
805 | 816 |
806 #endif | 817 #endif |
OLD | NEW |