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

Unified Diff: src/core/SkEdgeBuilder.cpp

Issue 16195004: add asserts to point<-->verb helpers (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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/core/SkEdgeBuilder.h ('k') | src/core/SkPath.cpp » ('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 608a83c7c73ff8d9cf6622b5f5e58dc01889b5e0..9ac4e9744394d8164cf03c22d5b257a1b2de6ab5 100644
--- a/src/core/SkEdgeBuilder.cpp
+++ b/src/core/SkEdgeBuilder.cpp
@@ -153,12 +153,22 @@ int SkEdgeBuilder::buildPoly(const SkPath& path, const SkIRect* iclip,
return edgePtr - fEdgeList;
}
+static void handle_quad(SkEdgeBuilder* builder, const SkPoint pts[3]) {
+ SkPoint monoX[5];
+ int n = SkChopQuadAtYExtrema(pts, monoX);
+ for (int i = 0; i <= n; i++) {
+ builder->addQuad(&monoX[i * 2]);
+ }
+}
+
int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
int shiftUp) {
fAlloc.reset();
fList.reset();
fShiftUp = shiftUp;
+ SkScalar conicTol = SK_ScalarHalf * (1 << shiftUp);
+
if (SkPath::kLine_SegmentMask == path.getSegmentMasks()) {
return this->buildPoly(path, iclip, shiftUp);
}
@@ -192,6 +202,24 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
this->addClipper(&clipper);
}
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)) {
+ this->addClipper(&clipper);
+ }
+ }
+ } break;
case SkPath::kCubic_Verb:
if (clipper.clipCubic(pts, clip)) {
this->addClipper(&clipper);
@@ -214,13 +242,26 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
this->addLine(pts);
break;
case SkPath::kQuad_Verb: {
- SkPoint monoX[5];
- int n = SkChopQuadAtYExtrema(pts, monoX);
- for (int i = 0; i <= n; i++) {
- this->addQuad(&monoX[i * 2]);
- }
+ handle_quad(this, pts);
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);
+ SkDebugf("--- quadCount = %d\n", quadCount);
+ for (int i = 0; i < quadCount; ++i) {
+ handle_quad(this, &storage[i * 2]);
+ }
+ } break;
case SkPath::kCubic_Verb: {
SkPoint monoY[10];
int n = SkChopCubicAtYExtrema(pts, monoY);
« no previous file with comments | « src/core/SkEdgeBuilder.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698