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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 inline bool isSimpleCircular() const { | 99 inline bool isSimpleCircular() const { |
100 return this->isSimple() && fRadii[0].fX == fRadii[0].fY; | 100 return this->isSimple() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].f Y); |
101 } | |
bsalomon
2015/09/11 13:05:46
I wonder if these should take a tolerance (just a
robertphillips
2015/09/11 15:55:35
Done. I've added a todo. Right now I only use isCi
| |
102 inline bool isCircle() const { | |
103 return this->isOval() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY) ; | |
101 } | 104 } |
102 inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); } | 105 inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); } |
103 inline bool isComplex() const { return kComplex_Type == this->getType(); } | 106 inline bool isComplex() const { return kComplex_Type == this->getType(); } |
104 | 107 |
105 bool allCornersCircular() const; | 108 bool allCornersCircular() const; |
106 | 109 |
107 SkScalar width() const { return fRect.width(); } | 110 SkScalar width() const { return fRect.width(); } |
108 SkScalar height() const { return fRect.height(); } | 111 SkScalar height() const { return fRect.height(); } |
109 | 112 |
110 /** | 113 /** |
(...skipping 22 matching lines...) Expand all Loading... | |
133 | 136 |
134 SkDEBUGCODE(this->validate();) | 137 SkDEBUGCODE(this->validate();) |
135 } | 138 } |
136 | 139 |
137 static SkRRect MakeRect(const SkRect& r) { | 140 static SkRRect MakeRect(const SkRect& r) { |
138 SkRRect rr; | 141 SkRRect rr; |
139 rr.setRect(r); | 142 rr.setRect(r); |
140 return rr; | 143 return rr; |
141 } | 144 } |
142 | 145 |
146 static SkRRect MakeOval(const SkRect& oval) { | |
147 SkRRect rr; | |
148 rr.setOval(oval); | |
149 return rr; | |
150 } | |
151 | |
143 /** | 152 /** |
144 * Set this RR to match the supplied oval. All x radii will equal half the | 153 * 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. | 154 * width and all y radii will equal half the height. |
146 */ | 155 */ |
147 void setOval(const SkRect& oval) { | 156 void setOval(const SkRect& oval) { |
148 if (oval.isEmpty()) { | 157 if (oval.isEmpty()) { |
149 this->setEmpty(); | 158 this->setEmpty(); |
150 return; | 159 return; |
151 } | 160 } |
152 | 161 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 // uninitialized data | 313 // uninitialized data |
305 | 314 |
306 void computeType(); | 315 void computeType(); |
307 bool checkCornerContainment(SkScalar x, SkScalar y) const; | 316 bool checkCornerContainment(SkScalar x, SkScalar y) const; |
308 | 317 |
309 // to access fRadii directly | 318 // to access fRadii directly |
310 friend class SkPath; | 319 friend class SkPath; |
311 }; | 320 }; |
312 | 321 |
313 #endif | 322 #endif |
OLD | NEW |