summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2010-08-07 17:57:22 -0700
committerDavid Schleef <ds@schleef.org>2011-05-17 10:23:01 -0700
commit2d5fbcdf55bcd49f03b48e70b42ecf664a3492f8 (patch)
tree1ae53881fa16ebfadce5d605e0d9dfab6d3939c7 /test
parent63bbdef0ca2c7b6f67a673b07c35de5a82a92248 (diff)
update for current orc
Diffstat (limited to 'test')
-rw-r--r--test/ds.c108
1 files changed, 78 insertions, 30 deletions
diff --git a/test/ds.c b/test/ds.c
index 24a0ee9..d16d98b 100644
--- a/test/ds.c
+++ b/test/ds.c
@@ -38,6 +38,8 @@
#define randu8() (random()&0xff)
+#define static
+
static uint32_t
combine_mask (const uint32_t *src, const uint32_t *mask, int i)
{
@@ -59,8 +61,46 @@ combine_mask (const uint32_t *src, const uint32_t *mask, int i)
return s;
}
+static void
+combine_add_u (pixman_implementation_t *imp,
+ pixman_op_t op,
+ uint32_t * dest,
+ const uint32_t * src,
+ const uint32_t * mask,
+ int width)
+{
+ int i;
+
+ for (i = 0; i < width; ++i)
+ {
+ uint32_t s = combine_mask (src, mask, i);
+ uint32_t d = *(dest + i);
+ UN8x4_ADD_UN8x4 (d, s);
+ *(dest + i) = d;
+ }
+}
+
void
-combine_xor_u (pixman_implementation_t *imp,
+combine_in_u (pixman_implementation_t *imp,
+ pixman_op_t op,
+ uint32_t * dest,
+ const uint32_t * src,
+ const uint32_t * mask,
+ int width)
+{
+ int i;
+
+ for (i = 0; i < width; ++i)
+ {
+ uint32_t s = combine_mask (src, mask, i);
+ uint32_t a = ALPHA_8 (*(dest + i));
+ UN8x4_MUL_UN8 (s, a);
+ *(dest + i) = s;
+ }
+}
+
+static void
+combine_over_u (pixman_implementation_t *imp,
pixman_op_t op,
uint32_t * dest,
const uint32_t * src,
@@ -73,22 +113,20 @@ combine_xor_u (pixman_implementation_t *imp,
{
uint32_t s = combine_mask (src, mask, i);
uint32_t d = *(dest + i);
- uint32_t src_ia = ALPHA_8 (~s);
- uint32_t dest_ia = ALPHA_8 (~d);
+ uint32_t ia = ALPHA_8 (~s);
- UN8x4_MUL_UN8_ADD_UN8x4_MUL_UN8 (s, dest_ia, d, src_ia);
- *(dest + i) = s;
+ UN8x4_MUL_UN8_ADD_UN8x4 (d, ia, s);
+ *(dest + i) = d;
}
}
-#if 0
static void
-combine_add_u (pixman_implementation_t *imp,
- pixman_op_t op,
- uint32_t * dest,
- const uint32_t * src,
- const uint32_t * mask,
- int width)
+combine_atop_u (pixman_implementation_t *imp,
+ pixman_op_t op,
+ uint32_t * dest,
+ const uint32_t * src,
+ const uint32_t * mask,
+ int width)
{
int i;
@@ -96,27 +134,32 @@ combine_add_u (pixman_implementation_t *imp,
{
uint32_t s = combine_mask (src, mask, i);
uint32_t d = *(dest + i);
- UN8x4_ADD_UN8x4 (d, s);
- *(dest + i) = d;
+ uint32_t dest_a = ALPHA_8 (d);
+ uint32_t src_ia = ALPHA_8 (~s);
+
+ UN8x4_MUL_UN8_ADD_UN8x4_MUL_UN8 (s, dest_a, d, src_ia);
+ *(dest + i) = s;
}
}
-#endif
static void
-combine_in_u (pixman_implementation_t *imp,
- pixman_op_t op,
- uint32_t * dest,
- const uint32_t * src,
- const uint32_t * mask,
- int width)
+combine_xor_u (pixman_implementation_t *imp,
+ pixman_op_t op,
+ uint32_t * dest,
+ const uint32_t * src,
+ const uint32_t * mask,
+ int width)
{
int i;
for (i = 0; i < width; ++i)
{
uint32_t s = combine_mask (src, mask, i);
- uint32_t a = ALPHA_8 (*(dest + i));
- UN8x4_MUL_UN8 (s, a);
+ uint32_t d = *(dest + i);
+ uint32_t src_ia = ALPHA_8 (~s);
+ uint32_t dest_ia = ALPHA_8 (~d);
+
+ UN8x4_MUL_UN8_ADD_UN8x4_MUL_UN8 (s, dest_ia, d, src_ia);
*(dest + i) = s;
}
}
@@ -151,8 +194,8 @@ int main (int argc, char *argv[])
orc_init();
for(i=0;i<256;i++){
- //dest_orig[i]=ORC_ARGB(255,0,0,255);
dest_orig[i]=rand_argb();
+ //dest_orig[i]=ORC_ARGB(0,0,0,255);
dest[i]=dest_orig[i];
dest_ref[i]=dest_orig[i];
}
@@ -163,13 +206,17 @@ int main (int argc, char *argv[])
}
for(i=0;i<256;i++){
- mask[i]=ORC_ARGB(255,0,0,0);
+ mask[i]=ORC_ARGB(i,0,0,0);
}
- //combine_xor_u (NULL, 0, dest, src, mask, 256);
- //combine_xor_u (NULL, 0, dest_ref, src, NULL, 256);
- combine_in_u (NULL, 0, dest_ref, src, NULL, 256);
- orc_code_combine_in_u_n (dest, src, 256);
+ //combine_add_u (NULL, 0, dest_ref, src, mask, 256);
+ //orc_code_combine_add_u (dest, src, mask, 256);
+
+ //combine_over_u (NULL, 0, dest_ref, src, mask, 256);
+ //orc_code_combine_over_u (dest, src, mask, 256);
+
+ combine_xor_u (NULL, 0, dest_ref, src, mask, 256);
+ orc_code_combine_xor_u (dest, src, mask, 256);
#if 0
for(i=0;i<256;i++){
@@ -197,7 +244,7 @@ int main (int argc, char *argv[])
#endif
for(i=0;i<256;i++){
- printf("%02x %02x %02x %02x %02x %02x %02x %02x -> "
+ printf("%02x %02x %02x %02x %02x %02x %02x %02x %02x -> "
"%02x %02x %02x %02x %02x %02x %02x %02x %s\n",
ORC_ARGB_A(dest_orig[i]),
ORC_ARGB_R(dest_orig[i]),
@@ -207,6 +254,7 @@ int main (int argc, char *argv[])
ORC_ARGB_R(src[i]),
ORC_ARGB_G(src[i]),
ORC_ARGB_B(src[i]),
+ ORC_ARGB_A(mask[i]),
ORC_ARGB_A(dest_ref[i]),
ORC_ARGB_R(dest_ref[i]),
ORC_ARGB_G(dest_ref[i]),