diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2016-10-02 12:47:22 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2016-10-02 13:16:40 +0200 |
commit | d0f14a4429e36d8cb70d14067e79fd252eb4ee7a (patch) | |
tree | d7ad641bce7f6f82591614076546cc904b7339bf /ext/gd | |
parent | 1c74398520bebdce6f0aceb3e3ace00ec965a171 (diff) | |
download | php-git-d0f14a4429e36d8cb70d14067e79fd252eb4ee7a.tar.gz |
Switch to libgd anti-aliased drawing API
Instead of rolling our own in the bundled libgd, we use libgd's anti-aliased
drawing API. This way imageantialias() is also available, when built against
a system libgd.
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/gd.c | 23 | ||||
-rw-r--r-- | ext/gd/libgd/gd.c | 18 | ||||
-rw-r--r-- | ext/gd/libgd/gd.h | 2 | ||||
-rw-r--r-- | ext/gd/php_gd.h | 2 | ||||
-rw-r--r-- | ext/gd/tests/bug28147.phpt | 1 | ||||
-rw-r--r-- | ext/gd/tests/bug42434.phpt | 1 | ||||
-rw-r--r-- | ext/gd/tests/imageantialias_error1.phpt | 1 | ||||
-rw-r--r-- | ext/gd/tests/imageantialias_error2.phpt | 1 |
8 files changed, 11 insertions, 38 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index b726aab10c..6ff2a1c940 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -786,12 +786,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_imageflip, 0) ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -#ifdef HAVE_GD_BUNDLED ZEND_BEGIN_ARG_INFO(arginfo_imageantialias, 0) ZEND_ARG_INFO(0, im) ZEND_ARG_INFO(0, on) ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_INFO(arginfo_imagecrop, 0) ZEND_ARG_INFO(0, im) @@ -884,9 +882,7 @@ const zend_function_entry gd_functions[] = { PHP_FE(imagerotate, arginfo_imagerotate) PHP_FE(imageflip, arginfo_imageflip) -#ifdef HAVE_GD_BUNDLED PHP_FE(imageantialias, arginfo_imageantialias) -#endif PHP_FE(imagecrop, arginfo_imagecrop) PHP_FE(imagecropauto, arginfo_imagecropauto) PHP_FE(imagescale, arginfo_imagescale) @@ -3111,14 +3107,11 @@ PHP_FUNCTION(imageline) RETURN_FALSE; } -#ifdef HAVE_GD_BUNDLED - if (im->antialias) { - gdImageAALine(im, x1, y1, x2, y2, col); - } else -#endif - { - gdImageLine(im, x1, y1, x2, y2, col); + if (im->AA) { + gdImageSetAntiAliased(im, col); + col = gdAntiAliased; } + gdImageLine(im, x1, y1, x2, y2, col); RETURN_TRUE; } /* }}} */ @@ -3398,6 +3391,10 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) } } + if (im->AA) { + gdImageSetAntiAliased(im, col); + col = gdAntiAliased; + } if (filled) { gdImageFilledPolygon(im, points, npoints, col); } else { @@ -4601,7 +4598,6 @@ PHP_FUNCTION(imageflip) } /* }}} */ -#ifdef HAVE_GD_BUNDLED /* {{{ proto bool imageantialias(resource im, bool on) Should antialiased functions used or not*/ PHP_FUNCTION(imageantialias) @@ -4617,11 +4613,10 @@ PHP_FUNCTION(imageantialias) if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { RETURN_FALSE; } - gdImageAntialias(im, alias); + gdImageSetAntiAliased(im, 0); RETURN_TRUE; } /* }}} */ -#endif /* {{{ proto void imagecrop(resource im, array rect) Crop an image using the given coordinates and size, x, y, width and height. */ diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 3e742561a6..5c3593ed1b 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2608,24 +2608,17 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c) { int i; int lx, ly; - typedef void (*image_line)(gdImagePtr im, int x1, int y1, int x2, int y2, int color); - image_line draw_line; if (n <= 0) { return; } - if ( im->antialias) { - draw_line = gdImageAALine; - } else { - draw_line = gdImageLine; - } lx = p->x; ly = p->y; - draw_line(im, lx, ly, p[n - 1].x, p[n - 1].y, c); + gdImageLine(im, lx, ly, p[n - 1].x, p[n - 1].y, c); for (i = 1; i < n; i++) { p++; - draw_line(im, lx, ly, p->x, p->y, c); + gdImageLine(im, lx, ly, p->x, p->y, c); lx = p->x; ly = p->y; } @@ -2953,13 +2946,6 @@ void gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg) im->alphaBlendingFlag = alphaBlendingArg; } -void gdImageAntialias (gdImagePtr im, int antialias) -{ - if (im->trueColor){ - im->antialias = antialias; - } -} - void gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg) { im->saveAlphaFlag = saveAlphaArg; diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h index b56afd1a47..12832ded34 100644 --- a/ext/gd/libgd/gd.h +++ b/ext/gd/libgd/gd.h @@ -222,8 +222,6 @@ typedef struct gdImageStruct { To do that, build your image as a truecolor image, then quantize down to 8 bits. */ int alphaBlendingFlag; - /* Should antialias functions be used */ - int antialias; /* Should the alpha channel of the image be saved? This affects PNG at the moment; other future formats may also have that capability. JPEG doesn't. */ diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h index d2c4697322..0b35423f88 100644 --- a/ext/gd/php_gd.h +++ b/ext/gd/php_gd.h @@ -123,9 +123,7 @@ PHP_FUNCTION(imagerotate); PHP_FUNCTION(imageflip); -#ifdef HAVE_GD_BUNDLED PHP_FUNCTION(imageantialias); -#endif PHP_FUNCTION(imagecrop); PHP_FUNCTION(imagecropauto); diff --git a/ext/gd/tests/bug28147.phpt b/ext/gd/tests/bug28147.phpt index de5c9022ad..fc5f37c5a0 100644 --- a/ext/gd/tests/bug28147.phpt +++ b/ext/gd/tests/bug28147.phpt @@ -3,7 +3,6 @@ Bug #28147 (Crash with anti-aliased line) --SKIPIF-- <?php if (!extension_loaded('gd')) die("skip gd extension not available\n"); - if (!function_exists("imageantialias")) die("skip requires bundled GD library\n"); ?> --FILE-- <?php diff --git a/ext/gd/tests/bug42434.phpt b/ext/gd/tests/bug42434.phpt index bc0790ede4..cede1ac17f 100644 --- a/ext/gd/tests/bug42434.phpt +++ b/ext/gd/tests/bug42434.phpt @@ -5,7 +5,6 @@ Bug #42434 (ImageLine w/ antialias = 1px shorter) if (!extension_loaded('gd')) {
die('skip gd extension not available');
}
-if (!GD_BUNDLED) die("skip requires bundled GD library\n");
?>
--FILE--
<?php
diff --git a/ext/gd/tests/imageantialias_error1.phpt b/ext/gd/tests/imageantialias_error1.phpt index e9475e9571..53fe0cc66a 100644 --- a/ext/gd/tests/imageantialias_error1.phpt +++ b/ext/gd/tests/imageantialias_error1.phpt @@ -6,7 +6,6 @@ Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> --SKIPIF-- <?php if (!extension_loaded("gd")) die("skip GD not present"); -if (!GD_BUNDLED) die("skip requires bundled GD library\n"); ?> --FILE-- <?php diff --git a/ext/gd/tests/imageantialias_error2.phpt b/ext/gd/tests/imageantialias_error2.phpt index 64b0a60eba..8dad8bd115 100644 --- a/ext/gd/tests/imageantialias_error2.phpt +++ b/ext/gd/tests/imageantialias_error2.phpt @@ -6,7 +6,6 @@ Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> --SKIPIF-- <?php if (!extension_loaded("gd")) die("skip GD not present"); -if (!GD_BUNDLED) die("skip requires bundled GD library\n"); ?> --FILE-- <?php |