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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 bool intersect(const SkIRect& r) { | 270 bool intersect(const SkIRect& r) { |
271 SkASSERT(&r); | 271 SkASSERT(&r); |
272 return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom); | 272 return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom); |
273 } | 273 } |
274 | 274 |
275 /** If rectangles a and b intersect, return true and set this rectangle to | 275 /** If rectangles a and b intersect, return true and set this rectangle to |
276 that intersection, otherwise return false and do not change this | 276 that intersection, otherwise return false and do not change this |
277 rectangle. If either rectangle is empty, do nothing and return false. | 277 rectangle. If either rectangle is empty, do nothing and return false. |
278 */ | 278 */ |
279 bool intersect(const SkIRect& a, const SkIRect& b) { | 279 bool intersect(const SkIRect& a, const SkIRect& b) { |
280 SkASSERT(&a && &b); | |
281 | 280 |
282 if (!a.isEmpty() && !b.isEmpty() && | 281 if (!a.isEmpty() && !b.isEmpty() && |
283 a.fLeft < b.fRight && b.fLeft < a.fRight && | 282 a.fLeft < b.fRight && b.fLeft < a.fRight && |
284 a.fTop < b.fBottom && b.fTop < a.fBottom) { | 283 a.fTop < b.fBottom && b.fTop < a.fBottom) { |
285 fLeft = SkMax32(a.fLeft, b.fLeft); | 284 fLeft = SkMax32(a.fLeft, b.fLeft); |
286 fTop = SkMax32(a.fTop, b.fTop); | 285 fTop = SkMax32(a.fTop, b.fTop); |
287 fRight = SkMin32(a.fRight, b.fRight); | 286 fRight = SkMin32(a.fRight, b.fRight); |
288 fBottom = SkMin32(a.fBottom, b.fBottom); | 287 fBottom = SkMin32(a.fBottom, b.fBottom); |
289 return true; | 288 return true; |
290 } | 289 } |
291 return false; | 290 return false; |
292 } | 291 } |
293 | 292 |
294 /** If rectangles a and b intersect, return true and set this rectangle to | 293 /** If rectangles a and b intersect, return true and set this rectangle to |
295 that intersection, otherwise return false and do not change this | 294 that intersection, otherwise return false and do not change this |
296 rectangle. For speed, no check to see if a or b are empty is performed. | 295 rectangle. For speed, no check to see if a or b are empty is performed. |
297 If either is, then the return result is undefined. In the debug build, | 296 If either is, then the return result is undefined. In the debug build, |
298 we assert that both rectangles are non-empty. | 297 we assert that both rectangles are non-empty. |
299 */ | 298 */ |
300 bool intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) { | 299 bool intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) { |
301 SkASSERT(&a && &b); | |
302 SkASSERT(!a.isEmpty() && !b.isEmpty()); | 300 SkASSERT(!a.isEmpty() && !b.isEmpty()); |
303 | 301 |
304 if (a.fLeft < b.fRight && b.fLeft < a.fRight && | 302 if (a.fLeft < b.fRight && b.fLeft < a.fRight && |
305 a.fTop < b.fBottom && b.fTop < a.fBottom) { | 303 a.fTop < b.fBottom && b.fTop < a.fBottom) { |
306 fLeft = SkMax32(a.fLeft, b.fLeft); | 304 fLeft = SkMax32(a.fLeft, b.fLeft); |
307 fTop = SkMax32(a.fTop, b.fTop); | 305 fTop = SkMax32(a.fTop, b.fTop); |
308 fRight = SkMin32(a.fRight, b.fRight); | 306 fRight = SkMin32(a.fRight, b.fRight); |
309 fBottom = SkMin32(a.fBottom, b.fBottom); | 307 fBottom = SkMin32(a.fBottom, b.fBottom); |
310 return true; | 308 return true; |
311 } | 309 } |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 * rely on the existence of this function or the formatting of its output. | 838 * rely on the existence of this function or the formatting of its output. |
841 */ | 839 */ |
842 void dump() const { | 840 void dump() const { |
843 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; | 841 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; |
844 } | 842 } |
845 #endif | 843 #endif |
846 | 844 |
847 }; | 845 }; |
848 | 846 |
849 #endif | 847 #endif |
OLD | NEW |