From: Nuno Lopes Date: Fri, 15 Jun 2007 19:50:05 +0000 (+0000) Subject: MFB: sync with libgd: improve _gdImageFillTiled() X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~446 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5da2f6e7de096ef5cbb14564380873492449e76d;p=php MFB: sync with libgd: improve _gdImageFillTiled() --- diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 30e0d78e2d..8e154182c4 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1941,7 +1941,7 @@ struct seg {int y, xl, xr, dy;}; #define FILL_POP(Y, XL, XR, DY) \ {sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;} -void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc); +static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc); void gdImageFill(gdImagePtr im, int x, int y, int nc) { @@ -2042,16 +2042,16 @@ done: im->alphaBlendingFlag = alphablending_bak; } -void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) +static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) { - int i,l, x1, x2, dy; + int l, x1, x2, dy; int oc; /* old pixel value */ int tiled; int wx2,wy2; /* stack of filled segments */ struct seg *stack; struct seg *sp; - char **pts; + char *pts; if (!im->tile) { return; @@ -2061,11 +2061,7 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (char **) ecalloc(im->sy, sizeof(char*)); - - for (i=0; isy;i++) { - pts[i] = (char *) ecalloc(im->sx, sizeof(char)); - } + pts = (char *) ecalloc(im->sy * im->sx, sizeof(char)); stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1); sp = stack; @@ -2078,9 +2074,9 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) FILL_PUSH(y+1, x, x, -1); while (sp>stack) { FILL_POP(y, x1, x2, dy); - for (x=x1; x>=0 && (!pts[y][x] && gdImageGetPixel(im,x,y)==oc); x--) { + for (x=x1; x>=0 && (!pts[y + x*wx2] && gdImageGetPixel(im,x,y)==oc); x--) { nc = gdImageTileGet(im,x,y); - pts[y][x]=1; + pts[y + x*wx2]=1; gdImageSetPixel(im,x, y, nc); } if (x>=x1) { @@ -2094,9 +2090,9 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) } x = x1+1; do { - for (; xx2+1) { FILL_PUSH(y, x2+1, x-1, -dy); } -skip: for (x++; x<=x2 && (pts[y][x] || gdImageGetPixel(im,x, y)!=oc); x++); +skip: for (x++; x<=x2 && (pts[y + x*wx2] || gdImageGetPixel(im,x, y)!=oc); x++); l = x; } while (x<=x2); } - for (i=0; isy;i++) { - efree(pts[i]); - } + efree(pts); efree(stack); }