mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-08 20:01:30 +11:00
move atlas rect to info
Atlas offset and image size were originally stored in the ptcl but are not tile dependent. Moving these to info saves 8 bytes per image tile.
This commit is contained in:
parent
165b3a083b
commit
a8585781cd
|
@ -126,13 +126,11 @@ fn write_grad(ty: u32, index: u32, info_offset: u32) {
|
|||
cmd_offset += 3u;
|
||||
}
|
||||
|
||||
fn write_image(xy: u32, width_height: u32, info_offset: u32) {
|
||||
alloc_cmd(4u);
|
||||
fn write_image(info_offset: u32) {
|
||||
alloc_cmd(2u);
|
||||
ptcl[cmd_offset] = CMD_IMAGE;
|
||||
ptcl[cmd_offset + 1u] = info_offset;
|
||||
ptcl[cmd_offset + 2u] = xy;
|
||||
ptcl[cmd_offset + 3u] = width_height;
|
||||
cmd_offset += 4u;
|
||||
cmd_offset += 2u;
|
||||
}
|
||||
|
||||
fn write_begin_clip() {
|
||||
|
@ -387,12 +385,10 @@ fn main(
|
|||
}
|
||||
}
|
||||
// DRAWTAG_FILL_IMAGE
|
||||
case 0x1c8u: {
|
||||
case 0x248u: {
|
||||
let linewidth = bitcast<f32>(info_bin_data[di]);
|
||||
if write_path(tile, linewidth) {
|
||||
let xy = scene[dd];
|
||||
let width_height = scene[dd + 1u];
|
||||
write_image(xy, width_height, di + 1u);
|
||||
write_image(di + 1u);
|
||||
}
|
||||
}
|
||||
// DRAWTAG_BEGIN_CLIP
|
||||
|
|
|
@ -125,7 +125,7 @@ fn main(
|
|||
linewidth *= sqrt(abs(matrx.x * matrx.w - matrx.y * matrx.z));
|
||||
}
|
||||
switch tag_word {
|
||||
// DRAWTAG_FILL_COLOR, DRAWTAG_FILL_IMAGE
|
||||
// DRAWTAG_FILL_COLOR
|
||||
case 0x44u: {
|
||||
info[di] = bitcast<u32>(linewidth);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ fn main(
|
|||
info[di + 10u] = bitcast<u32>(roff);
|
||||
}
|
||||
// DRAWTAG_FILL_IMAGE
|
||||
case 0x1c8u: {
|
||||
case 0x248u: {
|
||||
info[di] = bitcast<u32>(linewidth);
|
||||
let inv_det = 1.0 / (matrx.x * matrx.w - matrx.y * matrx.z);
|
||||
let inv_mat = inv_det * vec4(matrx.w, -matrx.y, -matrx.z, matrx.x);
|
||||
|
@ -183,6 +183,8 @@ fn main(
|
|||
info[di + 4u] = bitcast<u32>(inv_mat.w);
|
||||
info[di + 5u] = bitcast<u32>(inv_tr.x);
|
||||
info[di + 6u] = bitcast<u32>(inv_tr.y);
|
||||
info[di + 7u] = scene[dd];
|
||||
info[di + 8u] = scene[dd + 1u];
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
|
|
|
@ -86,14 +86,14 @@ fn read_rad_grad(cmd_ix: u32) -> CmdRadGrad {
|
|||
|
||||
fn read_image(cmd_ix: u32) -> CmdImage {
|
||||
let info_offset = ptcl[cmd_ix + 1u];
|
||||
let xy = ptcl[cmd_ix + 2u];
|
||||
let width_height = ptcl[cmd_ix + 3u];
|
||||
let m0 = bitcast<f32>(info[info_offset]);
|
||||
let m1 = bitcast<f32>(info[info_offset + 1u]);
|
||||
let m2 = bitcast<f32>(info[info_offset + 2u]);
|
||||
let m3 = bitcast<f32>(info[info_offset + 3u]);
|
||||
let matrx = vec4(m0, m1, m2, m3);
|
||||
let xlat = vec2(bitcast<f32>(info[info_offset + 4u]), bitcast<f32>(info[info_offset + 5u]));
|
||||
let xy = info[info_offset + 6u];
|
||||
let width_height = info[info_offset + 7u];
|
||||
// The following are not intended to be bitcasts
|
||||
let x = f32(xy >> 16u);
|
||||
let y = f32(xy & 0xffffu);
|
||||
|
@ -307,7 +307,7 @@ fn main(
|
|||
rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
|
||||
}
|
||||
}
|
||||
cmd_ix += 4u;
|
||||
cmd_ix += 2u;
|
||||
}
|
||||
// CMD_BEGIN_CLIP
|
||||
case 9u: {
|
||||
|
|
|
@ -19,7 +19,7 @@ let DRAWTAG_NOP = 0u;
|
|||
let DRAWTAG_FILL_COLOR = 0x44u;
|
||||
let DRAWTAG_FILL_LIN_GRADIENT = 0x114u;
|
||||
let DRAWTAG_FILL_RAD_GRADIENT = 0x2dcu;
|
||||
let DRAWTAG_FILL_IMAGE = 0x1c8u;
|
||||
let DRAWTAG_FILL_IMAGE = 0x248u;
|
||||
let DRAWTAG_BEGIN_CLIP = 0x9u;
|
||||
let DRAWTAG_END_CLIP = 0x21u;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl DrawTag {
|
|||
pub const RADIAL_GRADIENT: Self = Self(0x2dc);
|
||||
|
||||
/// Image fill.
|
||||
pub const IMAGE: Self = Self(0x1c8);
|
||||
pub const IMAGE: Self = Self(0x248);
|
||||
|
||||
/// Begin layer/clip.
|
||||
pub const BEGIN_CLIP: Self = Self(0x9);
|
||||
|
|
Loading…
Reference in a new issue