Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: src/gpu/GrAAConvexTessellator.cpp

Issue 1151623002: Fix for bisector computation bug in GrAAConvexTessellator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAAConvexTessellator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAAConvexTessellator.cpp
diff --git a/src/gpu/GrAAConvexTessellator.cpp b/src/gpu/GrAAConvexTessellator.cpp
index b2269c5afe17f6aac39c7da7026fc1b23ab1913a..5a1e4c2dfedcc56671ca4e80ddb01a34ba5b1919 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()));
}
« no previous file with comments | « src/gpu/GrAAConvexTessellator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698