aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-26 15:20:36 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-26 15:20:36 +0000
commit0bb18bb264b26afca45452910437c09445e23a3c (patch)
treede94a02e74a789b5a80ad9e6a3b8fdcda9573215 /src/core
parent904160772ed097cd481d6fcd8a3f4bf0a1af8b52 (diff)
explicitly track if a path is finite or not
we need this (it appears) so we can definitively reject non-finite paths in canvas, before passing them down into the guts. Review URL: https://codereview.appspot.com/6453047 git-svn-id: http://skia.googlecode.com/svn/trunk@4784 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPath.cpp20
-rw-r--r--src/core/SkRect.cpp7
2 files changed, 20 insertions, 7 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 36d18370a2..22d3d86963 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -80,9 +80,11 @@ public:
if (fEmpty) {
fPath->fBounds = fRect;
fPath->fBoundsIsDirty = false;
+ fPath->fIsFinite = fPath->fBounds.isFinite();
} else if (!fDirty) {
joinNoEmptyChecks(&fPath->fBounds, fRect);
fPath->fBoundsIsDirty = false;
+ fPath->fIsFinite = fPath->fBounds.isFinite();
}
}
@@ -104,12 +106,14 @@ private:
}
};
-static void compute_pt_bounds(SkRect* bounds, const SkTDArray<SkPoint>& pts) {
- if (pts.count() <= 1) { // we ignore just 1 point (moveto)
- bounds->set(0, 0, 0, 0);
+// Return true if the computed bounds are finite.
+static bool compute_pt_bounds(SkRect* bounds, const SkTDArray<SkPoint>& pts) {
+ int count = pts.count();
+ if (count <= 1) { // we ignore just 1 point (moveto)
+ bounds->setEmpty();
+ return count ? pts.begin()->isFinite() : true;
} else {
- bounds->set(pts.begin(), pts.count());
-// SkDebugf("------- compute bounds %p %d", &pts, pts.count());
+ return bounds->setBoundsCheck(pts.begin(), pts.count());
}
}
@@ -139,6 +143,7 @@ SkPath::SkPath()
fSegmentMask = 0;
fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE;
fIsOval = false;
+ fIsFinite = false; // gets computed when we know our bounds
#ifdef SK_BUILD_FOR_ANDROID
fGenerationID = 0;
fSourcePath = NULL;
@@ -169,6 +174,7 @@ SkPath& SkPath::operator=(const SkPath& src) {
fFillType = src.fFillType;
fBoundsIsDirty = src.fBoundsIsDirty;
fConvexity = src.fConvexity;
+ fIsFinite = src.fIsFinite;
fSegmentMask = src.fSegmentMask;
fLastMoveToIndex = src.fLastMoveToIndex;
fIsOval = src.fIsOval;
@@ -204,6 +210,7 @@ void SkPath::swap(SkPath& other) {
SkTSwap<uint8_t>(fSegmentMask, other.fSegmentMask);
SkTSwap<int>(fLastMoveToIndex, other.fLastMoveToIndex);
SkTSwap<SkBool8>(fIsOval, other.fIsOval);
+ SkTSwap<SkBool8>(fIsFinite, other.fIsFinite);
GEN_ID_INC;
}
}
@@ -449,7 +456,7 @@ void SkPath::computeBounds() const {
SkASSERT(fBoundsIsDirty);
fBoundsIsDirty = false;
- compute_pt_bounds(&fBounds, fPts);
+ fIsFinite = compute_pt_bounds(&fBounds, fPts);
}
void SkPath::setConvexity(Convexity c) {
@@ -1340,6 +1347,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const {
// if we're empty, fastbounds should not be mapped
matrix.mapRect(&dst->fBounds, fBounds);
dst->fBoundsIsDirty = false;
+ dst->fIsFinite = dst->fBounds.isFinite();
} else {
GEN_ID_PTR_INC(dst);
dst->fBoundsIsDirty = true;
diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp
index 2e7b184b31..55dbe3d6e0 100644
--- a/src/core/SkRect.cpp
+++ b/src/core/SkRect.cpp
@@ -70,8 +70,10 @@ void SkRect::toQuad(SkPoint quad[4]) const {
#define MINMAX_ELSE else
#endif
-void SkRect::set(const SkPoint pts[], int count) {
+bool SkRect::setBoundsCheck(const SkPoint pts[], int count) {
SkASSERT((pts && count > 0) || count == 0);
+
+ bool isFinite = true;
if (count <= 0) {
sk_bzero(this, sizeof(SkRect));
@@ -118,11 +120,14 @@ void SkRect::set(const SkPoint pts[], int count) {
SkASSERT(!accum || !SkScalarIsFinite(accum));
if (accum) {
l = t = r = b = 0;
+ isFinite = false;
}
#endif
this->set(l, t, r, b);
#endif
}
+
+ return isFinite;
}
bool SkRect::intersect(SkScalar left, SkScalar top, SkScalar right,