Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SVG: Increase hit-testing precision on strokes
Skia takes a precision value when generating strokes as an optimization. When rendering, we pass a value derived from the scale-factor in the CTM, but when hit-testing we were passing a hard-coded value. This worked reasonably well for solid strokes at moderate scales. However, at sufficiently high scales and especially for dashed strokes, the stroke generated for hit-testing was noticeably different from the rendered stroke. This change passes the CTM through to the hit-testing code, so that we can use the same high precision for hit testing as rendering. Bug: 964614 Change-Id: I8dfcb3ade86b9e7b63c7415baab5814ac2286ce8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2112955 Reviewed-by: Ian Prest <iapres@microsoft.com> Reviewed-by: Philip Rogers <pdr@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Commit-Queue: Ian Prest <iapres@microsoft.com> Cr-Commit-Position: refs/heads/master@{#759761}
- Loading branch information
1 parent
390b067
commit 6ac09a5
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
2dcontext/path-objects/2d.path.isPointInStroke.scaleddashes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /2dcontext/tools/gentest.py. --> | ||
<title>Canvas test: 2d.path.isPointInStroke.scaleddashes</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/2dcontext/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="/2dcontext/resources/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.path.isPointInStroke.scaleddashes</h1> | ||
<p class="desc">isPointInStroke() should return correct results on dashed paths at high scale factors</p> | ||
|
||
|
||
<p class="output">Actual output:</p> | ||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> | ||
|
||
<ul id="d"></ul> | ||
<script> | ||
var t = async_test("isPointInStroke() should return correct results on dashed paths at high scale factors"); | ||
_addTest(function(canvas, ctx) { | ||
|
||
var scale = 20; | ||
ctx.setLineDash([10, 21.4159]); // dash from t=0 to t=10 along the circle | ||
ctx.scale(scale, scale); | ||
ctx.ellipse(6, 10, 5, 5, 0, 2*Math.PI, false); | ||
ctx.stroke(); | ||
|
||
// hit-test the beginning of the dash (t=0) | ||
_assertSame(ctx.isPointInStroke(11*scale, 10*scale), true, "ctx.isPointInStroke(11*scale, 10*scale)", "true"); | ||
// hit-test the middle of the dash (t=5) | ||
_assertSame(ctx.isPointInStroke(8.70*scale, 14.21*scale), true, "ctx.isPointInStroke(8.70*scale, 14.21*scale)", "true"); | ||
// hit-test the end of the dash (t=9.8) | ||
_assertSame(ctx.isPointInStroke(4.10*scale, 14.63*scale), true, "ctx.isPointInStroke(4.10*scale, 14.63*scale)", "true"); | ||
// hit-test past the end of the dash (t=10.2) | ||
_assertSame(ctx.isPointInStroke(3.74*scale, 14.46*scale), false, "ctx.isPointInStroke(3.74*scale, 14.46*scale)", "false"); | ||
|
||
|
||
}); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions
35
svg/types/scripted/SVGGeometryElement.isPointInStroke-02.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.