aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-02-03 11:34:13 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-03 17:26:43 +0000
commit8d3196bdfcf478982bec9885d21e1d664ab9a72b (patch)
tree565d17927c9bb022cdb7bf10108bf7fc52b7a5db /src
parent20f00784b8500ccb68f0e402eeccd9bbf2707040 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPath.cpp22
-rw-r--r--src/core/SkPathPriv.h2
2 files changed, 11 insertions, 13 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 4c18e63b23..84dfca1fc7 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -3435,23 +3435,22 @@ static int compute_cubic_extremas(const SkPoint src[3], SkPoint extremas[5]) {
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 @@ bool SkPathPriv::ComputeTightBounds(const SkPath& path, SkRect* bounds) {
}
}
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 cbbb83edab..029cb759de 100644
--- a/src/core/SkPathPriv.h
+++ b/src/core/SkPathPriv.h
@@ -121,8 +121,6 @@ public:
static const SkScalar* ConicWeightData(const SkPath& path) {
return path.fPathRef->conicWeights();
}
-
- static bool ComputeTightBounds(const SkPath&, SkRect*);
};
#endif