-
Notifications
You must be signed in to change notification settings - Fork 306
Adjust the clip region for shadow elements. #2278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust the clip region for shadow elements. #2278
Conversation
|
r? @glennw |
|
Does this seem like a reasonable solution @gankro ? @GuanWen-Chen Thanks for the patch! Could you also add a wrench reftest to cover this case, and a gecko try run with this patch applied? |
|
I don't understand how the clip scroll tree works well enough anymore to say if this is right, but from what I remember it shouldn't be? How does this correctly handle: (I believe this roughly corresponds to the commands sent for Specifically only B should be offset, while A should still apply unchanged. It seems like the interesection you're doing is potentially applying this logic, but I thought the push_clip commands were too lossy today to reliably show up in the clipscroll tree? Also whatever the correct logic, it needs to be applied to text run shadows as well, as partial ligatures do the same trick. |
|
Sorry, didn't get to this today - will read through it in detail tomorrow. |
|
Hello @gankro Yes, I think only B (every clip nodes within shadow) should be offset, and I will apply this logic to text. However, I found a case this solution couldn't handle. In this case, according to current logic, when handling the line's shadow, we will adjust the line's shadow's local_clip rect to clip C's region and apply clip B; but the clip B is the clip without shadow offset. |
|
@mrobinson you're still the clip expert, right? |
webrender/src/frame_builder.rs
Outdated
| fast_clip_and_scroll = clip_and_scroll; | ||
| } else { | ||
| let node = clip_scroll_tree.nodes.get(&clip_and_scroll.clip_node_id()).unwrap(); | ||
| let mut clip_rect = node.local_viewport_rect.translate(&shadow_offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm. This feels a bit wrong to me. How do we know that the ClipScrollNode has the same coordinate system as the shadow? What about the other clips in the clip hierarchy? I'm not sure this is the correct approach here, but it could be that I simply don't understand the problem. I worry that this is merely hiding the overall issue.
Doesn't it make sense to render
|
Sorry for the late reply. Another question I have is how we know which clips should affect the shadow and which ones should not? |
|
@mrobinson the idea is that during DL construction, some clips are pushed while a text-shadow is still pushed, and those should have the shadow offset applied when rendering the shadow. This "inner" clip is used to make wavy/dashed lines from sibling elements "line up", and to draw a glyph where different parts have different styles (by drawing it multiple times with different clips). Here's some examples of this in action in firefox today: |
|
@gankro I suppose it isn't possible to modify Gecko to produce another clip with the proper offset and apply it to the shadow? I worry about building assumptions that only hold true for Gecko into WebRender... |
|
I discussed this briefly with @gankro on IRC. Conversation here for posterity: |
|
Ok so discussed this @mrobinson and @mstange today, and we think we've worked out what should work here. A key detail here is @demo99 (ethan lin) recently cleaned up the TextDrawTarget clipping, eliminating one of my points of confusion about the different clip sources: https://bugzilla.mozilla.org/show_bug.cgi?id=1424673 The high level idea is that we want shadows to offset only the local clip rect, and PushClip/PopClip on TextDrawTarget will manipulate this value.
One word of caution is that this introduces a semantic distinction between ClipScrollNodes and local clips; the latter will be offset by shadows. This means it isn't always a correct optimization to squash clips into children. If such an optimization is desirable, we can potentially add machinery to remember if we're currently adding things to a shadow to supress it when necessary. (cc @kats) Ideally we should add tests to that will break if anyone tries to do this without thinking about it. Does that make sense to you, @GuanWen-Chen ? |
|
Ok, I will modify the code in both gecko and WR sides. |
7100ccb to
efa3048
Compare
efa3048 to
c8cbae0
Compare
|
r? @gankro |
|
@bors-servo r+ awesome! |
|
📌 Commit c8cbae0 has been approved by |
… r=Gankro Adjust the clip region for shadow elements. This patch is intend to fix #1928. In webrender, shadow elements inherit the same clip with the original elements which leads the shadow to apply the wrong clip region when doing fast-shadow. To fix this, when adding a shadow line primitive, I adjust PrimitiveInfo's local_clip_rect to fit the correct clip region and apply the clip outside of the shadow to the shadow line primitive. <!-- 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/2278) <!-- Reviewable:end -->
|
☀️ Test successful - status-appveyor, status-taskcluster |


This patch is intend to fix #1928.
In webrender, shadow elements inherit the same clip with the original elements which leads the shadow to apply the wrong clip region when doing fast-shadow.
To fix this, when adding a shadow line primitive, I adjust PrimitiveInfo's local_clip_rect to fit the correct clip region and apply the clip outside of the shadow to the shadow line primitive.
This change is