aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPathRef.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-07-08 12:30:39 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-08 12:30:39 -0700
commitd5e3e6ae1b3434ad1158f441902ff65f1eeaa3a7 (patch)
tree5a05aeb57732eefef0bf13c2961eb0be80a671e9 /src/core/SkPathRef.cpp
parentf9552230dc0d15fd1c535ad6351c3a8edde5ac82 (diff)
Add SkRacy
SkRacy<T> is a zero-overhead wrapper for a T, except it also silences race warnings when TSAN is running. Here we apply in several classes. In SkMatrix and SkPathRef, we use it to opportunistically cache some idempotent work. In SkPixelRef, we wrap the genIDs. We think the worst that can happen here is we'll increment the global next-genID a few times instead of once when we go to get another ID. BUG=skia: R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/371363004
Diffstat (limited to 'src/core/SkPathRef.cpp')
-rw-r--r--src/core/SkPathRef.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index de7a8f56ae..e60f618b4f 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -30,9 +30,7 @@ SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
//////////////////////////////////////////////////////////////////////////////
SkPathRef* SkPathRef::CreateEmptyImpl() {
- SkPathRef* p = SkNEW(SkPathRef);
- p->computeBounds(); // Preemptively avoid a race to clear fBoundsIsDirty.
- return p;
+ return SkNEW(SkPathRef);
}
SkPathRef* SkPathRef::CreateEmpty() {
@@ -85,13 +83,13 @@ void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
if (canXformBounds) {
(*dst)->fBoundsIsDirty = false;
if (src.fIsFinite) {
- matrix.mapRect(&(*dst)->fBounds, src.fBounds);
- if (!((*dst)->fIsFinite = (*dst)->fBounds.isFinite())) {
- (*dst)->fBounds.setEmpty();
+ matrix.mapRect((*dst)->fBounds.get(), src.fBounds);
+ if (!((*dst)->fIsFinite = (*dst)->fBounds->isFinite())) {
+ (*dst)->fBounds->setEmpty();
}
} else {
(*dst)->fIsFinite = false;
- (*dst)->fBounds.setEmpty();
+ (*dst)->fBounds->setEmpty();
}
} else {
(*dst)->fBoundsIsDirty = true;
@@ -441,14 +439,14 @@ void SkPathRef::validate() const {
SkASSERT(this->currSize() ==
fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVerbCnt);
- if (!fBoundsIsDirty && !fBounds.isEmpty()) {
+ if (!fBoundsIsDirty && !fBounds->isEmpty()) {
bool isFinite = true;
for (int i = 0; i < fPointCnt; ++i) {
SkASSERT(!fPoints[i].isFinite() || (
- fBounds.fLeft - fPoints[i].fX < SK_ScalarNearlyZero &&
- fPoints[i].fX - fBounds.fRight < SK_ScalarNearlyZero &&
- fBounds.fTop - fPoints[i].fY < SK_ScalarNearlyZero &&
- fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero));
+ fBounds->fLeft - fPoints[i].fX < SK_ScalarNearlyZero &&
+ fPoints[i].fX - fBounds->fRight < SK_ScalarNearlyZero &&
+ fBounds->fTop - fPoints[i].fY < SK_ScalarNearlyZero &&
+ fPoints[i].fY - fBounds->fBottom < SK_ScalarNearlyZero));
if (!fPoints[i].isFinite()) {
isFinite = false;
}