Fill SkRRect::fType proactively.
I found no external mentions of SkRRect::kUnknown_Type. Motivating race found by TSAN: http://build.chromium.org/p/client.skia/builders/Test-Ubuntu13.10-GCE-NoGPU-x86_64-Release-TSAN-Trybot/builds/48/steps/dm/logs/stdio BUG=skia: Review URL: https://codereview.chromium.org/801693003
This commit is contained in:
parent
152d42f628
commit
8aacf20856
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user