aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-12-18 13:29:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-18 13:29:54 -0800
commit8aacf2085673f6302a43d590d4d2890789b87192 (patch)
treeee82bfd1b0289e9f715ec86c7aed8e413c4e4de0 /src/core
parent152d42f628335b747c7b527cedbb69fe2dc3d3ee (diff)
Fill SkRRect::fType proactively.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkRRect.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index 58e7de7910..52b1486a75 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -206,10 +206,8 @@ void SkRRect::setRectRadii(const SkRect& rect, const SkVector radii[4]) {
fRadii[3].fX = clamp_radius_add(fRadii[3].fX, rect.fLeft, rect.fRight);
fRadii[3].fY = clamp_radius_sub(fRadii[3].fY, rect.fTop, rect.fBottom);
- // At this point we're either oval, simple, or complex (not empty or rect)
- // but we lazily resolve the type to avoid the work if the information
- // isn't required.
- fType = (SkRRect::Type) kUnknown_Type;
+ // At this point we're either oval, simple, or complex (not empty or rect).
+ this->computeType();
SkDEBUGCODE(this->validate();)
}
@@ -305,8 +303,12 @@ static bool radii_are_nine_patch(const SkVector radii[4]) {
}
// There is a simplified version of this method in setRectXY
-void SkRRect::computeType() const {
- SkDEBUGCODE(this->validate();)
+void SkRRect::computeType() {
+ struct Validator {
+ Validator(const SkRRect* r) : fR(r) {}
+ ~Validator() { SkDEBUGCODE(fR->validate();) }
+ const SkRRect* fR;
+ } autoValidate(this);
if (fRect.isEmpty()) {
fType = kEmpty_Type;
@@ -564,9 +566,6 @@ void SkRRect::validate() const {
SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare);
SkASSERT(!patchesOfNine);
break;
- case kUnknown_Type:
- // no limits on this
- break;
}
}
#endif // SK_DEBUG