Code

fix these annoying y0 warnings.
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sat, 7 May 2005 15:45:52 +0000 (15:45 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sat, 7 May 2005 15:45:52 +0000 (15:45 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@501 a5681a0c-68f1-0310-ab6d-d61299d08faa

src/art_rgba_svp.c
src/rrd_gfx.c
src/rrd_gfx.h

index 81457d057e6e94113031f4c162b775b073ece9f1..b4adb4cdb52e0ff4a7b77d4d0b91baa7d1756978 100644 (file)
@@ -45,7 +45,7 @@ struct _ArtRgbaSVPAlphaData {
   art_u8 r, g, b, alpha;
   art_u8 *buf;
   int rowstride;
-  int x0, x1;
+  int libart_x0, libart_x1;
 };
 
 static void
@@ -56,15 +56,15 @@ art_rgba_svp_alpha_callback (void *callback_data, int y,
   art_u8 *linebuf;
   int run_x0, run_x1;
   art_u32 running_sum = start;
-  int x0, x1;
+  int libart_x0, libart_x1;
   int k;
   art_u8 r, g, b;
   int *alphatab;
   int alpha;
 
   linebuf = data->buf;
-  x0 = data->x0;
-  x1 = data->x1;
+  libart_x0 = data->libart_x0;
+  libart_x1 = data->libart_x1;
 
   r = data->r;
   g = data->g;
@@ -74,13 +74,13 @@ art_rgba_svp_alpha_callback (void *callback_data, int y,
   if (n_steps > 0)
     {
       run_x1 = steps[0].x;
-      if (run_x1 > x0)
+      if (run_x1 > libart_x0)
        {
          alpha = (running_sum >> 16) & 0xff;
          if (alpha)
            art_rgba_run_alpha (linebuf,
                               r, g, b, alphatab[alpha],
-                              run_x1 - x0);
+                              run_x1 - libart_x0);
        }
 
       /* render the steps into tmpbuf */
@@ -93,19 +93,19 @@ art_rgba_svp_alpha_callback (void *callback_data, int y,
            {
              alpha = (running_sum >> 16) & 0xff;
              if (alpha)
-               art_rgba_run_alpha (linebuf + (run_x0 - x0) * 4,
+               art_rgba_run_alpha (linebuf + (run_x0 - libart_x0) * 4,
                                   r, g, b, alphatab[alpha],
                                   run_x1 - run_x0);
            }
        }
       running_sum += steps[k].delta;
-      if (x1 > run_x1)
+      if (libart_x1 > run_x1)
        {
          alpha = (running_sum >> 16) & 0xff;
          if (alpha)
-           art_rgba_run_alpha (linebuf + (run_x1 - x0) * 4,
+           art_rgba_run_alpha (linebuf + (run_x1 - libart_x0) * 4,
                               r, g, b, alphatab[alpha],
-                              x1 - run_x1);
+                              libart_x1 - run_x1);
        }
     }
   else
@@ -114,7 +114,7 @@ art_rgba_svp_alpha_callback (void *callback_data, int y,
       if (alpha)
        art_rgba_run_alpha (linebuf,
                           r, g, b, alphatab[alpha],
-                          x1 - x0);
+                          libart_x1 - libart_x0);
     }
 
   data->buf += data->rowstride;
@@ -129,15 +129,15 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
   art_u8 *linebuf;
   int run_x0, run_x1;
   art_u32 running_sum = start;
-  int x0, x1;
+  int libart_x0, libart_x1;
   int k;
   art_u8 r, g, b;
   int *alphatab;
   int alpha;
 
   linebuf = data->buf;
-  x0 = data->x0;
-  x1 = data->x1;
+  libart_x0 = data->libart_x0;
+  libart_x1 = data->libart_x1;
 
   r = data->r;
   g = data->g;
@@ -147,7 +147,7 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
   if (n_steps > 0)
     {
       run_x1 = steps[0].x;
-      if (run_x1 > x0)
+      if (run_x1 > libart_x0)
        {
          alpha = running_sum >> 16;
          if (alpha)
@@ -155,11 +155,11 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
              if (alpha >= 255)
                art_rgba_fill_run (linebuf,
                                  r, g, b,
-                                 run_x1 - x0);
+                                 run_x1 - libart_x0);
              else
                art_rgba_run_alpha (linebuf,
                                   r, g, b, alphatab[alpha],
-                                  run_x1 - x0);
+                                  run_x1 - libart_x0);
            }
        }
 
@@ -175,30 +175,30 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
              if (alpha)
                {
                  if (alpha >= 255)
-                   art_rgba_fill_run (linebuf + (run_x0 - x0) * 4,
+                   art_rgba_fill_run (linebuf + (run_x0 - libart_x0) * 4,
                                      r, g, b,
                                      run_x1 - run_x0);
                  else
-                   art_rgba_run_alpha (linebuf + (run_x0 - x0) * 4,
+                   art_rgba_run_alpha (linebuf + (run_x0 - libart_x0) * 4,
                                       r, g, b, alphatab[alpha],
                                       run_x1 - run_x0);
                }
            }
        }
       running_sum += steps[k].delta;
-      if (x1 > run_x1)
+      if (libart_x1 > run_x1)
        {
          alpha = running_sum >> 16;
          if (alpha)
            {
              if (alpha >= 255)
-               art_rgba_fill_run (linebuf + (run_x1 - x0) * 4,
+               art_rgba_fill_run (linebuf + (run_x1 - libart_x0) * 4,
                                  r, g, b,
-                                 x1 - run_x1);
+                                 libart_x1 - run_x1);
              else
-               art_rgba_run_alpha (linebuf + (run_x1 - x0) * 4,
+               art_rgba_run_alpha (linebuf + (run_x1 - libart_x0) * 4,
                                   r, g, b, alphatab[alpha],
-                                  x1 - run_x1);
+                                  libart_x1 - run_x1);
            }
        }
     }
@@ -210,11 +210,11 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
          if (alpha >= 255)
            art_rgba_fill_run (linebuf,
                              r, g, b,
-                             x1 - x0);
+                             libart_x1 - libart_x0);
          else
            art_rgba_run_alpha (linebuf,
                               r, g, b, alphatab[alpha],
-                              x1 - x0);
+                              libart_x1 - libart_x0);
        }
     }
 
@@ -224,19 +224,19 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
 /**
  * gnome_print_art_rgba_svp_alpha: Alpha-composite sorted vector path over RGBA buffer.
  * @svp: The source sorted vector path.
- * @x0: Left coordinate of destination rectangle.
- * @y0: Top coordinate of destination rectangle.
- * @x1: Right coordinate of destination rectangle.
- * @y1: Bottom coordinate of destination rectangle.
+ * @libart_x0: Left coordinate of destination rectangle.
+ * @libart_y0: Top coordinate of destination rectangle.
+ * @libart_x1: Right coordinate of destination rectangle.
+ * @libart_y1: Bottom coordinate of destination rectangle.
  * @rgba: Color in 0xRRGGBBAA format.
  * @buf: Destination RGB buffer.
  * @rowstride: Rowstride of @buf buffer.
  * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing.
  *
  * Renders the shape specified with @svp over the @buf RGB buffer.
- * @x1 - @x0 specifies the width, and @y1 - @y0 specifies the height,
+ * @libart_x1 - @x0 specifies the width, and @libart_y1 - @libart_y0 specifies the height,
  * of the rectangle rendered. The new pixels are stored starting at
- * the first byte of @buf. Thus, the @x0 and @y0 parameters specify
+ * the first byte of @buf. Thus, the @x0 and @libart_y0 parameters specify
  * an offset within @svp, and may be tweaked as a way of doing
  * integer-pixel translations without fiddling with @svp itself.
  *
@@ -250,7 +250,7 @@ art_rgba_svp_alpha_opaque_callback (void *callback_data, int y,
  **/
 void
 gnome_print_art_rgba_svp_alpha (const ArtSVP *svp,
-                               int x0, int y0, int x1, int y1,
+                               int libart_x0, int libart_y0, int libart_x1, int libart_y1,
                                art_u32 rgba,
                                art_u8 *buf, int rowstride,
                                ArtAlphaGamma *alphagamma)
@@ -281,13 +281,13 @@ gnome_print_art_rgba_svp_alpha (const ArtSVP *svp,
 
   data.buf = buf;
   data.rowstride = rowstride;
-  data.x0 = x0;
-  data.x1 = x1;
+  data.libart_x0 = libart_x0;
+  data.libart_x1 = libart_x1;
   if (alpha == 255)
-    art_svp_render_aa (svp, x0, y0, x1, y1, art_rgba_svp_alpha_opaque_callback,
+    art_svp_render_aa (svp, libart_x0, libart_y0, libart_x1, libart_y1, art_rgba_svp_alpha_opaque_callback,
                       &data);
   else
-    art_svp_render_aa (svp, x0, y0, x1, y1, art_rgba_svp_alpha_callback, &data);
+    art_svp_render_aa (svp, libart_x0, libart_y0, libart_x1, libart_y1, art_rgba_svp_alpha_callback, &data);
 }
 
 static void
index faa9c916ccacc2a1d4f12cf9b85339d9154da2e3..a11e7f93b2e82b71bdb27b8d2c13d7f2785e28ec 100644 (file)
@@ -514,12 +514,12 @@ int           gfx_render_png (gfx_canvas_t *canvas,
     unsigned long pys_height = height * canvas->zoom;
     const int bytes_per_pixel = 4;
     unsigned long rowstride = pys_width*bytes_per_pixel; /* bytes per pixel */
-    art_u8 *buffer = art_new (art_u8, rowstride*pys_height);
+    
     /* fill that buffer with out background color */
-    gfx_color_t *buffp;
-    long i;
-    for (i=0,buffp=(gfx_color_t *)buffer;
-         i<pys_width*pys_height;
+    gfx_color_t *buffp = art_new (gfx_color_t, pys_width*pys_height);
+    art_u8 *buffer = (art_u8 *)buffp;
+    unsigned long i;
+    for (i=0;i<pys_width*pys_height;
         i++){
        *(buffp++)=background;
     }
@@ -528,26 +528,29 @@ int           gfx_render_png (gfx_canvas_t *canvas,
         switch (node->type) {
         case GFX_LINE:
         case GFX_AREA: {   
-            ArtVpath *vec,*pvec;
+            ArtVpath *vec;
             double dst[6];     
-            ArtSVP *svp,*svpt;
+            ArtSVP *svp;
             art_affine_scale(dst,canvas->zoom,canvas->zoom);
             vec = art_vpath_affine_transform(node->path,dst);
            if (node->closed_path)
                gfx_libart_close_path(node, &vec);
            /* gfx_round_scaled_coordinates(vec); */
             /* pvec = art_vpath_perturb(vec);
-           art_free(vec); */
+              art_free(vec); */
             if(node->type == GFX_LINE){
                 svp = art_svp_vpath_stroke ( vec, ART_PATH_STROKE_JOIN_ROUND,
                                              ART_PATH_STROKE_CAP_ROUND,
                                              node->size*canvas->zoom,4,0.25);
             } else {
                 svp  = art_svp_from_vpath ( vec );
-/*                svpt = art_svp_uncross( svp );
-                art_svp_free(svp);
-               svp  = art_svp_rewind_uncrossed(svpt,ART_WIND_RULE_NONZERO); 
-                art_svp_free(svpt);*/
+               /* this takes time and is unnecessary since we make
+                  sure elsewhere that the areas are going clock-whise */
+               /*  svpt = art_svp_uncross( svp );
+                    art_svp_free(svp);
+                   svp  = art_svp_rewind_uncrossed(svpt,ART_WIND_RULE_NONZERO); 
+                    art_svp_free(svpt);
+                 */
             }
             art_free(vec);
            /* this is from gnome since libart does not have this yet */
@@ -795,8 +798,9 @@ static int gfx_save_png (art_u8 *buffer, FILE *fp,  long width, long height, lon
   text[0].compression = PNG_TEXT_COMPRESSION_NONE;
   png_set_text (png_ptr, info_ptr, text, 1);
 
-  /* lets make this fast */
-  /* png_set_filter(png_ptr,0,PNG_FILTER_NONE); */
+  /* lets make this fast while ending up with some increass in image size */
+  png_set_filter(png_ptr,0,PNG_FILTER_NONE);
+  /* png_set_filter(png_ptr,0,PNG_FILTER_SUB); */
   png_set_compression_level(png_ptr,1);
   /* png_set_compression_strategy(png_ptr,Z_HUFFMAN_ONLY); */
   /* 
index e9c5c93569093c89c3497270f6091787b7b43012..e3c6025f6da95e2e2c3a6c394af8a7b492c85565 100644 (file)
@@ -8,9 +8,16 @@
 #define RRD_GFX_H
 #define LIBART_COMPILATION
 
+#define y0 libart_y0
+#define y1 libart_y1
+#define gamma libart_gamma
 #include <libart_lgpl/libart.h>
 #include <libart_lgpl/art_rgba.h>
 #include "art_rgba_svp.h"
+#undef gamma
+#undef y0
+#undef y1
+
 
 enum gfx_if_en {IF_PNG=0,IF_SVG,IF_EPS,IF_PDF};
 enum gfx_en { GFX_LINE=0,GFX_AREA,GFX_TEXT };