Chromium Code Reviews| Index: src/gpu/effects/GrConvexPolyEffect.cpp |
| diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp |
| index 7b78305bb1e014d8a8d5ca2597ff00c942ac884a..51fabdb11466c93dea47d65f1321448bb6756a0b 100644 |
| --- a/src/gpu/effects/GrConvexPolyEffect.cpp |
| +++ b/src/gpu/effects/GrConvexPolyEffect.cpp |
| @@ -247,13 +247,6 @@ GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const |
| return nullptr; |
| } |
| - if (path.countPoints() > kMaxEdges) { |
| - return nullptr; |
| - } |
| - |
| - SkPoint pts[kMaxEdges]; |
| - SkScalar edges[3 * kMaxEdges]; |
| - |
| SkPathPriv::FirstDirection dir; |
| // The only way this should fail is if the clip is effectively a infinitely thin line. In that |
| // case nothing is inside the clip. It'd be nice to detect this at a higher level and either |
| @@ -273,24 +266,40 @@ GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const |
| t = *offset; |
| } |
| - int count = path.getPoints(pts, kMaxEdges); |
| + SkScalar edges[3 * kMaxEdges]; |
| + SkPoint pts[4]; |
| + SkPath::Verb verb; |
| + SkPath::Iter iter(path, true); |
| + |
| int n = 0; |
| - for (int lastPt = count - 1, i = 0; i < count; lastPt = i++) { |
| - if (pts[lastPt] != pts[i]) { |
| - SkVector v = pts[i] - pts[lastPt]; |
| - v.normalize(); |
| - if (SkPathPriv::kCCW_FirstDirection == dir) { |
| - edges[3 * n] = v.fY; |
| - edges[3 * n + 1] = -v.fX; |
| - } else { |
| - edges[3 * n] = -v.fY; |
| - edges[3 * n + 1] = v.fX; |
| + while ((verb = iter.next(pts, true, true)) != SkPath::kDone_Verb) { |
|
bsalomon
2016/05/27 20:30:30
Perhaps we should have a comment that has multiple
|
| + switch (verb) { |
| + case SkPath::kMove_Verb: |
|
bsalomon
2016/05/27 20:30:30
Should we assert here that n is 0?
|
| + case SkPath::kClose_Verb: |
| + break; |
| + case SkPath::kLine_Verb: { |
| + if (n >= kMaxEdges) { |
| + return nullptr; |
| + } |
| + SkVector v = pts[1] - pts[0]; |
| + v.normalize(); |
| + if (SkPathPriv::kCCW_FirstDirection == dir) { |
| + edges[3 * n] = v.fY; |
| + edges[3 * n + 1] = -v.fX; |
| + } else { |
| + edges[3 * n] = -v.fY; |
| + edges[3 * n + 1] = v.fX; |
| + } |
| + SkPoint p = pts[1] + t; |
| + edges[3 * n + 2] = -(edges[3 * n] * p.fX + edges[3 * n + 1] * p.fY); |
| + ++n; |
| + break; |
| } |
| - SkPoint p = pts[i] + t; |
| - edges[3 * n + 2] = -(edges[3 * n] * p.fX + edges[3 * n + 1] * p.fY); |
| - ++n; |
| + default: |
| + return nullptr; |
| } |
| } |
| + |
| if (path.isInverseFillType()) { |
| type = GrInvertProcessorEdgeType(type); |
| } |