| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 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 #ifndef SkPathOpBounds_DEFINED | 7 #ifndef SkPathOpBounds_DEFINED |
| 8 #define SkPathOpBounds_DEFINED | 8 #define SkPathOpBounds_DEFINED |
| 9 | 9 |
| 10 #include "SkPathOpsRect.h" | 10 #include "SkPathOpsRect.h" |
| 11 #include "SkRect.h" | 11 #include "SkRect.h" |
| 12 | 12 |
| 13 // SkPathOpsBounds, unlike SkRect, does not consider a line to be empty. | 13 // SkPathOpsBounds, unlike SkRect, does not consider a line to be empty. |
| 14 struct SkPathOpsBounds : public SkRect { | 14 struct SkPathOpsBounds : public SkRect { |
| 15 static bool Intersects(const SkPathOpsBounds& a, const SkPathOpsBounds& b) { | 15 static bool Intersects(const SkPathOpsBounds& a, const SkPathOpsBounds& b) { |
| 16 return a.fLeft <= b.fRight && b.fLeft <= a.fRight && | 16 return a.fLeft <= b.fRight && b.fLeft <= a.fRight && |
| 17 a.fTop <= b.fBottom && b.fTop <= a.fBottom; | 17 a.fTop <= b.fBottom && b.fTop <= a.fBottom; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // FIXME: add() is generically useful and could be added directly to SkRect | 20 // Note that add(), unlike SkRect::join() or SkRect::growToInclude() |
| 21 // does not treat the bounds of horizontal and vertical lines as |
| 22 // empty rectangles. |
| 21 void add(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) { | 23 void add(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) { |
| 22 if (left < fLeft) fLeft = left; | 24 if (left < fLeft) fLeft = left; |
| 23 if (top < fTop) fTop = top; | 25 if (top < fTop) fTop = top; |
| 24 if (right > fRight) fRight = right; | 26 if (right > fRight) fRight = right; |
| 25 if (bottom > fBottom) fBottom = bottom; | 27 if (bottom > fBottom) fBottom = bottom; |
| 26 } | 28 } |
| 27 | 29 |
| 28 void add(const SkPathOpsBounds& toAdd) { | 30 void add(const SkPathOpsBounds& toAdd) { |
| 29 add(toAdd.fLeft, toAdd.fTop, toAdd.fRight, toAdd.fBottom); | 31 add(toAdd.fLeft, toAdd.fTop, toAdd.fRight, toAdd.fBottom); |
| 30 } | 32 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 52 fLeft = fRight = pt.fX; | 54 fLeft = fRight = pt.fX; |
| 53 fTop = fBottom = pt.fY; | 55 fTop = fBottom = pt.fY; |
| 54 } | 56 } |
| 55 | 57 |
| 56 typedef SkRect INHERITED; | 58 typedef SkRect INHERITED; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 extern void (SkPathOpsBounds::*SetCurveBounds[])(const SkPoint[]); | 61 extern void (SkPathOpsBounds::*SetCurveBounds[])(const SkPoint[]); |
| 60 | 62 |
| 61 #endif | 63 #endif |
| OLD | NEW |