render: Avoid assert from lyon with small miter limits

This commit is contained in:
Mike Welsh 2020-11-20 00:01:43 -08:00
parent 5d542680ae
commit ad4714f3b3
2 changed files with 28 additions and 16 deletions

View File

@ -254,11 +254,6 @@ impl ShapeTessellator {
let mut options = StrokeOptions::default() let mut options = StrokeOptions::default()
.with_line_width(width) .with_line_width(width)
.with_line_join(match style.join_style {
swf::LineJoinStyle::Round => tessellation::LineJoin::Round,
swf::LineJoinStyle::Bevel => tessellation::LineJoin::Bevel,
swf::LineJoinStyle::Miter(_) => tessellation::LineJoin::MiterClip,
})
.with_start_cap(match style.start_cap { .with_start_cap(match style.start_cap {
swf::LineCapStyle::None => tessellation::LineCap::Butt, swf::LineCapStyle::None => tessellation::LineCap::Butt,
swf::LineCapStyle::Round => tessellation::LineCap::Round, swf::LineCapStyle::Round => tessellation::LineCap::Round,
@ -270,9 +265,20 @@ impl ShapeTessellator {
swf::LineCapStyle::Square => tessellation::LineCap::Square, swf::LineCapStyle::Square => tessellation::LineCap::Square,
}); });
if let swf::LineJoinStyle::Miter(limit) = style.join_style { let line_join = match style.join_style {
options = options.with_miter_limit(limit); swf::LineJoinStyle::Round => tessellation::LineJoin::Round,
} swf::LineJoinStyle::Bevel => tessellation::LineJoin::Bevel,
swf::LineJoinStyle::Miter(limit) => {
// Avoid lyon assert with small miter limits.
if limit >= StrokeOptions::MINIMUM_MITER_LIMIT {
options = options.with_miter_limit(limit);
tessellation::LineJoin::MiterClip
} else {
tessellation::LineJoin::Bevel
}
}
};
options = options.with_line_join(line_join);
if let Err(e) = self.stroke_tess.tessellate_path( if let Err(e) = self.stroke_tess.tessellate_path(
&ruffle_path_to_lyon_path(commands, is_closed), &ruffle_path_to_lyon_path(commands, is_closed),

View File

@ -590,11 +590,6 @@ impl<T: RenderTarget> WgpuRenderBackend<T> {
let mut options = StrokeOptions::default() let mut options = StrokeOptions::default()
.with_line_width(width) .with_line_width(width)
.with_line_join(match style.join_style {
swf::LineJoinStyle::Round => tessellation::LineJoin::Round,
swf::LineJoinStyle::Bevel => tessellation::LineJoin::Bevel,
swf::LineJoinStyle::Miter(_) => tessellation::LineJoin::MiterClip,
})
.with_start_cap(match style.start_cap { .with_start_cap(match style.start_cap {
swf::LineCapStyle::None => tessellation::LineCap::Butt, swf::LineCapStyle::None => tessellation::LineCap::Butt,
swf::LineCapStyle::Round => tessellation::LineCap::Round, swf::LineCapStyle::Round => tessellation::LineCap::Round,
@ -606,9 +601,20 @@ impl<T: RenderTarget> WgpuRenderBackend<T> {
swf::LineCapStyle::Square => tessellation::LineCap::Square, swf::LineCapStyle::Square => tessellation::LineCap::Square,
}); });
if let swf::LineJoinStyle::Miter(limit) = style.join_style { let line_join = match style.join_style {
options = options.with_miter_limit(limit); swf::LineJoinStyle::Round => tessellation::LineJoin::Round,
} swf::LineJoinStyle::Bevel => tessellation::LineJoin::Bevel,
swf::LineJoinStyle::Miter(limit) => {
// Avoid lyon assert with small miter limits.
if limit >= StrokeOptions::MINIMUM_MITER_LIMIT {
options = options.with_miter_limit(limit);
tessellation::LineJoin::MiterClip
} else {
tessellation::LineJoin::Bevel
}
}
};
options = options.with_line_join(line_join);
if let Err(e) = stroke_tess.tessellate_path( if let Err(e) = stroke_tess.tessellate_path(
&ruffle_path_to_lyon_path(commands, is_closed), &ruffle_path_to_lyon_path(commands, is_closed),