diff options
author | David Schleef <ds@schleef.org> | 2009-11-23 14:27:36 -0800 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2011-05-17 10:22:05 -0700 |
commit | 76601d4676c99335a8bac64049868bd368ddc781 (patch) | |
tree | 260198bb76a4ee908ba12bbbdbb10e6600ed1656 /test | |
parent | 7407cd9402440ecec6e68afa2e8a2a41b6df58a4 (diff) |
Add atop operator
Diffstat (limited to 'test')
-rw-r--r-- | test/ds.c | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -18,6 +18,8 @@ #define COMPOSITE_ADD(d,s) ORC_CLAMP((d) + (s), 0, 255) #define COMPOSITE_IN(s,m) ORC_MULDIV_255((s),(m)) #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 ORC_DIVIDE_255(x) ((((x)+128) + (((x)+128)>>8))>>8) #define ORC_MULDIV_255(a,b) ORC_DIVIDE_255((a)*(b)) @@ -56,7 +58,7 @@ combine_mask (const uint32_t *src, const uint32_t *mask, int i) } void -combine_out_u (pixman_implementation_t *imp, +combine_atop_u (pixman_implementation_t *imp, pixman_op_t op, uint32_t * dest, const uint32_t * src, @@ -68,8 +70,11 @@ combine_out_u (pixman_implementation_t *imp, 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 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; } } @@ -119,18 +124,22 @@ int main (int argc, char *argv[]) mask[i]=ORC_ARGB(255,0,0,0); } - //combine_out_u (NULL, 0, dest, src, mask, 256); - combine_out_u (NULL, 0, dest_ref, src, NULL, 256); - orc_code_combine_out_u_n (dest, src, 256); + //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); #if 0 for(i=0;i<256;i++){ - int a = ORC_ARGB_A(dest[i]); + //int a = ORC_ARGB_A(dest[i]); dest[i] = ORC_ARGB( - COMPOSITE_OUT(ORC_ARGB_A(src[i]), a), - COMPOSITE_OUT(ORC_ARGB_R(src[i]), a), - COMPOSITE_OUT(ORC_ARGB_G(src[i]), a), - COMPOSITE_OUT(ORC_ARGB_B(src[i]), a)); + COMPOSITE_ATOP(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]), + ORC_ARGB_R(dest[i]), ORC_ARGB_A(src[i])), + COMPOSITE_ATOP(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]), + ORC_ARGB_B(dest[i]), ORC_ARGB_A(src[i]))); } #endif |