summaryrefslogtreecommitdiff
path: root/fb/fbpict.h
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@daimi.au.dk>2005-08-12 18:47:17 +0000
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>2005-08-12 18:47:17 +0000
commit1eed84f227311730ce1f9ffab190e95de967c7da (patch)
tree745829a5a8aec62d678bdb0bd036592d5f778070 /fb/fbpict.h
parent8bfffb96b552a3facb77ff9e81658e80becbf2f4 (diff)
Fri Aug 12 14:45:54 2005 Søren Sandmann <sandmann@redhat.com>
Fix up multiplications based on patch by Billy Biggs. Part of bug 3945.
Diffstat (limited to 'fb/fbpict.h')
-rw-r--r--fb/fbpict.h50
1 files changed, 27 insertions, 23 deletions
diff --git a/fb/fbpict.h b/fb/fbpict.h
index ab44bfa66..0e6a7f4ff 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -148,12 +148,12 @@
x_c = (x_c * a) / 255
*/
#define FbByteMul(x, a) do { \
- CARD32 t = (x & 0xff00ff) *a; \
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; \
+ CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
t &= 0xff00ff; \
\
- x = ((x >> 8) & 0xff00ff) * a; \
- x = (x + ((x >> 8) & 0xff00ff) + 0x800080); \
+ x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
+ x = (x + ((x >> 8) & 0xff00ff)); \
x &= 0xff00ff00; \
x += t; \
} while (0)
@@ -162,15 +162,15 @@
x_c = (x_c * a) / 255 + y
*/
#define FbByteMulAdd(x, a, y) do { \
- CARD32 t = (x & 0xff00ff) * a; \
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; \
+ CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
t &= 0xff00ff; \
t += y & 0xff00ff; \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
t &= 0xff00ff; \
\
- x = ((x >> 8) & 0xff00ff) * a; \
- x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8; \
+ x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
+ x = (x + ((x >> 8) & 0xff00ff)) >> 8; \
x &= 0xff00ff; \
x += (y >> 8) & 0xff00ff; \
x |= 0x1000100 - ((t >> 8) & 0xff00ff); \
@@ -184,8 +184,8 @@
*/
#define FbByteAddMul(x, a, y, b) do { \
CARD32 t; \
- CARD32 r = (x >> 24) * a + (y >> 24) * b; \
- r += (r >> 8) + 0x80; \
+ CARD32 r = (x >> 24) * a + (y >> 24) * b + 0x80; \
+ r += (r >> 8); \
r >>= 8; \
\
t = (x & 0xff00) * a + (y & 0xff00) * b; \
@@ -197,12 +197,12 @@
t &= 0xff00ff; \
t <<= 8; \
\
- r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b; \
- r += (r >> 8) + 0x80; \
+ r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80; \
+ r += (r >> 8); \
r >>= 8; \
\
- x = (x & 0xff) * a + (y & 0xff) * b; \
- x += (x >> 8) + 0x80; \
+ x = (x & 0xff) * a + (y & 0xff) * b + 0x80; \
+ x += (x >> 8); \
x >>= 8; \
x |= r << 16; \
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
@@ -229,13 +229,15 @@
CARD32 t; \
CARD32 r = (x & 0xff) * (a & 0xff); \
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
- r = (r + ((r >> 8) & 0xff00ff) + 0x800080) >> 8; \
+ r += 0x800080; \
+ r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
r &= 0xff00ff; \
\
x >>= 8; \
t = (x & 0xff) * ((a >> 8) & 0xff); \
t |= (x & 0xff0000) * (a >> 24); \
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080); \
+ t += 0x800080; \
+ t = t + ((t >> 8) & 0xff00ff); \
x = r | (t & 0xff00ff00); \
\
} while (0)
@@ -247,7 +249,8 @@
CARD32 t; \
CARD32 r = (x & 0xff) * (a & 0xff); \
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
- r = (r + ((r >> 8) & 0xff00ff) + 0x800080) >> 8; \
+ r += 0x800080; \
+ r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
r &= 0xff00ff; \
r += y & 0xff00ff; \
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
@@ -256,7 +259,8 @@
x >>= 8; \
t = (x & 0xff) * ((a >> 8) & 0xff); \
t |= (x & 0xff0000) * (a >> 24); \
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; \
+ t += 0x800080; \
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
t &= 0xff00ff; \
t += (y >> 8) & 0xff00ff; \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
@@ -282,12 +286,12 @@
t &= 0xff00ff; \
t <<= 8; \
\
- r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b; \
- r += (r >> 8) + 0x80; \
+ r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
+ r += (r >> 8); \
r >>= 8; \
\
- x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b; \
- x += (x >> 8) + 0x80; \
+ x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80; \
+ x += (x >> 8); \
x >>= 8; \
x |= r << 16; \
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
@@ -310,7 +314,7 @@
x = r; \
} while (0)
-#define div_255(x) (((x) + ((x) >> 8) + 0x80) >> 8)
+#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
#if defined(__i386__) && defined(__GNUC__)
#define FASTCALL __attribute__((regparm(3)))