Write alpha map fetching with FbByteMul() instead of div_255()
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 23 Jun 2009 17:41:27 +0000 (13:41 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 23 Jun 2009 17:57:03 +0000 (13:57 -0400)
Delete the div_255/div_65535 macros.

pixman/pixman-bits-image.c
pixman/pixman-private.h

index 82a480b..797bf85 100644 (file)
@@ -29,8 +29,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include "pixman-private.h"
+#include "pixman-combine32.h"
 
-#define Alpha(x) ((x) >> 24)
 #define Red(x) (((x) >> 16) & 0xff)
 #define Green(x) (((x) >> 8) & 0xff)
 #define Blue(x) ((x) & 0xff)
@@ -171,14 +171,11 @@ bits_image_fetch_alpha_pixels (bits_image_t *image, uint32_t *buffer, int n_pixe
        for (j = 0; j < tmp_n_pixels; ++j)
        {
            int a = alpha_pixels[j] >> 24;
-           
-           buffer[i] =
-               (a << 24)                                       |
-               div_255 (Red (buffer[2 * i - j]) * a) << 16     |
-               div_255 (Green (buffer[2 * i - j]) * a) << 8    |
-               div_255 (Blue (buffer[2 * i - j]) * a);
-           
-           i++;
+           uint32_t p = buffer[2 * i - j] | 0xff000000;
+
+           FbByteMul (p, a);
+
+           buffer[i++] = p;
        }
     }
 }
index 501139f..a39b6c4 100644 (file)
@@ -319,8 +319,6 @@ _pixman_gradient_walker_pixel (pixman_gradient_walker_t       *walker,
 #define FbIntAdd(x,y,t) (                                              \
        (t) = x + y,                                                    \
        (uint32_t) (uint8_t) ((t) | (0 - ((t) >> 8))))
-#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
-#define div_65535(x) (((x) + 0x8000 + (((x) + 0x8000) >> 16)) >> 16)
 
 #define PIXMAN_FORMAT_16BPC(f) (PIXMAN_FORMAT_A(f) > 8 || \
                                 PIXMAN_FORMAT_R(f) > 8 || \