]> git.imager.perl.org - imager.git/blobdiff - polygon.c
- eliminate many -Wall warnings
[imager.git] / polygon.c
index 9e53bb2e738eb085cd1638a85debd1cf28fe8ce2..7887a00b8bc0489e4c2a4840a20305125794ae2e 100644 (file)
--- a/polygon.c
+++ b/polygon.c
@@ -1,4 +1,4 @@
-#include "image.h"
+#include "imager.h"
 #include "draw.h"
 #include "log.h"
 
 #include "draw.h"
 #include "log.h"
 
@@ -91,7 +91,7 @@ p_eval_atx(p_line *l, pcord x) {
 
 static
 p_line *
 
 static
 p_line *
-line_set_new(double *x, double *y, int l) {
+line_set_new(const double *x, const double *y, int l) {
   int i;
   p_line *lset = mymalloc(sizeof(p_line) * l);
 
   int i;
   p_line *lset = mymalloc(sizeof(p_line) * l);
 
@@ -111,7 +111,7 @@ line_set_new(double *x, double *y, int l) {
 
 static
 p_point *
 
 static
 p_point *
-point_set_new(double *x, double *y, int l) {
+point_set_new(const double *x, const double *y, int l) {
   int i;
   p_point *pset = mymalloc(sizeof(p_point) * l);
   
   int i;
   p_point *pset = mymalloc(sizeof(p_point) * l);
   
@@ -123,13 +123,14 @@ point_set_new(double *x, double *y, int l) {
   return pset;
 }
 
   return pset;
 }
 
+#if 0
 static
 void
 p_line_dump(p_line *l) {
   printf("%d (%d,%d)->(%d,%d) [%d-%d,%d-%d]\n", l->n, l->x1, l->y1, l->x2, l->y2, 
         l->minx, l->maxx, l->miny, l->maxy);
 }
 static
 void
 p_line_dump(p_line *l) {
   printf("%d (%d,%d)->(%d,%d) [%d-%d,%d-%d]\n", l->n, l->x1, l->y1, l->x2, l->y2, 
         l->minx, l->maxx, l->miny, l->maxy);
 }
-
+#endif
 
 static
 void
 
 static
 void
@@ -179,6 +180,7 @@ lines_in_interval(p_line *lset, int l, p_slice *tllist, pcord minc, pcord maxc)
   return count;
 }
 
   return count;
 }
 
+#if 0
 static
 int
 lines_in_interval_old(p_line *lset, int l, p_slice *tllist, pcord cc) {
 static
 int
 lines_in_interval_old(p_line *lset, int l, p_slice *tllist, pcord cc) {
@@ -198,6 +200,7 @@ lines_in_interval_old(p_line *lset, int l, p_slice *tllist, pcord cc) {
   }
   return count;
 }
   }
   return count;
 }
+#endif
 
 /* marks the up variable for all lines in a slice */
 
 
 /* marks the up variable for all lines in a slice */
 
@@ -261,12 +264,12 @@ saturate(int in) {
   return 0;
 }
 
   return 0;
 }
 
-typedef void (*scanline_flusher)(i_img *im, ss_scanline *ss, int y, void *ctx);
+typedef void (*scanline_flusher)(i_img *im, ss_scanline *ss, int y, const void *ctx);
 
 /* This function must be modified later to do proper blending */
 
 static void
 
 /* This function must be modified later to do proper blending */
 
 static void
-scanline_flush(i_img *im, ss_scanline *ss, int y, void *ctx) {
+scanline_flush(i_img *im, ss_scanline *ss, int y, const void *ctx) {
   int x, ch, tv;
   i_color t;
   i_color *val = (i_color *)ctx;
   int x, ch, tv;
   i_color t;
   i_color *val = (i_color *)ctx;
@@ -302,8 +305,6 @@ pixel_coverage(p_line *line, pcord minx, pcord maxx, pcord  miny, pcord maxy) {
   double lycross, rycross;
   int l, r;
 
   double lycross, rycross;
   int l, r;
 
-  double xs, ys;
-  
   if (!line->updown) {
     l = r = 0;
   } else {
   if (!line->updown) {
     l = r = 0;
   } else {
@@ -364,7 +365,6 @@ render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r) {
   int thin;            /* boolean for thin/thick segment */
   int startpix;                /* temporary variable for "start of this interval" */
   int stoppix;         /* temporary variable for "end of this interval" */
   int thin;            /* boolean for thin/thick segment */
   int startpix;                /* temporary variable for "start of this interval" */
   int stoppix;         /* temporary variable for "end of this interval" */
-  int step2end;                /* temporary variable to mark where step2 ends */
 
   /* Find the y bounds of scanline_slice */
 
 
   /* Find the y bounds of scanline_slice */
 
@@ -406,7 +406,7 @@ render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r) {
 }
 
 
 }
 
 
-
+#if 0
 static
 void
 render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
 static
 void
 render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
@@ -418,7 +418,6 @@ render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
   int thin;            /* boolean for thin/thick segment */
   int startpix;                /* temporary variable for "start of this interval" */
   int stoppix;         /* temporary variable for "end of this interval" */
   int thin;            /* boolean for thin/thick segment */
   int startpix;                /* temporary variable for "start of this interval" */
   int stoppix;         /* temporary variable for "end of this interval" */
-  int step2end;                /* temporary variable to mark where step2 ends */
 
   /* Find the y bounds of scanline_slice */
 
 
   /* Find the y bounds of scanline_slice */
 
@@ -497,11 +496,7 @@ render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
   
   ss->line[cpix] += (16.0)*(maxy-miny) - pixel_coverage(r, cpix*16, cpix*16+16, miny, maxy);
 }
   
   ss->line[cpix] += (16.0)*(maxy-miny) - pixel_coverage(r, cpix*16, cpix*16+16, miny, maxy);
 }
-
-
-
-
-
+#endif
 
 /* Antialiasing polygon algorithm 
    specs:
 
 /* Antialiasing polygon algorithm 
    specs:
@@ -534,10 +529,9 @@ render_slice_scanline_old(ss_scanline *ss, int y, p_line *l, p_line *r) {
 
 
 static void
 
 
 static void
-i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flusher flusher) {
+i_poly_aa_low(i_img *im, int l, const double *x, const double *y, void const *ctx, scanline_flusher flusher) {
   int i ,k;                    /* Index variables */
   int clc;                     /* Lines inside current interval */
   int i ,k;                    /* Index variables */
   int clc;                     /* Lines inside current interval */
-  pcord miny ,maxy;            /* Min and max values of the current slice in the subcord system */
   pcord tempy;
   int cscl;                    /* Current scanline */
 
   pcord tempy;
   int cscl;                    /* Current scanline */
 
@@ -581,7 +575,6 @@ i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flushe
   for(i=0; i<l-1; i++) {
     int startscan = i_max( coarse(pset[i].y), 0);
     int stopscan = i_min( coarse(pset[i+1].y+15), im->ysize);
   for(i=0; i<l-1; i++) {
     int startscan = i_max( coarse(pset[i].y), 0);
     int stopscan = i_min( coarse(pset[i+1].y+15), im->ysize);
-    pcord cc = (pset[i].y + pset[i+1].y)/2;
 
     if (pset[i].y == pset[i+1].y) {
       POLY_DEB( printf("current slice thickness = 0 => skipping\n") );
 
     if (pset[i].y == pset[i+1].y) {
       POLY_DEB( printf("current slice thickness = 0 => skipping\n") );
@@ -602,8 +595,6 @@ i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flushe
     POLY_DEB( printf("Interval contains %d lines\n", clc) );
 
     for(k=0; k<clc; k++) {
     POLY_DEB( printf("Interval contains %d lines\n", clc) );
 
     for(k=0; k<clc; k++) {
-      int lno = tllist[k].n;
-      p_line *ln = lset+lno;
       POLY_DEB(
               printf("%d:  line #%2d: (%2d, %2d)->(%2d, %2d) (%2d/%2d, %2d/%2d) -> (%2d/%2d, %2d/%2d) alignment=%s\n",
                      k, lno, ln->x1, ln->y1, ln->x2, ln->y2, 
       POLY_DEB(
               printf("%d:  line #%2d: (%2d, %2d)->(%2d, %2d) (%2d/%2d, %2d/%2d) -> (%2d/%2d, %2d/%2d) alignment=%s\n",
                      k, lno, ln->x1, ln->y1, ln->x2, ln->y2, 
@@ -646,7 +637,7 @@ i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flushe
 } /* Function */
 
 void
 } /* Function */
 
 void
-i_poly_aa(i_img *im, int l, double *x, double *y, i_color *val) {
+i_poly_aa(i_img *im, int l, const double *x, const double *y, const i_color *val) {
   i_poly_aa_low(im, l, x, y, val, scanline_flush);
 }
 
   i_poly_aa_low(im, l, x, y, val, scanline_flush);
 }
 
@@ -658,12 +649,11 @@ struct poly_cfill_state {
 };
 
 static void
 };
 
 static void
-scanline_flush_cfill(i_img *im, ss_scanline *ss, int y, void *ctx) {
+scanline_flush_cfill(i_img *im, ss_scanline *ss, int y, const void *ctx) {
   int x, ch, tv;
   int x, ch, tv;
-  i_color t;
   int pos;
   int left, right;
   int pos;
   int left, right;
-  struct poly_cfill_state *state = (struct poly_cfill_state *)ctx;
+  struct poly_cfill_state const *state = (struct poly_cfill_state const *)ctx;
   i_color *fillbuf = state->fillbuf;
   i_color *line = state->linebuf;
 
   i_color *fillbuf = state->fillbuf;
   i_color *line = state->linebuf;
 
@@ -686,9 +676,9 @@ scanline_flush_cfill(i_img *im, ss_scanline *ss, int y, void *ctx) {
         tv = saturate(ss->line[x]);
         fillbuf[pos].channel[3] = 
           fillbuf[pos].channel[3] * tv / 255;
         tv = saturate(ss->line[x]);
         fillbuf[pos].channel[3] = 
           fillbuf[pos].channel[3] * tv / 255;
+       pos++;
       }
       (state->fill->combine)(line, fillbuf, im->channels, right-left);
       }
       (state->fill->combine)(line, fillbuf, im->channels, right-left);
-      pos++;
     }
     else {
       for (x = left; x < right; ++x) {
     }
     else {
       for (x = left; x < right; ++x) {
@@ -721,11 +711,11 @@ struct poly_cfill_state_f {
 };
 
 static void
 };
 
 static void
-scanline_flush_cfill_f(i_img *im, ss_scanline *ss, int y, void *ctx) {
+scanline_flush_cfill_f(i_img *im, ss_scanline *ss, int y, const void *ctx) {
   int x, ch, tv;
   int pos;
   int left, right;
   int x, ch, tv;
   int pos;
   int left, right;
-  struct poly_cfill_state_f *state = (struct poly_cfill_state_f *)ctx;
+  struct poly_cfill_state_f const *state = (struct poly_cfill_state_f const *)ctx;
   i_fcolor *fillbuf = state->fillbuf;
   i_fcolor *line = state->linebuf;
 
   i_fcolor *fillbuf = state->fillbuf;
   i_fcolor *line = state->linebuf;
 
@@ -748,9 +738,9 @@ scanline_flush_cfill_f(i_img *im, ss_scanline *ss, int y, void *ctx) {
         tv = saturate(ss->line[x]);
         fillbuf[pos].channel[3] = 
           fillbuf[pos].channel[3] * tv / 255;
         tv = saturate(ss->line[x]);
         fillbuf[pos].channel[3] = 
           fillbuf[pos].channel[3] * tv / 255;
+       pos++;
       }
       (state->fill->combinef)(line, fillbuf, im->channels, right-left);
       }
       (state->fill->combinef)(line, fillbuf, im->channels, right-left);
-      pos++;
     }
     else {
       for (x = left; x < right; ++x) {
     }
     else {
       for (x = left; x < right; ++x) {
@@ -776,7 +766,7 @@ scanline_flush_cfill_f(i_img *im, ss_scanline *ss, int y, void *ctx) {
 }
 
 void
 }
 
 void
-i_poly_aa_cfill(i_img *im, int l, double *x, double *y, i_fill_t *fill) {
+i_poly_aa_cfill(i_img *im, int l, const double *x, const double *y, i_fill_t *fill) {
   if (im->bits == i_8_bits && fill->fill_with_color) {
     struct poly_cfill_state ctx;
     ctx.fillbuf = mymalloc(sizeof(i_color) * im->xsize * 2);
   if (im->bits == i_8_bits && fill->fill_with_color) {
     struct poly_cfill_state ctx;
     ctx.fillbuf = mymalloc(sizeof(i_color) * im->xsize * 2);