diff --git a/shader/fine.wgsl b/shader/fine.wgsl index 4cb5a8e..5e7a772 100644 --- a/shader/fine.wgsl +++ b/shader/fine.wgsl @@ -251,7 +251,7 @@ fn main( for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) { let my_xy = vec2(xy.x + f32(i), xy.y); // TODO: can hoist y, but for now stick to the GLSL version - let xy_xformed = rad.matrx.xz * my_xy.x + rad.matrx.yw * my_xy.y - rad.xlat; + let xy_xformed = rad.matrx.xy * my_xy.x + rad.matrx.zw * my_xy.y - rad.xlat; let ba = dot(xy_xformed, rad.c1); let ca = rad.ra * dot(xy_xformed, xy_xformed); let t = sqrt(ba * ba + ca) - ba - rad.roff; diff --git a/src/encoding/encoding.rs b/src/encoding/encoding.rs index 4d866c2..588015c 100644 --- a/src/encoding/encoding.rs +++ b/src/encoding/encoding.rs @@ -120,10 +120,16 @@ impl Encoding { } /// Encodes a transform. - pub fn encode_transform(&mut self, transform: Transform) { + /// + /// If the given transform is different from the current one, encodes it an + /// returns true. Otherwise, encodes nothing and returns false. + pub fn encode_transform(&mut self, transform: Transform) -> bool { if self.transforms.last() != Some(&transform) { self.path_tags.push(PathTag::TRANSFORM); self.transforms.push(transform); + true + } else { + false } } diff --git a/src/scene.rs b/src/scene.rs index 3fb7a96..98d491a 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -140,13 +140,14 @@ impl<'a> SceneBuilder<'a> { }); if self.scene.encode_shape(shape, true) { if let Some(brush_transform) = brush_transform { - self.scene - .encode_transform(Transform::from_kurbo(&(transform * brush_transform))); - self.scene.swap_last_path_tags(); - self.scene.encode_brush(brush, 1.0); - } else { - self.scene.encode_brush(brush, 1.0); + if self + .scene + .encode_transform(Transform::from_kurbo(&(transform * brush_transform))) + { + self.scene.swap_last_path_tags(); + } } + self.scene.encode_brush(brush, 1.0); } } @@ -164,13 +165,14 @@ impl<'a> SceneBuilder<'a> { self.scene.encode_linewidth(style.width); if self.scene.encode_shape(shape, false) { if let Some(brush_transform) = brush_transform { - self.scene - .encode_transform(Transform::from_kurbo(&(transform * brush_transform))); - self.scene.swap_last_path_tags(); - self.scene.encode_brush(brush, 1.0); - } else { - self.scene.encode_brush(brush, 1.0); + if self + .scene + .encode_transform(Transform::from_kurbo(&(transform * brush_transform))) + { + self.scene.swap_last_path_tags(); + } } + self.scene.encode_brush(brush, 1.0); } }