diff --git a/piet-scene/src/geometry.rs b/piet-scene/src/geometry.rs index 1ea8f33..2df7f83 100644 --- a/piet-scene/src/geometry.rs +++ b/piet-scene/src/geometry.rs @@ -61,7 +61,7 @@ impl From<(f32, f32)> for Point { } /// Affine transformation matrix. -#[derive(Copy, Clone, Debug, Pod, Zeroable)] +#[derive(Copy, Clone, PartialEq, Debug, Pod, Zeroable)] #[repr(C)] pub struct Affine { pub xx: f32, diff --git a/piet-scene/src/scene/builder.rs b/piet-scene/src/scene/builder.rs index a890239..5394f88 100644 --- a/piet-scene/src/scene/builder.rs +++ b/piet-scene/src/scene/builder.rs @@ -160,11 +160,13 @@ impl<'a> Builder<'a> { pub fn append(&mut self, fragment: &Fragment, transform: Option) { let drawdata_base = self.scene.drawdata_stream.len(); let mut cur_transform = self.scene.transform_stream.last().copied(); - if cur_transform.is_none() { - if let Some(transform) = transform { - self.encode_transform(transform); + if let Some(transform) = transform { + if cur_transform.is_none() { cur_transform = Some(Affine::IDENTITY); } + self.encode_transform(transform); + } else if cur_transform != Some(Affine::IDENTITY) { + self.encode_transform(Affine::IDENTITY); } self.scene.append(&fragment.data, &transform); match &mut self.resources {