add compute-bounds for conics

git-svn-id: http://skia.googlecode.com/svn/trunk@8713 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
mike@reedtribe.org 2013-04-17 02:25:33 +00:00
parent 0c5c3867bd
commit 5c082a14ac
2 changed files with 22 additions and 0 deletions

View File

@ -227,6 +227,9 @@ struct SkRationalQuad {
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

View File

@ -1635,3 +1635,22 @@ bool SkRationalQuad::chopAtYExtrema(SkRationalQuad dst[2]) const {
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);
}