diff --git a/render-wasm/src/render.rs b/render-wasm/src/render.rs index ae25a366b4..040df0e6e7 100644 --- a/render-wasm/src/render.rs +++ b/render-wasm/src/render.rs @@ -464,13 +464,13 @@ impl RenderState { let text_content = text_content.new_bounds(shape.selrect()); let mut paragraphs = text_content.get_skia_paragraphs(); - if !shape.has_strokes() { + if !shape.has_visible_strokes() { shadows::render_text_drop_shadows(self, &shape, &mut paragraphs, antialias); } text::render(self, &shape, &mut paragraphs, None, None); - if shape.has_inner_strokes() { + if shape.has_visible_inner_strokes() { // Inner strokes paints need the text fill to apply correctly their blend modes // (e.g., SrcATop, DstOver) text::render( @@ -482,7 +482,7 @@ impl RenderState { ); } - for stroke in shape.strokes().rev() { + for stroke in shape.visible_strokes().rev() { let mut stroke_paragraphs = text_content.get_skia_stroke_paragraphs(stroke, &shape.selrect()); shadows::render_text_drop_shadows( @@ -541,7 +541,7 @@ impl RenderState { } } - for stroke in shape.strokes().rev() { + for stroke in shape.visible_strokes().rev() { shadows::render_stroke_drop_shadows(self, &shape, stroke, antialias); strokes::render(self, &shape, stroke, None, None, None, antialias, None); shadows::render_stroke_inner_shadows(self, &shape, stroke, antialias); diff --git a/render-wasm/src/render/text.rs b/render-wasm/src/render/text.rs index db01676ad3..2df1bf137d 100644 --- a/render-wasm/src/render/text.rs +++ b/render-wasm/src/render/text.rs @@ -232,7 +232,7 @@ pub fn render_as_path( // shadows::render_text_drop_shadows(self, &shape, &paths, antialias); // text::render(self, &paths, None, None); -// for stroke in shape.strokes().rev() { +// for stroke in shape.visible_strokes().rev() { // shadows::render_text_path_stroke_drop_shadows( // self, &shape, &paths, stroke, antialias, // ); diff --git a/render-wasm/src/shapes.rs b/render-wasm/src/shapes.rs index cbd78d1c13..fcbf353214 100644 --- a/render-wasm/src/shapes.rs +++ b/render-wasm/src/shapes.rs @@ -48,6 +48,7 @@ use crate::state::ShapesPool; const MIN_VISIBLE_SIZE: f32 = 2.0; const ANTIALIAS_THRESHOLD: f32 = 15.0; +const MIN_STROKE_WIDTH: f32 = 0.001; #[derive(Debug, Clone, PartialEq)] pub enum Type { @@ -550,8 +551,10 @@ impl Shape { self.fills.clear(); } - pub fn strokes(&self) -> std::slice::Iter { - self.strokes.iter() + pub fn visible_strokes(&self) -> impl DoubleEndedIterator { + self.strokes + .iter() + .filter(|stroke| stroke.width > MIN_STROKE_WIDTH) } pub fn add_stroke(&mut self, s: Stroke) { @@ -973,14 +976,13 @@ impl Shape { !self.fills.is_empty() } - pub fn has_strokes(&self) -> bool { - !self.strokes.is_empty() + pub fn has_visible_strokes(&self) -> bool { + self.visible_strokes().next().is_some() } - pub fn has_inner_strokes(&self) -> bool { - self.strokes.iter().any(|s| s.kind == StrokeKind::Inner) + pub fn has_visible_inner_strokes(&self) -> bool { + self.visible_strokes().any(|s| s.kind == StrokeKind::Inner) } - /* Returns the list of children taking into account the structure modifiers */