tor-browser

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

commit eb6fbdae0d4877e73c2de883f807cb1097bef74a
parent 81cb4a7dcca1a50801019b0c112bea54a708cac7
Author: Sotaro Ikeda <sotaro.ikeda.g@gmail.com>
Date:   Wed, 22 Oct 2025 00:17:57 +0000

Bug 1995445 - Add capability to show external composite rects in debug overlay for layer compositor r=gfx-reviewers,lsalzman

It helps to know if external composite is used.

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

Diffstat:
Mgfx/thebes/gfxPlatform.cpp | 2++
Mgfx/wr/webrender/src/renderer/init.rs | 1+
Mgfx/wr/webrender/src/renderer/mod.rs | 44+++++++++++++++++++++++++++++++++++++++++++-
Mgfx/wr/webrender_api/src/lib.rs | 3+++
Mmodules/libpref/init/all.js | 1+
5 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp @@ -569,6 +569,8 @@ static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) { wr::DebugFlags::MISSING_SNAPSHOT_PINK) GFX_WEBRENDER_DEBUG(".highlight-backdrop-filters", wr::DebugFlags::HIGHLIGHT_BACKDROP_FILTERS) + GFX_WEBRENDER_DEBUG(".external-composite-borders", + wr::DebugFlags::EXTERNAL_COMPOSITE_BORDERS) #undef GFX_WEBRENDER_DEBUG gfx::gfxVars::SetWebRenderDebugFlags(flags._0); diff --git a/gfx/wr/webrender/src/renderer/init.rs b/gfx/wr/webrender/src/renderer/init.rs @@ -840,6 +840,7 @@ pub fn create_webrender_instance( target_frame_publish_id: None, pending_result_msg: None, layer_compositor_frame_state_in_prev_frame: None, + external_composite_debug_items: Vec::new(), #[cfg(feature = "debugger")] debugger: Debugger::new(), }; diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs @@ -957,6 +957,9 @@ pub struct Renderer { /// Hold previous frame compositing state with layer compositor. layer_compositor_frame_state_in_prev_frame: Option<LayerCompositorFrameState>, + + /// Hold DebugItems of DebugFlags::EXTERNAL_COMPOSITE_BORDERS for debug overlay + external_composite_debug_items: Vec<DebugItem>, } #[derive(Debug)] @@ -1443,6 +1446,8 @@ impl Renderer { // event. Otherwise they would just pile up in this vector forever. self.notifications.clear(); + self.external_composite_debug_items = Vec::new(); + tracy_frame_marker!(); result @@ -1465,7 +1470,8 @@ impl Renderer { DebugFlags::PICTURE_CACHING_DBG | DebugFlags::PICTURE_BORDERS | DebugFlags::ZOOM_DBG | - DebugFlags::WINDOW_VISIBILITY_DBG + DebugFlags::WINDOW_VISIBILITY_DBG | + DebugFlags::EXTERNAL_COMPOSITE_BORDERS ); // Update the debug overlay surface, if we are running in native compositor mode. @@ -1758,6 +1764,7 @@ impl Renderer { self.draw_zoom_debug(device_size); self.draw_epoch_debug(); self.draw_window_visibility_debug(); + self.draw_external_composite_borders_debug(); draw_target }) }); @@ -3849,6 +3856,15 @@ impl Renderer { let clip_rect = tile.device_clip_rect.to_i32(); let is_opaque = tile.kind != TileKind::Alpha; + if self.debug_flags.contains(DebugFlags::EXTERNAL_COMPOSITE_BORDERS) { + self.external_composite_debug_items.push(DebugItem::Rect { + outer_color: debug_colors::ORANGERED, + inner_color: ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 }, + rect: tile.device_clip_rect, + thickness: 10, + }); + } + (rect.min.to_i32(), clip_rect, is_opaque) } CompositorSurfaceUsage::DebugOverlay => unreachable!(), @@ -5949,6 +5965,32 @@ impl Renderer { } + fn draw_external_composite_borders_debug(&mut self) { + if !self.debug_flags.contains(DebugFlags::EXTERNAL_COMPOSITE_BORDERS) { + return; + } + + let debug_renderer = match self.debug.get_mut(&mut self.device) { + Some(render) => render, + None => return, + }; + + for item in &self.external_composite_debug_items { + match item { + DebugItem::Rect { rect, outer_color, inner_color: _, thickness } => { + if outer_color.a > 0.001 { + debug_renderer.add_rect( + &rect.to_i32(), + *thickness, + (*outer_color).into(), + ); + } + } + DebugItem::Text { .. } => {} + } + } + } + fn draw_gpu_cache_debug(&mut self, device_size: DeviceIntSize) { if !self.debug_flags.contains(DebugFlags::GPU_CACHE_DBG) { return; diff --git a/gfx/wr/webrender_api/src/lib.rs b/gfx/wr/webrender_api/src/lib.rs @@ -759,6 +759,9 @@ bitflags! { const MISSING_SNAPSHOT_PINK = (1 as u64) << 32; /// Highlight backdrop filters const HIGHLIGHT_BACKDROP_FILTERS = (1 as u64) << 33; + /// Show external composite border rects in debug overlay. + /// TODO: Add native compositor support + const EXTERNAL_COMPOSITE_BORDERS = (1 as u64) << 34; } } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js @@ -438,6 +438,7 @@ pref("gfx.webrender.debug.glyph-flashing", false); pref("gfx.webrender.debug.capture-profiler", false); pref("gfx.webrender.debug.profiler-ui", "Default"); pref("gfx.webrender.debug.window-visibility", false); +pref("gfx.webrender.debug.external-composite-borders", false); pref("gfx.webrender.multithreading", true); #ifdef XP_WIN