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 upMake dashed-border rendering more similar to Gecko / other browsers. #3039
Conversation
|
It's probably not ideal that we need some border-specific code / flags in the common brush.glsl code, which I guess is what you were talking about on IRC? What we actually do for dashes in corners now webrender/webrender/src/border.rs Line 1096 in 9a2fbef is generate an instance for each dash / dot. We do this for corners because the size of the dash / dot varies with each instance as traced around the corner. I think what we probably want to do is something similar for dots / dashes in the border edge segments. This would give us complete control over specifying a local rect for each of the dashes, without affecting the common brush code. Previously, we wanted to do it in the shader to avoid generating a lot of instances per frame, but we now cache border segments to the texture cache, and re-use them between frames, so this isn't really a concern now. Having said all that, given our current deadlines and bug list - it's probably fine to merge a solution like this and do the work above as a follow up later on - thoughts? |
|
A little bit of a lie: It's green modulo some panic which is fixed in a commit here already. Previous try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=706f34643c938dbeafaf4db23d332b4bba64592c&selectedJob=198528498 New one: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d28f4117d92954f19cf509d5aef4e2542fd71983 |
webrender/res/brush_image.glsl, line 99 at r1 (raw file):
nit: I don't think this formatting changes are good. Better be consistent with both Rust and the rest of GLSL code and always use the brackets webrender/res/cs_border_segment.glsl, line 65 at r1 (raw file):
nit: can we put the webrender/res/cs_border_segment.glsl, line 367 at r1 (raw file):
nit: webrender/src/border.rs, line 247 at r1 (raw file):
what exactly makes no sense now? webrender/src/border.rs, line 369 at r1 (raw file):
this should have webrender/src/border.rs, line 992 at r1 (raw file):
asks to be an |
This commit ensures that dashed segments always start and end with half a dash. We should probably do better, and apply the condition in the TODO comment. But this matches existing rendering engines much closer than we do right now. We also ensure to always draw something in a dashed border corner.
|
Thanks for the review @kvark! Addressed comments and squashed the commits. I'll cleanup BorderCornerClipSource as a followup I think. Shouldn't be really hard. |
|
@bors-servo r=kvark |
|
|
Make dashed-border rendering more similar to Gecko / other browsers. This mostly focuses on non-cornered dashed borders. The worst case of this algorithm is the one where the borders are rounded and the space between corners (the solid segment) is small but non-zero. Thus I'm a bit on the fence on the fourth commit... I could preserve the current algorithm for the rounded corner cases. The tl;dr is that this makes a dashed segment always start with half a dash, which matches other browsers (modulo a TODO where other browsers start with the whole segment, and border-radius when each browser does something completely different so I suspect we may be a bit more lenient). I think we should do this for now if it doesn't cause problems, though it's trivial to extend it to do the same as Gecko for discontinued borders, etc. It's just a bit more annoying because instead of passing a flag I need to pass the offset around in a new float value. I ended up shifting the brush in `brush_picture.glsl`, where the rest of the repeating code is handled. That being said, I've done the transformation in local space, but there may be a better way to do it. There are some cleanups to the border code that I can do if this is a decent / acceptable approach. <!-- 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/3039) <!-- Reviewable:end -->
|
|
emilio commentedSep 10, 2018
•
edited by larsbergstrom
This mostly focuses on non-cornered dashed borders.
The worst case of this algorithm is the one where the borders are rounded and the space between corners (the solid segment) is small but non-zero.
Thus I'm a bit on the fence on the fourth commit... I could preserve the current algorithm for the rounded corner cases.
The tl;dr is that this makes a dashed segment always start with half a dash, which matches other browsers (modulo a TODO where other browsers start with the whole segment, and border-radius when each browser does something completely different so I suspect we may be a bit more lenient).
I think we should do this for now if it doesn't cause problems, though it's trivial to extend it to do the same as Gecko for discontinued borders, etc. It's just a bit more annoying because instead of passing a flag I need to pass the offset around in a new float value.
I ended up shifting the brush in
brush_picture.glsl, where the rest of the repeating code is handled. That being said, I've done the transformation in local space, but there may be a better way to do it.There are some cleanups to the border code that I can do if this is a decent / acceptable approach.
This change is