aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-05-20 11:49:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-20 11:49:55 -0700
commit364ad00446923d1cbc963c7358cd9b01efc53d3e (patch)
tree741625593083da65c7f4fdad51b7e22274ed5040 /src/gpu
parentfd6a07b1e835f692b7dcb837027db6d5cc253618 (diff)
Fix for bisector computation bug in GrAAConvexTessellator
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrAAConvexTessellator.cpp28
-rw-r--r--src/gpu/GrAAConvexTessellator.h2
2 files changed, 23 insertions, 7 deletions
diff --git a/src/gpu/GrAAConvexTessellator.cpp b/src/gpu/GrAAConvexTessellator.cpp
index b2269c5afe..5a1e4c2dfe 100644
--- a/src/gpu/GrAAConvexTessellator.cpp
+++ b/src/gpu/GrAAConvexTessellator.cpp
@@ -125,8 +125,16 @@ void GrAAConvexTessellator::computeBisectors() {
int prev = fBisectors.count() - 1;
for (int cur = 0; cur < fBisectors.count(); prev = cur, ++cur) {
fBisectors[cur] = fNorms[cur] + fNorms[prev];
- fBisectors[cur].normalize();
- fBisectors[cur].negate(); // make the bisector face in
+ if (!fBisectors[cur].normalize()) {
+ SkASSERT(SkPoint::kLeft_Side == fSide || SkPoint::kRight_Side == fSide);
+ fBisectors[cur].setOrthog(fNorms[cur], (SkPoint::Side)-fSide);
+ SkVector other;
+ other.setOrthog(fNorms[prev], fSide);
+ fBisectors[cur] += other;
+ SkAssertResult(fBisectors[cur].normalize());
+ } else {
+ fBisectors[cur].negate(); // make the bisector face in
+ }
SkASSERT(SkScalarNearlyEqual(1.0f, fBisectors[cur].length()));
}
@@ -627,7 +635,7 @@ void GrAAConvexTessellator::validate() const {
//////////////////////////////////////////////////////////////////////////////
void GrAAConvexTessellator::Ring::init(const GrAAConvexTessellator& tess) {
this->computeNormals(tess);
- this->computeBisectors();
+ this->computeBisectors(tess);
SkASSERT(this->isConvex(tess));
}
@@ -653,12 +661,20 @@ void GrAAConvexTessellator::Ring::computeNormals(const GrAAConvexTessellator& te
}
}
-void GrAAConvexTessellator::Ring::computeBisectors() {
+void GrAAConvexTessellator::Ring::computeBisectors(const GrAAConvexTessellator& tess) {
int prev = fPts.count() - 1;
for (int cur = 0; cur < fPts.count(); prev = cur, ++cur) {
fPts[cur].fBisector = fPts[cur].fNorm + fPts[prev].fNorm;
- fPts[cur].fBisector.normalize();
- fPts[cur].fBisector.negate(); // make the bisector face in
+ if (!fPts[cur].fBisector.normalize()) {
+ SkASSERT(SkPoint::kLeft_Side == tess.side() || SkPoint::kRight_Side == tess.side());
+ fPts[cur].fBisector.setOrthog(fPts[cur].fNorm, (SkPoint::Side)-tess.side());
+ SkVector other;
+ other.setOrthog(fPts[prev].fNorm, tess.side());
+ fPts[cur].fBisector += other;
+ SkAssertResult(fPts[cur].fBisector.normalize());
+ } else {
+ fPts[cur].fBisector.negate(); // make the bisector face in
+ }
SkASSERT(SkScalarNearlyEqual(1.0f, fPts[cur].fBisector.length()));
}
diff --git a/src/gpu/GrAAConvexTessellator.h b/src/gpu/GrAAConvexTessellator.h
index c2b751e571..707995fadd 100644
--- a/src/gpu/GrAAConvexTessellator.h
+++ b/src/gpu/GrAAConvexTessellator.h
@@ -146,7 +146,7 @@ private:
private:
void computeNormals(const GrAAConvexTessellator& result);
- void computeBisectors();
+ void computeBisectors(const GrAAConvexTessellator& tess);
SkDEBUGCODE(bool isConvex(const GrAAConvexTessellator& tess) const;)