Implement solid color cmd

Avoids empty fill segment list, which was a minor bug.

Also increase tolerance to 0.25 to juice performance.
This commit is contained in:
Raph Levien 2020-05-02 09:50:36 -07:00
parent aa83d782ed
commit dcdd35e0b8
6 changed files with 13 additions and 2 deletions

Binary file not shown.

View file

@ -110,7 +110,7 @@ void main() {
FillItemHeader fill_item = FillItemHeader_read(fill_th.items);
fill_th.items.offset += FillItemHeader_size;
// TODO: handle segments == 0 but backdrop != specially, it's a solid tile.
if (fill_item.segments.offset != 0 || fill_item.backdrop != 0) {
if (fill_item.segments.offset != 0) {
PietFill fill = PietItem_Fill_read(item_ref);
CmdFill cmd = CmdFill(
fill_item.segments.offset,
@ -120,6 +120,12 @@ void main() {
alloc_cmd(cmd_ref, cmd_limit);
Cmd_Fill_write(cmd_ref, cmd);
cmd_ref.offset += Cmd_size;
} else if (fill_item.backdrop != 0) {
// TODO: truncate existing cmd list if alpha is opaque
PietFill fill = PietItem_Fill_read(item_ref);
alloc_cmd(cmd_ref, cmd_limit);
Cmd_Solid_write(cmd_ref, CmdSolid(fill.rgba_color));
cmd_ref.offset += Cmd_size;
}
break;
}

Binary file not shown.

View file

@ -106,6 +106,11 @@ void main() {
alpha = min(abs(area), 1.0);
rgb = mix(rgb, fg_rgba.rgb, alpha * fg_rgba.a);
break;
case Cmd_Solid:
CmdSolid solid = Cmd_Solid_read(cmd_ref);
fg_rgba = unpackUnorm4x8(solid.rgba_color).wzyx;
rgb = mix(rgb, fg_rgba.rgb, fg_rgba.a);
break;
case Cmd_Jump:
cmd_ref = CmdRef(Cmd_Jump_read(cmd_ref).new_ref);
continue;

Binary file not shown.

View file

@ -39,7 +39,7 @@ pub enum PietGpuBrush {
Gradient,
}
const TOLERANCE: f64 = 0.1;
const TOLERANCE: f64 = 0.25;
impl PietGpuRenderContext {
pub fn new() -> PietGpuRenderContext {