expose new tight-bounds method on SkPath
BUG=skia:
Change-Id: Ie50df49c1758af203042a84dc2cd505046373d2c
Reviewed-on: https://skia-review.googlesource.com/7996
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 4c18e63..84dfca1 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -3435,23 +3435,22 @@
return n + 1;
}
-bool SkPathPriv::ComputeTightBounds(const SkPath& path, SkRect* bounds) {
- if (0 == path.countVerbs()) {
- return false;
+SkRect SkPath::computeTightBounds() const {
+ if (0 == this->countVerbs()) {
+ return SkRect::MakeEmpty();
}
- if (path.getSegmentMasks() == SkPath::kLine_SegmentMask) {
- *bounds = path.getBounds();
- return true;
+ if (this->getSegmentMasks() == SkPath::kLine_SegmentMask) {
+ return this->getBounds();
}
SkPoint extremas[5]; // big enough to hold worst-case curve type (cubic) extremas + 1
SkPoint pts[4];
- SkPath::RawIter iter(path);
+ SkPath::RawIter iter(*this);
// initial with the first MoveTo, so we don't have to check inside the switch
Sk2s min, max;
- min = max = from_point(path.getPoint(0));
+ min = max = from_point(this->getPoint(0));
for (;;) {
int count = 0;
switch (iter.next(pts)) {
@@ -3484,7 +3483,8 @@
}
}
DONE:
- min.store((SkPoint*)&bounds->fLeft);
- max.store((SkPoint*)&bounds->fRight);
- return true;
+ SkRect bounds;
+ min.store((SkPoint*)&bounds.fLeft);
+ max.store((SkPoint*)&bounds.fRight);
+ return bounds;
}
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h
index cbbb83e..029cb75 100644
--- a/src/core/SkPathPriv.h
+++ b/src/core/SkPathPriv.h
@@ -121,8 +121,6 @@
static const SkScalar* ConicWeightData(const SkPath& path) {
return path.fPathRef->conicWeights();
}
-
- static bool ComputeTightBounds(const SkPath&, SkRect*);
};
#endif