diff --git a/host-wasm/src/raster.rs b/host-wasm/src/raster.rs index e79e811..7503f25 100644 --- a/host-wasm/src/raster.rs +++ b/host-wasm/src/raster.rs @@ -552,11 +552,20 @@ impl Raster { /// panel, then client popups. The same layering as the software renderer's `render_scene`. pub fn submit(&mut self, f: &wt::Frame, fonts: &mut Fonts) { let (w, h) = (f.width.max(1), f.height.max(1)); - if w != self.w || h != self.h || self.fb.len() != (w * h * 4) as usize { + let resized = w != self.w || h != self.h || self.fb.len() != (w * h * 4) as usize; + if resized { self.w = w; self.h = h; self.fb = vec![0u8; (w * h * 4) as usize]; - } else { + } + // The frame starts from the cached backdrop (which covers every pixel), so the buffer is + // only cleared when there is none: no point zeroing 8 MB that is overwritten at once. + let backdrop_ready = match (&f.wallpaper, &self.wallpaper) { + (None, Some((_, cw, ch, _))) => *cw == w && *ch == h, + (Some(ops), Some((o, cw, ch, _))) => *cw == w && *ch == h && o == ops, + _ => false, + }; + if !resized && !backdrop_ready { self.fb.fill(0); } let surfaces = &self.surfaces;