Closed Bug 1370682 Opened 8 years ago Closed 8 years ago

Implement rounded corners clipping in webrender

Categories

(Core :: Graphics: WebRender, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: mstange, Assigned: kats)

References

Details

(Keywords: feature, Whiteboard: [gfx-noted])

Attachments

(2 files)

Our layers API does not have a way to specify clips with rounded rectangles. We only have ClipRect and a way to set a mask layer. So if you have an active layer with a rounded clip, we create a mask layer for that. We'd like to avoid the mask layers with WebRender. WebRender allows us to set clips with rounded corners, so we should make use of that functionality. As a first step, we probably need to add an API to Layer that allows us to specify rounded rectangle clips. Then we need to teach FrameLayerBuilder to have a mode that turns DisplayItemClips with rounded rectangles into rounded rectangle layer clips. And then we need to teach WebRenderLayerManager to turn those clips into rounded WebRender clips. There's a sketch of the first two pieces in the advanced-layers repo. This change should improve our performance on http://output.jsbin.com/surane/quiet where we currently create and destroy tons of mask layer images.
(In reply to Markus Stange [:mstange] from comment #0) > There's a sketch of the first two pieces in the advanced-layers repo. This code is at https://hg.mozilla.org/users/bschouten_mozilla.com/advanced-layers/rev/19535bcdfdea and at https://hg.mozilla.org/users/bschouten_mozilla.com/advanced-layers/file/f418dadba7b2/layout/painting/FrameLayerBuilder.cpp#l6355 However, it only handles the case of a single rounded corner clip. Unfortunately, the clip can be an intersection of multiple rounded corner clips. The API should handle that case without falling back to a much slower path.
AL never made use of this API, so it didn't make it over to bug 1365879. But if it comes back in some form it'd be great if layers-based compositors could make use of it as well.
If you wanted, you could make FLB always set the rounded rect clips, and move mask layer creation to be something that happens in the LayerManager/Compositor (with WR implementing it natively instead). That'd be nice since it'd reduce the FLB complexity instead of adding to it. More short term work though.
Keywords: feature
Priority: -- → P3
Whiteboard: [gfx-noted]
(In reply to Matt Woodrow (:mattwoodrow) from comment #3) > If you wanted, you could make FLB always set the rounded rect clips, and > move mask layer creation to be something that happens in the > LayerManager/Compositor (with WR implementing it natively instead). > > That'd be nice since it'd reduce the FLB complexity instead of adding to it. > More short term work though. I think I prefer this approach. To get some nice things immediately I'm thinking of just not translating the mask layer for display item layers and building the webrender clip from the display item directly. See bug 1375059
What's this story like in the layers-free world?
Flags: needinfo?(mstange)
layers-free is getting basic clipping in bug 1386483 but it currently ignores rounded corners. So rounded corners clipping still needs to be hooked up somewhere; it could be done in this bug but it won't go in FrameLayerBuilder.
Flags: needinfo?(mstange)
Blocks: stage-wr-nightly
No longer blocks: stage-wr-trains
Summary: Make FrameLayerBuilder turn rounded display item clips into rounded layer clips instead of into mask layers → Implement rounded corners clipping in webrender
(In reply to Markus Stange [:mstange] from comment #6) > layers-free is getting basic clipping in bug 1386483 but it currently > ignores rounded corners. So rounded corners clipping still needs to be > hooked up somewhere; it could be done in this bug but it won't go in > FrameLayerBuilder. I'm working on this, will use this bug for it.
Assignee: nobody → bugmail
Comment on attachment 8895593 [details] Bug 1370682 - Allow passing in LayoutDeviceSize to wr::ToBorderRadius for convenience. https://reviewboard.mozilla.org/r/166800/#review172330 Looks good to me.
Attachment #8895593 - Flags: review+
Comment on attachment 8895593 [details] Bug 1370682 - Allow passing in LayoutDeviceSize to wr::ToBorderRadius for convenience. https://reviewboard.mozilla.org/r/166800/#review172348
Attachment #8895593 - Flags: review?(mstange) → review+
Comment on attachment 8895594 [details] Bug 1370682 - Send DisplayItemClip's RoundedRect clips to WR. https://reviewboard.mozilla.org/r/166802/#review172350
Attachment #8895594 - Flags: review?(mstange) → review+
Pushed by kgupta@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e5936d7c91ba Allow passing in LayoutDeviceSize to wr::ToBorderRadius for convenience. r=jrmuizel,mstange https://hg.mozilla.org/integration/autoland/rev/972371dc461b Send DisplayItemClip's RoundedRect clips to WR. r=mstange
I really need to change my local mozconfig to build with -Werror...
Flags: needinfo?(bugmail)
Pushed by kgupta@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d403daf53fea Allow passing in LayoutDeviceSize to wr::ToBorderRadius for convenience. r=jrmuizel,mstange https://hg.mozilla.org/integration/autoland/rev/7543262c4791 Send DisplayItemClip's RoundedRect clips to WR. r=mstange
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: