more fiddling with edgestyles
authorMatthias Kramm <kramm@quiss.org>
Sat, 3 Apr 2010 00:11:58 +0000 (17:11 -0700)
committerMatthias Kramm <kramm@quiss.org>
Sat, 3 Apr 2010 00:11:58 +0000 (17:11 -0700)
lib/gfxpoly/poly.c
lib/gfxpoly/poly.h

index d02ce5e..c1dc318 100644 (file)
@@ -276,10 +276,9 @@ static void segment_dump(segment_t*s)
             (double)s->delta.x / s->delta.y, s->fs_orig);
 }
 
             (double)s->delta.x / s->delta.y, s->fs_orig);
 }
 
-static void segment_init(segment_t*s, int32_t x1, int32_t y1, int32_t x2, int32_t y2, edgestyle_t*fs, int polygon_nr, segment_dir_t dir)
+static void segment_init(segment_t*s, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int polygon_nr, segment_dir_t dir)
 {
     s->dir = dir;
 {
     s->dir = dir;
-    s->fs_orig = fs;
     if(y1!=y2) {
        assert(y1<y2);
     } else {
     if(y1!=y2) {
        assert(y1<y2);
     } else {
@@ -339,10 +338,10 @@ static void segment_init(segment_t*s, int32_t x1, int32_t y1, int32_t x2, int32_
 #endif
 }
 
 #endif
 }
 
-static segment_t* segment_new(point_t a, point_t b, edgestyle_t*fs, int polygon_nr, segment_dir_t dir)
+static segment_t* segment_new(point_t a, point_t b, int polygon_nr, segment_dir_t dir)
 {
     segment_t*s = (segment_t*)rfx_calloc(sizeof(segment_t));
 {
     segment_t*s = (segment_t*)rfx_calloc(sizeof(segment_t));
-    segment_init(s, a.x, a.y, b.x, b.y, fs, polygon_nr, dir);
+    segment_init(s, a.x, a.y, b.x, b.y, polygon_nr, dir);
     return s;
 }
 
     return s;
 }
 
@@ -367,7 +366,9 @@ static void advance_stroke(queue_t*queue, hqueue_t*hqueue, gfxpolystroke_t*strok
        before horizontal events */
     while(pos < stroke->num_points-1) {
        assert(stroke->points[pos].y <= stroke->points[pos+1].y);
        before horizontal events */
     while(pos < stroke->num_points-1) {
        assert(stroke->points[pos].y <= stroke->points[pos+1].y);
-       s = segment_new(stroke->points[pos], stroke->points[pos+1], stroke->fs, polygon_nr, stroke->dir);
+       s = segment_new(stroke->points[pos], stroke->points[pos+1], polygon_nr, stroke->dir);
+       s->fs_orig = stroke->fs;
+       s->fs_old = stroke->fs_old;
        pos++;
        s->stroke = 0;
        s->stroke_pos = 0;
        pos++;
        s->stroke = 0;
        s->stroke_pos = 0;
@@ -666,6 +667,7 @@ static void insert_point_into_segment(status_t*status, segment_t*s, point_t p)
                 s->pos.x, s->pos.y, p.x, p.y);
 #endif
        edgestyle_t*fs = s->fs_out;
                 s->pos.x, s->pos.y, p.x, p.y);
 #endif
        edgestyle_t*fs = s->fs_out;
+       edgestyle_t*fs_old = s->fs_orig;
 
         // omit horizontal lines
         if(s->pos.y != p.y) {
 
         // omit horizontal lines
         if(s->pos.y != p.y) {
@@ -678,7 +680,7 @@ static void insert_point_into_segment(status_t*status, segment_t*s, point_t p)
               matching our start point, and a matching edgestyle */
            while(stroke) {
                point_t p = stroke->points[stroke->num_points-1];
               matching our start point, and a matching edgestyle */
            while(stroke) {
                point_t p = stroke->points[stroke->num_points-1];
-               if(p.x == a.x && p.y == a.y && stroke->fs == fs)
+               if(p.x == a.x && p.y == a.y && stroke->fs == fs && stroke->fs_old == fs_old)
                    break;
                stroke = stroke->next;
            }
                    break;
                stroke = stroke->next;
            }
@@ -686,6 +688,7 @@ static void insert_point_into_segment(status_t*status, segment_t*s, point_t p)
                stroke = rfx_calloc(sizeof(gfxpolystroke_t));
                stroke->dir = DIR_DOWN;
                stroke->fs = fs;
                stroke = rfx_calloc(sizeof(gfxpolystroke_t));
                stroke->dir = DIR_DOWN;
                stroke->fs = fs;
+               stroke->fs_old = fs_old;
                stroke->next = status->strokes;
                status->strokes = stroke;
                stroke->points_size = 2;
                stroke->next = status->strokes;
                status->strokes = stroke;
                stroke->points_size = 2;
index bd1c992..619b779 100644 (file)
@@ -28,6 +28,7 @@ type_t point_type;
 typedef struct _gfxpolystroke {
     segment_dir_t dir;
     edgestyle_t*fs;
 typedef struct _gfxpolystroke {
     segment_dir_t dir;
     edgestyle_t*fs;
+    edgestyle_t*fs_old;
     int points_size;
     int num_points;
     point_t*points;
     int points_size;
     int num_points;
     point_t*points;
@@ -48,6 +49,7 @@ typedef struct _segment {
     segment_dir_t dir;
     edgestyle_t*fs_orig;
     edgestyle_t*fs_out;
     segment_dir_t dir;
     edgestyle_t*fs_orig;
     edgestyle_t*fs_out;
+    edgestyle_t*fs_old;
 #ifdef CHECKS
     char fs_out_ok;
 #endif
 #ifdef CHECKS
     char fs_out_ok;
 #endif