tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 0f038fc60815e52a0f45832777bee98027e708b9
parent a27819dbf46ad5b682c767aaeeed7a3c5d6e5ffe
Author: Sotaro Ikeda <sotaro.ikeda.g@gmail.com>
Date:   Thu, 11 Dec 2025 02:50:35 +0000

Bug 2002563 - Add overlay's rounded clip rects handling to WebRender layer compositor r=gfx-reviewers,gw

DCLayerTree already has the rounded corner handling for native compositor.

Differential Revision: https://phabricator.services.mozilla.com/D275413

Diffstat:
Mgfx/webrender_bindings/src/bindings.rs | 6++++--
Mgfx/wr/webrender/src/composite.rs | 5+++++
Mgfx/wr/webrender/src/renderer/mod.rs | 36++++++++++++++++++++++++++++++++++--
3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs @@ -1784,6 +1784,8 @@ impl LayerCompositor for WrLayerCompositor { transform: CompositorSurfaceTransform, clip_rect: DeviceIntRect, image_rendering: ImageRendering, + rounded_clip_rect: DeviceIntRect, + rounded_clip_radii: ClipRadius, ) { let layer = &self.visual_tree[index]; @@ -1794,8 +1796,8 @@ impl LayerCompositor for WrLayerCompositor { &transform, clip_rect, image_rendering, - clip_rect, - ClipRadius::EMPTY, + rounded_clip_rect, + rounded_clip_radii, ); } } diff --git a/gfx/wr/webrender/src/composite.rs b/gfx/wr/webrender/src/composite.rs @@ -613,6 +613,7 @@ pub struct CompositorTransform { #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] +#[derive(Debug)] pub struct CompositorClip { pub rect: DeviceRect, pub radius: BorderRadius, @@ -1609,6 +1610,8 @@ pub struct CompositorInputLayer { pub usage: CompositorSurfaceUsage, // If true, layer is opaque, blend can be disabled pub is_opaque: bool, + pub rounded_clip_rect: DeviceIntRect, + pub rounded_clip_radii: ClipRadius, } // Provides the parameters about the frame to the compositor implementation. @@ -1650,6 +1653,8 @@ pub trait LayerCompositor { transform: CompositorSurfaceTransform, clip_rect: DeviceIntRect, image_rendering: ImageRendering, + rounded_clip_rect: DeviceIntRect, + rounded_clip_radii: ClipRadius, ); // Finish compositing this frame - commit the visual tree to the OS diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs @@ -3661,6 +3661,8 @@ impl Renderer { is_opaque: false, offset: DeviceIntPoint::zero(), clip_rect: device_size.into(), + rounded_clip_rect: device_size.into(), + rounded_clip_radii: ClipRadius::EMPTY, }); swapchain_layers.push(SwapChainLayer { @@ -3798,12 +3800,14 @@ impl Renderer { }; if let Some(new_layer_kind) = new_layer_kind { - let (offset, clip_rect, is_opaque) = match usage { + let (offset, clip_rect, is_opaque, rounded_clip_rect, rounded_clip_radii) = match usage { CompositorSurfaceUsage::Content => { ( DeviceIntPoint::zero(), device_size.into(), false, // Assume not opaque, we'll calculate this later + device_size.into(), + ClipRadius::EMPTY, ) } CompositorSurfaceUsage::External { .. } => { @@ -3824,7 +3828,29 @@ impl Renderer { }); } - (rect.min.to_i32(), clip_rect, is_opaque) + let (rounded_clip_rect, rounded_clip_radii) = match tile.clip_index { + Some(clip_index) => { + let clip = composite_state.get_compositor_clip(clip_index); + let radius = ClipRadius { + top_left: clip.radius.top_left.width.round() as i32, + top_right: clip.radius.top_right.width.round() as i32, + bottom_left: clip.radius.bottom_left.width.round() as i32, + bottom_right: clip.radius.bottom_right.width.round() as i32, + }; + (clip.rect.to_i32(), radius) + } + None => { + (clip_rect, ClipRadius::EMPTY) + } + }; + + ( + rect.min.to_i32(), + clip_rect, + is_opaque, + rounded_clip_rect, + rounded_clip_radii, + ) } CompositorSurfaceUsage::DebugOverlay => unreachable!(), }; @@ -3834,6 +3860,8 @@ impl Renderer { is_opaque, offset, clip_rect, + rounded_clip_rect, + rounded_clip_radii, }); swapchain_layers.push(SwapChainLayer { @@ -3901,6 +3929,8 @@ impl Renderer { is_opaque: true, offset: DeviceIntPoint::zero(), clip_rect: device_size.into(), + rounded_clip_rect: device_size.into(), + rounded_clip_radii: ClipRadius::EMPTY, }); swapchain_layers.push(SwapChainLayer { @@ -4216,6 +4246,8 @@ impl Renderer { transform, layer.clip_rect, ImageRendering::Auto, + layer.rounded_clip_rect, + layer.rounded_clip_radii, ); } }