From 4a8e64cae3b5c62b7d866eb497dbe7d56273d7d8 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 7 May 2005 15:45:52 +0000 Subject: [PATCH] fix these annoying y0 warnings. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@501 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/art_rgba_svp.c | 74 +++++++++++++++++++++++++++--------------------------- src/rrd_gfx.c | 32 ++++++++++++----------- src/rrd_gfx.h | 7 ++++++ 3 files changed, 62 insertions(+), 51 deletions(-) diff --git a/src/art_rgba_svp.c b/src/art_rgba_svp.c index 81457d0..b4adb4c 100644 --- a/src/art_rgba_svp.c +++ b/src/art_rgba_svp.c @@ -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 diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index faa9c91..a11e7f9 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -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; - itype) { 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); */ /* diff --git a/src/rrd_gfx.h b/src/rrd_gfx.h index e9c5c93..e3c6025 100644 --- a/src/rrd_gfx.h +++ b/src/rrd_gfx.h @@ -8,9 +8,16 @@ #define RRD_GFX_H #define LIBART_COMPILATION +#define y0 libart_y0 +#define y1 libart_y1 +#define gamma libart_gamma #include #include #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 }; -- 2.11.0