From 5585b3563c3aa2d56ae784205f3321c84d31b314 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 6 Dec 2021 15:59:32 -0800 Subject: [PATCH] Account path tags correctly --- piet-gpu/src/encoder.rs | 5 +++++ piet-gpu/src/lib.rs | 5 ++++- piet-gpu/src/render_ctx.rs | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/piet-gpu/src/encoder.rs b/piet-gpu/src/encoder.rs index 0314003..338c01c 100644 --- a/piet-gpu/src/encoder.rs +++ b/piet-gpu/src/encoder.rs @@ -200,6 +200,11 @@ impl Encoder { self.transform_stream.len() } + /// The number of tags in the path stream. + pub(crate) fn n_pathtag(&self) -> usize { + self.tag_stream.len() + } + pub(crate) fn encode_glyph(&mut self, glyph: &GlyphEncoder) { self.tag_stream.extend(&glyph.tag_stream); self.pathseg_stream.extend(&glyph.pathseg_stream); diff --git a/piet-gpu/src/lib.rs b/piet-gpu/src/lib.rs index ad13c24..f045d65 100644 --- a/piet-gpu/src/lib.rs +++ b/piet-gpu/src/lib.rs @@ -96,6 +96,7 @@ pub struct Renderer { n_drawobj: usize, n_paths: usize, n_pathseg: usize, + n_pathtag: usize, // Keep a reference to the image so that it is not destroyed. _bg_image: Image, @@ -256,6 +257,7 @@ impl Renderer { n_drawobj: 0, n_paths: 0, n_pathseg: 0, + n_pathtag: 0, _bg_image: bg_image, gradient_bufs, gradients, @@ -280,6 +282,7 @@ impl Renderer { self.n_transform = render_ctx.n_transform(); self.n_drawobj = render_ctx.n_drawobj(); self.n_pathseg = render_ctx.n_pathseg() as usize; + self.n_pathtag = render_ctx.n_pathtag(); // These constants depend on encoding and may need to be updated. // Perhaps we can plumb these from piet-gpu-derive? @@ -345,7 +348,7 @@ impl Renderer { &self.element_bindings[buf_ix], self.n_transform as u64, self.n_paths as u32, - self.n_pathseg as u32, + self.n_pathtag as u32, self.n_drawobj as u64, ); cmd_buf.write_timestamp(&query_pool, 1); diff --git a/piet-gpu/src/render_ctx.rs b/piet-gpu/src/render_ctx.rs index d13a888..2c5ee73 100644 --- a/piet-gpu/src/render_ctx.rs +++ b/piet-gpu/src/render_ctx.rs @@ -125,6 +125,10 @@ impl PietGpuRenderContext { self.new_encoder.n_pathseg() } + pub fn n_pathtag(&self) -> usize { + self.new_encoder.n_pathtag() + } + pub fn n_transform(&self) -> usize { self.new_encoder.n_transform() }