Account path tags correctly

This commit is contained in:
Raph Levien 2021-12-06 15:59:32 -08:00
parent 55395fa533
commit 5585b3563c
3 changed files with 13 additions and 1 deletions

View file

@ -200,6 +200,11 @@ impl Encoder {
self.transform_stream.len() 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) { pub(crate) fn encode_glyph(&mut self, glyph: &GlyphEncoder) {
self.tag_stream.extend(&glyph.tag_stream); self.tag_stream.extend(&glyph.tag_stream);
self.pathseg_stream.extend(&glyph.pathseg_stream); self.pathseg_stream.extend(&glyph.pathseg_stream);

View file

@ -96,6 +96,7 @@ pub struct Renderer {
n_drawobj: usize, n_drawobj: usize,
n_paths: usize, n_paths: usize,
n_pathseg: usize, n_pathseg: usize,
n_pathtag: usize,
// Keep a reference to the image so that it is not destroyed. // Keep a reference to the image so that it is not destroyed.
_bg_image: Image, _bg_image: Image,
@ -256,6 +257,7 @@ impl Renderer {
n_drawobj: 0, n_drawobj: 0,
n_paths: 0, n_paths: 0,
n_pathseg: 0, n_pathseg: 0,
n_pathtag: 0,
_bg_image: bg_image, _bg_image: bg_image,
gradient_bufs, gradient_bufs,
gradients, gradients,
@ -280,6 +282,7 @@ impl Renderer {
self.n_transform = render_ctx.n_transform(); self.n_transform = render_ctx.n_transform();
self.n_drawobj = render_ctx.n_drawobj(); self.n_drawobj = render_ctx.n_drawobj();
self.n_pathseg = render_ctx.n_pathseg() as usize; 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. // These constants depend on encoding and may need to be updated.
// Perhaps we can plumb these from piet-gpu-derive? // Perhaps we can plumb these from piet-gpu-derive?
@ -345,7 +348,7 @@ impl Renderer {
&self.element_bindings[buf_ix], &self.element_bindings[buf_ix],
self.n_transform as u64, self.n_transform as u64,
self.n_paths as u32, self.n_paths as u32,
self.n_pathseg as u32, self.n_pathtag as u32,
self.n_drawobj as u64, self.n_drawobj as u64,
); );
cmd_buf.write_timestamp(&query_pool, 1); cmd_buf.write_timestamp(&query_pool, 1);

View file

@ -125,6 +125,10 @@ impl PietGpuRenderContext {
self.new_encoder.n_pathseg() self.new_encoder.n_pathseg()
} }
pub fn n_pathtag(&self) -> usize {
self.new_encoder.n_pathtag()
}
pub fn n_transform(&self) -> usize { pub fn n_transform(&self) -> usize {
self.new_encoder.n_transform() self.new_encoder.n_transform()
} }