Code

31567e6370686272ec506b935023f981bde9bcab
[inkscape.git] / src / livarot / int-line.h
1 #ifndef INKSCAPE_LIVAROT_INT_LINE_H
2 #define INKSCAPE_LIVAROT_INT_LINE_H
4 #include "livarot/livarot-forward.h"
5 #include "livarot/LivarotDefs.h"
7 /** \file
8  * Coverage with integer boundaries.
9  */
11 /// A run with integer boundaries.
12 struct int_ligne_run {
13     int st;
14     int en;
15     float vst;
16     float ven;
17 };
19 /// Integer boundary.
20 struct int_ligne_bord {
21     int pos;
22     bool start;
23     float val;
24     int other;
25     int prev;
26     int next;
27 };
29 /**
30  * Coverage with integer boundaries.
31  *
32  * This is what we want for actual rasterization. It contains the same 
33  * stuff as FloatLigne, but technically only the Copy() functions are used.
34  */
35 class IntLigne {
36 public:
37     
38     int nbBord;
39     int maxBord;
40     int_ligne_bord* bords;
42     int nbRun;
43     int maxRun;
44     int_ligne_run* runs;
46     int firstAc;
47     int lastAc;
49     IntLigne();
50     virtual ~IntLigne();
52     void Reset();
53     int AddBord(int spos, float sval, int epos, float eval);
55     void Flatten();
57     void Affiche();
59     int AddRun(int st, int en, float vst, float ven);
61     void Booleen(IntLigne* a, IntLigne* b, BooleanOp mod);
63     void Copy(IntLigne* a);
64     void Copy(FloatLigne* a);
65     void Copy(BitLigne* a);
66     void Copy(int nbSub,BitLigne **a); 
68     void Enqueue(int no);
69     void Dequeue(int no);
70     float RemainingValAt(int at);
72     static int CmpBord(void const *p1, void const *p2) {
73         int_ligne_bord const *d1 = reinterpret_cast<int_ligne_bord const *>(p1);
74         int_ligne_bord const *d2 = reinterpret_cast<int_ligne_bord const *>(p2);
75         
76         if ( d1->pos == d2->pos ) {
77             if ( d1->start && !(d2->start) ) {
78                 return 1;
79             }
80             if ( !(d1->start) && d2->start ) {
81                 return -1;
82             }
83             return 0;
84         }
85         return (( d1->pos < d2->pos ) ? -1 : 1);
86     };
88     inline float ValAt(int at, int ps, int pe, float vs, float ve) {
89         return ((at - ps) * ve + (pe - at) * vs) / (pe - ps);
90     };
92     void Raster(raster_info &dest, void *color, RasterInRunFunc worker);
93 };
96 #endif
98 /*
99   Local Variables:
100   mode:c++
101   c-file-style:"stroustrup"
102   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103   indent-tabs-mode:nil
104   fill-column:99
105   End:
106 */
107 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :