From 5be887f10bb755deb2e8b5605bd18227fb838560 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 3 Feb 2026 11:21:01 +0100 Subject: [PATCH] :tada: Improve plain shape calculation --- render-wasm/src/render.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/render-wasm/src/render.rs b/render-wasm/src/render.rs index 9b783e76b8..b1968e7e99 100644 --- a/render-wasm/src/render.rs +++ b/render-wasm/src/render.rs @@ -22,7 +22,7 @@ pub use surfaces::{SurfaceId, Surfaces}; use crate::performance; use crate::shapes::{ - all_with_ancestors, Blur, BlurType, Corners, Fill, Shadow, Shape, SolidColor, Stroke, Type, + all_with_ancestors, Blur, BlurType, Corners, Fill, Shadow, Shape, SolidColor, Type, }; use crate::state::{ShapesPoolMutRef, ShapesPoolRef}; use crate::tiles::{self, PendingTiles, TileRect}; @@ -1536,28 +1536,20 @@ impl RenderState { let world_offset = (mapped.x, mapped.y); // The opacity of fills and strokes shouldn't affect the shadow, - // so we paint everything black with the same opacity - plain_shape.to_mut().clear_fills(); + // so we paint everything black with the same opacity. + let plain_shape_mut = plain_shape.to_mut(); + plain_shape_mut.clear_fills(); if shape.has_fills() { - plain_shape - .to_mut() - .add_fill(Fill::Solid(SolidColor(skia::Color::BLACK))); + plain_shape_mut.add_fill(Fill::Solid(SolidColor(skia::Color::BLACK))); } - plain_shape.to_mut().clear_strokes(); - for stroke in shape.strokes.iter() { - plain_shape.to_mut().add_stroke(Stroke { - fill: Fill::Solid(SolidColor(skia::Color::BLACK)), - width: stroke.width, - style: stroke.style, - cap_end: stroke.cap_end, - cap_start: stroke.cap_start, - kind: stroke.kind, - }); + // Reuse existing strokes and only override their fill color. + for stroke in plain_shape_mut.strokes.iter_mut() { + stroke.fill = Fill::Solid(SolidColor(skia::Color::BLACK)); } - plain_shape.to_mut().clear_shadows(); - plain_shape.to_mut().blur = None; + plain_shape_mut.clear_shadows(); + plain_shape_mut.blur = None; let Some(drop_filter) = transformed_shadow.get_drop_shadow_filter() else { return;