Always (pre)compute path bounds when using a builder
Change-Id: I42ce8d2c7e6852a85b3aa798c772a2a0b1ce6c3b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313477 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
c113f004de
commit
f2845ac499
@ -60,6 +60,8 @@ public:
|
||||
fRRectOrOvalIsCCW = false;
|
||||
fRRectOrOvalStartIdx = 0xAC;
|
||||
SkDEBUGCODE(fEditorsAttached.store(0);)
|
||||
|
||||
this->computeBounds(); // do this now, before we worry about multiple owners/threads
|
||||
SkDEBUGCODE(this->validate();)
|
||||
}
|
||||
|
||||
|
@ -224,6 +224,11 @@ public:
|
||||
return path.fPathRef->unique();
|
||||
}
|
||||
|
||||
// Won't be needed once we can make path's immutable (with their bounds always computed)
|
||||
static bool HasComputedBounds(const SkPath& path) {
|
||||
return path.hasComputedBounds();
|
||||
}
|
||||
|
||||
/** Returns true if constructed by addCircle(), addOval(); and in some cases,
|
||||
addRoundRect(), addRRect(). SkPath constructed with conicTo() or rConicTo() will not
|
||||
return true though SkPath draws oval.
|
||||
|
@ -26,6 +26,11 @@ DEF_TEST(pathbuilder, reporter) {
|
||||
SkPath p1 = b.snapshot();
|
||||
SkPath p2 = b.detach();
|
||||
|
||||
// Builders should always precompute the path's bounds, so there is no race condition later
|
||||
REPORTER_ASSERT(reporter, SkPathPriv::HasComputedBounds(p0));
|
||||
REPORTER_ASSERT(reporter, SkPathPriv::HasComputedBounds(p1));
|
||||
REPORTER_ASSERT(reporter, SkPathPriv::HasComputedBounds(p2));
|
||||
|
||||
REPORTER_ASSERT(reporter, p0.getBounds() == SkRect::MakeLTRB(10, 10, 30, 20));
|
||||
REPORTER_ASSERT(reporter, p0.countPoints() == 4);
|
||||
|
||||
|
@ -84,8 +84,6 @@ void SkTestFont::init(const SkScalar* pts, const unsigned char* verbs) {
|
||||
}
|
||||
}
|
||||
fPaths[index] = b.detach();
|
||||
// This should make SkPath::getBounds() queries threadsafe.
|
||||
fPaths[index].updateBoundsCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user