add compute-bounds for conics
git-svn-id: http://skia.googlecode.com/svn/trunk@8713 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkGeometry.h b/include/core/SkGeometry.h
index cc1e4d67..f20195c 100644
--- a/include/core/SkGeometry.h
+++ b/include/core/SkGeometry.h
@@ -227,6 +227,9 @@
bool findYExtrema(SkScalar* t) const;
bool chopAtXExtrema(SkRationalQuad dst[2]) const;
bool chopAtYExtrema(SkRationalQuad dst[2]) const;
+
+ void computeTightBounds(SkRect* bounds) const;
+ void computeFastBounds(SkRect* bounds) const;
};
#endif
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index cdea29a..4454065 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -1635,3 +1635,22 @@
return false;
}
+void SkRationalQuad::computeTightBounds(SkRect* bounds) const {
+ SkPoint pts[4];
+ pts[0] = fPts[0];
+ pts[1] = fPts[2];
+ int count = 2;
+
+ SkScalar t;
+ if (this->findXExtrema(&t)) {
+ this->evalAt(t, &pts[count++]);
+ }
+ if (this->findYExtrema(&t)) {
+ this->evalAt(t, &pts[count++]);
+ }
+ bounds->set(pts, count);
+}
+
+void SkRationalQuad::computeFastBounds(SkRect* bounds) const {
+ bounds->set(fPts, 3);
+}