diff options
-rw-r--r-- | ext/gd/libgd/gd.c | 90 | ||||
-rw-r--r-- | ext/gd/libgd/gd.h | 17 |
2 files changed, 5 insertions, 102 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index df75054b3f..464f8d5b7a 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -93,7 +93,6 @@ extern int gdSinT[]; static void gdImageBrushApply(gdImagePtr im, int x, int y); static void gdImageTileApply(gdImagePtr im, int x, int y); -static void gdImageAntiAliasedApply(gdImagePtr im, int x, int y); static int gdLayerOverlay(int dst, int src); static int gdAlphaOverlayColor(int src, int dst, int max); int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y); @@ -139,7 +138,6 @@ gdImagePtr gdImageCreate (int sx, int sy) /* Row-major ever since gd 1.3 */ im->pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy); - im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy); im->polyInts = 0; im->polyAllocated = 0; im->brush = 0; @@ -148,7 +146,6 @@ gdImagePtr gdImageCreate (int sx, int sy) for (i = 0; i < sy; i++) { /* Row-major ever since gd 1.3 */ im->pixels[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char)); - im->AA_opacity[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char)); } im->sx = sx; im->sy = sy; @@ -157,7 +154,6 @@ gdImagePtr gdImageCreate (int sx, int sy) im->interlace = 0; im->thick = 1; im->AA = 0; - im->AA_polygon = 0; for (i = 0; i < gdMaxColors; i++) { im->open[i] = 1; im->red[i] = 0; @@ -197,7 +193,6 @@ gdImagePtr gdImageCreateTrueColor (int sx, int sy) im = (gdImage *) gdMalloc(sizeof(gdImage)); memset(im, 0, sizeof(gdImage)); im->tpixels = (int **) gdMalloc(sizeof(int *) * sy); - im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy); im->polyInts = 0; im->polyAllocated = 0; im->brush = 0; @@ -205,7 +200,6 @@ gdImagePtr gdImageCreateTrueColor (int sx, int sy) im->style = 0; for (i = 0; i < sy; i++) { im->tpixels[i] = (int *) gdCalloc(sx, sizeof(int)); - im->AA_opacity[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char)); } im->sx = sx; im->sy = sy; @@ -222,7 +216,6 @@ gdImagePtr gdImageCreateTrueColor (int sx, int sy) im->alphaBlendingFlag = 1; im->thick = 1; im->AA = 0; - im->AA_polygon = 0; im->cx1 = 0; im->cy1 = 0; im->cx2 = im->sx - 1; @@ -249,12 +242,6 @@ void gdImageDestroy (gdImagePtr im) } gdFree(im->tpixels); } - if (im->AA_opacity) { - for (i = 0; i < im->sy; i++) { - gdFree(im->AA_opacity[i]); - } - gdFree(im->AA_opacity); - } if (im->polyInts) { gdFree(im->polyInts); } @@ -760,7 +747,9 @@ void gdImageSetPixel (gdImagePtr im, int x, int y, int color) gdImageTileApply(im, x, y); break; case gdAntiAliased: - gdImageAntiAliasedApply(im, x, y); + /* This shouldn't happen (2.0.26) because we just call + gdImageAALine now, but do something sane. */ + gdImageSetPixel(im, x, y, im->AA_color); break; default: if (gdImageBoundsSafe(im, x, y)) { @@ -941,68 +930,6 @@ static int gdImageTileGet (gdImagePtr im, int x, int y) } -static void gdImageAntiAliasedApply (gdImagePtr im, int px, int py) -{ - float p_dist, p_alpha; - unsigned char opacity; - - /* - * Find the perpendicular distance from point C (px, py) to the line - * segment AB that is being drawn. (Adapted from an algorithm from the - * comp.graphics.algorithms FAQ.) - */ - - int LAC_2, LBC_2; - - int Ax_Cx = im->AAL_x1 - px; - int Ay_Cy = im->AAL_y1 - py; - - int Bx_Cx = im->AAL_x2 - px; - int By_Cy = im->AAL_y2 - py; - - /* 2.0.13: bounds check! AA_opacity is just as capable of - * overflowing as the main pixel array. Arne Jorgensen. - * 2.0.14: typo fixed. 2.0.15: moved down below declarations - * to satisfy non-C++ compilers. - */ - if (!gdImageBoundsSafe(im, px, py)) { - return; - } - - /* Get the squares of the lengths of the segemnts AC and BC. */ - LAC_2 = (Ax_Cx * Ax_Cx) + (Ay_Cy * Ay_Cy); - LBC_2 = (Bx_Cx * Bx_Cx) + (By_Cy * By_Cy); - - if (((im->AAL_LAB_2 + LAC_2) >= LBC_2) && ((im->AAL_LAB_2 + LBC_2) >= LAC_2)) { - /* The two angles are acute. The point lies inside the portion of the - * plane spanned by the line segment. - */ - p_dist = fabs ((float) ((Ay_Cy * im->AAL_Bx_Ax) - (Ax_Cx * im->AAL_By_Ay)) / im->AAL_LAB); - } else { - /* The point is past an end of the line segment. It's length from the - * segment is the shorter of the lengths from the endpoints, but call - * the distance -1, so as not to compute the alpha nor draw the pixel. - */ - p_dist = -1; - } - - if ((p_dist >= 0) && (p_dist <= (float) (im->thick))) { - p_alpha = pow (1.0 - (p_dist / 1.5), 2); - - if (p_alpha > 0) { - if (p_alpha >= 1) { - opacity = 255; - } else { - opacity = (unsigned char) (p_alpha * 255.0); - } - if (!im->AA_polygon || (im->AA_opacity[py][px] < opacity)) { - im->AA_opacity[py][px] = opacity; - } - } - } -} - - int gdImageGetPixel (gdImagePtr im, int x, int y) { if (gdImageBoundsSafe(im, x, y)) { @@ -2680,13 +2607,6 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c) return; } - /* Let it be known that we are drawing a polygon so that the opacity - * mask doesn't get cleared after each line. - */ - if (c == gdAntiAliased) { - im->AA_polygon = 1; - } - if ( im->antialias) { draw_line = gdImageAALine; } else { @@ -2701,10 +2621,6 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c) lx = p->x; ly = p->y; } - - if (c == gdAntiAliased) { - im->AA_polygon = 0; - } } int gdCompareInt (const void *a, const void *b); diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h index 251dbfb0be..b56afd1a47 100644 --- a/ext/gd/libgd/gd.h +++ b/ext/gd/libgd/gd.h @@ -229,24 +229,11 @@ typedef struct gdImageStruct { have that capability. JPEG doesn't. */ int saveAlphaFlag; - - /* 2.0.12: anti-aliased globals */ + /* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after + switching to the fast, memory-cheap implementation from PHP-gd. */ int AA; int AA_color; int AA_dont_blend; - unsigned char **AA_opacity; - int AA_polygon; - /* Stored and pre-computed variables for determining the perpendicular - * distance from a point to the anti-aliased line being drawn: - */ - int AAL_x1; - int AAL_y1; - int AAL_x2; - int AAL_y2; - int AAL_Bx_Ax; - int AAL_By_Ay; - int AAL_LAB_2; - float AAL_LAB; /* 2.0.12: simple clipping rectangle. These values must be checked for safety when set; please use gdImageSetClip */ int cx1; |