]> granicus.if.org Git - php/commitdiff
Port optimization from external libgd
authorChristoph M. Becker <cmbecker69@gmx.de>
Thu, 15 Sep 2016 11:18:54 +0000 (13:18 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Thu, 15 Sep 2016 11:24:43 +0000 (13:24 +0200)
The functionality is identical, but we save two function calls for partially
transparent pixels.

ext/gd/libgd/gdft.c

index 6de314e97100af0cdc1c1ec861ae917cb3a07257..f91fcf738c2c3593d00a4a1bd2f9b357be6553df 100644 (file)
@@ -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);
                                        }