summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2009-11-23 14:37:40 -0800
committerDavid Schleef <ds@schleef.org>2011-05-17 10:22:05 -0700
commitf5cf1c6c6c73f2068843dec2d5cdf47857f7d766 (patch)
tree580734b4be76441851c36f166f6486b33ad16b6c /test
parent76601d4676c99335a8bac64049868bd368ddc781 (diff)
Add xor operator
Diffstat (limited to 'test')
-rw-r--r--test/ds.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/test/ds.c b/test/ds.c
index 936d130..7e41ea0 100644
--- a/test/ds.c
+++ b/test/ds.c
@@ -20,6 +20,8 @@
#define COMPOSITE_OUT(s,m) (ORC_MULDIV_255((s),(255-m)))
#define COMPOSITE_ATOP(s,da,d,sa) \
(ORC_DIVIDE_255((s)*(da))+ORC_DIVIDE_255((d)*(255-(sa))))
+#define COMPOSITE_XOR(s,da,d,sa) \
+ (ORC_DIVIDE_255((s)*(255-da))+ORC_DIVIDE_255((d)*(255-(sa))))
#define ORC_DIVIDE_255(x) ((((x)+128) + (((x)+128)>>8))>>8)
#define ORC_MULDIV_255(a,b) ORC_DIVIDE_255((a)*(b))
@@ -58,7 +60,7 @@ combine_mask (const uint32_t *src, const uint32_t *mask, int i)
}
void
-combine_atop_u (pixman_implementation_t *imp,
+combine_xor_u (pixman_implementation_t *imp,
pixman_op_t op,
uint32_t * dest,
const uint32_t * src,
@@ -71,10 +73,10 @@ combine_atop_u (pixman_implementation_t *imp,
{
uint32_t s = combine_mask (src, mask, i);
uint32_t d = *(dest + i);
- uint32_t dest_a = ALPHA_8 (d);
uint32_t src_ia = ALPHA_8 (~s);
+ uint32_t dest_ia = ALPHA_8 (~d);
- UN8x4_MUL_UN8_ADD_UN8x4_MUL_UN8 (s, dest_a, d, src_ia);
+ UN8x4_MUL_UN8_ADD_UN8x4_MUL_UN8 (s, dest_ia, d, src_ia);
*(dest + i) = s;
}
}
@@ -124,25 +126,34 @@ int main (int argc, char *argv[])
mask[i]=ORC_ARGB(255,0,0,0);
}
- //combine_atop_u (NULL, 0, dest, src, mask, 256);
- combine_atop_u (NULL, 0, dest_ref, src, NULL, 256);
- orc_code_combine_atop_u_n (dest, src, 256);
+ //combine_xor_u (NULL, 0, dest, src, mask, 256);
+ combine_xor_u (NULL, 0, dest_ref, src, NULL, 256);
+ //orc_code_combine_xor_u_n (dest, src, 256);
-#if 0
+#if 1
for(i=0;i<256;i++){
- //int a = ORC_ARGB_A(dest[i]);
dest[i] = ORC_ARGB(
- COMPOSITE_ATOP(ORC_ARGB_A(src[i]), ORC_ARGB_A(dest[i]),
+ COMPOSITE_XOR(ORC_ARGB_A(src[i]), ORC_ARGB_A(dest[i]),
ORC_ARGB_A(dest[i]), ORC_ARGB_A(src[i])),
- COMPOSITE_ATOP(ORC_ARGB_R(src[i]), ORC_ARGB_A(dest[i]),
+ COMPOSITE_XOR(ORC_ARGB_R(src[i]), ORC_ARGB_A(dest[i]),
ORC_ARGB_R(dest[i]), ORC_ARGB_A(src[i])),
- COMPOSITE_ATOP(ORC_ARGB_G(src[i]), ORC_ARGB_A(dest[i]),
+ COMPOSITE_XOR(ORC_ARGB_G(src[i]), ORC_ARGB_A(dest[i]),
ORC_ARGB_G(dest[i]), ORC_ARGB_A(src[i])),
- COMPOSITE_ATOP(ORC_ARGB_B(src[i]), ORC_ARGB_A(dest[i]),
+ COMPOSITE_XOR(ORC_ARGB_B(src[i]), ORC_ARGB_A(dest[i]),
ORC_ARGB_B(dest[i]), ORC_ARGB_A(src[i])));
}
#endif
+#if 0
+ COMPOSITE_XOR(ORC_ARGB_A(src[i]), ORC_ARGB_A(dest[i]),
+ ORC_ARGB_A(dest[i]), ORC_ARGB_A(src[i])),
+ COMPOSITE_XOR(ORC_ARGB_R(src[i]), ORC_ARGB_A(dest[i]),
+ ORC_ARGB_R(dest[i]), ORC_ARGB_A(src[i])),
+ COMPOSITE_XOR(ORC_ARGB_G(src[i]), ORC_ARGB_A(dest[i]),
+ ORC_ARGB_G(dest[i]), ORC_ARGB_A(src[i])),
+ COMPOSITE_XOR(ORC_ARGB_B(src[i]), ORC_ARGB_A(dest[i]),
+ ORC_ARGB_B(dest[i]), ORC_ARGB_A(src[i])));
+#endif
for(i=0;i<256;i++){
printf("%02x %02x %02x %02x %02x %02x %02x %02x -> "