Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: src/core/SkRRect.cpp

Issue 801693003: Fill SkRRect::fType proactively. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: debug only Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkRRect.h ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRRect.cpp
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index 58e7de7910a1702cfc6e19cf502bfb629676d859..52b1486a759c5116864c1d3c78091a177522b3ea 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
« no previous file with comments | « include/core/SkRRect.h ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698