skia2/samplecode
caryclark feff7d2d77 Draw 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

Review URL: https://codereview.chromium.org/558163005
2014-10-09 05:36:04 -07:00
..
ClockFaceView.cpp Simplify flattening to just write enough to call the factory/public-constructor for the class. We want to *not* rely on private constructors, and not rely on calling through the inheritance hierarchy for either flattening or unflattening(CreateProc). 2014-08-21 07:59:51 -07:00
GMSampleView.h DM: also run benches once. 2014-02-26 23:01:57 +00:00
OverView.cpp Removes uses of unnamed namespace from samplecode. 2013-09-13 12:39:55 +00:00
OverView.h
Sample2PtRadial.cpp
SampleAAClip.cpp replace SkBitmap::Config with SkColorType in gms 2014-02-17 21:21:46 +00:00
SampleAARectModes.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleAARects.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleAll.cpp Change SkPicture::draw to playback 2014-09-04 08:42:50 -07:00
SampleAnimatedGradient.cpp
SampleAnimator.cpp
SampleAnimBlur.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleApp.cpp use SkDocument to capture pdfs from SampleApp 'e' 2014-10-08 11:10:51 -07:00
SampleApp.h use SkDocument to capture pdfs from SampleApp 'e' 2014-10-08 11:10:51 -07:00
SampleArc.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
SampleAvoid.cpp Factory methods for heap-allocated SkPathEffect and SkXfermode objects. 2014-02-20 20:40:19 +00:00
SampleBigBlur.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleBigGradient.cpp
SampleBitmapRect.cpp use surface in SkView/SampleApp 2014-09-18 11:29:01 -07:00
SampleBlur.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleBox.cpp
SampleCamera.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleChart.cpp "NULL !=" = NULL 2014-09-05 13:34:00 -07:00
SampleCircle.cpp add peekPixels to SkCanvas and SkSurface 2014-02-13 17:14:46 +00:00
SampleClamp.cpp
SampleClip.cpp Change old PRG to be SkLCGRandom; change new one to SkRandom 2013-09-09 20:09:12 +00:00
SampleClock.cpp Add Clock Sample. 2013-09-17 19:52:05 +00:00
SampleCode.h remove SkBounder -- unused and unloved 2014-06-03 10:54:00 -07:00
SampleColorFilter.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleComplexClip.cpp fix more 64bit warnings 2014-01-27 13:42:58 +00:00
SampleConcavePaths.cpp
SampleCull.cpp deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPRECATED_SCALARROUND for legacy clients 2013-12-17 19:22:07 +00:00
SampleDash.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleDegenerateTwoPtRadials.cpp remove remaining references to Sk64 (obsolete) 2014-01-13 14:53:55 +00:00
SampleDither.cpp add new copyTo version to SkBitmap, which takes SkColorType 2014-02-23 03:59:35 +00:00
SampleDitherBitmap.cpp remove alphatype from colortable 2014-09-29 12:10:27 -07:00
SampleDraw.cpp
SampleEffects.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleEmboss.cpp remove unused Kernel33MaskFilter 2014-05-12 13:35:55 +00:00
SampleEmptyPath.cpp Clean up SkTypes.h. 2013-10-11 18:50:45 +00:00
SampleEncode.cpp hide discardable factory from public imagegenerator api 2014-05-27 14:14:22 +00:00
SampleFatBits.cpp Hide fields in SkImageInfo 2014-09-03 11:54:58 -07:00
SampleFillType.cpp
SampleFilter2.cpp hide Config in SkImageDecoder -- use SkColorType instead 2014-06-12 17:40:00 -07:00
SampleFilter.cpp hide SkBitmap::Config entirely (behind a flag) 2014-06-17 08:38:31 -07:00
SampleFilterFuzz.cpp "NULL !=" = NULL 2014-09-05 13:34:00 -07:00
SampleFontCache.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleFontScalerTest.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
SampleFuzz.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleGradients.cpp Remove unused (by clients) SkUnitMapper 2014-05-22 12:27:41 +00:00
SampleHairCurves.cpp Change old PRG to be SkLCGRandom; change new one to SkRandom 2013-09-09 20:09:12 +00:00
SampleHairline.cpp Revert "Revert of add colortable support to imagegenerator (https://codereview.chromium.org/304443003/)" 2014-05-29 15:57:20 +00:00
SampleHairModes.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleIdentityScale.cpp add an animated test to verify that high-quality identity scaling doesn't change the image 2014-08-08 12:11:33 -07:00
SampleLayerMask.cpp Reduce internal explicit SaveFlags usage. 2014-04-18 14:19:31 +00:00
SampleLayers.cpp Remove unused (by clients) SkUnitMapper 2014-05-22 12:27:41 +00:00
SampleLCD.cpp
SampleLines.cpp remove unused Kernel33MaskFilter 2014-05-12 13:35:55 +00:00
SampleLua.cpp add drawImage to lua 2013-06-11 02:20:28 +00:00
SampleManyRects.cpp Change old PRG to be SkLCGRandom; change new one to SkRandom 2013-09-09 20:09:12 +00:00
SampleMeasure.cpp remove (unused) scale parameter from measureText 2014-08-26 11:30:01 -07:00
SampleMipMap.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleMovie.cpp Fix more clang errors. 2013-04-05 21:13:14 +00:00
SampleOvalTest.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SamplePatch.cpp parameterize tesselation params 2014-08-06 09:54:19 -07:00
SamplePath.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SamplePathClip.cpp Fixing some warnings on Linux 2013-03-07 20:52:59 +00:00
SamplePathEffects.cpp Builder class for SkLayerRasterizer. 2014-02-26 13:27:37 +00:00
SamplePathFill.cpp
SamplePathUtils.cpp Factory methods for heap-allocated SkPathEffect and SkXfermode objects. 2014-02-20 20:40:19 +00:00
SamplePdfFileViewer.cpp remove remaining references to Sk64 (obsolete) 2014-01-13 14:53:55 +00:00
SamplePictFile.cpp Change SkPicture::draw to playback 2014-09-04 08:42:50 -07:00
SamplePicture.cpp Cleanup usage of GetResourcePath() after commit bcbc1788b4. 2014-07-01 12:35:49 -07:00
SamplePoints.cpp remove unused Kernel33MaskFilter 2014-05-12 13:35:55 +00:00
SamplePolyToPoly.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
SampleRectanizer.cpp Move GrIPoint16 to SkIPoint16 (and remove GrPoint.h) 2014-06-02 10:20:15 -07:00
SampleRegion.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleRepeatTile.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleRotateCircles.cpp Draw more accurate thick-stroked Beziers (disabled) 2014-10-09 05:36:04 -07:00
SampleShaders.cpp
SampleShaderText.cpp remove unneeded inval 2014-06-02 14:41:24 -07:00
SampleSkLayer.cpp deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPRECATED_SCALARROUND for legacy clients 2013-12-17 19:22:07 +00:00
SampleSlides.cpp Remove unused (by clients) SkUnitMapper 2014-05-22 12:27:41 +00:00
SampleSpiral.cpp
SampleStringArt.cpp Type warning fix for: Add string art GM and sample. 2013-09-19 16:32:49 +00:00
SampleStrokePath.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleStrokeRect.cpp
SampleSubpixelTranslate.cpp Cleanup usage of GetResourcePath() after commit bcbc1788b4. 2014-07-01 12:35:49 -07:00
SampleText.cpp remove unused TextBufferDirection enum 2014-10-03 12:44:37 -07:00
SampleTextAlpha.cpp stop calling SkCanvas::getDevice 2014-06-30 09:05:34 -07:00
SampleTextBox.cpp
SampleTextOnPath.cpp Make sure SkDrawLooper objects can only be allocated on the heap. 2014-04-15 15:48:36 +00:00
SampleTextureDomain.cpp SkCanvas::drawImage is the new way for drawing a SkImage to a Canvas 2014-09-24 13:03:30 -07:00
SampleTiling.cpp "NULL !=" = NULL 2014-09-05 13:34:00 -07:00
SampleTinyBitmap.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleUnpremul.cpp make allocPixels throw on failure 2014-09-02 12:50:45 -07:00
SampleVertices.cpp Remove unused (by clients) SkUnitMapper 2014-05-22 12:27:41 +00:00
SampleWarp.cpp
SampleWritePixels.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleXfermodesBlur.cpp Revert "Revert of add colortable support to imagegenerator (https://codereview.chromium.org/304443003/)" 2014-05-29 15:57:20 +00:00
TransitionView.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
TransitionView.h
vertexdump.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00