diff options
-rw-r--r-- | include/core/SkRRect.h | 12 | ||||
-rw-r--r-- | src/core/SkRRect.cpp | 17 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 4 | ||||
-rw-r--r-- | src/utils/SkLua.cpp | 7 |
4 files changed, 13 insertions, 27 deletions
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h index f27d798bd4..b9c3a79763 100644 --- a/include/core/SkRRect.h +++ b/include/core/SkRRect.h @@ -52,9 +52,6 @@ public: * by type(). The subtypes become progressively less restrictive. */ enum Type { - // !< Internal indicator that the sub type must be computed. - kUnknown_Type = -1, - // !< The RR is empty kEmpty_Type, @@ -90,11 +87,6 @@ public: */ Type getType() const { SkDEBUGCODE(this->validate();) - - if (kUnknown_Type == fType) { - this->computeType(); - } - SkASSERT(kUnknown_Type != fType); return static_cast<Type>(fType); } @@ -301,11 +293,11 @@ private: // Radii order is UL, UR, LR, LL. Use Corner enum to index into fRadii[] SkVector fRadii[4]; // use an explicitly sized type so we're sure the class is dense (no uninitialized bytes) - mutable int32_t fType; + int32_t fType; // TODO: add padding so we can use memcpy for flattening and not copy // uninitialized data - void computeType() const; + void computeType(); bool checkCornerContainment(SkScalar x, SkScalar y) const; // to access fRadii directly 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 diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index b849c74805..b4c020f5e7 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -324,10 +324,6 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma NinePatch* patch) const { SkASSERT(patch != NULL); switch (rrect.getType()) { - case SkRRect::kUnknown_Type: - // Unknown should never be returned. - SkASSERT(false); - // Fall through. case SkRRect::kEmpty_Type: // Nothing to draw. return kFalse_FilterReturn; diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index baddb1a19c..2370b9925c 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -187,7 +187,7 @@ static SkScalar lua2scalar_def(lua_State* L, int index, SkScalar defaultValue) { static SkScalar getarray_scalar(lua_State* L, int stackIndex, int arrayIndex) { SkASSERT(lua_istable(L, stackIndex)); lua_rawgeti(L, stackIndex, arrayIndex); - + SkScalar value = lua2scalar(L, -1); lua_pop(L, 1); return value; @@ -404,7 +404,7 @@ static SkScalar getfield_scalar(lua_State* L, int index, const char key[]) { SkASSERT(lua_istable(L, index)); lua_pushstring(L, key); lua_gettable(L, index); - + SkScalar value = lua2scalar(L, -1); lua_pop(L, 1); return value; @@ -533,7 +533,7 @@ static int lcanvas_drawImageRect(lua_State* L) { srcRPtr = lua2rect(L, 3, &srcR); } lua2rect(L, 4, &dstR); - + SkPaint paint; canvas->drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint)); return 0; @@ -1579,7 +1579,6 @@ static const struct luaL_Reg gSkPath_Methods[] = { static const char* rrect_type(const SkRRect& rr) { switch (rr.getType()) { - case SkRRect::kUnknown_Type: return "unknown"; case SkRRect::kEmpty_Type: return "empty"; case SkRRect::kRect_Type: return "rect"; case SkRRect::kOval_Type: return "oval"; |