diff options
-rw-r--r-- | pixman/pixman-orc.c | 17 | ||||
-rw-r--r-- | pixman/pixman-orccode.orc | 17 | ||||
-rw-r--r-- | test/ds.c | 31 |
3 files changed, 53 insertions, 12 deletions
diff --git a/pixman/pixman-orc.c b/pixman/pixman-orc.c index f9dd886..c9ccb08 100644 --- a/pixman/pixman-orc.c +++ b/pixman/pixman-orc.c @@ -97,6 +97,21 @@ orc_combine_out_u (pixman_implementation_t *imp, } } +static void +orc_combine_atop_u (pixman_implementation_t *imp, + pixman_op_t op, + uint32_t * dst, + const uint32_t * src, + const uint32_t * mask, + int width) +{ + if (mask) { + orc_code_combine_atop_u (dst, src, mask, width); + } else { + orc_code_combine_atop_u_n (dst, src, width); + } +} + pixman_bool_t pixman_fill_orc (uint32_t *bits, @@ -482,7 +497,7 @@ _pixman_implementation_create_orc (void) //imp->combine_32[PIXMAN_OP_IN_REVERSE] = orc_combine_in_reverse_u; imp->combine_32[PIXMAN_OP_OUT] = orc_combine_out_u; //imp->combine_32[PIXMAN_OP_OUT_REVERSE] = orc_combine_out_reverse_u; - //imp->combine_32[PIXMAN_OP_ATOP] = orc_combine_atop_u; + imp->combine_32[PIXMAN_OP_ATOP] = orc_combine_atop_u; //imp->combine_32[PIXMAN_OP_ATOP_REVERSE] = orc_combine_atop_reverse_u; //imp->combine_32[PIXMAN_OP_XOR] = orc_combine_xor_u; imp->combine_32[PIXMAN_OP_ADD] = orc_combine_add_u; diff --git a/pixman/pixman-orccode.orc b/pixman/pixman-orccode.orc index 88d7291..f101a11 100644 --- a/pixman/pixman-orccode.orc +++ b/pixman/pixman-orccode.orc @@ -138,3 +138,20 @@ compout d1, d1, t1 compout d1, d1, s1 +.function orc_code_combine_atop_u +.dest 4 d1 +.source 4 s1 +.source 4 s2 +.temp 4 t1 + +compin t1, s1, s2 +compatop d1, d1, t1 + + +.function orc_code_combine_atop_u_n +.dest 4 d1 +.source 4 s1 + +compatop d1, d1, s1 + + @@ -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 |