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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 * contains(x,y) -> fLeft <= x < fRight && fTop <= y < fBottom. Also note | 684 * contains(x,y) -> fLeft <= x < fRight && fTop <= y < fBottom. Also note |
685 * that contains(x,y) always returns false if the rect is empty. | 685 * that contains(x,y) always returns false if the rect is empty. |
686 */ | 686 */ |
687 void growToInclude(SkScalar x, SkScalar y) { | 687 void growToInclude(SkScalar x, SkScalar y) { |
688 fLeft = SkMinScalar(x, fLeft); | 688 fLeft = SkMinScalar(x, fLeft); |
689 fRight = SkMaxScalar(x, fRight); | 689 fRight = SkMaxScalar(x, fRight); |
690 fTop = SkMinScalar(y, fTop); | 690 fTop = SkMinScalar(y, fTop); |
691 fBottom = SkMaxScalar(y, fBottom); | 691 fBottom = SkMaxScalar(y, fBottom); |
692 } | 692 } |
693 | 693 |
| 694 /** Bulk version of growToInclude */ |
| 695 void growToInclude(const SkPoint pts[], int count) { |
| 696 this->growToInclude(pts, sizeof(SkPoint), count); |
| 697 } |
| 698 |
| 699 /** Bulk version of growToInclude with stride. */ |
| 700 void growToInclude(const SkPoint pts[], size_t stride, int count) { |
| 701 SkASSERT(count >= 0); |
| 702 SkASSERT(stride >= sizeof(SkPoint)); |
| 703 const SkPoint* end = (const SkPoint*)((intptr_t)pts + count * stride); |
| 704 for (; pts < end; pts = (const SkPoint*)((intptr_t)pts + stride)) { |
| 705 this->growToInclude(pts->fX, pts->fY); |
| 706 } |
| 707 } |
| 708 |
694 /** | 709 /** |
695 * Returns true if (p.fX,p.fY) is inside the rectangle, and the rectangle | 710 * Returns true if (p.fX,p.fY) is inside the rectangle, and the rectangle |
696 * is not empty. | 711 * is not empty. |
697 * | 712 * |
698 * Contains treats the left and top differently from the right and bottom. | 713 * Contains treats the left and top differently from the right and bottom. |
699 * The left and top coordinates of the rectangle are themselves considered | 714 * The left and top coordinates of the rectangle are themselves considered |
700 * to be inside, while the right and bottom are not. Thus for the rectangle | 715 * to be inside, while the right and bottom are not. Thus for the rectangle |
701 * {0, 0, 5, 10}, (0,0) is contained, but (0,10), (5,0) and (5,10) are not. | 716 * {0, 0, 5, 10}, (0,0) is contained, but (0,10), (5,0) and (5,10) are not. |
702 */ | 717 */ |
703 bool contains(const SkPoint& p) const { | 718 bool contains(const SkPoint& p) const { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 */ | 797 */ |
783 void sort(); | 798 void sort(); |
784 | 799 |
785 /** | 800 /** |
786 * cast-safe way to treat the rect as an array of (4) SkScalars. | 801 * cast-safe way to treat the rect as an array of (4) SkScalars. |
787 */ | 802 */ |
788 const SkScalar* asScalars() const { return &fLeft; } | 803 const SkScalar* asScalars() const { return &fLeft; } |
789 }; | 804 }; |
790 | 805 |
791 #endif | 806 #endif |
OLD | NEW |