aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkEdgeBuilder.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-31 15:17:50 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-31 15:17:50 +0000
commit277c3f87656c44e0a651ed0dd56efa16c0ab07b4 (patch)
tree863b9897fe1ab6263150dfbd8d391cb0f28ea655 /src/core/SkEdgeBuilder.cpp
parent2d76d933ff8ba2090229599f32bdb2b17fb7ad50 (diff)
bump picture version since SkPath has changed (conics)
enable conics in SkPath git-svn-id: http://skia.googlecode.com/svn/trunk@9370 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkEdgeBuilder.cpp')
-rw-r--r--src/core/SkEdgeBuilder.cpp51
1 files changed, 46 insertions, 5 deletions
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index 608a83c7c7..9ac4e97443 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);