? pixman/src/attachment.cgi?id=3062 Index: pixman/ChangeLog =================================================================== RCS file: /cvs/cairo/cairo/pixman/ChangeLog,v retrieving revision 1.114 diff -u -p -r1.114 ChangeLog --- pixman/ChangeLog 22 Aug 2005 19:15:28 -0000 1.114 +++ pixman/ChangeLog 27 Aug 2005 23:06:31 -0000 @@ -1,3 +1,17 @@ +2005-08-27 Owen Taylor + + * src/fbmmx.c src/fbmmx.h (fbCompositeSrc_8888xnx8888mmx) + (fbCompositeSrc_x888xnx8888mmx): Rename from + 8888x8x8888mmx, 8888xnx8888mmx; fix to be able to handle + arbitrary mask formats. + + * src/fbmmx.c (fbCompositeSrc_8888xnx8888mmx) fbpict.c: Fix various + bugs, clean up unused variable. Renable in the master fbpict.c + switch. + + * src/fbmmx.c src/fbmmx.h src/fbpict.c (fbCompositeSrc_8888x8x8888mmx): + Add a case for (argb32 IN a8) OVER argb32. + 2005-08-22 Owen Taylor * src/pixregion.c (pixman_region_union_rect): When width/height Index: pixman/src/fbmmx.c =================================================================== RCS file: /cvs/cairo/cairo/pixman/src/fbmmx.c,v retrieving revision 1.3 diff -u -p -r1.3 fbmmx.c --- pixman/src/fbmmx.c 19 Aug 2005 02:13:06 -0000 1.3 +++ pixman/src/fbmmx.c 27 Aug 2005 23:06:31 -0000 @@ -172,6 +172,12 @@ expand_alpha_rev (__m64 pixel) } static __inline__ __m64 +expand_alpha_byte (CARD8 byte) +{ + return _mm_shuffle_pi16 (_mm_cvtsi32_si64 (byte), _MM_SHUFFLE(0, 0, 0, 0)); +} + +static __inline__ __m64 invert_colors (__m64 pixel) { return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 0, 1, 2)); @@ -211,6 +217,18 @@ expand_alpha_rev (__m64 pixel) } static __inline__ __m64 +expand_alpha_byte (CARD8 byte) +{ + __m64 t1, t2, t3; + + t1 = _mm_cvtsi32_si64 (byte); + t2 = _mm_or_si64 (t1, shift (t1, 16)); + t3 = _mm_or_si64 (t2, shift (t2, 32)); + + return t3; +} + +static __inline__ __m64 invert_colors (__m64 pixel) { __m64 x, y, z; @@ -1131,7 +1149,7 @@ fbCompositeSolidMask_nx8888x8888Cmmx (pi } void -fbCompositeSrc_8888x8x8888mmx (pixman_operator_t op, +fbCompositeSrc_8888xnx8888mmx (pixman_operator_t op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, @@ -1146,22 +1164,23 @@ fbCompositeSrc_8888x8x8888mmx (pixman_op { CARD32 *dstLine, *dst; CARD32 *srcLine, *src; - CARD8 *maskLine; - CARD32 mask; + FbBits maskPixel; + CARD8 maskAlpha; + CARD32 mask; __m64 vmask; - FbStride dstStride, srcStride, maskStride; + FbStride dstStride, srcStride; CARD16 w; - __m64 srca; CHECKPOINT(); fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - mask = *maskLine << 24 | *maskLine << 16 | *maskLine << 8 | *maskLine; + fbComposeGetSolid (pMask, maskPixel); + maskAlpha = maskPixel >> 24; + + mask = maskAlpha << 24 | maskAlpha << 16 | maskAlpha << 8 | maskAlpha; vmask = load8888 (mask); - srca = MC(4x00ff); while (height--) { @@ -1176,7 +1195,7 @@ fbCompositeSrc_8888x8x8888mmx (pixman_op __m64 s = load8888 (*src); __m64 d = load8888 (*dst); - *dst = store8888 (over (s, expand_alpha (s), d)); + *dst = store8888 (in_over (s, expand_alpha (s), vmask, d)); w--; dst++; @@ -1185,8 +1204,8 @@ fbCompositeSrc_8888x8x8888mmx (pixman_op while (w >= 2) { - __m64 vs = *(__m64 *)dst; - __m64 vd = *(__m64 *)src; + __m64 vs = *(__m64 *)src; + __m64 vd = *(__m64 *)dst; __m64 vsrc0 = expand8888 (vs, 0); __m64 vsrc1 = expand8888 (vs, 1); @@ -1216,7 +1235,7 @@ fbCompositeSrc_8888x8x8888mmx (pixman_op } void -fbCompositeSrc_x888x8x8888mmx (pixman_operator_t op, +fbCompositeSrc_8888x8x8888mmx (pixman_operator_t op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, @@ -1231,11 +1250,99 @@ fbCompositeSrc_x888x8x8888mmx (pixman_op { CARD32 *dstLine, *dst; CARD32 *srcLine, *src; - CARD8 *maskLine; - CARD32 mask; - __m64 vmask; + CARD8 *maskLine, *mask; FbStride dstStride, srcStride, maskStride; CARD16 w; + + CHECKPOINT(); + + fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); + fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); + fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); + + while (height--) + { + dst = dstLine; + dstLine += dstStride; + src = srcLine; + srcLine += srcStride; + mask = maskLine; + maskLine += maskStride; + w = width; + + while (w && (unsigned long)dst & 7) + { + __m64 s = load8888 (*src); + __m64 d = load8888 (*dst); + __m64 m = expand_alpha_byte (*mask); + + *dst = store8888 (in_over (s, expand_alpha (s), m, d)); + + w--; + dst++; + src++; + mask++; + } + + while (w >= 2) + { + __m64 vs = *(__m64 *)src; + __m64 vd = *(__m64 *)dst; + __m64 vsrc0 = expand8888 (vs, 0); + __m64 vsrc1 = expand8888 (vs, 1); + __m64 m0 = expand_alpha_byte (mask[0]); + __m64 m1 = expand_alpha_byte (mask[1]); + + *(__m64 *)dst = (__m64)pack8888 ( + in_over (vsrc0, expand_alpha (vsrc0), m0, expand8888 (vd, 0)), + in_over (vsrc1, expand_alpha (vsrc1), m1, expand8888 (vd, 1))); + + w -= 2; + dst += 2; + src += 2; + mask += 2; + } + + while (w) + { + __m64 s = load8888 (*src); + __m64 d = load8888 (*dst); + __m64 m = expand_alpha_byte (*mask); + + *dst = store8888 (in_over (s, expand_alpha (s), m, d)); + + w--; + dst++; + src++; + mask++; + } + } + + _mm_empty(); +} + +void +fbCompositeSrc_x888xnx8888mmx (pixman_operator_t op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + CARD32 *dstLine, *dst; + CARD32 *srcLine, *src; + FbBits maskPixel; + CARD8 maskAlpha; + CARD32 mask; + __m64 vmask; + FbStride dstStride, srcStride; + CARD16 w; __m64 srca; CHECKPOINT(); @@ -1244,7 +1351,10 @@ fbCompositeSrc_x888x8x8888mmx (pixman_op fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - mask = *maskLine << 24 | *maskLine << 16 | *maskLine << 8 | *maskLine; + fbComposeGetSolid (pMask, maskPixel); + maskAlpha = maskPixel >> 24; + + mask = maskAlpha << 24 | maskAlpha << 16 | maskAlpha << 8 | maskAlpha; vmask = load8888 (mask); srca = MC(4x00ff); Index: pixman/src/fbmmx.h =================================================================== RCS file: /cvs/cairo/cairo/pixman/src/fbmmx.h,v retrieving revision 1.2 diff -u -p -r1.2 fbmmx.h --- pixman/src/fbmmx.h 19 Aug 2005 02:13:06 -0000 1.2 +++ pixman/src/fbmmx.h 27 Aug 2005 23:06:31 -0000 @@ -174,7 +174,7 @@ void fbCompositeSolidMask_nx8x0565mmx (p INT16 yDst, CARD16 width, CARD16 height); -void fbCompositeSrc_x888x8x8888mmx (pixman_operator_t op, +void fbCompositeSrc_x888xnx8888mmx (pixman_operator_t op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, @@ -198,6 +198,18 @@ void fbCompositeSrc_8888x8x8888mmx (pixm INT16 yDst, CARD16 width, CARD16 height); +void fbCompositeSrc_8888xnx8888mmx (pixman_operator_t op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); void fbCompositeSrc_8888x8888mmx (pixman_operator_t op, PicturePtr pSrc, PicturePtr pMask, Index: pixman/src/fbpict.c =================================================================== RCS file: /cvs/cairo/cairo/pixman/src/fbpict.c,v retrieving revision 1.4 diff -u -p -r1.4 fbpict.c --- pixman/src/fbpict.c 22 Aug 2005 03:49:47 -0000 1.4 +++ pixman/src/fbpict.c 27 Aug 2005 23:06:31 -0000 @@ -1591,13 +1591,12 @@ pixman_composite (pixman_operator_t op, } break; } - else - { - /* non-repeating source, repeating mask => translucent window */ - if (maskRepeat && - pMask->pDrawable->width == 1 && - pMask->pDrawable->height == 1) + else if (maskRepeat && + pMask->pDrawable->width == 1 && + pMask->pDrawable->height == 1) { + /* non-repeating source, repeating mask => translucent window */ + switch (pSrc->format_code) { case PICT_r5g6b5: case PICT_b5g6r5: @@ -1616,19 +1615,15 @@ pixman_composite (pixman_operator_t op, pMask->format_code == PICT_a8 && fbHaveMMX()) func = fbCompositeSrc_x888x8x8888mmx; break; -#if 0 /* This case fails rendercheck for me */ case PICT_a8r8g8b8: - if ((pDst->format == PICT_a8r8g8b8 || - pDst->format == PICT_x8r8g8b8) && - pMask->format == PICT_a8 && fbHaveMMX()) - func = fbCompositeSrc_8888x8x8888mmx; + if ((pDst->format_code == PICT_a8r8g8b8 || + pDst->format_code == PICT_x8r8g8b8) && fbHaveMMX()) + func = fbCompositeSrc_8888xnx8888mmx; break; -#endif case PICT_a8b8g8r8: if ((pDst->format_code == PICT_a8b8g8r8 || - pDst->format_code == PICT_x8b8g8r8) && - pMask->format_code == PICT_a8 && fbHaveMMX()) - func = fbCompositeSrc_8888x8x8888mmx; + pDst->format_code == PICT_x8b8g8r8) && fbHaveMMX()) + func = fbCompositeSrc_8888xnx8888mmx; break; #endif } @@ -1636,7 +1631,25 @@ pixman_composite (pixman_operator_t op, if (func != pixman_compositeGeneral) maskRepeat = FALSE; } +#ifdef USE_MMX + else + { + switch (pSrc->format_code) { + case PICT_a8r8g8b8: + if ((pDst->format_code == PICT_a8r8g8b8 || + pDst->format_code == PICT_x8r8g8b8) && + pMask->format_code == PICT_a8 && fbHaveMMX()) + func = fbCompositeSrc_8888x8x8888mmx; + break; + case PICT_a8b8g8r8: + if ((pDst->format_code == PICT_a8b8g8r8 || + pDst->format_code == PICT_x8b8g8r8) && + pMask->format_code == PICT_a8 && fbHaveMMX()) + func = fbCompositeSrc_8888x8x8888mmx; + break; + } } +#endif } } else /* no mask */