Kernel 2 processes all the segments in the fill and stroke items. Here we'll concentrate on fill (stroke is similar).
Its input is: a list of fill items for this tilegroup, from kernel 1. Also access to the scene, for the items, and for the lists of points.
Its output is: for each item, a background fill and a list of segments. (there's potential complexity that the segments can be "fill" and "fill edge").
This note refers to the piet-metal source extensively. For the most part, it does the PietItem_Fill case (lines 248..365).
Some simplifications: we'll consider the item list a vec, with len and index operations. In practice, it is likely to be fragmented, to make dynamic allocation easier for kernel 1. We'll also write the code for output in pseudocode (it will have to do similar dynamic alloc tricks).