DescriptionDraw more accurate thick-stroked Beziers (disabled)
Draw thick-stroked Beziers by computing the outset quadratic, measuring the error, and subdividing until the error is within a predetermined limit.
To try this CL out, change src/core/SkStroke.h:18 to
#define QUAD_STROKE_APPROXIMATION 1
or from the command line: CPPFLAGS="-D QUAD_STROKE_APPROXIMATION=1" ./gyp_skia
Here's what's in this CL:
bench/BezierBench.cpp : a microbench for examining where the time is going
gm/beziers.cpp : random Beziers with various thicknesses
gm/smallarc.cpp : a distillation of bug skia:2769
samplecode/SampleRotateCircles.cpp : controls added for error, limit, width
src/core/SkStroke.cpp : the new stroke implementation (disabled)
tests/StrokerTest.cpp : a stroke torture test that checks normal and extreme values
The new stroke algorithm has a tweakable parameter:
stroker.setError(1); (SkStrokeRec.cpp:112)
The stroke error is the allowable gap between the midpoint of the stroke quadratic and the center Bezier. As the projection from the quadratic approaches the endpoints, the error is decreased proportionally so that it is always inside the quadratic curve.
An overview of how this works:
- For a given T range of a Bezier, compute the perpendiculars and find the points outset and inset for some radius.
- Construct tangents for the quadratic stroke.
- If the tangent don't intersect between them (may happen with cubics), subdivide.
- If the quadratic stroke end points are close (again, may happen with cubics), draw a line between them.
- Compute the quadratic formed by the intersecting tangents.
- If the midpoint of the quadratic is close to the midpoint of the Bezier perpendicular, return the quadratic.
- If the end of the stroke at the Bezier midpoint doesn't intersect the quad's bounds, subdivide.
- Find where the Bezier midpoint ray intersects the quadratic.
- If the intersection is too close to the quad's endpoints, subdivide.
- If the error is large proportional to the intersection's distance to the quad's endpoints, subdivide.
BUG=skia:723, skia:2769
Committed: https://skia.googlesource.com/skia/+/feff7d2d7719f52c7ea52db156003e609002bf04
Patch Set 1 #Patch Set 2 : new stroke somewhat working #Patch Set 3 : refactor cubic and quad stroking; fix sample #Patch Set 4 : add new gm and bench tests #Patch Set 5 : remove duplicate point calculations #Patch Set 6 : fix function camel case #Patch Set 7 : factor out tangent ray #Patch Set 8 : revert unrelated changes #Patch Set 9 : merge sampleapp debugging branch #Patch Set 10 : move stack depth debug variable into quad condition #Patch Set 11 : fix linux build #Patch Set 12 : fix degenerate case with no tangent at end #Patch Set 13 : save work in progress (not for review) #Patch Set 14 : add more tests #Patch Set 15 : stroke work in progress -- not for review #Patch Set 16 : stroke work in progress (not for review) #Patch Set 17 : quads work well; more to do on cubics #Patch Set 18 : cubic stroke work in progress (not for review) #Patch Set 19 : fix cubics #Patch Set 20 : handle case where cubic stroke share start and end #Patch Set 21 : allow error to be set by caller #Patch Set 22 : fix pt to line if line points are degenerate #Patch Set 23 : remove intersection limit experiment (unneeded) #Patch Set 24 : remove changes to path validate #Patch Set 25 : add time limit to new stroker test #Patch Set 26 : remove test files #Patch Set 27 : remove unnecessary changes, spaces #Patch Set 28 : turn off quad stroke approximation #Patch Set 29 : fix bench #
Messages
Total messages: 20 (7 generated)
|