mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
prevent bad encoding with only move-tos
This commit is contained in:
parent
373b027780
commit
a9170c4330
|
@ -13,6 +13,10 @@ pub fn render_funky_paths(sb: &mut SceneBuilder) {
|
||||||
LineTo((0.0, 400.0).into()),
|
LineTo((0.0, 400.0).into()),
|
||||||
LineTo((100.0, 400.0).into()),
|
LineTo((100.0, 400.0).into()),
|
||||||
];
|
];
|
||||||
|
let only_movetos = [
|
||||||
|
PathElement::MoveTo((0.0, 0.0).into()),
|
||||||
|
PathElement::MoveTo((100.0, 100.0).into()),
|
||||||
|
];
|
||||||
let empty: [PathElement; 0] = [];
|
let empty: [PathElement; 0] = [];
|
||||||
sb.fill(
|
sb.fill(
|
||||||
Fill::NonZero,
|
Fill::NonZero,
|
||||||
|
@ -28,6 +32,13 @@ pub fn render_funky_paths(sb: &mut SceneBuilder) {
|
||||||
None,
|
None,
|
||||||
empty,
|
empty,
|
||||||
);
|
);
|
||||||
|
sb.fill(
|
||||||
|
Fill::NonZero,
|
||||||
|
Affine::IDENTITY,
|
||||||
|
&Color::rgb8(0, 0, 255).into(),
|
||||||
|
None,
|
||||||
|
only_movetos,
|
||||||
|
);
|
||||||
sb.stroke(
|
sb.stroke(
|
||||||
&simple_stroke(8.0),
|
&simple_stroke(8.0),
|
||||||
Affine::translate(100.0, 100.0),
|
Affine::translate(100.0, 100.0),
|
||||||
|
|
|
@ -160,8 +160,8 @@ impl<'a> SceneBuilder<'a> {
|
||||||
PathElement::Close => b.close_path(),
|
PathElement::Close => b.close_path(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
b.finish();
|
||||||
if b.n_pathseg != 0 {
|
if b.n_pathseg != 0 {
|
||||||
b.path();
|
|
||||||
self.scene.n_path += 1;
|
self.scene.n_path += 1;
|
||||||
self.scene.n_pathseg += b.n_pathseg;
|
self.scene.n_pathseg += b.n_pathseg;
|
||||||
true
|
true
|
||||||
|
@ -434,7 +434,7 @@ impl<'a> PathBuilder<'a> {
|
||||||
self.state = PathState::Start;
|
self.state = PathState::Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&mut self) {
|
pub fn finish(&mut self) {
|
||||||
if self.is_fill {
|
if self.is_fill {
|
||||||
self.close_path();
|
self.close_path();
|
||||||
}
|
}
|
||||||
|
@ -442,17 +442,11 @@ impl<'a> PathBuilder<'a> {
|
||||||
let new_len = self.pathseg_stream.len() - 8;
|
let new_len = self.pathseg_stream.len() - 8;
|
||||||
self.pathseg_stream.truncate(new_len);
|
self.pathseg_stream.truncate(new_len);
|
||||||
}
|
}
|
||||||
if let Some(tag) = self.tag_stream.last_mut() {
|
if self.n_pathseg != 0 {
|
||||||
*tag |= 4;
|
if let Some(tag) = self.tag_stream.last_mut() {
|
||||||
|
*tag |= 4;
|
||||||
|
}
|
||||||
|
self.tag_stream.push(0x10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finish encoding a path.
|
|
||||||
///
|
|
||||||
/// Encode this after encoding path segments.
|
|
||||||
pub fn path(&mut self) {
|
|
||||||
self.finish();
|
|
||||||
// maybe don't encode if path is empty? might throw off sync though
|
|
||||||
self.tag_stream.push(0x10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue