aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkEdgeBuilder.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-12-17 08:21:04 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-17 08:21:05 -0800
commit220f926d9d4b38a9018c922c095847bbd261f583 (patch)
treeefce65017941c05999dffbc84c243b0fd14e8f77 /src/core/SkEdgeBuilder.cpp
parented9f7a9220db8484af2216bd66701dc1043abb4b (diff)
use conics
Diffstat (limited to 'src/core/SkEdgeBuilder.cpp')
-rw-r--r--src/core/SkEdgeBuilder.cpp41
1 files changed, 13 insertions, 28 deletions
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index c3f5dafe8d..51da3a199a 100644
--- a/src/core/SkEdgeBuilder.cpp
+++ b/src/core/SkEdgeBuilder.cpp
@@ -167,12 +167,13 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
fList.reset();
fShiftUp = shiftUp;
- SkScalar conicTol = SK_ScalarHalf * (1 << shiftUp);
-
if (SkPath::kLine_SegmentMask == path.getSegmentMasks()) {
return this->buildPoly(path, iclip, shiftUp);
}
+ SkAutoConicToQuads quadder;
+ const SkScalar conicTol = (SK_Scalar1 / 4) * (1 << shiftUp);
+
SkPath::Iter iter(path, true);
SkPoint pts[4];
SkPath::Verb verb;
@@ -203,21 +204,13 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
}
break;
case SkPath::kConic_Verb: {
- const int MAX_POW2 = 4;
- const int MAX_QUADS = 1 << MAX_POW2;
- const int MAX_QUAD_PTS = 1 + 2 * MAX_QUADS;
- SkPoint storage[MAX_QUAD_PTS];
-
- SkConic conic;
- conic.set(pts, iter.conicWeight());
- int pow2 = conic.computeQuadPOW2(conicTol);
- pow2 = SkMin32(pow2, MAX_POW2);
- int quadCount = conic.chopIntoQuadsPOW2(storage, pow2);
- SkASSERT(quadCount <= MAX_QUADS);
- for (int i = 0; i < quadCount; ++i) {
- if (clipper.clipQuad(&storage[i * 2], clip)) {
+ const SkPoint* quadPts = quadder.computeQuads(
+ pts, iter.conicWeight(), conicTol);
+ for (int i = 0; i < quadder.countQuads(); ++i) {
+ if (clipper.clipQuad(quadPts, clip)) {
this->addClipper(&clipper);
}
+ quadPts += 2;
}
} break;
case SkPath::kCubic_Verb:
@@ -246,19 +239,11 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
break;
}
case SkPath::kConic_Verb: {
- const int MAX_POW2 = 4;
- const int MAX_QUADS = 1 << MAX_POW2;
- const int MAX_QUAD_PTS = 1 + 2 * MAX_QUADS;
- SkPoint storage[MAX_QUAD_PTS];
-
- SkConic conic;
- conic.set(pts, iter.conicWeight());
- int pow2 = conic.computeQuadPOW2(conicTol);
- pow2 = SkMin32(pow2, MAX_POW2);
- int quadCount = conic.chopIntoQuadsPOW2(storage, pow2);
- SkASSERT(quadCount <= MAX_QUADS);
- for (int i = 0; i < quadCount; ++i) {
- handle_quad(this, &storage[i * 2]);
+ const SkPoint* quadPts = quadder.computeQuads(
+ pts, iter.conicWeight(), conicTol);
+ for (int i = 0; i < quadder.countQuads(); ++i) {
+ handle_quad(this, quadPts);
+ quadPts += 2;
}
} break;
case SkPath::kCubic_Verb: {