From c3c9d1ce6b7fe67e87c6b6f3045763977adcb1d1 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 9 Apr 2021 01:53:34 +0000 Subject: [PATCH] Bug 1694721 - Don't do a debug render if there is no debug overlay. r=gw When toggling debug state, we can sometimes queue debug renders, without any debug overlay to send them to. This patch ensures we don't actually draw anything in the debug renderer when there is no debug overlay. Differential Revision: https://phabricator.services.mozilla.com/D111355 --- gfx/wr/webrender/src/renderer/mod.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs index a53511c39a64..7e7afbe7cb55 100644 --- a/gfx/wr/webrender/src/renderer/mod.rs +++ b/gfx/wr/webrender/src/renderer/mod.rs @@ -2185,16 +2185,17 @@ impl Renderer { let _gm = self.gpu_profiler.start_marker("end frame"); self.gpu_profiler.end_frame(); - if let Some(device_size) = device_size { + let debug_overlay = device_size.and_then(|device_size| { // Bind a surface to draw the debug / profiler information to. - if let Some(draw_target) = self.bind_debug_overlay(device_size) { + self.bind_debug_overlay(device_size).map(|draw_target| { self.draw_render_target_debug(&draw_target); self.draw_texture_cache_debug(&draw_target); self.draw_gpu_cache_debug(device_size); self.draw_zoom_debug(device_size); self.draw_epoch_debug(); - } - } + draw_target + }) + }); self.profile.end_time(profiler::RENDERER_TIME); self.profile.end_time_if_started(profiler::TOTAL_FRAME_CPU_TIME); @@ -2270,9 +2271,11 @@ impl Renderer { CompositorKind::Native { .. } => true, CompositorKind::Draw { .. } => self.device.surface_origin_is_top_left(), }; + // If there is a debug overlay, render it. Otherwise, just clear + // the debug renderer. debug_renderer.render( &mut self.device, - device_size, + debug_overlay.and(device_size), scale, surface_origin_is_top_left, ); @@ -2282,7 +2285,7 @@ impl Renderer { self.texture_upload_pbo_pool.end_frame(&mut self.device); self.device.end_frame(); - if device_size.is_some() { + if debug_overlay.is_some() { self.last_time = current_time; // Unbind the target for the debug overlay. No debug or profiler drawing