🐛 Fix visible 0 width strokes in wasm render

This commit is contained in:
Alejandro Alonso 2025-07-28 08:31:38 +02:00
parent b93e96a18d
commit e473f45048
3 changed files with 14 additions and 12 deletions

View file

@ -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);

View file

@ -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,
// );

View file

@ -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<Stroke> {
self.strokes.iter()
pub fn visible_strokes(&self) -> impl DoubleEndedIterator<Item = &Stroke> {
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
*/