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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 bool contains(const SkIRect& r) const { | 250 bool contains(const SkIRect& r) const { |
251 return !r.isEmpty() && !this->isEmpty() && // check for empties | 251 return !r.isEmpty() && !this->isEmpty() && // check for empties |
252 fLeft <= r.fLeft && fTop <= r.fTop && | 252 fLeft <= r.fLeft && fTop <= r.fTop && |
253 fRight >= r.fRight && fBottom >= r.fBottom; | 253 fRight >= r.fRight && fBottom >= r.fBottom; |
254 } | 254 } |
255 | 255 |
256 /** Returns true if the specified rectangle r is inside or equal to this rec tangle. | 256 /** Returns true if the specified rectangle r is inside or equal to this rec tangle. |
257 */ | 257 */ |
258 bool contains(const SkRect& r) const; | 258 bool contains(const SkRect& r) const; |
259 | 259 |
260 /** Returns true if the rectangle r is contained by the would-be non-integer rectangle that | |
261 * results from outsetting this rectangle by "fuzz". | |
262 */ | |
263 bool fuzzyContains(const SkRect& r, SkScalar fuzz) const; | |
bsalomon
2016/07/08 22:49:00
Instead of adding this to the public API, can we j
| |
264 | |
260 /** Return true if this rectangle contains the specified rectangle. | 265 /** Return true if this rectangle contains the specified rectangle. |
261 For speed, this method does not check if either this or the specified | 266 For speed, this method does not check if either this or the specified |
262 rectangles are empty, and if either is, its return value is undefined. | 267 rectangles are empty, and if either is, its return value is undefined. |
263 In the debugging build however, we assert that both this and the | 268 In the debugging build however, we assert that both this and the |
264 specified rectangles are non-empty. | 269 specified rectangles are non-empty. |
265 */ | 270 */ |
266 bool containsNoEmptyCheck(int32_t left, int32_t top, | 271 bool containsNoEmptyCheck(int32_t left, int32_t top, |
267 int32_t right, int32_t bottom) const { | 272 int32_t right, int32_t bottom) const { |
268 SkASSERT(fLeft < fRight && fTop < fBottom); | 273 SkASSERT(fLeft < fRight && fTop < fBottom); |
269 SkASSERT(left < right && top < bottom); | 274 SkASSERT(left < right && top < bottom); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 void dump() const { this->dump(false); } | 900 void dump() const { this->dump(false); } |
896 void dumpHex() const { this->dump(true); } | 901 void dumpHex() const { this->dump(true); } |
897 }; | 902 }; |
898 | 903 |
899 inline bool SkIRect::contains(const SkRect& r) const { | 904 inline bool SkIRect::contains(const SkRect& r) const { |
900 return !r.isEmpty() && !this->isEmpty() && // check for empties | 905 return !r.isEmpty() && !this->isEmpty() && // check for empties |
901 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && | 906 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && |
902 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; | 907 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; |
903 } | 908 } |
904 | 909 |
910 inline bool SkIRect::fuzzyContains(const SkRect& r, SkScalar fuzz) const { | |
911 SkASSERT(fuzz >= 0); | |
912 return !r.isEmpty() && !this->isEmpty() && // check for empties | |
913 (SkScalar)fLeft <= (r.fLeft + fuzz) && (SkScalar)fTop <= (r.fTop + f uzz) && | |
914 (SkScalar)fRight >= (r.fRight - fuzz) && (SkScalar)fBottom >= (r.fBo ttom - fuzz); | |
915 } | |
916 | |
905 #endif | 917 #endif |
OLD | NEW |