reworked edgestyle logic
[swftools.git] / lib / gfxpoly / renderpoly.c
index 2da9c63..9594bd2 100644 (file)
@@ -7,7 +7,7 @@ typedef struct _renderpoint
 {
     double x;
     segment_dir_t dir;
-    fillstyle_t*fs;
+    edgestyle_t*fs;
     int polygon_nr;
 } renderpoint_t;
 
@@ -27,7 +27,7 @@ typedef struct _renderbuf
     renderline_t*lines;
 } renderbuf_t;
 
-static inline void add_pixel(renderbuf_t*buf, double x, int y, segment_dir_t dir, fillstyle_t*fs, int polygon_nr)
+static inline void add_pixel(renderbuf_t*buf, double x, int y, segment_dir_t dir, edgestyle_t*fs, int polygon_nr)
 {
     renderpoint_t p;
     p.x = x;
@@ -48,7 +48,7 @@ static inline void add_pixel(renderbuf_t*buf, double x, int y, segment_dir_t dir
     l->num++;
 }
 #define CUT 0.5
-static void add_line(renderbuf_t*buf, double x1, double y1, double x2, double y2, fillstyle_t*fs, int polygon_nr)
+static void add_line(renderbuf_t*buf, double x1, double y1, double x2, double y2, edgestyle_t*fs, int polygon_nr)
 {
     x1 *= buf->zoom;
     y1 *= buf->zoom;
@@ -140,8 +140,8 @@ unsigned char* render_polygon(gfxpoly_t*polygon, intbbox_t*bbox, double zoom, wi
 
     int polygon_nr = 0;
     int s,t;
-    for(s=0;s<polygon->num_strokes;s++) {
-       gfxpolystroke_t*stroke = &polygon->strokes[s];
+    gfxpolystroke_t*stroke = polygon->strokes;
+    for(;stroke;stroke=stroke->next) {
        for(t=0;t<stroke->num_points-1;t++) {
            point_t a = stroke->points[t];
            point_t b = stroke->points[t+1];
@@ -175,7 +175,7 @@ unsigned char* render_polygon(gfxpoly_t*polygon, intbbox_t*bbox, double zoom, wi
         }
         if(fill.is_filled && lastx!=buf->width) {
             /* we're bleeding, fill over padding, too. */
-            fprintf(stderr, "Polygon %08x is bleeding in line %d\n", polygon, y);
+            fprintf(stderr, "Polygon %p is bleeding in line %d\n", polygon, y);
             fill_bitwise(line, lastx, width8*8);
            assert(line[width8-1]&0x01);
            bleeding = 1;
@@ -198,8 +198,8 @@ unsigned char* render_polygon(gfxpoly_t*polygon, intbbox_t*bbox, double zoom, wi
 #define MAX_WIDTH 8192
 #define MAX_HEIGHT 4096
 
-static inline max(double a, double b) {return a>b?a:b;}
-static inline min(double a, double b) {return a<b?a:b;}
+static inline double max(double a, double b) {return a>b?a:b;}
+static inline double min(double a, double b) {return a<b?a:b;}
 
 static int adjust_x(int xmin, int xmax)
 {
@@ -228,15 +228,15 @@ intbbox_t intbbox_from_polygon(gfxpoly_t*polygon, double zoom)
 
     double g = zoom*polygon->gridsize;
 
-    if(polygon->num_strokes && polygon->strokes[0].num_points) {
-        b.xmin = polygon->strokes[0].points[0].x*g;
-        b.ymin = polygon->strokes[0].points[0].y*g;
-        b.xmax = polygon->strokes[0].points[0].x*g;
-        b.ymax = polygon->strokes[0].points[0].y*g;
+    if(polygon->strokes && polygon->strokes->num_points) {
+        b.xmin = polygon->strokes->points[0].x*g;
+        b.ymin = polygon->strokes->points[0].y*g;
+        b.xmax = polygon->strokes->points[0].x*g;
+        b.ymax = polygon->strokes->points[0].y*g;
     }
     int s,t;
-    for(s=0;s<polygon->num_strokes;s++) {
-       gfxpolystroke_t*stroke = &polygon->strokes[s];
+    gfxpolystroke_t*stroke = polygon->strokes;
+    for(;stroke;stroke=stroke->next) {
        for(t=0;t<stroke->num_points;t++) {
            point_t p = stroke->points[t];
            int x1 = floor(p.x);