ee0be13cb80bc05028f07d53c7fd4d521e9e3659
[swftools.git] / lib / gfxpoly / xrow.h
1 #ifndef __xrow_h__
2 #define __xrow_h__
3
4 #include <stdint.h>
5
6 #include "poly.h"
7
8 typedef struct _xrow {
9     int32_t*x;
10     int num;
11     int size;
12     int32_t lastx;
13 } xrow_t;
14
15 xrow_t* xrow_new();
16
17 /* so the idea is this:
18    Before processing any events for a given y, store the list+tree of the current active
19    list (that might be useful anyway for adding xrow points to segments).
20    Then, for every starting segment and for every segment that receives a point, add a (x,segment)
21    tuple to a list which we later sort.
22    These segments will at that point have their *old* fill styles set.
23    Then, order that list, and also merge identical x values using left<->right comparisons on
24    the *old* active list, so that for every x coordinate we have the rightmost (old) segment. (For
25    small active lists, it might be faster to just mark the segments (and store the x in them), and
26    then walk the active list from left to right, collecting marked segments)
27    This list now gives us the information about what the fill areas look like above the scanline and to
28    the right of segments which received a point.
29    Now, apply fill style changes and resort the list, this time using the *new* active
30    list for merging identical x values. That gives us the information on what fill areas look like
31    *below* the scanline and to the right of segments which received a point.
32    Every time an "above" fillstyle differs from a "below" fillstyle, we need to draw a horizontal
33    line (from right to left, using the below fillstyle).
34 */
35
36 /* Another approach: since we really only need to know the below *or* above fillstyles in order to
37    determine whether a horizontal line is still needed (if its edgestyle doesn't change the windstate,
38    it's not needed), we can also process horizontal lines after the start events: walk the temporary
39    end segment list and the active list interleaved for each horizontal line, insert horizontal fragments
40    whenever they seem to modify the fillstyle (e.g. apply them with dir=UP).
41    This means that "very horizontal" segments ending in a scanline that encounter hot pixels
42    on their way (and thus don't receive "their" endpoint) need to store a horizontal event. Same for
43    general segments that pass/intersect multiple hotpixels in a scanline.
44 */
45
46
47 void xrow_add(xrow_t*xrow, int32_t x);
48
49 void xrow_sort(xrow_t*xrow);
50 void xrow_dump(xrow_t*xrow);
51 void xrow_reset(xrow_t*xrow);
52 void xrow_destroy(xrow_t*xrow);
53
54 #endif