Replace them with inline functions in pixman-bits-image.c.
const uint8_t *pixel = (const uint8_t *)bits + 3*x;
const uint8_t *end = pixel + 3*width;
while (pixel < end) {
- uint32_t b = Fetch24(pict, pixel) | 0xff000000;
- pixel += 3;
+ uint32_t b = 0xff000000;
+#ifdef WORDS_BIGENDIAN
+ b |= (READ(pict, pixel++) << 16);
+ b |= (READ(pict, pixel++) << 8);
+ b |= (READ(pict, pixel++));
+#else
+ b |= (READ(pict, pixel++));
+ b |= (READ(pict, pixel++) << 8);
+ b |= (READ(pict, pixel++) << 16);
+#endif
*buffer++ = b;
}
}
{
int i;
uint8_t *pixel = ((uint8_t *) bits) + 3*x;
- for (i = 0; i < width; ++i) {
- Store24(image, pixel, values[i]);
- pixel += 3;
+ for (i = 0; i < width; ++i)
+ {
+ uint32_t val = values[i];
+#ifdef WORDS_BIGENDIAN
+ WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
+ WRITE(image, pixel++, (val & 0x0000ff00) >> 8);
+ WRITE(image, pixel++, (val & 0x000000ff) >> 0);
+#else
+ WRITE(image, pixel++, (val & 0x000000ff) >> 0);
+ WRITE(image, pixel++, (val & 0x0000ff00) >> 8);
+ WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
+#endif
}
}
{
int i;
uint8_t *pixel = ((uint8_t *) bits) + 3*x;
- for (i = 0; i < width; ++i) {
+ for (i = 0; i < width; ++i)
+ {
uint32_t val = values[i];
#ifdef WORDS_BIGENDIAN
WRITE(image, pixel++, (val & 0x000000ff) >> 0);
#include "pixman-combine32.h"
static force_inline uint32_t
+Fetch24 (uint8_t *a)
+{
+ if (((unsigned long)a) & 1)
+ {
+#ifdef WORDS_BIGENDIAN
+ return (*a << 16) | (*(uint16_t *)(a + 1));
+#else
+ return *a | (*(uint16_t *)(a + 1) << 8);
+#endif
+ }
+ else
+ {
+#ifdef WORDS_BIGENDIAN
+ return (*(uint16_t *)a << 8) | *(a + 2);
+#else
+ return *(uint16_t *)a | (*(a + 2) << 16);
+#endif
+ }
+}
+
+static force_inline void
+Store24 (uint8_t *a, uint32_t v)
+{
+ if (((unsigned long)a) & 1)
+ {
+#ifdef WORDS_BIGENDIAN
+ *a = (uint8_t) (v >> 16);
+ *(uint16_t *)(a + 1) = (uint16_t) (v);
+#else
+ *a = (uint8_t) (v);
+ *(uint16_t *)(a + 1) = (uint16_t) (v >> 8);
+#endif
+ }
+ else
+ {
+#ifdef WORDS_BIGENDIAN
+ *(uint16_t *)a = (uint16_t)(v >> 8)
+ *(a + 2) = (uint8_t)v;
+#else
+ *(uint16_t *)a = (uint16_t)v;
+ *(a + 2) = (uint8_t)(v >> 16);
+#endif
+ }
+}
+
+static force_inline uint32_t
fbOver (uint32_t src, uint32_t dest)
{
- // dest = (dest * (255 - alpha)) / 255 + src
- uint32_t a = ~src >> 24; // 255 - alpha == 255 + (~alpha + 1) == ~alpha
+ uint32_t a = ~src >> 24;
+
FbByteMulAdd(dest, a, src);
return dest;
d = src;
else
{
- d = Fetch24(pDst, dst);
+ d = Fetch24(dst);
d = fbOver24 (src, d);
}
- Store24(pDst, dst,d);
+ Store24(dst, d);
}
else if (m)
{
- d = fbOver24 (fbIn(src,m), Fetch24(pDst, dst));
- Store24(pDst, dst, d);
+ d = fbOver24 (fbIn(src,m), Fetch24(dst));
+ Store24(dst, d);
}
dst += 3;
}
if (a == 0xff)
d = s;
else
- d = fbOver24 (s, Fetch24(pDst, dst));
- Store24(pDst, dst, d);
+ d = fbOver24 (s, Fetch24(dst));
+
+ Store24(dst, d);
}
dst += 3;
}
_pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
pixman_fixed_32_32_t x);
-
-
-#ifdef WORDS_BIGENDIAN
-#define Fetch24(img, a) ((unsigned long) (a) & 1 ? \
- ((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \
- ((READ(img, (uint16_t *) (a)) << 8) | READ(img, (a)+2)))
-#define Store24(img,a,v) ((unsigned long) (a) & 1 ? \
- (WRITE(img, a, (uint8_t) ((v) >> 16)), \
- WRITE(img, (uint16_t *) ((a)+1), (uint16_t) (v))) : \
- (WRITE(img, (uint16_t *) (a), (uint16_t) ((v) >> 8)), \
- WRITE(img, (a)+2, (uint8_t) (v))))
-#else
-#define Fetch24(img,a) ((unsigned long) (a) & 1 ? \
- (READ(img, a) | (READ(img, (uint16_t *) ((a)+1)) << 8)) : \
- (READ(img, (uint16_t *) (a)) | (READ(img, (a)+2) << 16)))
-#define Store24(img,a,v) ((unsigned long) (a) & 1 ? \
- (WRITE(img, a, (uint8_t) (v)), \
- WRITE(img, (uint16_t *) ((a)+1), (uint16_t) ((v) >> 8))) : \
- (WRITE(img, (uint16_t *) (a), (uint16_t) (v)), \
- WRITE(img, (a)+2, (uint8_t) ((v) >> 16))))
-#endif
-
#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
#define FbIntDiv(a,b) (((uint16_t) (a) * 255) / (b))