OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2012 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 #ifndef SkPathOpsRect_DEFINED |
| 8 #define SkPathOpsRect_DEFINED |
| 9 |
| 10 #include "SkPathOpsPoint.h" |
| 11 |
| 12 struct SkDRect { |
| 13 double fLeft, fTop, fRight, fBottom; |
| 14 |
| 15 void add(const SkDPoint& pt) { |
| 16 if (fLeft > pt.fX) { |
| 17 fLeft = pt.fX; |
| 18 } |
| 19 if (fTop > pt.fY) { |
| 20 fTop = pt.fY; |
| 21 } |
| 22 if (fRight < pt.fX) { |
| 23 fRight = pt.fX; |
| 24 } |
| 25 if (fBottom < pt.fY) { |
| 26 fBottom = pt.fY; |
| 27 } |
| 28 } |
| 29 |
| 30 // FIXME: used by debugging only ? |
| 31 bool contains(const SkDPoint& pt) const { |
| 32 return approximately_between(fLeft, pt.fX, fRight) |
| 33 && approximately_between(fTop, pt.fY, fBottom); |
| 34 } |
| 35 |
| 36 bool intersects(SkDRect* r) const { |
| 37 SkASSERT(fLeft <= fRight); |
| 38 SkASSERT(fTop <= fBottom); |
| 39 SkASSERT(r->fLeft <= r->fRight); |
| 40 SkASSERT(r->fTop <= r->fBottom); |
| 41 return r->fLeft <= fRight && fLeft <= r->fRight && r->fTop <= fBottom &&
fTop <= r->fBottom; |
| 42 } |
| 43 |
| 44 void set(const SkDPoint& pt) { |
| 45 fLeft = fRight = pt.fX; |
| 46 fTop = fBottom = pt.fY; |
| 47 } |
| 48 |
| 49 void setBounds(const SkDLine&); |
| 50 void setBounds(const SkDCubic&); |
| 51 void setBounds(const SkDQuad&); |
| 52 void setRawBounds(const SkDCubic&); |
| 53 void setRawBounds(const SkDQuad&); |
| 54 }; |
| 55 |
| 56 #endif |
OLD | NEW |