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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 * be max 32bit and right will be min 32bit). | 155 * be max 32bit and right will be min 32bit). |
156 */ | 156 */ |
157 void setLargestInverted() { | 157 void setLargestInverted() { |
158 fLeft = fTop = SK_MaxS32; | 158 fLeft = fTop = SK_MaxS32; |
159 fRight = fBottom = SK_MinS32; | 159 fRight = fBottom = SK_MinS32; |
160 } | 160 } |
161 | 161 |
162 /** | 162 /** |
163 * Return a new IRect, built as an offset of this rect. | 163 * Return a new IRect, built as an offset of this rect. |
164 */ | 164 */ |
165 SkIRect makeOffset(int dx, int dy) const { | 165 SkIRect makeOffset(int32_t dx, int32_t dy) const { |
166 return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy); | 166 return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy); |
167 } | 167 } |
168 | 168 |
169 /** | 169 /** |
170 * Return a new IRect, built as an inset of this rect. | 170 * Return a new IRect, built as an inset of this rect. |
171 */ | 171 */ |
172 SkIRect makeInset(int dx, int dy) const { | 172 SkIRect makeInset(int32_t dx, int32_t dy) const { |
173 return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy); | 173 return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy); |
174 } | 174 } |
175 | 175 |
| 176 /** |
| 177 * Return a new Rect, built as an outset of this rect. |
| 178 */ |
| 179 SkIRect makeOutset(int32_t dx, int32_t dy) const { |
| 180 return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy); |
| 181 } |
| 182 |
176 /** Offset set the rectangle by adding dx to its left and right, | 183 /** Offset set the rectangle by adding dx to its left and right, |
177 and adding dy to its top and bottom. | 184 and adding dy to its top and bottom. |
178 */ | 185 */ |
179 void offset(int32_t dx, int32_t dy) { | 186 void offset(int32_t dx, int32_t dy) { |
180 fLeft += dx; | 187 fLeft += dx; |
181 fTop += dy; | 188 fTop += dy; |
182 fRight += dx; | 189 fRight += dx; |
183 fBottom += dy; | 190 fBottom += dy; |
184 } | 191 } |
185 | 192 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 fLeft = fTop = SK_ScalarMax; | 608 fLeft = fTop = SK_ScalarMax; |
602 fRight = fBottom = SK_ScalarMin; | 609 fRight = fBottom = SK_ScalarMin; |
603 } | 610 } |
604 | 611 |
605 /** | 612 /** |
606 * Return a new Rect, built as an offset of this rect. | 613 * Return a new Rect, built as an offset of this rect. |
607 */ | 614 */ |
608 SkRect makeOffset(SkScalar dx, SkScalar dy) const { | 615 SkRect makeOffset(SkScalar dx, SkScalar dy) const { |
609 return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy); | 616 return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy); |
610 } | 617 } |
611 | 618 |
612 /** | 619 /** |
613 * Return a new Rect, built as an inset of this rect. | 620 * Return a new Rect, built as an inset of this rect. |
614 */ | 621 */ |
615 SkRect makeInset(SkScalar dx, SkScalar dy) const { | 622 SkRect makeInset(SkScalar dx, SkScalar dy) const { |
616 return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy); | 623 return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy); |
617 } | 624 } |
618 | 625 |
| 626 /** |
| 627 * Return a new Rect, built as an outset of this rect. |
| 628 */ |
| 629 SkRect makeOutset(SkScalar dx, SkScalar dy) const { |
| 630 return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy); |
| 631 } |
| 632 |
619 /** Offset set the rectangle by adding dx to its left and right, | 633 /** Offset set the rectangle by adding dx to its left and right, |
620 and adding dy to its top and bottom. | 634 and adding dy to its top and bottom. |
621 */ | 635 */ |
622 void offset(SkScalar dx, SkScalar dy) { | 636 void offset(SkScalar dx, SkScalar dy) { |
623 fLeft += dx; | 637 fLeft += dx; |
624 fTop += dy; | 638 fTop += dy; |
625 fRight += dx; | 639 fRight += dx; |
626 fBottom += dy; | 640 fBottom += dy; |
627 } | 641 } |
628 | 642 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 void dumpHex() const { this->dump(true); } | 910 void dumpHex() const { this->dump(true); } |
897 }; | 911 }; |
898 | 912 |
899 inline bool SkIRect::contains(const SkRect& r) const { | 913 inline bool SkIRect::contains(const SkRect& r) const { |
900 return !r.isEmpty() && !this->isEmpty() && // check for empties | 914 return !r.isEmpty() && !this->isEmpty() && // check for empties |
901 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && | 915 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && |
902 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; | 916 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; |
903 } | 917 } |
904 | 918 |
905 #endif | 919 #endif |
OLD | NEW |