| 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 | 7 |
| 8 #ifndef SkRRect_DEFINED | 8 #ifndef SkRRect_DEFINED |
| 9 #define SkRRect_DEFINED | 9 #define SkRRect_DEFINED |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 SkDEBUGCODE(this->validate();) | 89 SkDEBUGCODE(this->validate();) |
| 90 return static_cast<Type>(fType); | 90 return static_cast<Type>(fType); |
| 91 } | 91 } |
| 92 | 92 |
| 93 Type type() const { return this->getType(); } | 93 Type type() const { return this->getType(); } |
| 94 | 94 |
| 95 inline bool isEmpty() const { return kEmpty_Type == this->getType(); } | 95 inline bool isEmpty() const { return kEmpty_Type == this->getType(); } |
| 96 inline bool isRect() const { return kRect_Type == this->getType(); } | 96 inline bool isRect() const { return kRect_Type == this->getType(); } |
| 97 inline bool isOval() const { return kOval_Type == this->getType(); } | 97 inline bool isOval() const { return kOval_Type == this->getType(); } |
| 98 inline bool isSimple() const { return kSimple_Type == this->getType(); } | 98 inline bool isSimple() const { return kSimple_Type == this->getType(); } |
| 99 // TODO: should isSimpleCircular & isCircle take a tolerance? This could hel
p |
| 100 // instances where the mapping to device space is noisy. |
| 99 inline bool isSimpleCircular() const { | 101 inline bool isSimpleCircular() const { |
| 100 return this->isSimple() && fRadii[0].fX == fRadii[0].fY; | 102 return this->isSimple() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].f
Y); |
| 103 } |
| 104 inline bool isCircle() const { |
| 105 return this->isOval() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY)
; |
| 101 } | 106 } |
| 102 inline bool isNinePatch() const { return kNinePatch_Type == this->getType();
} | 107 inline bool isNinePatch() const { return kNinePatch_Type == this->getType();
} |
| 103 inline bool isComplex() const { return kComplex_Type == this->getType(); } | 108 inline bool isComplex() const { return kComplex_Type == this->getType(); } |
| 104 | 109 |
| 105 bool allCornersCircular() const; | 110 bool allCornersCircular() const; |
| 106 | 111 |
| 107 SkScalar width() const { return fRect.width(); } | 112 SkScalar width() const { return fRect.width(); } |
| 108 SkScalar height() const { return fRect.height(); } | 113 SkScalar height() const { return fRect.height(); } |
| 109 | 114 |
| 110 /** | 115 /** |
| (...skipping 22 matching lines...) Expand all Loading... |
| 133 | 138 |
| 134 SkDEBUGCODE(this->validate();) | 139 SkDEBUGCODE(this->validate();) |
| 135 } | 140 } |
| 136 | 141 |
| 137 static SkRRect MakeRect(const SkRect& r) { | 142 static SkRRect MakeRect(const SkRect& r) { |
| 138 SkRRect rr; | 143 SkRRect rr; |
| 139 rr.setRect(r); | 144 rr.setRect(r); |
| 140 return rr; | 145 return rr; |
| 141 } | 146 } |
| 142 | 147 |
| 148 static SkRRect MakeOval(const SkRect& oval) { |
| 149 SkRRect rr; |
| 150 rr.setOval(oval); |
| 151 return rr; |
| 152 } |
| 153 |
| 143 /** | 154 /** |
| 144 * Set this RR to match the supplied oval. All x radii will equal half the | 155 * Set this RR to match the supplied oval. All x radii will equal half the |
| 145 * width and all y radii will equal half the height. | 156 * width and all y radii will equal half the height. |
| 146 */ | 157 */ |
| 147 void setOval(const SkRect& oval) { | 158 void setOval(const SkRect& oval) { |
| 148 if (oval.isEmpty()) { | 159 if (oval.isEmpty()) { |
| 149 this->setEmpty(); | 160 this->setEmpty(); |
| 150 return; | 161 return; |
| 151 } | 162 } |
| 152 | 163 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // uninitialized data | 315 // uninitialized data |
| 305 | 316 |
| 306 void computeType(); | 317 void computeType(); |
| 307 bool checkCornerContainment(SkScalar x, SkScalar y) const; | 318 bool checkCornerContainment(SkScalar x, SkScalar y) const; |
| 308 | 319 |
| 309 // to access fRadii directly | 320 // to access fRadii directly |
| 310 friend class SkPath; | 321 friend class SkPath; |
| 311 }; | 322 }; |
| 312 | 323 |
| 313 #endif | 324 #endif |
| OLD | NEW |