2021-12-03 03:41:41 +11:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
|
|
|
|
|
|
|
|
// Common data structures and functions for the draw tag stream.
|
|
|
|
|
2022-03-03 09:44:03 +11:00
|
|
|
// Design of draw tag: & 0x1c gives scene size in bytes
|
|
|
|
// & 1 gives clip
|
|
|
|
// (tag >> 4) & 0x1c is info size in bytes
|
|
|
|
|
|
|
|
#define Drawtag_Nop 0
|
|
|
|
#define Drawtag_FillColor 0x44
|
|
|
|
#define Drawtag_FillLinGradient 0x114
|
|
|
|
#define Drawtag_FillImage 0x48
|
|
|
|
#define Drawtag_BeginClip 0x05
|
|
|
|
#define Drawtag_EndClip 0x25
|
|
|
|
|
2021-12-03 03:41:41 +11:00
|
|
|
struct DrawMonoid {
|
|
|
|
uint path_ix;
|
|
|
|
uint clip_ix;
|
2022-03-03 09:44:03 +11:00
|
|
|
uint scene_offset;
|
|
|
|
uint info_offset;
|
2021-12-03 03:41:41 +11:00
|
|
|
};
|
|
|
|
|
2022-03-03 09:44:03 +11:00
|
|
|
DrawMonoid draw_monoid_identity() {
|
|
|
|
return DrawMonoid(0, 0, 0, 0);
|
2021-12-03 03:41:41 +11:00
|
|
|
}
|
|
|
|
|
2022-03-03 09:44:03 +11:00
|
|
|
DrawMonoid combine_draw_monoid(DrawMonoid a, DrawMonoid b) {
|
2021-12-03 03:41:41 +11:00
|
|
|
DrawMonoid c;
|
|
|
|
c.path_ix = a.path_ix + b.path_ix;
|
|
|
|
c.clip_ix = a.clip_ix + b.clip_ix;
|
2022-03-03 09:44:03 +11:00
|
|
|
c.scene_offset = a.scene_offset + b.scene_offset;
|
|
|
|
c.info_offset = a.info_offset + b.info_offset;
|
2021-12-03 03:41:41 +11:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawMonoid map_tag(uint tag_word) {
|
2022-03-03 09:44:03 +11:00
|
|
|
// TODO: at some point, EndClip should not generate a path
|
|
|
|
uint has_path = uint(tag_word != Drawtag_Nop);
|
|
|
|
return DrawMonoid(has_path, tag_word & 1, tag_word & 0x1c, (tag_word >> 4) & 0x1c);
|
2021-12-03 03:41:41 +11:00
|
|
|
}
|