michael@0: /* michael@0: * Copyright © 2004, 2005 Red Hat, Inc. michael@0: * Copyright © 2004 Nicholas Miell michael@0: * Copyright © 2005 Trolltech AS michael@0: * michael@0: * Permission to use, copy, modify, distribute, and sell this software and its michael@0: * documentation for any purpose is hereby granted without fee, provided that michael@0: * the above copyright notice appear in all copies and that both that michael@0: * copyright notice and this permission notice appear in supporting michael@0: * documentation, and that the name of Red Hat not be used in advertising or michael@0: * publicity pertaining to distribution of the software without specific, michael@0: * written prior permission. Red Hat makes no representations about the michael@0: * suitability of this software for any purpose. It is provided "as is" michael@0: * without express or implied warranty. michael@0: * michael@0: * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS michael@0: * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND michael@0: * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY michael@0: * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES michael@0: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN michael@0: * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING michael@0: * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS michael@0: * SOFTWARE. michael@0: * michael@0: * Author: Søren Sandmann (sandmann@redhat.com) michael@0: * Minor Improvements: Nicholas Miell (nmiell@gmail.com) michael@0: * MMX code paths for fbcompose.c by Lars Knoll (lars@trolltech.com) michael@0: * michael@0: * Based on work by Owen Taylor michael@0: */ michael@0: michael@0: #ifdef HAVE_CONFIG_H michael@0: #include michael@0: #endif michael@0: michael@0: #if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI michael@0: michael@0: #ifdef USE_LOONGSON_MMI michael@0: #include michael@0: #else michael@0: #include michael@0: #endif michael@0: #include "pixman-private.h" michael@0: #include "pixman-combine32.h" michael@0: #include "pixman-inlines.h" michael@0: michael@0: #define no_vERBOSE michael@0: michael@0: #ifdef VERBOSE michael@0: #define CHECKPOINT() error_f ("at %s %d\n", __FUNCTION__, __LINE__) michael@0: #else michael@0: #define CHECKPOINT() michael@0: #endif michael@0: michael@0: #if defined USE_ARM_IWMMXT && __GNUC__ == 4 && __GNUC_MINOR__ < 8 michael@0: /* Empty the multimedia state. For some reason, ARM's mmintrin.h doesn't provide this. */ michael@0: extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) michael@0: _mm_empty (void) michael@0: { michael@0: michael@0: } michael@0: #endif michael@0: michael@0: #ifdef USE_X86_MMX michael@0: # if (defined(__SUNPRO_C) || defined(_MSC_VER) || defined(_WIN64)) michael@0: # include michael@0: # else michael@0: /* We have to compile with -msse to use xmmintrin.h, but that causes SSE michael@0: * instructions to be generated that we don't want. Just duplicate the michael@0: * functions we want to use. */ michael@0: extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) michael@0: _mm_movemask_pi8 (__m64 __A) michael@0: { michael@0: int ret; michael@0: michael@0: asm ("pmovmskb %1, %0\n\t" michael@0: : "=r" (ret) michael@0: : "y" (__A) michael@0: ); michael@0: michael@0: return ret; michael@0: } michael@0: michael@0: extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) michael@0: _mm_mulhi_pu16 (__m64 __A, __m64 __B) michael@0: { michael@0: asm ("pmulhuw %1, %0\n\t" michael@0: : "+y" (__A) michael@0: : "y" (__B) michael@0: ); michael@0: return __A; michael@0: } michael@0: michael@0: # ifdef __OPTIMIZE__ michael@0: extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) michael@0: _mm_shuffle_pi16 (__m64 __A, int8_t const __N) michael@0: { michael@0: __m64 ret; michael@0: michael@0: asm ("pshufw %2, %1, %0\n\t" michael@0: : "=y" (ret) michael@0: : "y" (__A), "K" (__N) michael@0: ); michael@0: michael@0: return ret; michael@0: } michael@0: # else michael@0: # define _mm_shuffle_pi16(A, N) \ michael@0: ({ \ michael@0: __m64 ret; \ michael@0: \ michael@0: asm ("pshufw %2, %1, %0\n\t" \ michael@0: : "=y" (ret) \ michael@0: : "y" (A), "K" ((const int8_t)N) \ michael@0: ); \ michael@0: \ michael@0: ret; \ michael@0: }) michael@0: # endif michael@0: # endif michael@0: #endif michael@0: michael@0: #ifndef _MSC_VER michael@0: #define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \ michael@0: (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | (fp0)) michael@0: #endif michael@0: michael@0: /* Notes about writing mmx code michael@0: * michael@0: * give memory operands as the second operand. If you give it as the michael@0: * first, gcc will first load it into a register, then use that michael@0: * register michael@0: * michael@0: * ie. use michael@0: * michael@0: * _mm_mullo_pi16 (x, mmx_constant); michael@0: * michael@0: * not michael@0: * michael@0: * _mm_mullo_pi16 (mmx_constant, x); michael@0: * michael@0: * Also try to minimize dependencies. i.e. when you need a value, try michael@0: * to calculate it from a value that was calculated as early as michael@0: * possible. michael@0: */ michael@0: michael@0: /* --------------- MMX primitives ------------------------------------- */ michael@0: michael@0: /* If __m64 is defined as a struct or union, then define M64_MEMBER to be michael@0: * the name of the member used to access the data. michael@0: * If __m64 requires using mm_cvt* intrinsics functions to convert between michael@0: * uint64_t and __m64 values, then define USE_CVT_INTRINSICS. michael@0: * If __m64 and uint64_t values can just be cast to each other directly, michael@0: * then define USE_M64_CASTS. michael@0: * If __m64 is a double datatype, then define USE_M64_DOUBLE. michael@0: */ michael@0: #ifdef _MSC_VER michael@0: # define M64_MEMBER m64_u64 michael@0: #elif defined(__ICC) michael@0: # define USE_CVT_INTRINSICS michael@0: #elif defined(USE_LOONGSON_MMI) michael@0: # define USE_M64_DOUBLE michael@0: #elif defined(__GNUC__) michael@0: # define USE_M64_CASTS michael@0: #elif defined(__SUNPRO_C) michael@0: # if (__SUNPRO_C >= 0x5120) && !defined(__NOVECTORSIZE__) michael@0: /* Solaris Studio 12.3 (Sun C 5.12) introduces __attribute__(__vector_size__) michael@0: * support, and defaults to using it to define __m64, unless __NOVECTORSIZE__ michael@0: * is defined. If it is used, then the mm_cvt* intrinsics must be used. michael@0: */ michael@0: # define USE_CVT_INTRINSICS michael@0: # else michael@0: /* For Studio 12.2 or older, or when __attribute__(__vector_size__) is michael@0: * disabled, __m64 is defined as a struct containing "unsigned long long l_". michael@0: */ michael@0: # define M64_MEMBER l_ michael@0: # endif michael@0: #endif michael@0: michael@0: #if defined(USE_M64_CASTS) || defined(USE_CVT_INTRINSICS) || defined(USE_M64_DOUBLE) michael@0: typedef uint64_t mmxdatafield; michael@0: #else michael@0: typedef __m64 mmxdatafield; michael@0: #endif michael@0: michael@0: typedef struct michael@0: { michael@0: mmxdatafield mmx_4x00ff; michael@0: mmxdatafield mmx_4x0080; michael@0: mmxdatafield mmx_565_rgb; michael@0: mmxdatafield mmx_565_unpack_multiplier; michael@0: mmxdatafield mmx_565_pack_multiplier; michael@0: mmxdatafield mmx_565_r; michael@0: mmxdatafield mmx_565_g; michael@0: mmxdatafield mmx_565_b; michael@0: mmxdatafield mmx_packed_565_rb; michael@0: mmxdatafield mmx_packed_565_g; michael@0: mmxdatafield mmx_expand_565_g; michael@0: mmxdatafield mmx_expand_565_b; michael@0: mmxdatafield mmx_expand_565_r; michael@0: #ifndef USE_LOONGSON_MMI michael@0: mmxdatafield mmx_mask_0; michael@0: mmxdatafield mmx_mask_1; michael@0: mmxdatafield mmx_mask_2; michael@0: mmxdatafield mmx_mask_3; michael@0: #endif michael@0: mmxdatafield mmx_full_alpha; michael@0: mmxdatafield mmx_4x0101; michael@0: mmxdatafield mmx_ff000000; michael@0: } mmx_data_t; michael@0: michael@0: #if defined(_MSC_VER) michael@0: # define MMXDATA_INIT(field, val) { val ## UI64 } michael@0: #elif defined(M64_MEMBER) /* __m64 is a struct, not an integral type */ michael@0: # define MMXDATA_INIT(field, val) field = { val ## ULL } michael@0: #else /* mmxdatafield is an integral type */ michael@0: # define MMXDATA_INIT(field, val) field = val ## ULL michael@0: #endif michael@0: michael@0: static const mmx_data_t c = michael@0: { michael@0: MMXDATA_INIT (.mmx_4x00ff, 0x00ff00ff00ff00ff), michael@0: MMXDATA_INIT (.mmx_4x0080, 0x0080008000800080), michael@0: MMXDATA_INIT (.mmx_565_rgb, 0x000001f0003f001f), michael@0: MMXDATA_INIT (.mmx_565_unpack_multiplier, 0x0000008404100840), michael@0: MMXDATA_INIT (.mmx_565_pack_multiplier, 0x2000000420000004), michael@0: MMXDATA_INIT (.mmx_565_r, 0x000000f800000000), michael@0: MMXDATA_INIT (.mmx_565_g, 0x0000000000fc0000), michael@0: MMXDATA_INIT (.mmx_565_b, 0x00000000000000f8), michael@0: MMXDATA_INIT (.mmx_packed_565_rb, 0x00f800f800f800f8), michael@0: MMXDATA_INIT (.mmx_packed_565_g, 0x0000fc000000fc00), michael@0: MMXDATA_INIT (.mmx_expand_565_g, 0x07e007e007e007e0), michael@0: MMXDATA_INIT (.mmx_expand_565_b, 0x001f001f001f001f), michael@0: MMXDATA_INIT (.mmx_expand_565_r, 0xf800f800f800f800), michael@0: #ifndef USE_LOONGSON_MMI michael@0: MMXDATA_INIT (.mmx_mask_0, 0xffffffffffff0000), michael@0: MMXDATA_INIT (.mmx_mask_1, 0xffffffff0000ffff), michael@0: MMXDATA_INIT (.mmx_mask_2, 0xffff0000ffffffff), michael@0: MMXDATA_INIT (.mmx_mask_3, 0x0000ffffffffffff), michael@0: #endif michael@0: MMXDATA_INIT (.mmx_full_alpha, 0x00ff000000000000), michael@0: MMXDATA_INIT (.mmx_4x0101, 0x0101010101010101), michael@0: MMXDATA_INIT (.mmx_ff000000, 0xff000000ff000000), michael@0: }; michael@0: michael@0: #ifdef USE_CVT_INTRINSICS michael@0: # define MC(x) to_m64 (c.mmx_ ## x) michael@0: #elif defined(USE_M64_CASTS) michael@0: # define MC(x) ((__m64)c.mmx_ ## x) michael@0: #elif defined(USE_M64_DOUBLE) michael@0: # define MC(x) (*(__m64 *)&c.mmx_ ## x) michael@0: #else michael@0: # define MC(x) c.mmx_ ## x michael@0: #endif michael@0: michael@0: static force_inline __m64 michael@0: to_m64 (uint64_t x) michael@0: { michael@0: #ifdef USE_CVT_INTRINSICS michael@0: return _mm_cvtsi64_m64 (x); michael@0: #elif defined M64_MEMBER /* __m64 is a struct, not an integral type */ michael@0: __m64 res; michael@0: michael@0: res.M64_MEMBER = x; michael@0: return res; michael@0: #elif defined USE_M64_DOUBLE michael@0: return *(__m64 *)&x; michael@0: #else /* USE_M64_CASTS */ michael@0: return (__m64)x; michael@0: #endif michael@0: } michael@0: michael@0: static force_inline uint64_t michael@0: to_uint64 (__m64 x) michael@0: { michael@0: #ifdef USE_CVT_INTRINSICS michael@0: return _mm_cvtm64_si64 (x); michael@0: #elif defined M64_MEMBER /* __m64 is a struct, not an integral type */ michael@0: uint64_t res = x.M64_MEMBER; michael@0: return res; michael@0: #elif defined USE_M64_DOUBLE michael@0: return *(uint64_t *)&x; michael@0: #else /* USE_M64_CASTS */ michael@0: return (uint64_t)x; michael@0: #endif michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: shift (__m64 v, michael@0: int s) michael@0: { michael@0: if (s > 0) michael@0: return _mm_slli_si64 (v, s); michael@0: else if (s < 0) michael@0: return _mm_srli_si64 (v, -s); michael@0: else michael@0: return v; michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: negate (__m64 mask) michael@0: { michael@0: return _mm_xor_si64 (mask, MC (4x00ff)); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: pix_multiply (__m64 a, __m64 b) michael@0: { michael@0: __m64 res; michael@0: michael@0: res = _mm_mullo_pi16 (a, b); michael@0: res = _mm_adds_pu16 (res, MC (4x0080)); michael@0: res = _mm_mulhi_pu16 (res, MC (4x0101)); michael@0: michael@0: return res; michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: pix_add (__m64 a, __m64 b) michael@0: { michael@0: return _mm_adds_pu8 (a, b); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: expand_alpha (__m64 pixel) michael@0: { michael@0: return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE (3, 3, 3, 3)); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: expand_alpha_rev (__m64 pixel) michael@0: { michael@0: return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE (0, 0, 0, 0)); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: invert_colors (__m64 pixel) michael@0: { michael@0: return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE (3, 0, 1, 2)); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: over (__m64 src, michael@0: __m64 srca, michael@0: __m64 dest) michael@0: { michael@0: return _mm_adds_pu8 (src, pix_multiply (dest, negate (srca))); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: over_rev_non_pre (__m64 src, __m64 dest) michael@0: { michael@0: __m64 srca = expand_alpha (src); michael@0: __m64 srcfaaa = _mm_or_si64 (srca, MC (full_alpha)); michael@0: michael@0: return over (pix_multiply (invert_colors (src), srcfaaa), srca, dest); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: in (__m64 src, __m64 mask) michael@0: { michael@0: return pix_multiply (src, mask); michael@0: } michael@0: michael@0: #ifndef _MSC_VER michael@0: static force_inline __m64 michael@0: in_over (__m64 src, __m64 srca, __m64 mask, __m64 dest) michael@0: { michael@0: return over (in (src, mask), pix_multiply (srca, mask), dest); michael@0: } michael@0: michael@0: #else michael@0: michael@0: #define in_over(src, srca, mask, dest) \ michael@0: over (in (src, mask), pix_multiply (srca, mask), dest) michael@0: michael@0: #endif michael@0: michael@0: /* Elemental unaligned loads */ michael@0: michael@0: static force_inline __m64 ldq_u(__m64 *p) michael@0: { michael@0: #ifdef USE_X86_MMX michael@0: /* x86's alignment restrictions are very relaxed. */ michael@0: return *(__m64 *)p; michael@0: #elif defined USE_ARM_IWMMXT michael@0: int align = (uintptr_t)p & 7; michael@0: __m64 *aligned_p; michael@0: if (align == 0) michael@0: return *p; michael@0: aligned_p = (__m64 *)((uintptr_t)p & ~7); michael@0: return (__m64) _mm_align_si64 (aligned_p[0], aligned_p[1], align); michael@0: #else michael@0: struct __una_u64 { __m64 x __attribute__((packed)); }; michael@0: const struct __una_u64 *ptr = (const struct __una_u64 *) p; michael@0: return (__m64) ptr->x; michael@0: #endif michael@0: } michael@0: michael@0: static force_inline uint32_t ldl_u(const uint32_t *p) michael@0: { michael@0: #ifdef USE_X86_MMX michael@0: /* x86's alignment restrictions are very relaxed. */ michael@0: return *p; michael@0: #else michael@0: struct __una_u32 { uint32_t x __attribute__((packed)); }; michael@0: const struct __una_u32 *ptr = (const struct __una_u32 *) p; michael@0: return ptr->x; michael@0: #endif michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: load (const uint32_t *v) michael@0: { michael@0: #ifdef USE_LOONGSON_MMI michael@0: __m64 ret; michael@0: asm ("lwc1 %0, %1\n\t" michael@0: : "=f" (ret) michael@0: : "m" (*v) michael@0: ); michael@0: return ret; michael@0: #else michael@0: return _mm_cvtsi32_si64 (*v); michael@0: #endif michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: load8888 (const uint32_t *v) michael@0: { michael@0: #ifdef USE_LOONGSON_MMI michael@0: return _mm_unpacklo_pi8_f (*(__m32 *)v, _mm_setzero_si64 ()); michael@0: #else michael@0: return _mm_unpacklo_pi8 (load (v), _mm_setzero_si64 ()); michael@0: #endif michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: load8888u (const uint32_t *v) michael@0: { michael@0: uint32_t l = ldl_u (v); michael@0: return load8888 (&l); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: pack8888 (__m64 lo, __m64 hi) michael@0: { michael@0: return _mm_packs_pu16 (lo, hi); michael@0: } michael@0: michael@0: static force_inline void michael@0: store (uint32_t *dest, __m64 v) michael@0: { michael@0: #ifdef USE_LOONGSON_MMI michael@0: asm ("swc1 %1, %0\n\t" michael@0: : "=m" (*dest) michael@0: : "f" (v) michael@0: : "memory" michael@0: ); michael@0: #else michael@0: *dest = _mm_cvtsi64_si32 (v); michael@0: #endif michael@0: } michael@0: michael@0: static force_inline void michael@0: store8888 (uint32_t *dest, __m64 v) michael@0: { michael@0: v = pack8888 (v, _mm_setzero_si64 ()); michael@0: store (dest, v); michael@0: } michael@0: michael@0: static force_inline pixman_bool_t michael@0: is_equal (__m64 a, __m64 b) michael@0: { michael@0: #ifdef USE_LOONGSON_MMI michael@0: /* __m64 is double, we can compare directly. */ michael@0: return a == b; michael@0: #else michael@0: return _mm_movemask_pi8 (_mm_cmpeq_pi8 (a, b)) == 0xff; michael@0: #endif michael@0: } michael@0: michael@0: static force_inline pixman_bool_t michael@0: is_opaque (__m64 v) michael@0: { michael@0: #ifdef USE_LOONGSON_MMI michael@0: return is_equal (_mm_and_si64 (v, MC (full_alpha)), MC (full_alpha)); michael@0: #else michael@0: __m64 ffs = _mm_cmpeq_pi8 (v, v); michael@0: return (_mm_movemask_pi8 (_mm_cmpeq_pi8 (v, ffs)) & 0x40); michael@0: #endif michael@0: } michael@0: michael@0: static force_inline pixman_bool_t michael@0: is_zero (__m64 v) michael@0: { michael@0: return is_equal (v, _mm_setzero_si64 ()); michael@0: } michael@0: michael@0: /* Expand 16 bits positioned at @pos (0-3) of a mmx register into michael@0: * michael@0: * 00RR00GG00BB michael@0: * michael@0: * --- Expanding 565 in the low word --- michael@0: * michael@0: * m = (m << (32 - 3)) | (m << (16 - 5)) | m; michael@0: * m = m & (01f0003f001f); michael@0: * m = m * (008404100840); michael@0: * m = m >> 8; michael@0: * michael@0: * Note the trick here - the top word is shifted by another nibble to michael@0: * avoid it bumping into the middle word michael@0: */ michael@0: static force_inline __m64 michael@0: expand565 (__m64 pixel, int pos) michael@0: { michael@0: __m64 p = pixel; michael@0: __m64 t1, t2; michael@0: michael@0: /* move pixel to low 16 bit and zero the rest */ michael@0: #ifdef USE_LOONGSON_MMI michael@0: p = loongson_extract_pi16 (p, pos); michael@0: #else michael@0: p = shift (shift (p, (3 - pos) * 16), -48); michael@0: #endif michael@0: michael@0: t1 = shift (p, 36 - 11); michael@0: t2 = shift (p, 16 - 5); michael@0: michael@0: p = _mm_or_si64 (t1, p); michael@0: p = _mm_or_si64 (t2, p); michael@0: p = _mm_and_si64 (p, MC (565_rgb)); michael@0: michael@0: pixel = _mm_mullo_pi16 (p, MC (565_unpack_multiplier)); michael@0: return _mm_srli_pi16 (pixel, 8); michael@0: } michael@0: michael@0: /* Expand 4 16 bit pixels in an mmx register into two mmx registers of michael@0: * michael@0: * AARRGGBBRRGGBB michael@0: */ michael@0: static force_inline void michael@0: expand_4xpacked565 (__m64 vin, __m64 *vout0, __m64 *vout1, int full_alpha) michael@0: { michael@0: __m64 t0, t1, alpha = _mm_setzero_si64 (); michael@0: __m64 r = _mm_and_si64 (vin, MC (expand_565_r)); michael@0: __m64 g = _mm_and_si64 (vin, MC (expand_565_g)); michael@0: __m64 b = _mm_and_si64 (vin, MC (expand_565_b)); michael@0: if (full_alpha) michael@0: alpha = _mm_cmpeq_pi32 (alpha, alpha); michael@0: michael@0: /* Replicate high bits into empty low bits. */ michael@0: r = _mm_or_si64 (_mm_srli_pi16 (r, 8), _mm_srli_pi16 (r, 13)); michael@0: g = _mm_or_si64 (_mm_srli_pi16 (g, 3), _mm_srli_pi16 (g, 9)); michael@0: b = _mm_or_si64 (_mm_slli_pi16 (b, 3), _mm_srli_pi16 (b, 2)); michael@0: michael@0: r = _mm_packs_pu16 (r, _mm_setzero_si64 ()); /* 00 00 00 00 R3 R2 R1 R0 */ michael@0: g = _mm_packs_pu16 (g, _mm_setzero_si64 ()); /* 00 00 00 00 G3 G2 G1 G0 */ michael@0: b = _mm_packs_pu16 (b, _mm_setzero_si64 ()); /* 00 00 00 00 B3 B2 B1 B0 */ michael@0: michael@0: t1 = _mm_unpacklo_pi8 (r, alpha); /* A3 R3 A2 R2 A1 R1 A0 R0 */ michael@0: t0 = _mm_unpacklo_pi8 (b, g); /* G3 B3 G2 B2 G1 B1 G0 B0 */ michael@0: michael@0: *vout0 = _mm_unpacklo_pi16 (t0, t1); /* A1 R1 G1 B1 A0 R0 G0 B0 */ michael@0: *vout1 = _mm_unpackhi_pi16 (t0, t1); /* A3 R3 G3 B3 A2 R2 G2 B2 */ michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: expand8888 (__m64 in, int pos) michael@0: { michael@0: if (pos == 0) michael@0: return _mm_unpacklo_pi8 (in, _mm_setzero_si64 ()); michael@0: else michael@0: return _mm_unpackhi_pi8 (in, _mm_setzero_si64 ()); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: expandx888 (__m64 in, int pos) michael@0: { michael@0: return _mm_or_si64 (expand8888 (in, pos), MC (full_alpha)); michael@0: } michael@0: michael@0: static force_inline void michael@0: expand_4x565 (__m64 vin, __m64 *vout0, __m64 *vout1, __m64 *vout2, __m64 *vout3, int full_alpha) michael@0: { michael@0: __m64 v0, v1; michael@0: expand_4xpacked565 (vin, &v0, &v1, full_alpha); michael@0: *vout0 = expand8888 (v0, 0); michael@0: *vout1 = expand8888 (v0, 1); michael@0: *vout2 = expand8888 (v1, 0); michael@0: *vout3 = expand8888 (v1, 1); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: pack_565 (__m64 pixel, __m64 target, int pos) michael@0: { michael@0: __m64 p = pixel; michael@0: __m64 t = target; michael@0: __m64 r, g, b; michael@0: michael@0: r = _mm_and_si64 (p, MC (565_r)); michael@0: g = _mm_and_si64 (p, MC (565_g)); michael@0: b = _mm_and_si64 (p, MC (565_b)); michael@0: michael@0: #ifdef USE_LOONGSON_MMI michael@0: r = shift (r, -(32 - 8)); michael@0: g = shift (g, -(16 - 3)); michael@0: b = shift (b, -(0 + 3)); michael@0: michael@0: p = _mm_or_si64 (r, g); michael@0: p = _mm_or_si64 (p, b); michael@0: return loongson_insert_pi16 (t, p, pos); michael@0: #else michael@0: r = shift (r, -(32 - 8) + pos * 16); michael@0: g = shift (g, -(16 - 3) + pos * 16); michael@0: b = shift (b, -(0 + 3) + pos * 16); michael@0: michael@0: if (pos == 0) michael@0: t = _mm_and_si64 (t, MC (mask_0)); michael@0: else if (pos == 1) michael@0: t = _mm_and_si64 (t, MC (mask_1)); michael@0: else if (pos == 2) michael@0: t = _mm_and_si64 (t, MC (mask_2)); michael@0: else if (pos == 3) michael@0: t = _mm_and_si64 (t, MC (mask_3)); michael@0: michael@0: p = _mm_or_si64 (r, t); michael@0: p = _mm_or_si64 (g, p); michael@0: michael@0: return _mm_or_si64 (b, p); michael@0: #endif michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: pack_4xpacked565 (__m64 a, __m64 b) michael@0: { michael@0: __m64 rb0 = _mm_and_si64 (a, MC (packed_565_rb)); michael@0: __m64 rb1 = _mm_and_si64 (b, MC (packed_565_rb)); michael@0: michael@0: __m64 t0 = _mm_madd_pi16 (rb0, MC (565_pack_multiplier)); michael@0: __m64 t1 = _mm_madd_pi16 (rb1, MC (565_pack_multiplier)); michael@0: michael@0: __m64 g0 = _mm_and_si64 (a, MC (packed_565_g)); michael@0: __m64 g1 = _mm_and_si64 (b, MC (packed_565_g)); michael@0: michael@0: t0 = _mm_or_si64 (t0, g0); michael@0: t1 = _mm_or_si64 (t1, g1); michael@0: michael@0: t0 = shift(t0, -5); michael@0: #ifdef USE_ARM_IWMMXT michael@0: t1 = shift(t1, -5); michael@0: return _mm_packs_pu32 (t0, t1); michael@0: #else michael@0: t1 = shift(t1, -5 + 16); michael@0: return _mm_shuffle_pi16 (_mm_or_si64 (t0, t1), _MM_SHUFFLE (3, 1, 2, 0)); michael@0: #endif michael@0: } michael@0: michael@0: #ifndef _MSC_VER michael@0: michael@0: static force_inline __m64 michael@0: pack_4x565 (__m64 v0, __m64 v1, __m64 v2, __m64 v3) michael@0: { michael@0: return pack_4xpacked565 (pack8888 (v0, v1), pack8888 (v2, v3)); michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b) michael@0: { michael@0: x = pix_multiply (x, a); michael@0: y = pix_multiply (y, b); michael@0: michael@0: return pix_add (x, y); michael@0: } michael@0: michael@0: #else michael@0: michael@0: /* MSVC only handles a "pass by register" of up to three SSE intrinsics */ michael@0: michael@0: #define pack_4x565(v0, v1, v2, v3) \ michael@0: pack_4xpacked565 (pack8888 (v0, v1), pack8888 (v2, v3)) michael@0: michael@0: #define pix_add_mul(x, a, y, b) \ michael@0: ( x = pix_multiply (x, a), \ michael@0: y = pix_multiply (y, b), \ michael@0: pix_add (x, y) ) michael@0: michael@0: #endif michael@0: michael@0: /* --------------- MMX code patch for fbcompose.c --------------------- */ michael@0: michael@0: static force_inline __m64 michael@0: combine (const uint32_t *src, const uint32_t *mask) michael@0: { michael@0: __m64 vsrc = load8888 (src); michael@0: michael@0: if (mask) michael@0: { michael@0: __m64 m = load8888 (mask); michael@0: michael@0: m = expand_alpha (m); michael@0: vsrc = pix_multiply (vsrc, m); michael@0: } michael@0: michael@0: return vsrc; michael@0: } michael@0: michael@0: static force_inline __m64 michael@0: core_combine_over_u_pixel_mmx (__m64 vsrc, __m64 vdst) michael@0: { michael@0: vsrc = _mm_unpacklo_pi8 (vsrc, _mm_setzero_si64 ()); michael@0: michael@0: if (is_opaque (vsrc)) michael@0: { michael@0: return vsrc; michael@0: } michael@0: else if (!is_zero (vsrc)) michael@0: { michael@0: return over (vsrc, expand_alpha (vsrc), michael@0: _mm_unpacklo_pi8 (vdst, _mm_setzero_si64 ())); michael@0: } michael@0: michael@0: return _mm_unpacklo_pi8 (vdst, _mm_setzero_si64 ()); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_over_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 vsrc = combine (src, mask); michael@0: michael@0: if (is_opaque (vsrc)) michael@0: { michael@0: store8888 (dest, vsrc); michael@0: } michael@0: else if (!is_zero (vsrc)) michael@0: { michael@0: __m64 sa = expand_alpha (vsrc); michael@0: store8888 (dest, over (vsrc, sa, load8888 (dest))); michael@0: } michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_over_reverse_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 d, da; michael@0: __m64 s = combine (src, mask); michael@0: michael@0: d = load8888 (dest); michael@0: da = expand_alpha (d); michael@0: store8888 (dest, over (d, da, s)); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_in_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 a; michael@0: __m64 x = combine (src, mask); michael@0: michael@0: a = load8888 (dest); michael@0: a = expand_alpha (a); michael@0: x = pix_multiply (x, a); michael@0: michael@0: store8888 (dest, x); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_in_reverse_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 a = combine (src, mask); michael@0: __m64 x; michael@0: michael@0: x = load8888 (dest); michael@0: a = expand_alpha (a); michael@0: x = pix_multiply (x, a); michael@0: store8888 (dest, x); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_out_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 a; michael@0: __m64 x = combine (src, mask); michael@0: michael@0: a = load8888 (dest); michael@0: a = expand_alpha (a); michael@0: a = negate (a); michael@0: x = pix_multiply (x, a); michael@0: store8888 (dest, x); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_out_reverse_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 a = combine (src, mask); michael@0: __m64 x; michael@0: michael@0: x = load8888 (dest); michael@0: a = expand_alpha (a); michael@0: a = negate (a); michael@0: x = pix_multiply (x, a); michael@0: michael@0: store8888 (dest, x); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_atop_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 da, d, sia; michael@0: __m64 s = combine (src, mask); michael@0: michael@0: d = load8888 (dest); michael@0: sia = expand_alpha (s); michael@0: sia = negate (sia); michael@0: da = expand_alpha (d); michael@0: s = pix_add_mul (s, da, d, sia); michael@0: store8888 (dest, s); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_atop_reverse_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end; michael@0: michael@0: end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 dia, d, sa; michael@0: __m64 s = combine (src, mask); michael@0: michael@0: d = load8888 (dest); michael@0: sa = expand_alpha (s); michael@0: dia = expand_alpha (d); michael@0: dia = negate (dia); michael@0: s = pix_add_mul (s, dia, d, sa); michael@0: store8888 (dest, s); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_xor_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 dia, d, sia; michael@0: __m64 s = combine (src, mask); michael@0: michael@0: d = load8888 (dest); michael@0: sia = expand_alpha (s); michael@0: dia = expand_alpha (d); michael@0: sia = negate (sia); michael@0: dia = negate (dia); michael@0: s = pix_add_mul (s, dia, d, sia); michael@0: store8888 (dest, s); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_add_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: __m64 d; michael@0: __m64 s = combine (src, mask); michael@0: michael@0: d = load8888 (dest); michael@0: s = pix_add (s, d); michael@0: store8888 (dest, s); michael@0: michael@0: ++dest; michael@0: ++src; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_saturate_u (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = dest + width; michael@0: michael@0: while (dest < end) michael@0: { michael@0: uint32_t s, sa, da; michael@0: uint32_t d = *dest; michael@0: __m64 ms = combine (src, mask); michael@0: __m64 md = load8888 (dest); michael@0: michael@0: store8888(&s, ms); michael@0: da = ~d >> 24; michael@0: sa = s >> 24; michael@0: michael@0: if (sa > da) michael@0: { michael@0: uint32_t quot = DIV_UN8 (da, sa) << 24; michael@0: __m64 msa = load8888 ("); michael@0: msa = expand_alpha (msa); michael@0: ms = pix_multiply (ms, msa); michael@0: } michael@0: michael@0: md = pix_add (md, ms); michael@0: store8888 (dest, md); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: if (mask) michael@0: mask++; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_src_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: michael@0: s = pix_multiply (s, a); michael@0: store8888 (dest, s); michael@0: michael@0: ++src; michael@0: ++mask; michael@0: ++dest; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_over_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 sa = expand_alpha (s); michael@0: michael@0: store8888 (dest, in_over (s, sa, a, d)); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_over_reverse_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 da = expand_alpha (d); michael@0: michael@0: store8888 (dest, over (d, da, in (s, a))); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_in_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 da = expand_alpha (d); michael@0: michael@0: s = pix_multiply (s, a); michael@0: s = pix_multiply (s, da); michael@0: store8888 (dest, s); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_in_reverse_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 sa = expand_alpha (s); michael@0: michael@0: a = pix_multiply (a, sa); michael@0: d = pix_multiply (d, a); michael@0: store8888 (dest, d); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_out_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 da = expand_alpha (d); michael@0: michael@0: da = negate (da); michael@0: s = pix_multiply (s, a); michael@0: s = pix_multiply (s, da); michael@0: store8888 (dest, s); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_out_reverse_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 sa = expand_alpha (s); michael@0: michael@0: a = pix_multiply (a, sa); michael@0: a = negate (a); michael@0: d = pix_multiply (d, a); michael@0: store8888 (dest, d); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_atop_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 da = expand_alpha (d); michael@0: __m64 sa = expand_alpha (s); michael@0: michael@0: s = pix_multiply (s, a); michael@0: a = pix_multiply (a, sa); michael@0: a = negate (a); michael@0: d = pix_add_mul (d, a, s, da); michael@0: store8888 (dest, d); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_atop_reverse_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 da = expand_alpha (d); michael@0: __m64 sa = expand_alpha (s); michael@0: michael@0: s = pix_multiply (s, a); michael@0: a = pix_multiply (a, sa); michael@0: da = negate (da); michael@0: d = pix_add_mul (d, a, s, da); michael@0: store8888 (dest, d); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_xor_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: __m64 da = expand_alpha (d); michael@0: __m64 sa = expand_alpha (s); michael@0: michael@0: s = pix_multiply (s, a); michael@0: a = pix_multiply (a, sa); michael@0: da = negate (da); michael@0: a = negate (a); michael@0: d = pix_add_mul (d, a, s, da); michael@0: store8888 (dest, d); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_combine_add_ca (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width) michael@0: { michael@0: const uint32_t *end = src + width; michael@0: michael@0: while (src < end) michael@0: { michael@0: __m64 a = load8888 (mask); michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dest); michael@0: michael@0: s = pix_multiply (s, a); michael@0: d = pix_add (s, d); michael@0: store8888 (dest, d); michael@0: michael@0: ++src; michael@0: ++dest; michael@0: ++mask; michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: /* ------------- MMX code paths called from fbpict.c -------------------- */ michael@0: michael@0: static void michael@0: mmx_composite_over_n_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src; michael@0: uint32_t *dst_line, *dst; michael@0: int32_t w; michael@0: int dst_stride; michael@0: __m64 vsrc, vsrca; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: store8888 (dst, over (vsrc, vsrca, load8888 (dst))); michael@0: michael@0: w--; michael@0: dst++; michael@0: } michael@0: michael@0: while (w >= 2) michael@0: { michael@0: __m64 vdest; michael@0: __m64 dest0, dest1; michael@0: michael@0: vdest = *(__m64 *)dst; michael@0: michael@0: dest0 = over (vsrc, vsrca, expand8888 (vdest, 0)); michael@0: dest1 = over (vsrc, vsrca, expand8888 (vdest, 1)); michael@0: michael@0: *(__m64 *)dst = pack8888 (dest0, dest1); michael@0: michael@0: dst += 2; michael@0: w -= 2; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: if (w) michael@0: { michael@0: store8888 (dst, over (vsrc, vsrca, load8888 (dst))); michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_n_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src; michael@0: uint16_t *dst_line, *dst; michael@0: int32_t w; michael@0: int dst_stride; michael@0: __m64 vsrc, vsrca; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: uint64_t d = *dst; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: michael@0: vdest = pack_565 (over (vsrc, vsrca, vdest), vdest, 0); michael@0: *dst = to_uint64 (vdest); michael@0: michael@0: w--; michael@0: dst++; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: __m64 v0, v1, v2, v3; michael@0: michael@0: expand_4x565 (vdest, &v0, &v1, &v2, &v3, 0); michael@0: michael@0: v0 = over (vsrc, vsrca, v0); michael@0: v1 = over (vsrc, vsrca, v1); michael@0: v2 = over (vsrc, vsrca, v2); michael@0: v3 = over (vsrc, vsrca, v3); michael@0: michael@0: *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3); michael@0: michael@0: dst += 4; michael@0: w -= 4; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w) michael@0: { michael@0: uint64_t d = *dst; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: michael@0: vdest = pack_565 (over (vsrc, vsrca, vdest), vdest, 0); michael@0: *dst = to_uint64 (vdest); michael@0: michael@0: w--; michael@0: dst++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_n_8888_8888_ca (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src; michael@0: uint32_t *dst_line; michael@0: uint32_t *mask_line; michael@0: int dst_stride, mask_stride; michael@0: __m64 vsrc, vsrca; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: int twidth = width; michael@0: uint32_t *p = (uint32_t *)mask_line; michael@0: uint32_t *q = (uint32_t *)dst_line; michael@0: michael@0: while (twidth && (uintptr_t)q & 7) michael@0: { michael@0: uint32_t m = *(uint32_t *)p; michael@0: michael@0: if (m) michael@0: { michael@0: __m64 vdest = load8888 (q); michael@0: vdest = in_over (vsrc, vsrca, load8888 (&m), vdest); michael@0: store8888 (q, vdest); michael@0: } michael@0: michael@0: twidth--; michael@0: p++; michael@0: q++; michael@0: } michael@0: michael@0: while (twidth >= 2) michael@0: { michael@0: uint32_t m0, m1; michael@0: m0 = *p; michael@0: m1 = *(p + 1); michael@0: michael@0: if (m0 | m1) michael@0: { michael@0: __m64 dest0, dest1; michael@0: __m64 vdest = *(__m64 *)q; michael@0: michael@0: dest0 = in_over (vsrc, vsrca, load8888 (&m0), michael@0: expand8888 (vdest, 0)); michael@0: dest1 = in_over (vsrc, vsrca, load8888 (&m1), michael@0: expand8888 (vdest, 1)); michael@0: michael@0: *(__m64 *)q = pack8888 (dest0, dest1); michael@0: } michael@0: michael@0: p += 2; michael@0: q += 2; michael@0: twidth -= 2; michael@0: } michael@0: michael@0: if (twidth) michael@0: { michael@0: uint32_t m = *(uint32_t *)p; michael@0: michael@0: if (m) michael@0: { michael@0: __m64 vdest = load8888 (q); michael@0: vdest = in_over (vsrc, vsrca, load8888 (&m), vdest); michael@0: store8888 (q, vdest); michael@0: } michael@0: michael@0: twidth--; michael@0: p++; michael@0: q++; michael@0: } michael@0: michael@0: dst_line += dst_stride; michael@0: mask_line += mask_stride; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_8888_n_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: uint32_t mask; michael@0: __m64 vmask; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: mask = _pixman_image_get_solid (imp, mask_image, dest_image->bits.format); michael@0: vmask = expand_alpha (load8888 (&mask)); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dst); michael@0: michael@0: store8888 (dst, in_over (s, expand_alpha (s), vmask, d)); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: michael@0: while (w >= 2) michael@0: { michael@0: __m64 vs = ldq_u ((__m64 *)src); michael@0: __m64 vd = *(__m64 *)dst; michael@0: __m64 vsrc0 = expand8888 (vs, 0); michael@0: __m64 vsrc1 = expand8888 (vs, 1); michael@0: michael@0: *(__m64 *)dst = pack8888 ( michael@0: in_over (vsrc0, expand_alpha (vsrc0), vmask, expand8888 (vd, 0)), michael@0: in_over (vsrc1, expand_alpha (vsrc1), vmask, expand8888 (vd, 1))); michael@0: michael@0: w -= 2; michael@0: dst += 2; michael@0: src += 2; michael@0: } michael@0: michael@0: if (w) michael@0: { michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dst); michael@0: michael@0: store8888 (dst, in_over (s, expand_alpha (s), vmask, d)); michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_x888_n_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: uint32_t mask; michael@0: __m64 vmask; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: __m64 srca; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: mask = _pixman_image_get_solid (imp, mask_image, dest_image->bits.format); michael@0: michael@0: vmask = expand_alpha (load8888 (&mask)); michael@0: srca = MC (4x00ff); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: uint32_t ssrc = *src | 0xff000000; michael@0: __m64 s = load8888 (&ssrc); michael@0: __m64 d = load8888 (dst); michael@0: michael@0: store8888 (dst, in_over (s, srca, vmask, d)); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: michael@0: while (w >= 16) michael@0: { michael@0: __m64 vd0 = *(__m64 *)(dst + 0); michael@0: __m64 vd1 = *(__m64 *)(dst + 2); michael@0: __m64 vd2 = *(__m64 *)(dst + 4); michael@0: __m64 vd3 = *(__m64 *)(dst + 6); michael@0: __m64 vd4 = *(__m64 *)(dst + 8); michael@0: __m64 vd5 = *(__m64 *)(dst + 10); michael@0: __m64 vd6 = *(__m64 *)(dst + 12); michael@0: __m64 vd7 = *(__m64 *)(dst + 14); michael@0: michael@0: __m64 vs0 = ldq_u ((__m64 *)(src + 0)); michael@0: __m64 vs1 = ldq_u ((__m64 *)(src + 2)); michael@0: __m64 vs2 = ldq_u ((__m64 *)(src + 4)); michael@0: __m64 vs3 = ldq_u ((__m64 *)(src + 6)); michael@0: __m64 vs4 = ldq_u ((__m64 *)(src + 8)); michael@0: __m64 vs5 = ldq_u ((__m64 *)(src + 10)); michael@0: __m64 vs6 = ldq_u ((__m64 *)(src + 12)); michael@0: __m64 vs7 = ldq_u ((__m64 *)(src + 14)); michael@0: michael@0: vd0 = pack8888 ( michael@0: in_over (expandx888 (vs0, 0), srca, vmask, expand8888 (vd0, 0)), michael@0: in_over (expandx888 (vs0, 1), srca, vmask, expand8888 (vd0, 1))); michael@0: michael@0: vd1 = pack8888 ( michael@0: in_over (expandx888 (vs1, 0), srca, vmask, expand8888 (vd1, 0)), michael@0: in_over (expandx888 (vs1, 1), srca, vmask, expand8888 (vd1, 1))); michael@0: michael@0: vd2 = pack8888 ( michael@0: in_over (expandx888 (vs2, 0), srca, vmask, expand8888 (vd2, 0)), michael@0: in_over (expandx888 (vs2, 1), srca, vmask, expand8888 (vd2, 1))); michael@0: michael@0: vd3 = pack8888 ( michael@0: in_over (expandx888 (vs3, 0), srca, vmask, expand8888 (vd3, 0)), michael@0: in_over (expandx888 (vs3, 1), srca, vmask, expand8888 (vd3, 1))); michael@0: michael@0: vd4 = pack8888 ( michael@0: in_over (expandx888 (vs4, 0), srca, vmask, expand8888 (vd4, 0)), michael@0: in_over (expandx888 (vs4, 1), srca, vmask, expand8888 (vd4, 1))); michael@0: michael@0: vd5 = pack8888 ( michael@0: in_over (expandx888 (vs5, 0), srca, vmask, expand8888 (vd5, 0)), michael@0: in_over (expandx888 (vs5, 1), srca, vmask, expand8888 (vd5, 1))); michael@0: michael@0: vd6 = pack8888 ( michael@0: in_over (expandx888 (vs6, 0), srca, vmask, expand8888 (vd6, 0)), michael@0: in_over (expandx888 (vs6, 1), srca, vmask, expand8888 (vd6, 1))); michael@0: michael@0: vd7 = pack8888 ( michael@0: in_over (expandx888 (vs7, 0), srca, vmask, expand8888 (vd7, 0)), michael@0: in_over (expandx888 (vs7, 1), srca, vmask, expand8888 (vd7, 1))); michael@0: michael@0: *(__m64 *)(dst + 0) = vd0; michael@0: *(__m64 *)(dst + 2) = vd1; michael@0: *(__m64 *)(dst + 4) = vd2; michael@0: *(__m64 *)(dst + 6) = vd3; michael@0: *(__m64 *)(dst + 8) = vd4; michael@0: *(__m64 *)(dst + 10) = vd5; michael@0: *(__m64 *)(dst + 12) = vd6; michael@0: *(__m64 *)(dst + 14) = vd7; michael@0: michael@0: w -= 16; michael@0: dst += 16; michael@0: src += 16; michael@0: } michael@0: michael@0: while (w) michael@0: { michael@0: uint32_t ssrc = *src | 0xff000000; michael@0: __m64 s = load8888 (&ssrc); michael@0: __m64 d = load8888 (dst); michael@0: michael@0: store8888 (dst, in_over (s, srca, vmask, d)); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_8888_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: uint32_t s; michael@0: int dst_stride, src_stride; michael@0: uint8_t a; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: a = s >> 24; michael@0: michael@0: if (a == 0xff) michael@0: { michael@0: *dst = s; michael@0: } michael@0: else if (s) michael@0: { michael@0: __m64 ms, sa; michael@0: ms = load8888 (&s); michael@0: sa = expand_alpha (ms); michael@0: store8888 (dst, over (ms, sa, load8888 (dst))); michael@0: } michael@0: michael@0: dst++; michael@0: } michael@0: } michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_8888_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: #if 0 michael@0: /* FIXME */ michael@0: assert (src_image->drawable == mask_image->drawable); michael@0: #endif michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: __m64 vsrc = load8888 (src); michael@0: uint64_t d = *dst; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: michael@0: vdest = pack_565 ( michael@0: over (vsrc, expand_alpha (vsrc), vdest), vdest, 0); michael@0: michael@0: *dst = to_uint64 (vdest); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: __m64 v0, v1, v2, v3; michael@0: __m64 vsrc0, vsrc1, vsrc2, vsrc3; michael@0: michael@0: expand_4x565 (vdest, &v0, &v1, &v2, &v3, 0); michael@0: michael@0: vsrc0 = load8888 ((src + 0)); michael@0: vsrc1 = load8888 ((src + 1)); michael@0: vsrc2 = load8888 ((src + 2)); michael@0: vsrc3 = load8888 ((src + 3)); michael@0: michael@0: v0 = over (vsrc0, expand_alpha (vsrc0), v0); michael@0: v1 = over (vsrc1, expand_alpha (vsrc1), v1); michael@0: v2 = over (vsrc2, expand_alpha (vsrc2), v2); michael@0: v3 = over (vsrc3, expand_alpha (vsrc3), v3); michael@0: michael@0: *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3); michael@0: michael@0: w -= 4; michael@0: dst += 4; michael@0: src += 4; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w) michael@0: { michael@0: __m64 vsrc = load8888 (src); michael@0: uint64_t d = *dst; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: michael@0: vdest = pack_565 (over (vsrc, expand_alpha (vsrc), vdest), vdest, 0); michael@0: michael@0: *dst = to_uint64 (vdest); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_n_8_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint32_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: __m64 vsrc, vsrca; michael@0: uint64_t srcsrc; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: srcsrc = (uint64_t)src << 32 | src; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: __m64 vdest = in_over (vsrc, vsrca, michael@0: expand_alpha_rev (to_m64 (m)), michael@0: load8888 (dst)); michael@0: michael@0: store8888 (dst, vdest); michael@0: } michael@0: michael@0: w--; michael@0: mask++; michael@0: dst++; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w >= 2) michael@0: { michael@0: uint64_t m0, m1; michael@0: michael@0: m0 = *mask; michael@0: m1 = *(mask + 1); michael@0: michael@0: if (srca == 0xff && (m0 & m1) == 0xff) michael@0: { michael@0: *(uint64_t *)dst = srcsrc; michael@0: } michael@0: else if (m0 | m1) michael@0: { michael@0: __m64 vdest; michael@0: __m64 dest0, dest1; michael@0: michael@0: vdest = *(__m64 *)dst; michael@0: michael@0: dest0 = in_over (vsrc, vsrca, expand_alpha_rev (to_m64 (m0)), michael@0: expand8888 (vdest, 0)); michael@0: dest1 = in_over (vsrc, vsrca, expand_alpha_rev (to_m64 (m1)), michael@0: expand8888 (vdest, 1)); michael@0: michael@0: *(__m64 *)dst = pack8888 (dest0, dest1); michael@0: } michael@0: michael@0: mask += 2; michael@0: dst += 2; michael@0: w -= 2; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: if (w) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: __m64 vdest = load8888 (dst); michael@0: michael@0: vdest = in_over ( michael@0: vsrc, vsrca, expand_alpha_rev (to_m64 (m)), vdest); michael@0: store8888 (dst, vdest); michael@0: } michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: mmx_fill (pixman_implementation_t *imp, michael@0: uint32_t * bits, michael@0: int stride, michael@0: int bpp, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler) michael@0: { michael@0: uint64_t fill; michael@0: __m64 vfill; michael@0: uint32_t byte_width; michael@0: uint8_t *byte_line; michael@0: michael@0: #if defined __GNUC__ && defined USE_X86_MMX michael@0: __m64 v1, v2, v3, v4, v5, v6, v7; michael@0: #endif michael@0: michael@0: if (bpp != 16 && bpp != 32 && bpp != 8) michael@0: return FALSE; michael@0: michael@0: if (bpp == 8) michael@0: { michael@0: stride = stride * (int) sizeof (uint32_t) / 1; michael@0: byte_line = (uint8_t *)(((uint8_t *)bits) + stride * y + x); michael@0: byte_width = width; michael@0: stride *= 1; michael@0: filler = (filler & 0xff) * 0x01010101; michael@0: } michael@0: else if (bpp == 16) michael@0: { michael@0: stride = stride * (int) sizeof (uint32_t) / 2; michael@0: byte_line = (uint8_t *)(((uint16_t *)bits) + stride * y + x); michael@0: byte_width = 2 * width; michael@0: stride *= 2; michael@0: filler = (filler & 0xffff) * 0x00010001; michael@0: } michael@0: else michael@0: { michael@0: stride = stride * (int) sizeof (uint32_t) / 4; michael@0: byte_line = (uint8_t *)(((uint32_t *)bits) + stride * y + x); michael@0: byte_width = 4 * width; michael@0: stride *= 4; michael@0: } michael@0: michael@0: fill = ((uint64_t)filler << 32) | filler; michael@0: vfill = to_m64 (fill); michael@0: michael@0: #if defined __GNUC__ && defined USE_X86_MMX michael@0: __asm__ ( michael@0: "movq %7, %0\n" michael@0: "movq %7, %1\n" michael@0: "movq %7, %2\n" michael@0: "movq %7, %3\n" michael@0: "movq %7, %4\n" michael@0: "movq %7, %5\n" michael@0: "movq %7, %6\n" michael@0: : "=&y" (v1), "=&y" (v2), "=&y" (v3), michael@0: "=&y" (v4), "=&y" (v5), "=&y" (v6), "=y" (v7) michael@0: : "y" (vfill)); michael@0: #endif michael@0: michael@0: while (height--) michael@0: { michael@0: int w; michael@0: uint8_t *d = byte_line; michael@0: michael@0: byte_line += stride; michael@0: w = byte_width; michael@0: michael@0: if (w >= 1 && ((uintptr_t)d & 1)) michael@0: { michael@0: *(uint8_t *)d = (filler & 0xff); michael@0: w--; michael@0: d++; michael@0: } michael@0: michael@0: if (w >= 2 && ((uintptr_t)d & 3)) michael@0: { michael@0: *(uint16_t *)d = filler; michael@0: w -= 2; michael@0: d += 2; michael@0: } michael@0: michael@0: while (w >= 4 && ((uintptr_t)d & 7)) michael@0: { michael@0: *(uint32_t *)d = filler; michael@0: michael@0: w -= 4; michael@0: d += 4; michael@0: } michael@0: michael@0: while (w >= 64) michael@0: { michael@0: #if defined __GNUC__ && defined USE_X86_MMX michael@0: __asm__ ( michael@0: "movq %1, (%0)\n" michael@0: "movq %2, 8(%0)\n" michael@0: "movq %3, 16(%0)\n" michael@0: "movq %4, 24(%0)\n" michael@0: "movq %5, 32(%0)\n" michael@0: "movq %6, 40(%0)\n" michael@0: "movq %7, 48(%0)\n" michael@0: "movq %8, 56(%0)\n" michael@0: : michael@0: : "r" (d), michael@0: "y" (vfill), "y" (v1), "y" (v2), "y" (v3), michael@0: "y" (v4), "y" (v5), "y" (v6), "y" (v7) michael@0: : "memory"); michael@0: #else michael@0: *(__m64*) (d + 0) = vfill; michael@0: *(__m64*) (d + 8) = vfill; michael@0: *(__m64*) (d + 16) = vfill; michael@0: *(__m64*) (d + 24) = vfill; michael@0: *(__m64*) (d + 32) = vfill; michael@0: *(__m64*) (d + 40) = vfill; michael@0: *(__m64*) (d + 48) = vfill; michael@0: *(__m64*) (d + 56) = vfill; michael@0: #endif michael@0: w -= 64; michael@0: d += 64; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: *(uint32_t *)d = filler; michael@0: michael@0: w -= 4; michael@0: d += 4; michael@0: } michael@0: if (w >= 2) michael@0: { michael@0: *(uint16_t *)d = filler; michael@0: w -= 2; michael@0: d += 2; michael@0: } michael@0: if (w >= 1) michael@0: { michael@0: *(uint8_t *)d = (filler & 0xff); michael@0: w--; michael@0: d++; michael@0: } michael@0: michael@0: } michael@0: michael@0: _mm_empty (); michael@0: return TRUE; michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_src_x888_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t *src_line, *src, s; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: s = *src++; michael@0: *dst = convert_8888_to_0565 (s); michael@0: dst++; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vdest; michael@0: __m64 vsrc0 = ldq_u ((__m64 *)(src + 0)); michael@0: __m64 vsrc1 = ldq_u ((__m64 *)(src + 2)); michael@0: michael@0: vdest = pack_4xpacked565 (vsrc0, vsrc1); michael@0: michael@0: *(__m64 *)dst = vdest; michael@0: michael@0: w -= 4; michael@0: src += 4; michael@0: dst += 4; michael@0: } michael@0: michael@0: while (w) michael@0: { michael@0: s = *src++; michael@0: *dst = convert_8888_to_0565 (s); michael@0: dst++; michael@0: w--; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_src_n_8_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint32_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: __m64 vsrc; michael@0: uint64_t srcsrc; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: { michael@0: mmx_fill (imp, dest_image->bits.bits, dest_image->bits.rowstride, michael@0: PIXMAN_FORMAT_BPP (dest_image->bits.format), michael@0: dest_x, dest_y, width, height, 0); michael@0: return; michael@0: } michael@0: michael@0: srcsrc = (uint64_t)src << 32 | src; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: __m64 vdest = in (vsrc, expand_alpha_rev (to_m64 (m))); michael@0: michael@0: store8888 (dst, vdest); michael@0: } michael@0: else michael@0: { michael@0: *dst = 0; michael@0: } michael@0: michael@0: w--; michael@0: mask++; michael@0: dst++; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w >= 2) michael@0: { michael@0: uint64_t m0, m1; michael@0: m0 = *mask; michael@0: m1 = *(mask + 1); michael@0: michael@0: if (srca == 0xff && (m0 & m1) == 0xff) michael@0: { michael@0: *(uint64_t *)dst = srcsrc; michael@0: } michael@0: else if (m0 | m1) michael@0: { michael@0: __m64 dest0, dest1; michael@0: michael@0: dest0 = in (vsrc, expand_alpha_rev (to_m64 (m0))); michael@0: dest1 = in (vsrc, expand_alpha_rev (to_m64 (m1))); michael@0: michael@0: *(__m64 *)dst = pack8888 (dest0, dest1); michael@0: } michael@0: else michael@0: { michael@0: *(uint64_t *)dst = 0; michael@0: } michael@0: michael@0: mask += 2; michael@0: dst += 2; michael@0: w -= 2; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: if (w) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: __m64 vdest = load8888 (dst); michael@0: michael@0: vdest = in (vsrc, expand_alpha_rev (to_m64 (m))); michael@0: store8888 (dst, vdest); michael@0: } michael@0: else michael@0: { michael@0: *dst = 0; michael@0: } michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_n_8_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint16_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: __m64 vsrc, vsrca, tmp; michael@0: __m64 srcsrcsrcsrc; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: tmp = pack_565 (vsrc, _mm_setzero_si64 (), 0); michael@0: srcsrcsrcsrc = expand_alpha_rev (tmp); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: uint64_t d = *dst; michael@0: __m64 vd = to_m64 (d); michael@0: __m64 vdest = in_over ( michael@0: vsrc, vsrca, expand_alpha_rev (to_m64 (m)), expand565 (vd, 0)); michael@0: michael@0: vd = pack_565 (vdest, _mm_setzero_si64 (), 0); michael@0: *dst = to_uint64 (vd); michael@0: } michael@0: michael@0: w--; michael@0: mask++; michael@0: dst++; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w >= 4) michael@0: { michael@0: uint64_t m0, m1, m2, m3; michael@0: m0 = *mask; michael@0: m1 = *(mask + 1); michael@0: m2 = *(mask + 2); michael@0: m3 = *(mask + 3); michael@0: michael@0: if (srca == 0xff && (m0 & m1 & m2 & m3) == 0xff) michael@0: { michael@0: *(__m64 *)dst = srcsrcsrcsrc; michael@0: } michael@0: else if (m0 | m1 | m2 | m3) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: __m64 v0, v1, v2, v3; michael@0: __m64 vm0, vm1, vm2, vm3; michael@0: michael@0: expand_4x565 (vdest, &v0, &v1, &v2, &v3, 0); michael@0: michael@0: vm0 = to_m64 (m0); michael@0: v0 = in_over (vsrc, vsrca, expand_alpha_rev (vm0), v0); michael@0: michael@0: vm1 = to_m64 (m1); michael@0: v1 = in_over (vsrc, vsrca, expand_alpha_rev (vm1), v1); michael@0: michael@0: vm2 = to_m64 (m2); michael@0: v2 = in_over (vsrc, vsrca, expand_alpha_rev (vm2), v2); michael@0: michael@0: vm3 = to_m64 (m3); michael@0: v3 = in_over (vsrc, vsrca, expand_alpha_rev (vm3), v3); michael@0: michael@0: *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3);; michael@0: } michael@0: michael@0: w -= 4; michael@0: mask += 4; michael@0: dst += 4; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: uint64_t d = *dst; michael@0: __m64 vd = to_m64 (d); michael@0: __m64 vdest = in_over (vsrc, vsrca, expand_alpha_rev (to_m64 (m)), michael@0: expand565 (vd, 0)); michael@0: vd = pack_565 (vdest, _mm_setzero_si64 (), 0); michael@0: *dst = to_uint64 (vd); michael@0: } michael@0: michael@0: w--; michael@0: mask++; michael@0: dst++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_pixbuf_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: #if 0 michael@0: /* FIXME */ michael@0: assert (src_image->drawable == mask_image->drawable); michael@0: #endif michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: __m64 vsrc = load8888 (src); michael@0: uint64_t d = *dst; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: michael@0: vdest = pack_565 (over_rev_non_pre (vsrc, vdest), vdest, 0); michael@0: michael@0: *dst = to_uint64 (vdest); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w >= 4) michael@0: { michael@0: uint32_t s0, s1, s2, s3; michael@0: unsigned char a0, a1, a2, a3; michael@0: michael@0: s0 = *src; michael@0: s1 = *(src + 1); michael@0: s2 = *(src + 2); michael@0: s3 = *(src + 3); michael@0: michael@0: a0 = (s0 >> 24); michael@0: a1 = (s1 >> 24); michael@0: a2 = (s2 >> 24); michael@0: a3 = (s3 >> 24); michael@0: michael@0: if ((a0 & a1 & a2 & a3) == 0xFF) michael@0: { michael@0: __m64 v0 = invert_colors (load8888 (&s0)); michael@0: __m64 v1 = invert_colors (load8888 (&s1)); michael@0: __m64 v2 = invert_colors (load8888 (&s2)); michael@0: __m64 v3 = invert_colors (load8888 (&s3)); michael@0: michael@0: *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3); michael@0: } michael@0: else if (s0 | s1 | s2 | s3) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: __m64 v0, v1, v2, v3; michael@0: michael@0: __m64 vsrc0 = load8888 (&s0); michael@0: __m64 vsrc1 = load8888 (&s1); michael@0: __m64 vsrc2 = load8888 (&s2); michael@0: __m64 vsrc3 = load8888 (&s3); michael@0: michael@0: expand_4x565 (vdest, &v0, &v1, &v2, &v3, 0); michael@0: michael@0: v0 = over_rev_non_pre (vsrc0, v0); michael@0: v1 = over_rev_non_pre (vsrc1, v1); michael@0: v2 = over_rev_non_pre (vsrc2, v2); michael@0: v3 = over_rev_non_pre (vsrc3, v3); michael@0: michael@0: *(__m64 *)dst = pack_4x565 (v0, v1, v2, v3); michael@0: } michael@0: michael@0: w -= 4; michael@0: dst += 4; michael@0: src += 4; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w) michael@0: { michael@0: __m64 vsrc = load8888 (src); michael@0: uint64_t d = *dst; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: michael@0: vdest = pack_565 (over_rev_non_pre (vsrc, vdest), vdest, 0); michael@0: michael@0: *dst = to_uint64 (vdest); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: #if 0 michael@0: /* FIXME */ michael@0: assert (src_image->drawable == mask_image->drawable); michael@0: #endif michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dst); michael@0: michael@0: store8888 (dst, over_rev_non_pre (s, d)); michael@0: michael@0: w--; michael@0: dst++; michael@0: src++; michael@0: } michael@0: michael@0: while (w >= 2) michael@0: { michael@0: uint32_t s0, s1; michael@0: unsigned char a0, a1; michael@0: __m64 d0, d1; michael@0: michael@0: s0 = *src; michael@0: s1 = *(src + 1); michael@0: michael@0: a0 = (s0 >> 24); michael@0: a1 = (s1 >> 24); michael@0: michael@0: if ((a0 & a1) == 0xFF) michael@0: { michael@0: d0 = invert_colors (load8888 (&s0)); michael@0: d1 = invert_colors (load8888 (&s1)); michael@0: michael@0: *(__m64 *)dst = pack8888 (d0, d1); michael@0: } michael@0: else if (s0 | s1) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: michael@0: d0 = over_rev_non_pre (load8888 (&s0), expand8888 (vdest, 0)); michael@0: d1 = over_rev_non_pre (load8888 (&s1), expand8888 (vdest, 1)); michael@0: michael@0: *(__m64 *)dst = pack8888 (d0, d1); michael@0: } michael@0: michael@0: w -= 2; michael@0: dst += 2; michael@0: src += 2; michael@0: } michael@0: michael@0: if (w) michael@0: { michael@0: __m64 s = load8888 (src); michael@0: __m64 d = load8888 (dst); michael@0: michael@0: store8888 (dst, over_rev_non_pre (s, d)); michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_n_8888_0565_ca (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src; michael@0: uint16_t *dst_line; michael@0: uint32_t *mask_line; michael@0: int dst_stride, mask_stride; michael@0: __m64 vsrc, vsrca; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: int twidth = width; michael@0: uint32_t *p = (uint32_t *)mask_line; michael@0: uint16_t *q = (uint16_t *)dst_line; michael@0: michael@0: while (twidth && ((uintptr_t)q & 7)) michael@0: { michael@0: uint32_t m = *(uint32_t *)p; michael@0: michael@0: if (m) michael@0: { michael@0: uint64_t d = *q; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: vdest = pack_565 (in_over (vsrc, vsrca, load8888 (&m), vdest), vdest, 0); michael@0: *q = to_uint64 (vdest); michael@0: } michael@0: michael@0: twidth--; michael@0: p++; michael@0: q++; michael@0: } michael@0: michael@0: while (twidth >= 4) michael@0: { michael@0: uint32_t m0, m1, m2, m3; michael@0: michael@0: m0 = *p; michael@0: m1 = *(p + 1); michael@0: m2 = *(p + 2); michael@0: m3 = *(p + 3); michael@0: michael@0: if ((m0 | m1 | m2 | m3)) michael@0: { michael@0: __m64 vdest = *(__m64 *)q; michael@0: __m64 v0, v1, v2, v3; michael@0: michael@0: expand_4x565 (vdest, &v0, &v1, &v2, &v3, 0); michael@0: michael@0: v0 = in_over (vsrc, vsrca, load8888 (&m0), v0); michael@0: v1 = in_over (vsrc, vsrca, load8888 (&m1), v1); michael@0: v2 = in_over (vsrc, vsrca, load8888 (&m2), v2); michael@0: v3 = in_over (vsrc, vsrca, load8888 (&m3), v3); michael@0: michael@0: *(__m64 *)q = pack_4x565 (v0, v1, v2, v3); michael@0: } michael@0: twidth -= 4; michael@0: p += 4; michael@0: q += 4; michael@0: } michael@0: michael@0: while (twidth) michael@0: { michael@0: uint32_t m; michael@0: michael@0: m = *(uint32_t *)p; michael@0: if (m) michael@0: { michael@0: uint64_t d = *q; michael@0: __m64 vdest = expand565 (to_m64 (d), 0); michael@0: vdest = pack_565 (in_over (vsrc, vsrca, load8888 (&m), vdest), vdest, 0); michael@0: *q = to_uint64 (vdest); michael@0: } michael@0: michael@0: twidth--; michael@0: p++; michael@0: q++; michael@0: } michael@0: michael@0: mask_line += mask_stride; michael@0: dst_line += dst_stride; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_in_n_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: uint32_t src; michael@0: uint8_t sa; michael@0: __m64 vsrc, vsrca; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: sa = src >> 24; michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: uint16_t tmp; michael@0: uint8_t a; michael@0: uint32_t m, d; michael@0: michael@0: a = *mask++; michael@0: d = *dst; michael@0: michael@0: m = MUL_UN8 (sa, a, tmp); michael@0: d = MUL_UN8 (m, d, tmp); michael@0: michael@0: *dst++ = d; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vmask; michael@0: __m64 vdest; michael@0: michael@0: vmask = load8888u ((uint32_t *)mask); michael@0: vdest = load8888 ((uint32_t *)dst); michael@0: michael@0: store8888 ((uint32_t *)dst, in (in (vsrca, vmask), vdest)); michael@0: michael@0: dst += 4; michael@0: mask += 4; michael@0: w -= 4; michael@0: } michael@0: michael@0: while (w--) michael@0: { michael@0: uint16_t tmp; michael@0: uint8_t a; michael@0: uint32_t m, d; michael@0: michael@0: a = *mask++; michael@0: d = *dst; michael@0: michael@0: m = MUL_UN8 (sa, a, tmp); michael@0: d = MUL_UN8 (m, d, tmp); michael@0: michael@0: *dst++ = d; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_in_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *src_line, *src; michael@0: int src_stride, dst_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 3) michael@0: { michael@0: uint8_t s, d; michael@0: uint16_t tmp; michael@0: michael@0: s = *src; michael@0: d = *dst; michael@0: michael@0: *dst = MUL_UN8 (s, d, tmp); michael@0: michael@0: src++; michael@0: dst++; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: uint32_t *s = (uint32_t *)src; michael@0: uint32_t *d = (uint32_t *)dst; michael@0: michael@0: store8888 (d, in (load8888u (s), load8888 (d))); michael@0: michael@0: w -= 4; michael@0: dst += 4; michael@0: src += 4; michael@0: } michael@0: michael@0: while (w--) michael@0: { michael@0: uint8_t s, d; michael@0: uint16_t tmp; michael@0: michael@0: s = *src; michael@0: d = *dst; michael@0: michael@0: *dst = MUL_UN8 (s, d, tmp); michael@0: michael@0: src++; michael@0: dst++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_add_n_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: uint32_t src; michael@0: uint8_t sa; michael@0: __m64 vsrc, vsrca; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: sa = src >> 24; michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: vsrc = load8888 (&src); michael@0: vsrca = expand_alpha (vsrc); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 3) michael@0: { michael@0: uint16_t tmp; michael@0: uint16_t a; michael@0: uint32_t m, d; michael@0: uint32_t r; michael@0: michael@0: a = *mask++; michael@0: d = *dst; michael@0: michael@0: m = MUL_UN8 (sa, a, tmp); michael@0: r = ADD_UN8 (m, d, tmp); michael@0: michael@0: *dst++ = r; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vmask; michael@0: __m64 vdest; michael@0: michael@0: vmask = load8888u ((uint32_t *)mask); michael@0: vdest = load8888 ((uint32_t *)dst); michael@0: michael@0: store8888 ((uint32_t *)dst, _mm_adds_pu8 (in (vsrca, vmask), vdest)); michael@0: michael@0: dst += 4; michael@0: mask += 4; michael@0: w -= 4; michael@0: } michael@0: michael@0: while (w--) michael@0: { michael@0: uint16_t tmp; michael@0: uint16_t a; michael@0: uint32_t m, d; michael@0: uint32_t r; michael@0: michael@0: a = *mask++; michael@0: d = *dst; michael@0: michael@0: m = MUL_UN8 (sa, a, tmp); michael@0: r = ADD_UN8 (m, d, tmp); michael@0: michael@0: *dst++ = r; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_add_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: uint8_t s, d; michael@0: uint16_t t; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: s = *src; michael@0: d = *dst; michael@0: t = d + s; michael@0: s = t | (0 - (t >> 8)); michael@0: *dst = s; michael@0: michael@0: dst++; michael@0: src++; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 8) michael@0: { michael@0: *(__m64*)dst = _mm_adds_pu8 (ldq_u ((__m64 *)src), *(__m64*)dst); michael@0: dst += 8; michael@0: src += 8; michael@0: w -= 8; michael@0: } michael@0: michael@0: while (w) michael@0: { michael@0: s = *src; michael@0: d = *dst; michael@0: t = d + s; michael@0: s = t | (0 - (t >> 8)); michael@0: *dst = s; michael@0: michael@0: dst++; michael@0: src++; michael@0: w--; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_add_0565_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint16_t *src_line, *src; michael@0: uint32_t s; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint16_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: s = *src++; michael@0: if (s) michael@0: { michael@0: d = *dst; michael@0: s = convert_0565_to_8888 (s); michael@0: if (d) michael@0: { michael@0: d = convert_0565_to_8888 (d); michael@0: UN8x4_ADD_UN8x4 (s, d); michael@0: } michael@0: *dst = convert_8888_to_0565 (s); michael@0: } michael@0: dst++; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: __m64 vsrc = ldq_u ((__m64 *)src); michael@0: __m64 vd0, vd1; michael@0: __m64 vs0, vs1; michael@0: michael@0: expand_4xpacked565 (vdest, &vd0, &vd1, 0); michael@0: expand_4xpacked565 (vsrc, &vs0, &vs1, 0); michael@0: michael@0: vd0 = _mm_adds_pu8 (vd0, vs0); michael@0: vd1 = _mm_adds_pu8 (vd1, vs1); michael@0: michael@0: *(__m64 *)dst = pack_4xpacked565 (vd0, vd1); michael@0: michael@0: dst += 4; michael@0: src += 4; michael@0: w -= 4; michael@0: } michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: if (s) michael@0: { michael@0: d = *dst; michael@0: s = convert_0565_to_8888 (s); michael@0: if (d) michael@0: { michael@0: d = convert_0565_to_8888 (d); michael@0: UN8x4_ADD_UN8x4 (s, d); michael@0: } michael@0: *dst = convert_8888_to_0565 (s); michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_add_8888_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: store (dst, _mm_adds_pu8 (load ((const uint32_t *)src), michael@0: load ((const uint32_t *)dst))); michael@0: dst++; michael@0: src++; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 2) michael@0: { michael@0: *(__m64 *)dst = _mm_adds_pu8 (ldq_u ((__m64 *)src), *(__m64*)dst); michael@0: dst += 2; michael@0: src += 2; michael@0: w -= 2; michael@0: } michael@0: michael@0: if (w) michael@0: { michael@0: store (dst, _mm_adds_pu8 (load ((const uint32_t *)src), michael@0: load ((const uint32_t *)dst))); michael@0: michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: mmx_blt (pixman_implementation_t *imp, michael@0: uint32_t * src_bits, michael@0: uint32_t * dst_bits, michael@0: int src_stride, michael@0: int dst_stride, michael@0: int src_bpp, michael@0: int dst_bpp, michael@0: int src_x, michael@0: int src_y, michael@0: int dest_x, michael@0: int dest_y, michael@0: int width, michael@0: int height) michael@0: { michael@0: uint8_t * src_bytes; michael@0: uint8_t * dst_bytes; michael@0: int byte_width; michael@0: michael@0: if (src_bpp != dst_bpp) michael@0: return FALSE; michael@0: michael@0: if (src_bpp == 16) michael@0: { michael@0: src_stride = src_stride * (int) sizeof (uint32_t) / 2; michael@0: dst_stride = dst_stride * (int) sizeof (uint32_t) / 2; michael@0: src_bytes = (uint8_t *)(((uint16_t *)src_bits) + src_stride * (src_y) + (src_x)); michael@0: dst_bytes = (uint8_t *)(((uint16_t *)dst_bits) + dst_stride * (dest_y) + (dest_x)); michael@0: byte_width = 2 * width; michael@0: src_stride *= 2; michael@0: dst_stride *= 2; michael@0: } michael@0: else if (src_bpp == 32) michael@0: { michael@0: src_stride = src_stride * (int) sizeof (uint32_t) / 4; michael@0: dst_stride = dst_stride * (int) sizeof (uint32_t) / 4; michael@0: src_bytes = (uint8_t *)(((uint32_t *)src_bits) + src_stride * (src_y) + (src_x)); michael@0: dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + dst_stride * (dest_y) + (dest_x)); michael@0: byte_width = 4 * width; michael@0: src_stride *= 4; michael@0: dst_stride *= 4; michael@0: } michael@0: else michael@0: { michael@0: return FALSE; michael@0: } michael@0: michael@0: while (height--) michael@0: { michael@0: int w; michael@0: uint8_t *s = src_bytes; michael@0: uint8_t *d = dst_bytes; michael@0: src_bytes += src_stride; michael@0: dst_bytes += dst_stride; michael@0: w = byte_width; michael@0: michael@0: if (w >= 1 && ((uintptr_t)d & 1)) michael@0: { michael@0: *(uint8_t *)d = *(uint8_t *)s; michael@0: w -= 1; michael@0: s += 1; michael@0: d += 1; michael@0: } michael@0: michael@0: if (w >= 2 && ((uintptr_t)d & 3)) michael@0: { michael@0: *(uint16_t *)d = *(uint16_t *)s; michael@0: w -= 2; michael@0: s += 2; michael@0: d += 2; michael@0: } michael@0: michael@0: while (w >= 4 && ((uintptr_t)d & 7)) michael@0: { michael@0: *(uint32_t *)d = ldl_u ((uint32_t *)s); michael@0: michael@0: w -= 4; michael@0: s += 4; michael@0: d += 4; michael@0: } michael@0: michael@0: while (w >= 64) michael@0: { michael@0: #if (defined (__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined USE_X86_MMX michael@0: __asm__ ( michael@0: "movq (%1), %%mm0\n" michael@0: "movq 8(%1), %%mm1\n" michael@0: "movq 16(%1), %%mm2\n" michael@0: "movq 24(%1), %%mm3\n" michael@0: "movq 32(%1), %%mm4\n" michael@0: "movq 40(%1), %%mm5\n" michael@0: "movq 48(%1), %%mm6\n" michael@0: "movq 56(%1), %%mm7\n" michael@0: michael@0: "movq %%mm0, (%0)\n" michael@0: "movq %%mm1, 8(%0)\n" michael@0: "movq %%mm2, 16(%0)\n" michael@0: "movq %%mm3, 24(%0)\n" michael@0: "movq %%mm4, 32(%0)\n" michael@0: "movq %%mm5, 40(%0)\n" michael@0: "movq %%mm6, 48(%0)\n" michael@0: "movq %%mm7, 56(%0)\n" michael@0: : michael@0: : "r" (d), "r" (s) michael@0: : "memory", michael@0: "%mm0", "%mm1", "%mm2", "%mm3", michael@0: "%mm4", "%mm5", "%mm6", "%mm7"); michael@0: #else michael@0: __m64 v0 = ldq_u ((__m64 *)(s + 0)); michael@0: __m64 v1 = ldq_u ((__m64 *)(s + 8)); michael@0: __m64 v2 = ldq_u ((__m64 *)(s + 16)); michael@0: __m64 v3 = ldq_u ((__m64 *)(s + 24)); michael@0: __m64 v4 = ldq_u ((__m64 *)(s + 32)); michael@0: __m64 v5 = ldq_u ((__m64 *)(s + 40)); michael@0: __m64 v6 = ldq_u ((__m64 *)(s + 48)); michael@0: __m64 v7 = ldq_u ((__m64 *)(s + 56)); michael@0: *(__m64 *)(d + 0) = v0; michael@0: *(__m64 *)(d + 8) = v1; michael@0: *(__m64 *)(d + 16) = v2; michael@0: *(__m64 *)(d + 24) = v3; michael@0: *(__m64 *)(d + 32) = v4; michael@0: *(__m64 *)(d + 40) = v5; michael@0: *(__m64 *)(d + 48) = v6; michael@0: *(__m64 *)(d + 56) = v7; michael@0: #endif michael@0: michael@0: w -= 64; michael@0: s += 64; michael@0: d += 64; michael@0: } michael@0: while (w >= 4) michael@0: { michael@0: *(uint32_t *)d = ldl_u ((uint32_t *)s); michael@0: michael@0: w -= 4; michael@0: s += 4; michael@0: d += 4; michael@0: } michael@0: if (w >= 2) michael@0: { michael@0: *(uint16_t *)d = *(uint16_t *)s; michael@0: w -= 2; michael@0: s += 2; michael@0: d += 2; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: michael@0: return TRUE; michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_copy_area (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: michael@0: mmx_blt (imp, src_image->bits.bits, michael@0: dest_image->bits.bits, michael@0: src_image->bits.rowstride, michael@0: dest_image->bits.rowstride, michael@0: PIXMAN_FORMAT_BPP (src_image->bits.format), michael@0: PIXMAN_FORMAT_BPP (dest_image->bits.format), michael@0: src_x, src_y, dest_x, dest_y, width, height); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_x888_8_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *src, *src_line; michael@0: uint32_t *dst, *dst_line; michael@0: uint8_t *mask, *mask_line; michael@0: int src_stride, mask_stride, dst_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: uint64_t m = *mask; michael@0: michael@0: if (m) michael@0: { michael@0: uint32_t ssrc = *src | 0xff000000; michael@0: __m64 s = load8888 (&ssrc); michael@0: michael@0: if (m == 0xff) michael@0: { michael@0: store8888 (dst, s); michael@0: } michael@0: else michael@0: { michael@0: __m64 sa = expand_alpha (s); michael@0: __m64 vm = expand_alpha_rev (to_m64 (m)); michael@0: __m64 vdest = in_over (s, sa, vm, load8888 (dst)); michael@0: michael@0: store8888 (dst, vdest); michael@0: } michael@0: } michael@0: michael@0: mask++; michael@0: dst++; michael@0: src++; michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: static void michael@0: mmx_composite_over_reverse_n_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src; michael@0: uint32_t *dst_line, *dst; michael@0: int32_t w; michael@0: int dst_stride; michael@0: __m64 vsrc; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: michael@0: vsrc = load8888 (&src); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: w = width; michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: while (w && (uintptr_t)dst & 7) michael@0: { michael@0: __m64 vdest = load8888 (dst); michael@0: michael@0: store8888 (dst, over (vdest, expand_alpha (vdest), vsrc)); michael@0: michael@0: w--; michael@0: dst++; michael@0: } michael@0: michael@0: while (w >= 2) michael@0: { michael@0: __m64 vdest = *(__m64 *)dst; michael@0: __m64 dest0 = expand8888 (vdest, 0); michael@0: __m64 dest1 = expand8888 (vdest, 1); michael@0: michael@0: michael@0: dest0 = over (dest0, expand_alpha (dest0), vsrc); michael@0: dest1 = over (dest1, expand_alpha (dest1), vsrc); michael@0: michael@0: *(__m64 *)dst = pack8888 (dest0, dest1); michael@0: michael@0: dst += 2; michael@0: w -= 2; michael@0: } michael@0: michael@0: CHECKPOINT (); michael@0: michael@0: if (w) michael@0: { michael@0: __m64 vdest = load8888 (dst); michael@0: michael@0: store8888 (dst, over (vdest, expand_alpha (vdest), vsrc)); michael@0: } michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: #define BSHIFT ((1 << BILINEAR_INTERPOLATION_BITS)) michael@0: #define BMSK (BSHIFT - 1) michael@0: michael@0: #define BILINEAR_DECLARE_VARIABLES \ michael@0: const __m64 mm_wt = _mm_set_pi16 (wt, wt, wt, wt); \ michael@0: const __m64 mm_wb = _mm_set_pi16 (wb, wb, wb, wb); \ michael@0: const __m64 mm_BSHIFT = _mm_set_pi16 (BSHIFT, BSHIFT, BSHIFT, BSHIFT); \ michael@0: const __m64 mm_addc7 = _mm_set_pi16 (0, 1, 0, 1); \ michael@0: const __m64 mm_xorc7 = _mm_set_pi16 (0, BMSK, 0, BMSK); \ michael@0: const __m64 mm_ux = _mm_set_pi16 (unit_x, unit_x, unit_x, unit_x); \ michael@0: const __m64 mm_zero = _mm_setzero_si64 (); \ michael@0: __m64 mm_x = _mm_set_pi16 (vx, vx, vx, vx) michael@0: michael@0: #define BILINEAR_INTERPOLATE_ONE_PIXEL(pix) \ michael@0: do { \ michael@0: /* fetch 2x2 pixel block into 2 mmx registers */ \ michael@0: __m64 t = ldq_u ((__m64 *)&src_top [pixman_fixed_to_int (vx)]); \ michael@0: __m64 b = ldq_u ((__m64 *)&src_bottom [pixman_fixed_to_int (vx)]); \ michael@0: /* vertical interpolation */ \ michael@0: __m64 t_hi = _mm_mullo_pi16 (_mm_unpackhi_pi8 (t, mm_zero), mm_wt); \ michael@0: __m64 t_lo = _mm_mullo_pi16 (_mm_unpacklo_pi8 (t, mm_zero), mm_wt); \ michael@0: __m64 b_hi = _mm_mullo_pi16 (_mm_unpackhi_pi8 (b, mm_zero), mm_wb); \ michael@0: __m64 b_lo = _mm_mullo_pi16 (_mm_unpacklo_pi8 (b, mm_zero), mm_wb); \ michael@0: __m64 hi = _mm_add_pi16 (t_hi, b_hi); \ michael@0: __m64 lo = _mm_add_pi16 (t_lo, b_lo); \ michael@0: vx += unit_x; \ michael@0: if (BILINEAR_INTERPOLATION_BITS < 8) \ michael@0: { \ michael@0: /* calculate horizontal weights */ \ michael@0: __m64 mm_wh = _mm_add_pi16 (mm_addc7, _mm_xor_si64 (mm_xorc7, \ michael@0: _mm_srli_pi16 (mm_x, \ michael@0: 16 - BILINEAR_INTERPOLATION_BITS))); \ michael@0: /* horizontal interpolation */ \ michael@0: __m64 p = _mm_unpacklo_pi16 (lo, hi); \ michael@0: __m64 q = _mm_unpackhi_pi16 (lo, hi); \ michael@0: lo = _mm_madd_pi16 (p, mm_wh); \ michael@0: hi = _mm_madd_pi16 (q, mm_wh); \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: /* calculate horizontal weights */ \ michael@0: __m64 mm_wh_lo = _mm_sub_pi16 (mm_BSHIFT, _mm_srli_pi16 (mm_x, \ michael@0: 16 - BILINEAR_INTERPOLATION_BITS)); \ michael@0: __m64 mm_wh_hi = _mm_srli_pi16 (mm_x, \ michael@0: 16 - BILINEAR_INTERPOLATION_BITS); \ michael@0: /* horizontal interpolation */ \ michael@0: __m64 mm_lo_lo = _mm_mullo_pi16 (lo, mm_wh_lo); \ michael@0: __m64 mm_lo_hi = _mm_mullo_pi16 (hi, mm_wh_hi); \ michael@0: __m64 mm_hi_lo = _mm_mulhi_pu16 (lo, mm_wh_lo); \ michael@0: __m64 mm_hi_hi = _mm_mulhi_pu16 (hi, mm_wh_hi); \ michael@0: lo = _mm_add_pi32 (_mm_unpacklo_pi16 (mm_lo_lo, mm_hi_lo), \ michael@0: _mm_unpacklo_pi16 (mm_lo_hi, mm_hi_hi)); \ michael@0: hi = _mm_add_pi32 (_mm_unpackhi_pi16 (mm_lo_lo, mm_hi_lo), \ michael@0: _mm_unpackhi_pi16 (mm_lo_hi, mm_hi_hi)); \ michael@0: } \ michael@0: mm_x = _mm_add_pi16 (mm_x, mm_ux); \ michael@0: /* shift and pack the result */ \ michael@0: hi = _mm_srli_pi32 (hi, BILINEAR_INTERPOLATION_BITS * 2); \ michael@0: lo = _mm_srli_pi32 (lo, BILINEAR_INTERPOLATION_BITS * 2); \ michael@0: lo = _mm_packs_pi32 (lo, hi); \ michael@0: lo = _mm_packs_pu16 (lo, lo); \ michael@0: pix = lo; \ michael@0: } while (0) michael@0: michael@0: #define BILINEAR_SKIP_ONE_PIXEL() \ michael@0: do { \ michael@0: vx += unit_x; \ michael@0: mm_x = _mm_add_pi16 (mm_x, mm_ux); \ michael@0: } while(0) michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_mmx_8888_8888_SRC (uint32_t * dst, michael@0: const uint32_t * mask, michael@0: const uint32_t * src_top, michael@0: const uint32_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: BILINEAR_DECLARE_VARIABLES; michael@0: __m64 pix; michael@0: michael@0: while (w--) michael@0: { michael@0: BILINEAR_INTERPOLATE_ONE_PIXEL (pix); michael@0: store (dst, pix); michael@0: dst++; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_cover_SRC, michael@0: scaled_bilinear_scanline_mmx_8888_8888_SRC, michael@0: uint32_t, uint32_t, uint32_t, michael@0: COVER, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_pad_SRC, michael@0: scaled_bilinear_scanline_mmx_8888_8888_SRC, michael@0: uint32_t, uint32_t, uint32_t, michael@0: PAD, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_none_SRC, michael@0: scaled_bilinear_scanline_mmx_8888_8888_SRC, michael@0: uint32_t, uint32_t, uint32_t, michael@0: NONE, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_normal_SRC, michael@0: scaled_bilinear_scanline_mmx_8888_8888_SRC, michael@0: uint32_t, uint32_t, uint32_t, michael@0: NORMAL, FLAG_NONE) michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_mmx_8888_8888_OVER (uint32_t * dst, michael@0: const uint32_t * mask, michael@0: const uint32_t * src_top, michael@0: const uint32_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: BILINEAR_DECLARE_VARIABLES; michael@0: __m64 pix1, pix2; michael@0: michael@0: while (w) michael@0: { michael@0: BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); michael@0: michael@0: if (!is_zero (pix1)) michael@0: { michael@0: pix2 = load (dst); michael@0: store8888 (dst, core_combine_over_u_pixel_mmx (pix1, pix2)); michael@0: } michael@0: michael@0: w--; michael@0: dst++; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_cover_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8888_OVER, michael@0: uint32_t, uint32_t, uint32_t, michael@0: COVER, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_pad_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8888_OVER, michael@0: uint32_t, uint32_t, uint32_t, michael@0: PAD, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_none_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8888_OVER, michael@0: uint32_t, uint32_t, uint32_t, michael@0: NONE, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8888_normal_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8888_OVER, michael@0: uint32_t, uint32_t, uint32_t, michael@0: NORMAL, FLAG_NONE) michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_mmx_8888_8_8888_OVER (uint32_t * dst, michael@0: const uint8_t * mask, michael@0: const uint32_t * src_top, michael@0: const uint32_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: BILINEAR_DECLARE_VARIABLES; michael@0: __m64 pix1, pix2; michael@0: uint32_t m; michael@0: michael@0: while (w) michael@0: { michael@0: m = (uint32_t) *mask++; michael@0: michael@0: if (m) michael@0: { michael@0: BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); michael@0: michael@0: if (m == 0xff && is_opaque (pix1)) michael@0: { michael@0: store (dst, pix1); michael@0: } michael@0: else michael@0: { michael@0: __m64 ms, md, ma, msa; michael@0: michael@0: pix2 = load (dst); michael@0: ma = expand_alpha_rev (to_m64 (m)); michael@0: ms = _mm_unpacklo_pi8 (pix1, _mm_setzero_si64 ()); michael@0: md = _mm_unpacklo_pi8 (pix2, _mm_setzero_si64 ()); michael@0: michael@0: msa = expand_alpha (ms); michael@0: michael@0: store8888 (dst, (in_over (ms, msa, ma, md))); michael@0: } michael@0: } michael@0: else michael@0: { michael@0: BILINEAR_SKIP_ONE_PIXEL (); michael@0: } michael@0: michael@0: w--; michael@0: dst++; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: } michael@0: michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8_8888_cover_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8_8888_OVER, michael@0: uint32_t, uint8_t, uint32_t, michael@0: COVER, FLAG_HAVE_NON_SOLID_MASK) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8_8888_pad_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8_8888_OVER, michael@0: uint32_t, uint8_t, uint32_t, michael@0: PAD, FLAG_HAVE_NON_SOLID_MASK) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8_8888_none_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8_8888_OVER, michael@0: uint32_t, uint8_t, uint32_t, michael@0: NONE, FLAG_HAVE_NON_SOLID_MASK) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (mmx_8888_8_8888_normal_OVER, michael@0: scaled_bilinear_scanline_mmx_8888_8_8888_OVER, michael@0: uint32_t, uint8_t, uint32_t, michael@0: NORMAL, FLAG_HAVE_NON_SOLID_MASK) michael@0: michael@0: static uint32_t * michael@0: mmx_fetch_x8r8g8b8 (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: int w = iter->width; michael@0: uint32_t *dst = iter->buffer; michael@0: uint32_t *src = (uint32_t *)iter->bits; michael@0: michael@0: iter->bits += iter->stride; michael@0: michael@0: while (w && ((uintptr_t)dst) & 7) michael@0: { michael@0: *dst++ = (*src++) | 0xff000000; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 8) michael@0: { michael@0: __m64 vsrc1 = ldq_u ((__m64 *)(src + 0)); michael@0: __m64 vsrc2 = ldq_u ((__m64 *)(src + 2)); michael@0: __m64 vsrc3 = ldq_u ((__m64 *)(src + 4)); michael@0: __m64 vsrc4 = ldq_u ((__m64 *)(src + 6)); michael@0: michael@0: *(__m64 *)(dst + 0) = _mm_or_si64 (vsrc1, MC (ff000000)); michael@0: *(__m64 *)(dst + 2) = _mm_or_si64 (vsrc2, MC (ff000000)); michael@0: *(__m64 *)(dst + 4) = _mm_or_si64 (vsrc3, MC (ff000000)); michael@0: *(__m64 *)(dst + 6) = _mm_or_si64 (vsrc4, MC (ff000000)); michael@0: michael@0: dst += 8; michael@0: src += 8; michael@0: w -= 8; michael@0: } michael@0: michael@0: while (w) michael@0: { michael@0: *dst++ = (*src++) | 0xff000000; michael@0: w--; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: return iter->buffer; michael@0: } michael@0: michael@0: static uint32_t * michael@0: mmx_fetch_r5g6b5 (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: int w = iter->width; michael@0: uint32_t *dst = iter->buffer; michael@0: uint16_t *src = (uint16_t *)iter->bits; michael@0: michael@0: iter->bits += iter->stride; michael@0: michael@0: while (w && ((uintptr_t)dst) & 0x0f) michael@0: { michael@0: uint16_t s = *src++; michael@0: michael@0: *dst++ = convert_0565_to_8888 (s); michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 4) michael@0: { michael@0: __m64 vsrc = ldq_u ((__m64 *)src); michael@0: __m64 mm0, mm1; michael@0: michael@0: expand_4xpacked565 (vsrc, &mm0, &mm1, 1); michael@0: michael@0: *(__m64 *)(dst + 0) = mm0; michael@0: *(__m64 *)(dst + 2) = mm1; michael@0: michael@0: dst += 4; michael@0: src += 4; michael@0: w -= 4; michael@0: } michael@0: michael@0: while (w) michael@0: { michael@0: uint16_t s = *src++; michael@0: michael@0: *dst++ = convert_0565_to_8888 (s); michael@0: w--; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: return iter->buffer; michael@0: } michael@0: michael@0: static uint32_t * michael@0: mmx_fetch_a8 (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: int w = iter->width; michael@0: uint32_t *dst = iter->buffer; michael@0: uint8_t *src = iter->bits; michael@0: michael@0: iter->bits += iter->stride; michael@0: michael@0: while (w && (((uintptr_t)dst) & 15)) michael@0: { michael@0: *dst++ = *(src++) << 24; michael@0: w--; michael@0: } michael@0: michael@0: while (w >= 8) michael@0: { michael@0: __m64 mm0 = ldq_u ((__m64 *)src); michael@0: michael@0: __m64 mm1 = _mm_unpacklo_pi8 (_mm_setzero_si64(), mm0); michael@0: __m64 mm2 = _mm_unpackhi_pi8 (_mm_setzero_si64(), mm0); michael@0: __m64 mm3 = _mm_unpacklo_pi16 (_mm_setzero_si64(), mm1); michael@0: __m64 mm4 = _mm_unpackhi_pi16 (_mm_setzero_si64(), mm1); michael@0: __m64 mm5 = _mm_unpacklo_pi16 (_mm_setzero_si64(), mm2); michael@0: __m64 mm6 = _mm_unpackhi_pi16 (_mm_setzero_si64(), mm2); michael@0: michael@0: *(__m64 *)(dst + 0) = mm3; michael@0: *(__m64 *)(dst + 2) = mm4; michael@0: *(__m64 *)(dst + 4) = mm5; michael@0: *(__m64 *)(dst + 6) = mm6; michael@0: michael@0: dst += 8; michael@0: src += 8; michael@0: w -= 8; michael@0: } michael@0: michael@0: while (w) michael@0: { michael@0: *dst++ = *(src++) << 24; michael@0: w--; michael@0: } michael@0: michael@0: _mm_empty (); michael@0: return iter->buffer; michael@0: } michael@0: michael@0: typedef struct michael@0: { michael@0: pixman_format_code_t format; michael@0: pixman_iter_get_scanline_t get_scanline; michael@0: } fetcher_info_t; michael@0: michael@0: static const fetcher_info_t fetchers[] = michael@0: { michael@0: { PIXMAN_x8r8g8b8, mmx_fetch_x8r8g8b8 }, michael@0: { PIXMAN_r5g6b5, mmx_fetch_r5g6b5 }, michael@0: { PIXMAN_a8, mmx_fetch_a8 }, michael@0: { PIXMAN_null } michael@0: }; michael@0: michael@0: static pixman_bool_t michael@0: mmx_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) michael@0: { michael@0: pixman_image_t *image = iter->image; michael@0: michael@0: #define FLAGS \ michael@0: (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | \ michael@0: FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST) michael@0: michael@0: if ((iter->iter_flags & ITER_NARROW) && michael@0: (iter->image_flags & FLAGS) == FLAGS) michael@0: { michael@0: const fetcher_info_t *f; michael@0: michael@0: for (f = &fetchers[0]; f->format != PIXMAN_null; f++) michael@0: { michael@0: if (image->common.extended_format_code == f->format) michael@0: { michael@0: uint8_t *b = (uint8_t *)image->bits.bits; michael@0: int s = image->bits.rowstride * 4; michael@0: michael@0: iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (f->format) / 8; michael@0: iter->stride = s; michael@0: michael@0: iter->get_scanline = f->get_scanline; michael@0: return TRUE; michael@0: } michael@0: } michael@0: } michael@0: michael@0: return FALSE; michael@0: } michael@0: michael@0: static const pixman_fast_path_t mmx_fast_paths[] = michael@0: { michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, mmx_composite_over_n_8_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, mmx_composite_over_n_8_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8r8g8b8, mmx_composite_over_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8r8g8b8, mmx_composite_over_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8b8g8r8, mmx_composite_over_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8b8g8r8, mmx_composite_over_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, a8r8g8b8, mmx_composite_over_n_8888_8888_ca ), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, x8r8g8b8, mmx_composite_over_n_8888_8888_ca ), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, r5g6b5, mmx_composite_over_n_8888_0565_ca ), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, a8b8g8r8, mmx_composite_over_n_8888_8888_ca ), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, x8b8g8r8, mmx_composite_over_n_8888_8888_ca ), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, b5g6r5, mmx_composite_over_n_8888_0565_ca ), michael@0: PIXMAN_STD_FAST_PATH (OVER, pixbuf, pixbuf, a8r8g8b8, mmx_composite_over_pixbuf_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, pixbuf, pixbuf, x8r8g8b8, mmx_composite_over_pixbuf_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, pixbuf, pixbuf, r5g6b5, mmx_composite_over_pixbuf_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, rpixbuf, rpixbuf, a8b8g8r8, mmx_composite_over_pixbuf_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, rpixbuf, rpixbuf, x8b8g8r8, mmx_composite_over_pixbuf_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, rpixbuf, rpixbuf, b5g6r5, mmx_composite_over_pixbuf_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, solid, a8r8g8b8, mmx_composite_over_x888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, solid, x8r8g8b8, mmx_composite_over_x888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, solid, a8b8g8r8, mmx_composite_over_x888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, solid, x8b8g8r8, mmx_composite_over_x888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, solid, a8r8g8b8, mmx_composite_over_8888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, solid, x8r8g8b8, mmx_composite_over_8888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, solid, a8b8g8r8, mmx_composite_over_8888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, solid, x8b8g8r8, mmx_composite_over_8888_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, x8r8g8b8, mmx_composite_over_x888_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, a8r8g8b8, mmx_composite_over_x888_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, x8b8g8r8, mmx_composite_over_x888_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, a8b8g8r8, mmx_composite_over_x888_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, null, a8r8g8b8, mmx_composite_over_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, null, x8r8g8b8, mmx_composite_over_n_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, null, r5g6b5, mmx_composite_over_n_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, null, b5g6r5, mmx_composite_over_n_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, null, x8r8g8b8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, null, x8b8g8r8, mmx_composite_copy_area ), michael@0: michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, a8r8g8b8, mmx_composite_over_8888_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, x8r8g8b8, mmx_composite_over_8888_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, r5g6b5, mmx_composite_over_8888_0565 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, a8b8g8r8, mmx_composite_over_8888_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, x8b8g8r8, mmx_composite_over_8888_8888 ), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, b5g6r5, mmx_composite_over_8888_0565 ), michael@0: michael@0: PIXMAN_STD_FAST_PATH (OVER_REVERSE, solid, null, a8r8g8b8, mmx_composite_over_reverse_n_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER_REVERSE, solid, null, a8b8g8r8, mmx_composite_over_reverse_n_8888), michael@0: michael@0: PIXMAN_STD_FAST_PATH (ADD, r5g6b5, null, r5g6b5, mmx_composite_add_0565_0565 ), michael@0: PIXMAN_STD_FAST_PATH (ADD, b5g6r5, null, b5g6r5, mmx_composite_add_0565_0565 ), michael@0: PIXMAN_STD_FAST_PATH (ADD, a8r8g8b8, null, a8r8g8b8, mmx_composite_add_8888_8888 ), michael@0: PIXMAN_STD_FAST_PATH (ADD, a8b8g8r8, null, a8b8g8r8, mmx_composite_add_8888_8888 ), michael@0: PIXMAN_STD_FAST_PATH (ADD, a8, null, a8, mmx_composite_add_8_8 ), michael@0: PIXMAN_STD_FAST_PATH (ADD, solid, a8, a8, mmx_composite_add_n_8_8 ), michael@0: michael@0: PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, r5g6b5, mmx_composite_src_x888_0565 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, b5g6r5, mmx_composite_src_x888_0565 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, r5g6b5, mmx_composite_src_x888_0565 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, b5g6r5, mmx_composite_src_x888_0565 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8r8g8b8, mmx_composite_src_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8r8g8b8, mmx_composite_src_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8b8g8r8, mmx_composite_src_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8b8g8r8, mmx_composite_src_n_8_8888 ), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, a8r8g8b8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, a8b8g8r8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, x8r8g8b8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, x8b8g8r8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, x8r8g8b8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, x8b8g8r8, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, r5g6b5, null, r5g6b5, mmx_composite_copy_area ), michael@0: PIXMAN_STD_FAST_PATH (SRC, b5g6r5, null, b5g6r5, mmx_composite_copy_area ), michael@0: michael@0: PIXMAN_STD_FAST_PATH (IN, a8, null, a8, mmx_composite_in_8_8 ), michael@0: PIXMAN_STD_FAST_PATH (IN, solid, a8, a8, mmx_composite_in_n_8_8 ), michael@0: michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, mmx_8888_8888 ), michael@0: michael@0: SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, mmx_8888_8888 ), michael@0: SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, mmx_8888_8888 ), michael@0: michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, mmx_8888_8_8888 ), michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, mmx_8888_8_8888 ), michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, mmx_8888_8_8888 ), michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, mmx_8888_8_8888 ), michael@0: michael@0: { PIXMAN_OP_NONE }, michael@0: }; michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_mmx (pixman_implementation_t *fallback) michael@0: { michael@0: pixman_implementation_t *imp = _pixman_implementation_create (fallback, mmx_fast_paths); michael@0: michael@0: imp->combine_32[PIXMAN_OP_OVER] = mmx_combine_over_u; michael@0: imp->combine_32[PIXMAN_OP_OVER_REVERSE] = mmx_combine_over_reverse_u; michael@0: imp->combine_32[PIXMAN_OP_IN] = mmx_combine_in_u; michael@0: imp->combine_32[PIXMAN_OP_IN_REVERSE] = mmx_combine_in_reverse_u; michael@0: imp->combine_32[PIXMAN_OP_OUT] = mmx_combine_out_u; michael@0: imp->combine_32[PIXMAN_OP_OUT_REVERSE] = mmx_combine_out_reverse_u; michael@0: imp->combine_32[PIXMAN_OP_ATOP] = mmx_combine_atop_u; michael@0: imp->combine_32[PIXMAN_OP_ATOP_REVERSE] = mmx_combine_atop_reverse_u; michael@0: imp->combine_32[PIXMAN_OP_XOR] = mmx_combine_xor_u; michael@0: imp->combine_32[PIXMAN_OP_ADD] = mmx_combine_add_u; michael@0: imp->combine_32[PIXMAN_OP_SATURATE] = mmx_combine_saturate_u; michael@0: michael@0: imp->combine_32_ca[PIXMAN_OP_SRC] = mmx_combine_src_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_OVER] = mmx_combine_over_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_OVER_REVERSE] = mmx_combine_over_reverse_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_IN] = mmx_combine_in_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_IN_REVERSE] = mmx_combine_in_reverse_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_OUT] = mmx_combine_out_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_OUT_REVERSE] = mmx_combine_out_reverse_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_ATOP] = mmx_combine_atop_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_ATOP_REVERSE] = mmx_combine_atop_reverse_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_XOR] = mmx_combine_xor_ca; michael@0: imp->combine_32_ca[PIXMAN_OP_ADD] = mmx_combine_add_ca; michael@0: michael@0: imp->blt = mmx_blt; michael@0: imp->fill = mmx_fill; michael@0: michael@0: imp->src_iter_init = mmx_src_iter_init; michael@0: michael@0: return imp; michael@0: } michael@0: michael@0: #endif /* USE_X86_MMX || USE_ARM_IWMMXT || USE_LOONGSON_MMI */