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

Unified Diff: src/core/SkEdgeBuilder.cpp

Issue 455043002: use conics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments Created 6 years 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 | « include/core/SkPathMeasure.h ('k') | src/core/SkGeometry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkEdgeBuilder.cpp
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index c3f5dafe8d7ef104f13d98ffc0fb6818da55c04e..51da3a199af8f869ba71e64c2abd50bd3ea5ed48 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: {
« no previous file with comments | « include/core/SkPathMeasure.h ('k') | src/core/SkGeometry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698