From: Christoph M. Becker Date: Thu, 15 Sep 2016 11:18:54 +0000 (+0200) Subject: Port optimization from external libgd X-Git-Tag: php-7.2.0alpha1~1254 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba2b50d097569381f98b306c932e240cd50cbb3d;p=php Port optimization from external libgd The functionality is identical, but we save two function calls for partially transparent pixels. --- diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index 6de314e971..f91fcf738c 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -626,6 +626,7 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, { unsigned char *pixel = NULL; int *tpixel = NULL; + int opixel; int x, y, row, col, pc, pcr; tweencolor_t *tc_elem; @@ -683,7 +684,13 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, } } else { if (im->alphaBlendingFlag) { - *tpixel = gdAlphaBlend(*tpixel, (level << 24) + (fg & 0xFFFFFF)); + opixel = *tpixel; + if (gdTrueColorGetAlpha(opixel) != gdAlphaTransparent) { + *tpixel = gdAlphaBlend (opixel, + (level << 24) + (fg & 0xFFFFFF)); + } else { + *tpixel = (level << 24) + (fg & 0xFFFFFF); + } } else { *tpixel = (level << 24) + (fg & 0xFFFFFF); }