Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport dashed borders with new border path. #1175
Conversation
|
r? @kvark Sorry for another large patch - hopefully the remaining border work should be much smaller patches after this one :) |
leeoniya
commented
Apr 28, 2017
•
|
having been part of the Gecko discussion regarding dot/dash spacing, gonna drop this here for posterity: https://bugzilla.mozilla.org/show_bug.cgi?id=382721 |
|
@leeoniya Thanks! This patch will definitely need a lot more work to get the exact results and edges cases that Gecko handles - but it puts the foundation in place :) |
|
Reviewed 18 of 18 files at r1. webrender/res/cs_clip_border.fs.glsl, line 1 at r1 (raw file):
let's add webrender/res/cs_clip_border.fs.glsl, line 25 at r1 (raw file):
I don't understand this part. So webrender/res/cs_clip_border.fs.glsl, line 26 at r1 (raw file):
shouldn't we use the minimum of clip distances instead of the maximum? webrender/res/cs_clip_border.vs.glsl, line 16 at r1 (raw file):
nit: webrender/res/cs_clip_border.vs.glsl, line 49 at r1 (raw file):
nit: I think doing webrender/res/cs_clip_border.vs.glsl, line 66 at r1 (raw file):
why is this webrender/res/cs_clip_border.vs.glsl, line 66 at r1 (raw file):
in a similar call to webrender/res/ps_border_edge.vs.glsl, line 69 at r1 (raw file):
what's the reason for webrender/src/border.rs, line 98 at r1 (raw file):
it appears that you can produce only webrender/src/ellipse.rs, line 30 at r1 (raw file):
Heavy math methods like this ask for a few unit tests to be sane. webrender/src/renderer.rs, line 500 at r1 (raw file):
it's great to see the clip mechanics helping out in seemingly unrelated areas ;) Comments from Reviewable |
Dashed border edges are handled by the standard ps_border_edge shader. Dashed border corners instead create a clip mask for the border and draw each dash stroke to the clip mask. The math for determining the correct dash strokes is too complex to evaluate efficiently in a shader, doing it this way allows us to support arbitrary kinds of dash strokes. In the future, we will either specialize this to a border render task (to avoid the clip mask target allocation for the whole border rect), or make use of upcoming optimization work in the clip mask code to handle this case more efficiently. This will also serve as the basis for dotted border corners, which are also too complex to evaluate inside a shader. For now, we just treat everything as an ellipse when evaluating the dash strokes. This gives the correct result for ellipses and circle radii, but is very inefficient for circles. As a follow up, we will include a fast path for corners where the x/y radii are equal. Deciding the exact dash length etc is not well specified. The current code is a rough approximation to what Gecko does. In the future we can iterate on this and make it closer to Gecko's rules for dash length.
|
Review status: 13 of 18 files reviewed at latest revision, 11 unresolved discussions. webrender/res/cs_clip_border.fs.glsl, line 1 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/res/cs_clip_border.fs.glsl, line 25 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
For now, I have just used the existing AA step code in other shaders. I intend to work on the AA quality of the borders (and other clip shaders) once the main border work is done. webrender/res/cs_clip_border.fs.glsl, line 26 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
The distances are different signs inside the line, so this is a signed distance field subtract operation. webrender/res/cs_clip_border.vs.glsl, line 16 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/res/cs_clip_border.vs.glsl, line 49 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/res/cs_clip_border.vs.glsl, line 66 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
In the case of a 3d transform, this ensures we get the right Z value to do the correct interpolation in the fragment shader. webrender/res/cs_clip_border.vs.glsl, line 66 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
In webrender/res/ps_border_edge.vs.glsl, line 69 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
We want the length of a dash, which is half the length of an on/off segment. Added a comment. webrender/src/border.rs, line 98 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I'm not sure how you can do that - could you explain? Comments from Reviewable |
|
Reviewed 5 of 5 files at r2. webrender/src/border.rs, line 98 at r1 (raw file): Previously, glennw (Glenn Watson) wrote…
Sure: let sign_modifier = match corner {...};
let origin = /*some math on sign_modifier*/;
let clip_center = /*some math on sign_modifier*/;That should be shorter, but not necessarily clearer, so I'm not pushing for it :) Comments from Reviewable |
|
@bors-servo r+ |
|
|
Support dashed borders with new border path. Dashed border edges are handled by the standard ps_border_edge shader. Dashed border corners instead create a clip mask for the border and draw each dash stroke to the clip mask. The math for determining the correct dash strokes is too complex to evaluate efficiently in a shader, doing it this way allows us to support arbitrary kinds of dash strokes. In the future, we will either specialize this to a border render task (to avoid the clip mask target allocation for the whole border rect), or make use of upcoming optimization work in the clip mask code to handle this case more efficiently. This will also serve as the basis for dotted border corners, which are also too complex to evaluate inside a shader. For now, we just treat everything as an ellipse when evaluating the dash strokes. This gives the correct result for ellipses and circle radii, but is very inefficient for circles. As a follow up, we will include a fast path for corners where the x/y radii are equal. Deciding the exact dash length etc is not well specified. The current code is a rough approximation to what Gecko does. In the future we can iterate on this and make it closer to Gecko's rules for dash length. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1175) <!-- Reviewable:end -->
|
|

glennw commentedApr 28, 2017
•
edited by larsbergstrom
Dashed border edges are handled by the standard ps_border_edge shader.
Dashed border corners instead create a clip mask for the border and
draw each dash stroke to the clip mask. The math for determining the correct
dash strokes is too complex to evaluate efficiently in a shader, doing
it this way allows us to support arbitrary kinds of dash strokes.
In the future, we will either specialize this to a border render task (to
avoid the clip mask target allocation for the whole border rect), or make
use of upcoming optimization work in the clip mask code to handle this
case more efficiently.
This will also serve as the basis for dotted border corners, which are also
too complex to evaluate inside a shader.
For now, we just treat everything as an ellipse when evaluating the dash
strokes. This gives the correct result for ellipses and circle radii,
but is very inefficient for circles. As a follow up, we will include
a fast path for corners where the x/y radii are equal.
Deciding the exact dash length etc is not well specified. The current
code is a rough approximation to what Gecko does. In the future we
can iterate on this and make it closer to Gecko's rules for dash length.
This change is