fix fragment transform logic

This commit is contained in:
Chad Brokaw 2022-08-05 14:00:30 -04:00
parent d7773bf877
commit 2e8be24fc9
2 changed files with 6 additions and 4 deletions

View file

@ -61,7 +61,7 @@ impl From<(f32, f32)> for Point {
} }
/// Affine transformation matrix. /// Affine transformation matrix.
#[derive(Copy, Clone, Debug, Pod, Zeroable)] #[derive(Copy, Clone, PartialEq, Debug, Pod, Zeroable)]
#[repr(C)] #[repr(C)]
pub struct Affine { pub struct Affine {
pub xx: f32, pub xx: f32,

View file

@ -160,11 +160,13 @@ impl<'a> Builder<'a> {
pub fn append(&mut self, fragment: &Fragment, transform: Option<Affine>) { pub fn append(&mut self, fragment: &Fragment, transform: Option<Affine>) {
let drawdata_base = self.scene.drawdata_stream.len(); let drawdata_base = self.scene.drawdata_stream.len();
let mut cur_transform = self.scene.transform_stream.last().copied(); let mut cur_transform = self.scene.transform_stream.last().copied();
if cur_transform.is_none() { if let Some(transform) = transform {
if let Some(transform) = transform { if cur_transform.is_none() {
self.encode_transform(transform);
cur_transform = Some(Affine::IDENTITY); 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); self.scene.append(&fragment.data, &transform);
match &mut self.resources { match &mut self.resources {