diff options
author | mtklein <mtklein@chromium.org> | 2014-12-18 13:29:54 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-18 13:29:54 -0800 |
commit | 8aacf2085673f6302a43d590d4d2890789b87192 (patch) | |
tree | ee82bfd1b0289e9f715ec86c7aed8e413c4e4de0 /src/core | |
parent | 152d42f628335b747c7b527cedbb69fe2dc3d3ee (diff) |
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
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkRRect.cpp | 17 |
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 |