mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
Merge branch 'master' into image_work
This commit is contained in:
commit
97dcb5122e
|
@ -9,10 +9,6 @@ piet_gpu! {
|
||||||
bbox: [f32; 4],
|
bbox: [f32; 4],
|
||||||
rgba_color: u32,
|
rgba_color: u32,
|
||||||
}
|
}
|
||||||
struct AnnoFillMask {
|
|
||||||
bbox: [f32; 4],
|
|
||||||
mask: f32,
|
|
||||||
}
|
|
||||||
struct AnnoStroke {
|
struct AnnoStroke {
|
||||||
bbox: [f32; 4],
|
bbox: [f32; 4],
|
||||||
rgba_color: u32,
|
rgba_color: u32,
|
||||||
|
@ -27,8 +23,6 @@ piet_gpu! {
|
||||||
Nop,
|
Nop,
|
||||||
Stroke(AnnoStroke),
|
Stroke(AnnoStroke),
|
||||||
Fill(AnnoFill),
|
Fill(AnnoFill),
|
||||||
FillMask(AnnoFillMask),
|
|
||||||
FillMaskInv(AnnoFillMask),
|
|
||||||
BeginClip(AnnoClip),
|
BeginClip(AnnoClip),
|
||||||
EndClip(AnnoClip),
|
EndClip(AnnoClip),
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,6 @@ piet_gpu! {
|
||||||
backdrop: i32,
|
backdrop: i32,
|
||||||
rgba_color: u32,
|
rgba_color: u32,
|
||||||
}
|
}
|
||||||
struct CmdFillMask {
|
|
||||||
tile_ref: u32,
|
|
||||||
backdrop: i32,
|
|
||||||
mask: f32,
|
|
||||||
}
|
|
||||||
struct CmdBeginClip {
|
struct CmdBeginClip {
|
||||||
tile_ref: u32,
|
tile_ref: u32,
|
||||||
backdrop: i32,
|
backdrop: i32,
|
||||||
|
@ -57,8 +52,6 @@ piet_gpu! {
|
||||||
Circle(CmdCircle),
|
Circle(CmdCircle),
|
||||||
Line(CmdLine),
|
Line(CmdLine),
|
||||||
Fill(CmdFill),
|
Fill(CmdFill),
|
||||||
FillMask(CmdFillMask),
|
|
||||||
FillMaskInv(CmdFillMask),
|
|
||||||
BeginClip(CmdBeginClip),
|
BeginClip(CmdBeginClip),
|
||||||
BeginSolidClip(CmdBeginSolidClip),
|
BeginSolidClip(CmdBeginSolidClip),
|
||||||
EndClip(CmdEndClip),
|
EndClip(CmdEndClip),
|
||||||
|
@ -67,24 +60,5 @@ piet_gpu! {
|
||||||
SolidMask(CmdSolidMask),
|
SolidMask(CmdSolidMask),
|
||||||
Jump(CmdJump),
|
Jump(CmdJump),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: strongly consider using f16. If so, these would be
|
|
||||||
// relative to the tile. We're doing f32 for now to minimize
|
|
||||||
// divergence from piet-metal originals.
|
|
||||||
struct Segment {
|
|
||||||
start: [f32; 2],
|
|
||||||
end: [f32; 2],
|
|
||||||
|
|
||||||
// This is used for fills only, but we're including it in
|
|
||||||
// the general structure for simplicity.
|
|
||||||
y_edge: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SegChunk {
|
|
||||||
n: u32,
|
|
||||||
next: Ref<SegChunk>,
|
|
||||||
// Actually a reference to a variable-sized slice.
|
|
||||||
segs: Ref<Segment>,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,6 @@ piet_gpu! {
|
||||||
struct Fill {
|
struct Fill {
|
||||||
rgba_color: u32,
|
rgba_color: u32,
|
||||||
}
|
}
|
||||||
struct FillMask {
|
|
||||||
mask: f32,
|
|
||||||
}
|
|
||||||
struct Stroke {
|
struct Stroke {
|
||||||
rgba_color: u32,
|
rgba_color: u32,
|
||||||
}
|
}
|
||||||
|
@ -59,8 +56,6 @@ piet_gpu! {
|
||||||
Fill(Fill),
|
Fill(Fill),
|
||||||
SetLineWidth(SetLineWidth),
|
SetLineWidth(SetLineWidth),
|
||||||
Transform(Transform),
|
Transform(Transform),
|
||||||
FillMask(FillMask),
|
|
||||||
FillMaskInv(FillMask),
|
|
||||||
BeginClip(Clip),
|
BeginClip(Clip),
|
||||||
EndClip(Clip),
|
EndClip(Clip),
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,6 @@ struct AnnoFillRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnnoFillMaskRef {
|
|
||||||
uint offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AnnoStrokeRef {
|
struct AnnoStrokeRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
@ -31,17 +27,6 @@ AnnoFillRef AnnoFill_index(AnnoFillRef ref, uint index) {
|
||||||
return AnnoFillRef(ref.offset + index * AnnoFill_size);
|
return AnnoFillRef(ref.offset + index * AnnoFill_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AnnoFillMask {
|
|
||||||
vec4 bbox;
|
|
||||||
float mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define AnnoFillMask_size 20
|
|
||||||
|
|
||||||
AnnoFillMaskRef AnnoFillMask_index(AnnoFillMaskRef ref, uint index) {
|
|
||||||
return AnnoFillMaskRef(ref.offset + index * AnnoFillMask_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AnnoStroke {
|
struct AnnoStroke {
|
||||||
vec4 bbox;
|
vec4 bbox;
|
||||||
uint rgba_color;
|
uint rgba_color;
|
||||||
|
@ -67,10 +52,8 @@ AnnoClipRef AnnoClip_index(AnnoClipRef ref, uint index) {
|
||||||
#define Annotated_Nop 0
|
#define Annotated_Nop 0
|
||||||
#define Annotated_Stroke 1
|
#define Annotated_Stroke 1
|
||||||
#define Annotated_Fill 2
|
#define Annotated_Fill 2
|
||||||
#define Annotated_FillMask 3
|
#define Annotated_BeginClip 3
|
||||||
#define Annotated_FillMaskInv 4
|
#define Annotated_EndClip 4
|
||||||
#define Annotated_BeginClip 5
|
|
||||||
#define Annotated_EndClip 6
|
|
||||||
#define Annotated_size 28
|
#define Annotated_size 28
|
||||||
|
|
||||||
AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) {
|
AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) {
|
||||||
|
@ -99,28 +82,6 @@ void AnnoFill_write(AnnoFillRef ref, AnnoFill s) {
|
||||||
annotated[ix + 4] = s.rgba_color;
|
annotated[ix + 4] = s.rgba_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnoFillMask AnnoFillMask_read(AnnoFillMaskRef ref) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
uint raw0 = annotated[ix + 0];
|
|
||||||
uint raw1 = annotated[ix + 1];
|
|
||||||
uint raw2 = annotated[ix + 2];
|
|
||||||
uint raw3 = annotated[ix + 3];
|
|
||||||
uint raw4 = annotated[ix + 4];
|
|
||||||
AnnoFillMask s;
|
|
||||||
s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
|
||||||
s.mask = uintBitsToFloat(raw4);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnoFillMask_write(AnnoFillMaskRef ref, AnnoFillMask s) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
annotated[ix + 0] = floatBitsToUint(s.bbox.x);
|
|
||||||
annotated[ix + 1] = floatBitsToUint(s.bbox.y);
|
|
||||||
annotated[ix + 2] = floatBitsToUint(s.bbox.z);
|
|
||||||
annotated[ix + 3] = floatBitsToUint(s.bbox.w);
|
|
||||||
annotated[ix + 4] = floatBitsToUint(s.mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
AnnoStroke AnnoStroke_read(AnnoStrokeRef ref) {
|
AnnoStroke AnnoStroke_read(AnnoStrokeRef ref) {
|
||||||
uint ix = ref.offset >> 2;
|
uint ix = ref.offset >> 2;
|
||||||
uint raw0 = annotated[ix + 0];
|
uint raw0 = annotated[ix + 0];
|
||||||
|
@ -177,14 +138,6 @@ AnnoFill Annotated_Fill_read(AnnotatedRef ref) {
|
||||||
return AnnoFill_read(AnnoFillRef(ref.offset + 4));
|
return AnnoFill_read(AnnoFillRef(ref.offset + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnoFillMask Annotated_FillMask_read(AnnotatedRef ref) {
|
|
||||||
return AnnoFillMask_read(AnnoFillMaskRef(ref.offset + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
AnnoFillMask Annotated_FillMaskInv_read(AnnotatedRef ref) {
|
|
||||||
return AnnoFillMask_read(AnnoFillMaskRef(ref.offset + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
AnnoClip Annotated_BeginClip_read(AnnotatedRef ref) {
|
AnnoClip Annotated_BeginClip_read(AnnotatedRef ref) {
|
||||||
return AnnoClip_read(AnnoClipRef(ref.offset + 4));
|
return AnnoClip_read(AnnoClipRef(ref.offset + 4));
|
||||||
}
|
}
|
||||||
|
@ -207,16 +160,6 @@ void Annotated_Fill_write(AnnotatedRef ref, AnnoFill s) {
|
||||||
AnnoFill_write(AnnoFillRef(ref.offset + 4), s);
|
AnnoFill_write(AnnoFillRef(ref.offset + 4), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Annotated_FillMask_write(AnnotatedRef ref, AnnoFillMask s) {
|
|
||||||
annotated[ref.offset >> 2] = Annotated_FillMask;
|
|
||||||
AnnoFillMask_write(AnnoFillMaskRef(ref.offset + 4), s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Annotated_FillMaskInv_write(AnnotatedRef ref, AnnoFillMask s) {
|
|
||||||
annotated[ref.offset >> 2] = Annotated_FillMaskInv;
|
|
||||||
AnnoFillMask_write(AnnoFillMaskRef(ref.offset + 4), s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Annotated_BeginClip_write(AnnotatedRef ref, AnnoClip s) {
|
void Annotated_BeginClip_write(AnnotatedRef ref, AnnoClip s) {
|
||||||
annotated[ref.offset >> 2] = Annotated_BeginClip;
|
annotated[ref.offset >> 2] = Annotated_BeginClip;
|
||||||
AnnoClip_write(AnnoClipRef(ref.offset + 4), s);
|
AnnoClip_write(AnnoClipRef(ref.offset + 4), s);
|
||||||
|
|
|
@ -55,8 +55,6 @@ void main() {
|
||||||
uint tag = Annotated_tag(ref);
|
uint tag = Annotated_tag(ref);
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Annotated_Fill:
|
case Annotated_Fill:
|
||||||
case Annotated_FillMask:
|
|
||||||
case Annotated_FillMaskInv:
|
|
||||||
case Annotated_BeginClip:
|
case Annotated_BeginClip:
|
||||||
PathRef path_ref = PathRef(element_ix * Path_size);
|
PathRef path_ref = PathRef(element_ix * Path_size);
|
||||||
Path path = Path_read(path_ref);
|
Path path = Path_read(path_ref);
|
||||||
|
|
Binary file not shown.
|
@ -59,8 +59,6 @@ void main() {
|
||||||
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Annotated_Fill:
|
case Annotated_Fill:
|
||||||
case Annotated_FillMask:
|
|
||||||
case Annotated_FillMaskInv:
|
|
||||||
case Annotated_Stroke:
|
case Annotated_Stroke:
|
||||||
case Annotated_BeginClip:
|
case Annotated_BeginClip:
|
||||||
case Annotated_EndClip:
|
case Annotated_EndClip:
|
||||||
|
|
Binary file not shown.
|
@ -169,8 +169,6 @@ void main() {
|
||||||
uint tile_count;
|
uint tile_count;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Annotated_Fill:
|
case Annotated_Fill:
|
||||||
case Annotated_FillMask:
|
|
||||||
case Annotated_FillMaskInv:
|
|
||||||
case Annotated_Stroke:
|
case Annotated_Stroke:
|
||||||
case Annotated_BeginClip:
|
case Annotated_BeginClip:
|
||||||
case Annotated_EndClip:
|
case Annotated_EndClip:
|
||||||
|
@ -234,9 +232,7 @@ void main() {
|
||||||
// Include the path in the tile if
|
// Include the path in the tile if
|
||||||
// - the tile contains at least a segment (tile offset non-zero)
|
// - the tile contains at least a segment (tile offset non-zero)
|
||||||
// - the tile is completely covered (backdrop non-zero)
|
// - the tile is completely covered (backdrop non-zero)
|
||||||
bool inside = tile.backdrop != 0;
|
include_tile = tile.tile.offset != 0 || tile.backdrop != 0;
|
||||||
bool fill = tag != Annotated_FillMaskInv;
|
|
||||||
include_tile = tile.tile.offset != 0 || inside == fill;
|
|
||||||
}
|
}
|
||||||
if (include_tile) {
|
if (include_tile) {
|
||||||
uint el_slice = el_ix / 32;
|
uint el_slice = el_ix / 32;
|
||||||
|
@ -312,27 +308,6 @@ void main() {
|
||||||
Cmd_EndClip_write(cmd_ref, CmdEndClip(1.0));
|
Cmd_EndClip_write(cmd_ref, CmdEndClip(1.0));
|
||||||
cmd_ref.offset += Cmd_size;
|
cmd_ref.offset += Cmd_size;
|
||||||
break;
|
break;
|
||||||
case Annotated_FillMask:
|
|
||||||
case Annotated_FillMaskInv:
|
|
||||||
tile = Tile_read(TileRef(sh_tile_base[element_ref_ix]
|
|
||||||
+ (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size));
|
|
||||||
AnnoFillMask fill_mask = Annotated_FillMask_read(ref);
|
|
||||||
alloc_cmd(cmd_ref, cmd_limit);
|
|
||||||
if (tile.tile.offset != 0) {
|
|
||||||
CmdFillMask cmd_fill;
|
|
||||||
cmd_fill.tile_ref = tile.tile.offset;
|
|
||||||
cmd_fill.backdrop = tile.backdrop;
|
|
||||||
cmd_fill.mask = fill_mask.mask;
|
|
||||||
if (tag == Annotated_FillMask) {
|
|
||||||
Cmd_FillMask_write(cmd_ref, cmd_fill);
|
|
||||||
} else {
|
|
||||||
Cmd_FillMaskInv_write(cmd_ref, cmd_fill);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Cmd_SolidMask_write(cmd_ref, CmdSolidMask(fill_mask.mask));
|
|
||||||
}
|
|
||||||
cmd_ref.offset += Cmd_size;
|
|
||||||
break;
|
|
||||||
case Annotated_Stroke:
|
case Annotated_Stroke:
|
||||||
tile = Tile_read(TileRef(sh_tile_base[element_ref_ix]
|
tile = Tile_read(TileRef(sh_tile_base[element_ref_ix]
|
||||||
+ (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size));
|
+ (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size));
|
||||||
|
|
Binary file not shown.
|
@ -129,8 +129,6 @@ State map_element(ElementRef ref) {
|
||||||
c.pathseg_count = 1;
|
c.pathseg_count = 1;
|
||||||
break;
|
break;
|
||||||
case Element_Fill:
|
case Element_Fill:
|
||||||
case Element_FillMask:
|
|
||||||
case Element_FillMaskInv:
|
|
||||||
case Element_Stroke:
|
case Element_Stroke:
|
||||||
case Element_BeginClip:
|
case Element_BeginClip:
|
||||||
c.flags = FLAG_RESET_BBOX;
|
c.flags = FLAG_RESET_BBOX;
|
||||||
|
@ -408,23 +406,6 @@ void main() {
|
||||||
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
|
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
|
||||||
Annotated_Fill_write(out_ref, anno_fill);
|
Annotated_Fill_write(out_ref, anno_fill);
|
||||||
break;
|
break;
|
||||||
case Element_FillMask:
|
|
||||||
FillMask fill_mask = Element_FillMask_read(this_ref);
|
|
||||||
AnnoFillMask anno_fill_mask;
|
|
||||||
anno_fill_mask.mask = fill_mask.mask;
|
|
||||||
anno_fill_mask.bbox = st.bbox;
|
|
||||||
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
|
|
||||||
Annotated_FillMask_write(out_ref, anno_fill_mask);
|
|
||||||
break;
|
|
||||||
case Element_FillMaskInv:
|
|
||||||
fill_mask = Element_FillMaskInv_read(this_ref);
|
|
||||||
anno_fill_mask.mask = fill_mask.mask;
|
|
||||||
// The inverse fill conceptually takes up the entire screen.
|
|
||||||
// TODO: Tighten bounds to contain only affected paths.
|
|
||||||
anno_fill_mask.bbox = vec4(0, 0, 1e9, 1e9);
|
|
||||||
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
|
|
||||||
Annotated_FillMaskInv_write(out_ref, anno_fill_mask);
|
|
||||||
break;
|
|
||||||
case Element_BeginClip:
|
case Element_BeginClip:
|
||||||
Clip begin_clip = Element_BeginClip_read(this_ref);
|
Clip begin_clip = Element_BeginClip_read(this_ref);
|
||||||
AnnoClip anno_begin_clip = AnnoClip(begin_clip.bbox);
|
AnnoClip anno_begin_clip = AnnoClip(begin_clip.bbox);
|
||||||
|
|
Binary file not shown.
|
@ -161,20 +161,6 @@ void main() {
|
||||||
rgb[k] = mix(rgb[k], fg_rgba.rgb, mask[k] * area[k] * fg_rgba.a);
|
rgb[k] = mix(rgb[k], fg_rgba.rgb, mask[k] * area[k] * fg_rgba.a);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Cmd_FillMask:
|
|
||||||
CmdFillMask fill_mask = Cmd_FillMask_read(cmd_ref);
|
|
||||||
area = computeArea(xy, fill_mask.backdrop, fill_mask.tile_ref);
|
|
||||||
for (uint k = 0; k < CHUNK; k++) {
|
|
||||||
mask[k] = mix(mask[k], fill_mask.mask, area[k]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Cmd_FillMaskInv:
|
|
||||||
fill_mask = Cmd_FillMask_read(cmd_ref);
|
|
||||||
area = computeArea(xy, fill_mask.backdrop, fill_mask.tile_ref);
|
|
||||||
for (uint k = 0; k < CHUNK; k++) {
|
|
||||||
mask[k] = mix(mask[k], fill_mask.mask, 1.0 - area[k]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Cmd_BeginClip:
|
case Cmd_BeginClip:
|
||||||
case Cmd_BeginSolidClip:
|
case Cmd_BeginSolidClip:
|
||||||
uint blend_slot = blend_sp % BLEND_STACK_SIZE;
|
uint blend_slot = blend_sp % BLEND_STACK_SIZE;
|
||||||
|
|
Binary file not shown.
|
@ -16,10 +16,6 @@ struct CmdFillRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmdFillMaskRef {
|
|
||||||
uint offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CmdBeginClipRef {
|
struct CmdBeginClipRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
@ -48,14 +44,6 @@ struct CmdRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SegmentRef {
|
|
||||||
uint offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SegChunkRef {
|
|
||||||
uint offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CmdCircle {
|
struct CmdCircle {
|
||||||
vec2 center;
|
vec2 center;
|
||||||
float radius;
|
float radius;
|
||||||
|
@ -103,18 +91,6 @@ CmdFillRef CmdFill_index(CmdFillRef ref, uint index) {
|
||||||
return CmdFillRef(ref.offset + index * CmdFill_size);
|
return CmdFillRef(ref.offset + index * CmdFill_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CmdFillMask {
|
|
||||||
uint tile_ref;
|
|
||||||
int backdrop;
|
|
||||||
float mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define CmdFillMask_size 12
|
|
||||||
|
|
||||||
CmdFillMaskRef CmdFillMask_index(CmdFillMaskRef ref, uint index) {
|
|
||||||
return CmdFillMaskRef(ref.offset + index * CmdFillMask_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CmdBeginClip {
|
struct CmdBeginClip {
|
||||||
uint tile_ref;
|
uint tile_ref;
|
||||||
int backdrop;
|
int backdrop;
|
||||||
|
@ -180,45 +156,19 @@ CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) {
|
||||||
#define Cmd_Circle 1
|
#define Cmd_Circle 1
|
||||||
#define Cmd_Line 2
|
#define Cmd_Line 2
|
||||||
#define Cmd_Fill 3
|
#define Cmd_Fill 3
|
||||||
#define Cmd_FillMask 4
|
#define Cmd_BeginClip 4
|
||||||
#define Cmd_FillMaskInv 5
|
#define Cmd_BeginSolidClip 5
|
||||||
#define Cmd_BeginClip 6
|
#define Cmd_EndClip 6
|
||||||
#define Cmd_BeginSolidClip 7
|
#define Cmd_Stroke 7
|
||||||
#define Cmd_EndClip 8
|
#define Cmd_Solid 8
|
||||||
#define Cmd_Stroke 9
|
#define Cmd_SolidMask 9
|
||||||
#define Cmd_Solid 10
|
#define Cmd_Jump 10
|
||||||
#define Cmd_SolidMask 11
|
|
||||||
#define Cmd_Jump 12
|
|
||||||
#define Cmd_size 20
|
#define Cmd_size 20
|
||||||
|
|
||||||
CmdRef Cmd_index(CmdRef ref, uint index) {
|
CmdRef Cmd_index(CmdRef ref, uint index) {
|
||||||
return CmdRef(ref.offset + index * Cmd_size);
|
return CmdRef(ref.offset + index * Cmd_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Segment {
|
|
||||||
vec2 start;
|
|
||||||
vec2 end;
|
|
||||||
float y_edge;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define Segment_size 20
|
|
||||||
|
|
||||||
SegmentRef Segment_index(SegmentRef ref, uint index) {
|
|
||||||
return SegmentRef(ref.offset + index * Segment_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SegChunk {
|
|
||||||
uint n;
|
|
||||||
SegChunkRef next;
|
|
||||||
SegmentRef segs;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SegChunk_size 12
|
|
||||||
|
|
||||||
SegChunkRef SegChunk_index(SegChunkRef ref, uint index) {
|
|
||||||
return SegChunkRef(ref.offset + index * SegChunk_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
CmdCircle CmdCircle_read(CmdCircleRef ref) {
|
CmdCircle CmdCircle_read(CmdCircleRef ref) {
|
||||||
uint ix = ref.offset >> 2;
|
uint ix = ref.offset >> 2;
|
||||||
uint raw0 = ptcl[ix + 0];
|
uint raw0 = ptcl[ix + 0];
|
||||||
|
@ -298,25 +248,6 @@ void CmdFill_write(CmdFillRef ref, CmdFill s) {
|
||||||
ptcl[ix + 2] = s.rgba_color;
|
ptcl[ix + 2] = s.rgba_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdFillMask CmdFillMask_read(CmdFillMaskRef ref) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
uint raw0 = ptcl[ix + 0];
|
|
||||||
uint raw1 = ptcl[ix + 1];
|
|
||||||
uint raw2 = ptcl[ix + 2];
|
|
||||||
CmdFillMask s;
|
|
||||||
s.tile_ref = raw0;
|
|
||||||
s.backdrop = int(raw1);
|
|
||||||
s.mask = uintBitsToFloat(raw2);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CmdFillMask_write(CmdFillMaskRef ref, CmdFillMask s) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
ptcl[ix + 0] = s.tile_ref;
|
|
||||||
ptcl[ix + 1] = uint(s.backdrop);
|
|
||||||
ptcl[ix + 2] = floatBitsToUint(s.mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
CmdBeginClip CmdBeginClip_read(CmdBeginClipRef ref) {
|
CmdBeginClip CmdBeginClip_read(CmdBeginClipRef ref) {
|
||||||
uint ix = ref.offset >> 2;
|
uint ix = ref.offset >> 2;
|
||||||
uint raw0 = ptcl[ix + 0];
|
uint raw0 = ptcl[ix + 0];
|
||||||
|
@ -414,14 +345,6 @@ CmdFill Cmd_Fill_read(CmdRef ref) {
|
||||||
return CmdFill_read(CmdFillRef(ref.offset + 4));
|
return CmdFill_read(CmdFillRef(ref.offset + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdFillMask Cmd_FillMask_read(CmdRef ref) {
|
|
||||||
return CmdFillMask_read(CmdFillMaskRef(ref.offset + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
CmdFillMask Cmd_FillMaskInv_read(CmdRef ref) {
|
|
||||||
return CmdFillMask_read(CmdFillMaskRef(ref.offset + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
CmdBeginClip Cmd_BeginClip_read(CmdRef ref) {
|
CmdBeginClip Cmd_BeginClip_read(CmdRef ref) {
|
||||||
return CmdBeginClip_read(CmdBeginClipRef(ref.offset + 4));
|
return CmdBeginClip_read(CmdBeginClipRef(ref.offset + 4));
|
||||||
}
|
}
|
||||||
|
@ -469,16 +392,6 @@ void Cmd_Fill_write(CmdRef ref, CmdFill s) {
|
||||||
CmdFill_write(CmdFillRef(ref.offset + 4), s);
|
CmdFill_write(CmdFillRef(ref.offset + 4), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cmd_FillMask_write(CmdRef ref, CmdFillMask s) {
|
|
||||||
ptcl[ref.offset >> 2] = Cmd_FillMask;
|
|
||||||
CmdFillMask_write(CmdFillMaskRef(ref.offset + 4), s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cmd_FillMaskInv_write(CmdRef ref, CmdFillMask s) {
|
|
||||||
ptcl[ref.offset >> 2] = Cmd_FillMaskInv;
|
|
||||||
CmdFillMask_write(CmdFillMaskRef(ref.offset + 4), s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cmd_BeginClip_write(CmdRef ref, CmdBeginClip s) {
|
void Cmd_BeginClip_write(CmdRef ref, CmdBeginClip s) {
|
||||||
ptcl[ref.offset >> 2] = Cmd_BeginClip;
|
ptcl[ref.offset >> 2] = Cmd_BeginClip;
|
||||||
CmdBeginClip_write(CmdBeginClipRef(ref.offset + 4), s);
|
CmdBeginClip_write(CmdBeginClipRef(ref.offset + 4), s);
|
||||||
|
@ -514,45 +427,3 @@ void Cmd_Jump_write(CmdRef ref, CmdJump s) {
|
||||||
CmdJump_write(CmdJumpRef(ref.offset + 4), s);
|
CmdJump_write(CmdJumpRef(ref.offset + 4), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
Segment Segment_read(SegmentRef ref) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
uint raw0 = ptcl[ix + 0];
|
|
||||||
uint raw1 = ptcl[ix + 1];
|
|
||||||
uint raw2 = ptcl[ix + 2];
|
|
||||||
uint raw3 = ptcl[ix + 3];
|
|
||||||
uint raw4 = ptcl[ix + 4];
|
|
||||||
Segment s;
|
|
||||||
s.start = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
||||||
s.end = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
|
||||||
s.y_edge = uintBitsToFloat(raw4);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Segment_write(SegmentRef ref, Segment s) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
ptcl[ix + 0] = floatBitsToUint(s.start.x);
|
|
||||||
ptcl[ix + 1] = floatBitsToUint(s.start.y);
|
|
||||||
ptcl[ix + 2] = floatBitsToUint(s.end.x);
|
|
||||||
ptcl[ix + 3] = floatBitsToUint(s.end.y);
|
|
||||||
ptcl[ix + 4] = floatBitsToUint(s.y_edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
SegChunk SegChunk_read(SegChunkRef ref) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
uint raw0 = ptcl[ix + 0];
|
|
||||||
uint raw1 = ptcl[ix + 1];
|
|
||||||
uint raw2 = ptcl[ix + 2];
|
|
||||||
SegChunk s;
|
|
||||||
s.n = raw0;
|
|
||||||
s.next = SegChunkRef(raw1);
|
|
||||||
s.segs = SegmentRef(raw2);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SegChunk_write(SegChunkRef ref, SegChunk s) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
ptcl[ix + 0] = s.n;
|
|
||||||
ptcl[ix + 1] = s.next.offset;
|
|
||||||
ptcl[ix + 2] = s.segs.offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,6 @@ struct FillRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FillMaskRef {
|
|
||||||
uint offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct StrokeRef {
|
struct StrokeRef {
|
||||||
uint offset;
|
uint offset;
|
||||||
};
|
};
|
||||||
|
@ -86,16 +82,6 @@ FillRef Fill_index(FillRef ref, uint index) {
|
||||||
return FillRef(ref.offset + index * Fill_size);
|
return FillRef(ref.offset + index * Fill_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FillMask {
|
|
||||||
float mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define FillMask_size 4
|
|
||||||
|
|
||||||
FillMaskRef FillMask_index(FillMaskRef ref, uint index) {
|
|
||||||
return FillMaskRef(ref.offset + index * FillMask_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Stroke {
|
struct Stroke {
|
||||||
uint rgba_color;
|
uint rgba_color;
|
||||||
};
|
};
|
||||||
|
@ -148,10 +134,8 @@ ClipRef Clip_index(ClipRef ref, uint index) {
|
||||||
#define Element_Fill 8
|
#define Element_Fill 8
|
||||||
#define Element_SetLineWidth 9
|
#define Element_SetLineWidth 9
|
||||||
#define Element_Transform 10
|
#define Element_Transform 10
|
||||||
#define Element_FillMask 11
|
#define Element_BeginClip 11
|
||||||
#define Element_FillMaskInv 12
|
#define Element_EndClip 12
|
||||||
#define Element_BeginClip 13
|
|
||||||
#define Element_EndClip 14
|
|
||||||
#define Element_size 36
|
#define Element_size 36
|
||||||
|
|
||||||
ElementRef Element_index(ElementRef ref, uint index) {
|
ElementRef Element_index(ElementRef ref, uint index) {
|
||||||
|
@ -211,14 +195,6 @@ Fill Fill_read(FillRef ref) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
FillMask FillMask_read(FillMaskRef ref) {
|
|
||||||
uint ix = ref.offset >> 2;
|
|
||||||
uint raw0 = scene[ix + 0];
|
|
||||||
FillMask s;
|
|
||||||
s.mask = uintBitsToFloat(raw0);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
Stroke Stroke_read(StrokeRef ref) {
|
Stroke Stroke_read(StrokeRef ref) {
|
||||||
uint ix = ref.offset >> 2;
|
uint ix = ref.offset >> 2;
|
||||||
uint raw0 = scene[ix + 0];
|
uint raw0 = scene[ix + 0];
|
||||||
|
@ -304,14 +280,6 @@ Transform Element_Transform_read(ElementRef ref) {
|
||||||
return Transform_read(TransformRef(ref.offset + 4));
|
return Transform_read(TransformRef(ref.offset + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
FillMask Element_FillMask_read(ElementRef ref) {
|
|
||||||
return FillMask_read(FillMaskRef(ref.offset + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
FillMask Element_FillMaskInv_read(ElementRef ref) {
|
|
||||||
return FillMask_read(FillMaskRef(ref.offset + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
Clip Element_BeginClip_read(ElementRef ref) {
|
Clip Element_BeginClip_read(ElementRef ref) {
|
||||||
return Clip_read(ClipRef(ref.offset + 4));
|
return Clip_read(ClipRef(ref.offset + 4));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@ void main() {
|
||||||
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Annotated_Fill:
|
case Annotated_Fill:
|
||||||
case Annotated_FillMask:
|
|
||||||
case Annotated_FillMaskInv:
|
|
||||||
case Annotated_Stroke:
|
case Annotated_Stroke:
|
||||||
case Annotated_BeginClip:
|
case Annotated_BeginClip:
|
||||||
case Annotated_EndClip:
|
case Annotated_EndClip:
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue