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 #include "SkRRect.h" | 8 #include "SkRRect.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // x^2 y^2 | 165 // x^2 y^2 |
166 // ----- + ----- <= 1 | 166 // ----- + ----- <= 1 |
167 // a^2 b^2 | 167 // a^2 b^2 |
168 // or : | 168 // or : |
169 // b^2*x^2 + a^2*y^2 <= (ab)^2 | 169 // b^2*x^2 + a^2*y^2 <= (ab)^2 |
170 SkScalar dist = SkScalarMul(SkScalarSquare(canonicalPt.fX), SkScalarSquare(
fRadii[index].fY)) + | 170 SkScalar dist = SkScalarMul(SkScalarSquare(canonicalPt.fX), SkScalarSquare(
fRadii[index].fY)) + |
171 SkScalarMul(SkScalarSquare(canonicalPt.fY), SkScalarSquare(
fRadii[index].fX)); | 171 SkScalarMul(SkScalarSquare(canonicalPt.fY), SkScalarSquare(
fRadii[index].fX)); |
172 return dist <= SkScalarSquare(SkScalarMul(fRadii[index].fX, fRadii[index].fY
)); | 172 return dist <= SkScalarSquare(SkScalarMul(fRadii[index].fX, fRadii[index].fY
)); |
173 } | 173 } |
174 | 174 |
| 175 bool SkRRect::allCornersCircular() const { |
| 176 return fRadii[0].fX == fRadii[0].fY && |
| 177 fRadii[1].fX == fRadii[1].fY && |
| 178 fRadii[2].fX == fRadii[2].fY && |
| 179 fRadii[3].fX == fRadii[3].fY; |
| 180 } |
| 181 |
175 bool SkRRect::contains(const SkRect& rect) const { | 182 bool SkRRect::contains(const SkRect& rect) const { |
176 if (!this->getBounds().contains(rect)) { | 183 if (!this->getBounds().contains(rect)) { |
177 // If 'rect' isn't contained by the RR's bounds then the | 184 // If 'rect' isn't contained by the RR's bounds then the |
178 // RR definitely doesn't contain it | 185 // RR definitely doesn't contain it |
179 return false; | 186 return false; |
180 } | 187 } |
181 | 188 |
182 if (this->isRect()) { | 189 if (this->isRect()) { |
183 // the prior test was sufficient | 190 // the prior test was sufficient |
184 return true; | 191 return true; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare); | 422 SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare); |
416 break; | 423 break; |
417 case kUnknown_Type: | 424 case kUnknown_Type: |
418 // no limits on this | 425 // no limits on this |
419 break; | 426 break; |
420 } | 427 } |
421 } | 428 } |
422 #endif // SK_DEBUG | 429 #endif // SK_DEBUG |
423 | 430 |
424 /////////////////////////////////////////////////////////////////////////////// | 431 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |