aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkStroke.cpp
Commit message (Collapse)AuthorAge
* Ignore fill when stroke & filling convex line-only pathsGravatar robertphillips2016-08-26
| | | | | | | | | | | | | | | | | | This seems to work well for miter and bevel joins with the resulting stroke and fill path remaining convex. There seems to be an issue with round joins where the outer generated shell is usually not convex. Without this CL the resulting stroke & filled paths are always concave. Perf-wise (on Windows): convex-lineonly-paths-stroke-and-fill bench (in ms) w/o w/CL %decrease 8888 2.88 2.01 30.2 gpu 4.4 1.38 68.6 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2275243003 Review-Url: https://codereview.chromium.org/2275243003
* Don't leave fResScale uninitialized when constructing an SkStroke.Gravatar deanm2016-08-03
| | | | | | | | | | | Set a default value of 1. Users can set it with setResScale, but it's better that the constructor doesn't just leave the field uninitialized otherwise. R=reed@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2207753003 Review-Url: https://codereview.chromium.org/2207753003
* always compute a cubic tangentGravatar caryclark2016-06-01
| | | | | | | | | | | | | | | | If the inflection of a cubic is also the cusp, the tangent is degenerate at that t when computed directly. Rather than giving up, subdivide the curve there and use the computed control points to compute the tangent. This strategy also removes the error paths where the tangent formerly could not be computed. R=reed@google.com BUG=615686 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2020293002 Review-Url: https://codereview.chromium.org/2020293002
* cubic stroke fixGravatar caryclark2016-04-06
| | | | | | | | | | | | | | | Normally parallel tangents means that the stroke can be represented with a line. But looping cubics can have parallel tangents if the loop is 180 degrees. Check to see if the tangents direction is opposite to subdivide further. R=reed@google.com BUG=skia:5099 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1862753002 Review URL: https://codereview.chromium.org/1862753002
* Style bikeshed - remove extraneous whitespaceGravatar halcanary2016-03-29
| | | | | | GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842753002 Review URL: https://codereview.chromium.org/1842753002
* skip stroke outset of all teeny linesGravatar caryclark2016-03-16
| | | | | | | | | | | | Allow a small amount of slop when seeing if the previous moveTo and subsequent lineTo are the same. R=robertphillips@google.com BUG=593049 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1805913002 Review URL: https://codereview.chromium.org/1805913002
* allow move/zero-line/close to draw capsGravatar caryclark2016-02-22
| | | | | | | | R=fmalita@chromium.org BUG=skia:4784 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1720953002 Review URL: https://codereview.chromium.org/1720953002
* Zero length lines may have caps, but do not need joins.Gravatar caryclark2015-12-08
| | | | | | | | | | Check to see if the point is preceeded or followed by a line with a computable tangent before adding the join. R=reed@google.com BUG=566075 Review URL: https://codereview.chromium.org/1504043002
* add more conservative check for wayward divideGravatar caryclark2015-11-30
| | | | | | | | | | | | | When the parallel stroke to the curve can't be computed from the intersection of the tangent lines, as straight line connects the two points instead. Allow the intersection to succeed unless the ratio isn't finite or the contribution of (1 - ratio) isn't significant. R=reed@google.com,fmalita@chromium.org BUG=skia:4603 Review URL: https://codereview.chromium.org/1484873003
* fix for teeny strokesGravatar caryclark2015-10-26
| | | | | | | | | | | Pass the scale before evaluating degenerate line segments. This does not change other GMs. R=reed@google.com BUG=478337 Review URL: https://codereview.chromium.org/1418133007
* Reland of more zero-length changes for svg compatibility (patchset #1 id:1 ↵Gravatar caryclark2015-09-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of https://codereview.chromium.org/1334543002/ ) Reason for revert: DEPS should be fixed now Original issue's description: > Revert of more zero-length changes for svg compatibility (patchset #6 id:100001 of https://codereview.chromium.org/1330623003/ ) > > Reason for revert: > breaks DEPS > > Original issue's description: > > more zero-length changes for svg compatibility > > > > If a path contains a moveTo followed by a line or curve, > > even if the line or curve has no length, SVG expects > > the end caps to draw if the cap style is round or square. > > > > Fredrik Söderquist attached a patch to the chrome bug > > (slightly modified here) that fixes layout test failures > > resulting from deleting special-case code in SVG > > dealing with zero-length path segments. > > > > R=reed@google.com,fs@opera.com > > BUG=22974 > > > > Committed: https://skia.googlesource.com/skia/+/62fb1ba1786863e545c89839b5706ad5151cec15 > > TBR=fs@opera.com,reed@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=22974 > > Committed: https://skia.googlesource.com/skia/+/5ca4fa3846067a47e88d35ace895df3ebe3ec2a5 TBR=fs@opera.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=22974 Review URL: https://codereview.chromium.org/1314833004
* Revert of more zero-length changes for svg compatibility (patchset #6 ↵Gravatar caryclark2015-09-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | id:100001 of https://codereview.chromium.org/1330623003/ ) Reason for revert: breaks DEPS Original issue's description: > more zero-length changes for svg compatibility > > If a path contains a moveTo followed by a line or curve, > even if the line or curve has no length, SVG expects > the end caps to draw if the cap style is round or square. > > Fredrik Söderquist attached a patch to the chrome bug > (slightly modified here) that fixes layout test failures > resulting from deleting special-case code in SVG > dealing with zero-length path segments. > > R=reed@google.com,fs@opera.com > BUG=22974 > > Committed: https://skia.googlesource.com/skia/+/62fb1ba1786863e545c89839b5706ad5151cec15 TBR=fs@opera.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=22974 Review URL: https://codereview.chromium.org/1334543002
* more zero-length changes for svg compatibilityGravatar caryclark2015-09-09
| | | | | | | | | | | | | | | | If a path contains a moveTo followed by a line or curve, even if the line or curve has no length, SVG expects the end caps to draw if the cap style is round or square. Fredrik Söderquist attached a patch to the chrome bug (slightly modified here) that fixes layout test failures resulting from deleting special-case code in SVG dealing with zero-length path segments. R=reed@google.com,fs@opera.com BUG=22974 Review URL: https://codereview.chromium.org/1330623003
* Style Change: NULL->nullptrGravatar halcanary2015-08-27
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316233002 Review URL: https://codereview.chromium.org/1316233002
* zero-length cap fixGravatar caryclark2015-08-26
| | | | | | | | | | | | | | | | | | Re-land; layout tests are suppressed and gm differences are understood. A merge conflict prevented a automatic reland. If the endcap is not butt, draw the endcaps even when the line has zero length. If the dash length is zero, generate a zero length line segment. Treat a move followed by a close as a move followed by a zero-length line. TBR=reed@google.com BUG=422974 Review URL: https://codereview.chromium.org/1314213002
* Revert of experiment with zero-length round capped line segments (patchset ↵Gravatar caryclark2015-08-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #4 id:60001 of https://codereview.chromium.org/1309753002/ ) Reason for revert: More GMs changed than I expected. Will probably affect layout tests as well; reverting until I can verify that the changes are correct. Original issue's description: > experiment with zero-length round capped line segments > > If the endcap is not butt, draw the endcaps even when the line > has zero length. > > If the dash length is zero, generate a zero length line segment. > > Treat a move followed by a close as a move followed by a zero-length > line. > > R=reed@google.com,schenney@google.com > BUG=422974 > > Committed: https://skia.googlesource.com/skia/+/dd3c165828fffb369d0f4b13b48381169a0249a9 TBR=reed@google.com,schenney@google.com,schenney@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=422974 Review URL: https://codereview.chromium.org/1304163008
* experiment with zero-length round capped line segmentsGravatar caryclark2015-08-21
| | | | | | | | | | | | | | | If the endcap is not butt, draw the endcaps even when the line has zero length. If the dash length is zero, generate a zero length line segment. Treat a move followed by a close as a move followed by a zero-length line. R=reed@google.com,schenney@google.com BUG=422974 Review URL: https://codereview.chromium.org/1309753002
* Use static_assert instead of SK_COMPILE_ASSERT.Gravatar bungeman2015-08-20
| | | | | | | Now that static_assert is allowed, there is no need to use a non- standard compile time assertion Review URL: https://codereview.chromium.org/1306443004
* Very tiny paths are subsumed by the ConvexicatorGravatar caryclark2015-07-14
| | | | | | | | | | | | | | | and are treated as convex when they are not. Allow the SkPath::Iter to leave degenerate path segments unmolested by passing an additional exact bool to next(). Treat any non-zero length as significant in addPt(). R=reed@google.com,robertphillips@google.com BUG=493450 Review URL: https://codereview.chromium.org/1228383002
* SkPath::Direction serves two masters:Gravatar reed2015-06-10
| | | | | | | | | | | | | - input param to addFoo (e.g. addRect), where only CW or CCW are valid) - output param from computing functions, that sometimes return kUnknown This CL's intent is to split these into distinct enums/features: - Direction (public) loses kUnknown, and is only used for input - FirstDirection (private) is used for computing the first direction we see when analyzing a contour BUG=skia: Review URL: https://codereview.chromium.org/1176953002
* another double squareGravatar caryclark2015-06-01
| | | | | | | | | | This is also a case where the square term is passed to a helper function that squares the error term a second time. R=reed@google.com BUG=skia:3877 Review URL: https://codereview.chromium.org/1152623005
* don't square error term twiceGravatar caryclark2015-06-01
| | | | | | | | | | The cubic code erroneously passed the error square term to a function which in turn squares the error term. R=reed@google.com BUG=skia:3877 Review URL: https://codereview.chromium.org/1163843003
* use inline version of eval quad if tangent is not neededGravatar caryclark2015-05-29
| | | | | | R=reed@google.com Review URL: https://codereview.chromium.org/1160163002
* remove SK_LEGACY_STROKE_CURVESGravatar caryclark2015-05-22
| | | | | | | | | The change in Chrome has been landed so this guard is no longer needed. R=reed@google.com,fmalita@chromium.org BUG=102411 Review URL: https://codereview.chromium.org/1157623003
* fix win 8 botGravatar caryclark2015-05-20
| | | | | | | | | Comment out assert (runtime documentation) It fails on Win 8 because the result isn't bit identical. TBR=bungeman@google.com Review URL: https://codereview.chromium.org/1148053003
* handle large conic strokes betterGravatar caryclark2015-05-19
| | | | | | | | | | | | | | | | | | | | A stroked conic computes the outset quad's control point by computing the intersection of the quad's endpoints. If the the denominator used to compute the scale factor for the control point is small, check to see if the numerator is also small so that the division stays bounded. Also clean up error returns and internal function calls to simplify the code. Additionally, remove comic max curvature (unimplemented) and call extrema functions instead to handle cases where the conic is degenerate or is a line. R=reed@google.com, fmalita@chromium.org BUG=skia:3843 Review URL: https://codereview.chromium.org/1144883003
* Revert of Revert of stop calling SkScalarDiv (patchset #1 id:1 of ↵Gravatar reed2015-05-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1138263002/) Reason for revert: android patched, blink has rolled Original issue's description: > Revert of stop calling SkScalarDiv (patchset #4 id:60001 of https://codereview.chromium.org/1135053002/) > > Reason for revert: > need to wait for Blink roll (and patch android) > > Original issue's description: > > stop calling SkScalarDiv > > > > BUG=skia: > > TBR= > > > > Committed: https://skia.googlesource.com/skia/+/67d71c898249a7af3523b16c6a69895a63bfae0a > > TBR= > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/2629697933b5cc975e45d2a45c48f803fc6cbcec TBR= NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1135693003
* Revert of stop calling SkScalarDiv (patchset #4 id:60001 of ↵Gravatar reed2015-05-12
| | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1135053002/) Reason for revert: need to wait for Blink roll (and patch android) Original issue's description: > stop calling SkScalarDiv > > BUG=skia: > TBR= > > Committed: https://skia.googlesource.com/skia/+/67d71c898249a7af3523b16c6a69895a63bfae0a TBR= NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1138263002
* stop calling SkScalarDivGravatar reed2015-05-12
| | | | | | | BUG=skia: TBR= Review URL: https://codereview.chromium.org/1135053002
* Fix build warning: reference cannot be bound to dereferenced null pointer in ↵Gravatar dongseong.hwang2015-04-30
| | | | | | well-defined C++ code; comparison may be assumed to always evaluate to true [-Wtautological-undefined-compare] Review URL: https://codereview.chromium.org/1110353003
* fuzzer fixesGravatar caryclark2015-02-25
| | | | | | | | | | | | | | | | | | | Fix path bugs exposed by the path fuzzer. Changes to existing gm and samplecode files defer their calls to construct SkPath objects until the first draw instead of at test initialization. Add an experimental call to SkPath to validate the internal SkPathRef. Fix SkPath::addPoly to set the last moveto after adding a close verb. Fix stroke to handle failures when computing the unit normal. Add a unit test for the unit normal failure. R=reed@google.com Review URL: https://codereview.chromium.org/953383002
* flip stroke to chrome compatible defineGravatar caryclark2015-02-24
| | | | Review URL: https://codereview.chromium.org/932723003
* break out of cubic stroker loop on degenerate caseGravatar caryclark2015-02-23
| | | | | | | | | | | | | The looper can generate more than one quad, but if any one is degenerate, give up, but not before generating the state for the line join to produce the correct end. Before, the early return allowed the inside path to contain multiple movetos that caused reversePath to assert. R=reed@google.com Review URL: https://codereview.chromium.org/948043002
* This uses quad approximations of the outer and inner paths describing a ↵Gravatar caryclark2015-02-20
| | | | | | | | | | stroke. Cubics and conics' thick strokes are approximated with quads as well. The approximation uses a similar error term as the fill scan converter to determine the number of quads to use. This also updates SampleApp QuadStroker test with conics, ovals, and stroked text. Review URL: https://codereview.chromium.org/932113002
* optional res-scale parameter to getFillPathGravatar reed2015-02-12
| | | | | | | | BUG=skia: NOTREECHECKS=True TBR= Review URL: https://codereview.chromium.org/911053005
* Update stroke path to use rect returned from isRect (to fix trailing moveTo bug)Gravatar robertphillips2014-12-29
| | | | | | | | | | This basically recreates what was done in: https://codereview.chromium.org/16950021/ (add rect-output parameter to isRect, allowing us to return the correct bounds even if a rectagular path has a trailing moveTo) with the addition of GM representation BUG=skia:247770 Review URL: https://codereview.chromium.org/834503002
* Set temporary paths volatile so we don't cache them.Gravatar jvanverth2014-10-24
| | | | | | | | | | Any path that is generated frame-to-frame should not be rendered by using the DistanceFieldPathRenderer, because generating the initial distance field, uploading it and rendering it takes longer than the SoftwarePathRenderer. BUG=skia:2935 Review URL: https://codereview.chromium.org/677463002
* Draw more accurate thick-stroked Beziers (disabled)Gravatar caryclark2014-10-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fallback to moveTo when unable to find the first tangent in cubicToGravatar piotaixr2014-08-26
| | | | | | | | | | | | | | | | | | | | When calling cubicTo(a, b, c) and if the distance between fPrevPt and a is too small, b is used instead of a to calculate the first tangent, even if the distance between fPrevPt and b is too small. In debug mode, this is causing an assertion to fail in SkPathStroker::preJoinTo() and, in Release, the use of an unitialized value. The first patch set is adding a failing test. The second one add the fix to SkPathStroker::cubicTo() BUG=skia:2820 R=bsalomon@chromium.org, junov@chromium.org, reed@google.com, caryclark@google.com, bsalomon@google.com Author: piotaixr@chromium.org Review URL: https://codereview.chromium.org/460813002
* Revert of fix the error that path is inversed for stroke and strokeAndFill ↵Gravatar commit-bot@chromium.org2014-05-04
| | | | | | | | | | | | | | | | | | | | | | | | | | styles (https://codereview.chromium.org/183683010/) R=bsalomon@google.com, reed@google.com, yunchao.he@intel.com TBR=reed@google.com NOTRY=True Reason for revert: broke unittests Original issue's description: > fix the error that path is inversed for stroke and strokeAndFill styles. > > However, because hairline stroke + fill = fill (see src/core/SkStrokeRec.cpp), strokeAndFill will be thought as fill style when paint.getStrokeWidth() <= 0, this edge case can be inverse-filled. > > BUG=skia:2222 > > Committed: http://code.google.com/p/skia/source/detail?r=14561 Author: reed@chromium.org Review URL: https://codereview.chromium.org/269903002 git-svn-id: http://skia.googlecode.com/svn/trunk@14562 2bbb7eff-a529-9590-31e7-b0007b416f81
* fix the error that path is inversed for stroke and strokeAndFill styles.Gravatar commit-bot@chromium.org2014-05-04
| | | | | | | | | | | | | However, because hairline stroke + fill = fill (see src/core/SkStrokeRec.cpp), strokeAndFill will be thought as fill style when paint.getStrokeWidth() <= 0, this edge case can be inverse-filled. BUG=skia:2222 R=bsalomon@google.com, reed@google.com Author: yunchao.he@intel.com Review URL: https://codereview.chromium.org/183683010 git-svn-id: http://skia.googlecode.com/svn/trunk@14561 2bbb7eff-a529-9590-31e7-b0007b416f81
* Sanitizing source files in Housekeeper-NightlyGravatar skia.committer@gmail.com2013-08-16
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@10764 2bbb7eff-a529-9590-31e7-b0007b416f81
* fine-tune tolerance for pinchy quads in strokerGravatar reed@google.com2013-08-15
| | | | | | | | | BUG= R=jvanverth@google.com Review URL: https://codereview.chromium.org/22947005 git-svn-id: http://skia.googlecode.com/svn/trunk@10753 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert r9724 (add rect-output parameter to isRect) to allow the DEPS rollGravatar robertphillips@google.com2013-06-25
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@9750 2bbb7eff-a529-9590-31e7-b0007b416f81
* add rect-output parameter to isRect, allowing us to return the correct ↵Gravatar reed@google.com2013-06-21
| | | | | | | | | | | | bounds even if a rectagular path has a trailing moveTo https://code.google.com/p/chromium/issues/detail?id=247770 R=caryclark@google.com Review URL: https://codereview.chromium.org/16950021 git-svn-id: http://skia.googlecode.com/svn/trunk@9724 2bbb7eff-a529-9590-31e7-b0007b416f81
* test thick stroking of conicsGravatar reed@google.com2013-06-12
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@9535 2bbb7eff-a529-9590-31e7-b0007b416f81
* fix bug introduced with SK_IGNORE_CUBIC_STROKE_FIX where we no longer respectedGravatar reed@google.com2013-04-10
| | | | | | | | | | | | | subDivide limit. This caused problems with degenate paths (too much recursion). The fix was two parts: 1. decrement the subDivide limit as we recurse 2. up the limit for cubics to 7, to match our current quality added unittest that replicated the too-much-recursion bug. Review URL: https://codereview.chromium.org/14086002 git-svn-id: http://skia.googlecode.com/svn/trunk@8599 2bbb7eff-a529-9590-31e7-b0007b416f81
* fix handling of stroked cubics when we exhaust our recursion limit.Gravatar reed@google.com2013-03-12
| | | | | | Review URL: https://codereview.chromium.org/12567006 git-svn-id: http://skia.googlecode.com/svn/trunk@8093 2bbb7eff-a529-9590-31e7-b0007b416f81
* remove dead/#if 0/if (0) code blocks. no change to compiled output.Gravatar reed@google.com2013-03-08
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@8043 2bbb7eff-a529-9590-31e7-b0007b416f81
* remove obsolete build flags:Gravatar reed@google.com2013-02-22
| | | | | | | | | | | | | SK_IGNORE_TRANS_CLAMP_FIX SK_IGNORE_1XN_BITMAP_OPT SK_IGNORE_CLIP_BUG_FIX SK_IGNORE_FAST_SCALEMATRIX_INVERT SK_IGNORE_QUAD_STROKE_FIX SK_IGNORE_MULTIPLY_XFERMODE_OPT SK_IGNORE_LARGE_DASH_OPT Review URL: https://codereview.appspot.com/7381050 git-svn-id: http://skia.googlecode.com/svn/trunk@7829 2bbb7eff-a529-9590-31e7-b0007b416f81