diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2007-06-11 15:29:11 -0400 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-uranus.epoch.ncsc.mil> | 2007-06-11 15:29:11 -0400 |
commit | e2a720c9a17dc860ee0a858c2b21fd71e86cdcd0 (patch) | |
tree | 980937a838242092b0ec6b9cfc89b39af99d045b /fb | |
parent | 878cac71aa0018deee861b297638c0744dba631b (diff) | |
parent | 3f9adb18f127318d054f30a57e3a77176e14c692 (diff) |
Merge branch 'master' into XACE-SELINUX
Conflicts:
dix/dixutils.c
Diffstat (limited to 'fb')
-rw-r--r-- | fb/Makefile.am | 4 | ||||
-rw-r--r-- | fb/fb.h | 6 | ||||
-rw-r--r-- | fb/fbcopy.c | 24 | ||||
-rw-r--r-- | fb/fbedge.c | 314 | ||||
-rw-r--r-- | fb/fbedgeimp.h | 145 | ||||
-rw-r--r-- | fb/fbfill.c | 19 | ||||
-rw-r--r-- | fb/fbmmx.c | 2607 | ||||
-rw-r--r-- | fb/fbmmx.h | 264 | ||||
-rw-r--r-- | fb/fbpict.c | 372 | ||||
-rw-r--r-- | fb/fbpict.h | 12 | ||||
-rw-r--r-- | fb/fbtrap.c | 103 | ||||
-rw-r--r-- | fb/fbwindow.c | 27 | ||||
-rw-r--r-- | fb/wfbrename.h | 2 |
13 files changed, 292 insertions, 3607 deletions
diff --git a/fb/Makefile.am b/fb/Makefile.am index 01e81da41..28c0cc703 100644 --- a/fb/Makefile.am +++ b/fb/Makefile.am @@ -69,9 +69,7 @@ libfb_la_SOURCES = \ fbutil.c \ fbwindow.c \ fbpseudocolor.c \ - fbpseudocolor.h \ - fbedge.c \ - fbedgeimp.h + fbpseudocolor.h libwfb_la_SOURCES = $(libfb_la_SOURCES) @@ -26,6 +26,8 @@ #define _FB_H_ #include <X11/X.h> +#include <pixman/pixman.h> + #include "scrnintstr.h" #include "pixmap.h" #include "pixmapstr.h" @@ -2147,4 +2149,8 @@ void fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what); +pixman_image_t *image_from_pict (PicturePtr pict, + Bool has_clip); + #endif /* _FB_H_ */ + diff --git a/fb/fbcopy.c b/fb/fbcopy.c index 164cd3d67..a4302037a 100644 --- a/fb/fbcopy.c +++ b/fb/fbcopy.c @@ -60,21 +60,17 @@ fbCopyNtoN (DrawablePtr pSrcDrawable, while (nbox--) { -#ifdef USE_MMX +#ifndef FB_ACCESS_WRAPPER /* pixman_blt() doesn't support accessors yet */ if (pm == FB_ALLONES && alu == GXcopy && !reverse && - !upsidedown && fbHaveMMX()) + !upsidedown) { - if (!fbCopyAreammx (pSrcDrawable, - pDstDrawable, - - (pbox->x1 + dx), - (pbox->y1 + dy), - - (pbox->x1), - (pbox->y1), - - (pbox->x2 - pbox->x1), - (pbox->y2 - pbox->y1))) + if (!pixman_blt ((uint32_t *)src, (uint32_t *)dst, srcStride, dstStride, srcBpp, dstBpp, + (pbox->x1 + dx + srcXoff), + (pbox->y1 + dy + srcYoff), + (pbox->x1 + srcXoff), + (pbox->y1 + srcYoff), + (pbox->x2 - pbox->x1), + (pbox->y2 - pbox->y1))) goto fallback; else goto next; @@ -98,7 +94,7 @@ fbCopyNtoN (DrawablePtr pSrcDrawable, reverse, upsidedown); -#ifdef USE_MMX +#ifndef FB_ACCESS_WRAPPER next: #endif pbox++; diff --git a/fb/fbedge.c b/fb/fbedge.c deleted file mode 100644 index 70fc423bd..000000000 --- a/fb/fbedge.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2004 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include <string.h> - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "fb.h" - -#ifdef RENDER - -#include "picturestr.h" -#include "mipict.h" -#include "renderedge.h" -#include "fbpict.h" - -/* - * 4 bit alpha - */ - -#define N_BITS 4 -#define rasterizeEdges fbRasterizeEdges4 - -#if BITMAP_BIT_ORDER == LSBFirst -#define Shift4(o) ((o) << 2) -#else -#define Shift4(o) ((1-(o)) << 2) -#endif - -#define Get4(x,o) (((x) >> Shift4(o)) & 0xf) -#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o))) - -#define DefineAlpha(line,x) \ - CARD8 *__ap = (CARD8 *) line + ((x) >> 1); \ - int __ao = (x) & 1 - -#define StepAlpha ((__ap += __ao), (__ao ^= 1)) - -#define AddAlpha(a) { \ - CARD8 __o = READ(__ap); \ - CARD8 __a = (a) + Get4(__o, __ao); \ - WRITE(__ap, Put4 (__o, __ao, __a | (0 - ((__a) >> 4)))); \ -} - -#include "fbedgeimp.h" - -#undef AddAlpha -#undef StepAlpha -#undef DefineAlpha -#undef rasterizeEdges -#undef N_BITS - - -/* - * 1 bit alpha - */ - -#define N_BITS 1 -#define rasterizeEdges fbRasterizeEdges1 - -#include "fbedgeimp.h" - -#undef rasterizeEdges -#undef N_BITS - -/* - * 8 bit alpha - */ - -static INLINE CARD8 -clip255 (int x) -{ - if (x > 255) return 255; - return x; -} - -static INLINE void -add_saturate_8 (CARD8 *buf, int value, int length) -{ - while (length--) - { - WRITE(buf, clip255 (READ(buf) + value)); - buf++; - } -} - -/* - * We want to detect the case where we add the same value to a long - * span of pixels. The triangles on the end are filled in while we - * count how many sub-pixel scanlines contribute to the middle section. - * - * +--------------------------+ - * fill_height =| \ / - * +------------------+ - * |================| - * fill_start fill_end - */ -static void -fbRasterizeEdges8 (FbBits *buf, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b) -{ - xFixed y = t; - FbBits *line; - int fill_start = -1, fill_end = -1; - int fill_size = 0; - - line = buf + xFixedToInt (y) * stride; - - for (;;) - { - CARD8 *ap = (CARD8 *) line; - xFixed lx, rx; - int lxi, rxi; - - /* clip X */ - lx = l->x; - if (lx < 0) - lx = 0; - rx = r->x; - if (xFixedToInt (rx) >= width) - rx = IntToxFixed (width); - - /* Skip empty (or backwards) sections */ - if (rx > lx) - { - int lxs, rxs; - - /* Find pixel bounds for span. */ - lxi = xFixedToInt (lx); - rxi = xFixedToInt (rx); - - /* Sample coverage for edge pixels */ - lxs = RenderSamplesX (lx, 8); - rxs = RenderSamplesX (rx, 8); - - /* Add coverage across row */ - if (lxi == rxi) - { - WRITE(ap +lxi, clip255 (READ(ap + lxi) + rxs - lxs)); - } - else - { - WRITE(ap + lxi, clip255 (READ(ap + lxi) + N_X_FRAC(8) - lxs)); - - /* Move forward so that lxi/rxi is the pixel span */ - lxi++; - - /* Don't bother trying to optimize the fill unless - * the span is longer than 4 pixels. */ - if (rxi - lxi > 4) - { - if (fill_start < 0) - { - fill_start = lxi; - fill_end = rxi; - fill_size++; - } - else - { - if (lxi >= fill_end || rxi < fill_start) - { - /* We're beyond what we saved, just fill it */ - add_saturate_8 (ap + fill_start, - fill_size * N_X_FRAC(8), - fill_end - fill_start); - fill_start = lxi; - fill_end = rxi; - fill_size = 1; - } - else - { - /* Update fill_start */ - if (lxi > fill_start) - { - add_saturate_8 (ap + fill_start, - fill_size * N_X_FRAC(8), - lxi - fill_start); - fill_start = lxi; - } - else if (lxi < fill_start) - { - add_saturate_8 (ap + lxi, N_X_FRAC(8), - fill_start - lxi); - } - - /* Update fill_end */ - if (rxi < fill_end) - { - add_saturate_8 (ap + rxi, - fill_size * N_X_FRAC(8), - fill_end - rxi); - fill_end = rxi; - } - else if (fill_end < rxi) - { - add_saturate_8 (ap + fill_end, - N_X_FRAC(8), - rxi - fill_end); - } - fill_size++; - } - } - } - else - { - add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi); - } - - /* Do not add in a 0 alpha here. This check is - * necessary to avoid a buffer overrun, (when rx - * is exactly on a pixel boundary). */ - if (rxs) - WRITE(ap + rxi, clip255 (READ(ap + rxi) + rxs)); - } - } - - if (y == b) { - /* We're done, make sure we clean up any remaining fill. */ - if (fill_start != fill_end) { - if (fill_size == N_Y_FRAC(8)) - { - MEMSET_WRAPPED (ap + fill_start, 0xff, fill_end - fill_start); - } - else - { - add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8), - fill_end - fill_start); - } - } - break; - } - - if (xFixedFrac (y) != Y_FRAC_LAST(8)) - { - RenderEdgeStepSmall (l); - RenderEdgeStepSmall (r); - y += STEP_Y_SMALL(8); - } - else - { - RenderEdgeStepBig (l); - RenderEdgeStepBig (r); - y += STEP_Y_BIG(8); - if (fill_start != fill_end) - { - if (fill_size == N_Y_FRAC(8)) - { - MEMSET_WRAPPED (ap + fill_start, 0xff, fill_end - fill_start); - } - else - { - add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8), - fill_end - fill_start); - } - fill_start = fill_end = -1; - fill_size = 0; - } - line += stride; - } - } -} - -void -fbRasterizeEdges (FbBits *buf, - int bpp, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b) -{ - switch (bpp) { - case 1: - fbRasterizeEdges1 (buf, width, stride, l, r, t, b); - break; - case 4: - fbRasterizeEdges4 (buf, width, stride, l, r, t, b); - break; - case 8: - fbRasterizeEdges8 (buf, width, stride, l, r, t, b); - break; - } -} - -#endif /* RENDER */ diff --git a/fb/fbedgeimp.h b/fb/fbedgeimp.h deleted file mode 100644 index 57da31a39..000000000 --- a/fb/fbedgeimp.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * $Id$ - * - * Copyright © 2004 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef rasterizeSpan -#endif - -static void -rasterizeEdges (FbBits *buf, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b) -{ - xFixed y = t; - FbBits *line; - - line = buf + xFixedToInt (y) * stride; - - for (;;) - { - xFixed lx, rx; - int lxi, rxi; - - /* clip X */ - lx = l->x; - if (lx < 0) - lx = 0; - rx = r->x; - if (xFixedToInt (rx) >= width) - rx = IntToxFixed (width); - - /* Skip empty (or backwards) sections */ - if (rx > lx) - { - - /* Find pixel bounds for span */ - lxi = xFixedToInt (lx); - rxi = xFixedToInt (rx); - -#if N_BITS == 1 - { - FbBits *a = line; - FbBits startmask, endmask; - int nmiddle; - int width = rxi - lxi; - int x = lxi; - - a += x >> FB_SHIFT; - x &= FB_MASK; - - FbMaskBits (x, width, startmask, nmiddle, endmask); - if (startmask) { - WRITE(a, READ(a) | startmask); - a++; - } - while (nmiddle--) - WRITE(a++, FB_ALLONES); - if (endmask) - WRITE(a, READ(a) | endmask); - } -#else - { - DefineAlpha(line,lxi); - int lxs, rxs; - - /* Sample coverage for edge pixels */ - lxs = RenderSamplesX (lx, N_BITS); - rxs = RenderSamplesX (rx, N_BITS); - - /* Add coverage across row */ - if (lxi == rxi) - { - AddAlpha (rxs - lxs); - } - else - { - int xi; - - AddAlpha (N_X_FRAC(N_BITS) - lxs); - StepAlpha; - for (xi = lxi + 1; xi < rxi; xi++) - { - AddAlpha (N_X_FRAC(N_BITS)); - StepAlpha; - } - /* Do not add in a 0 alpha here. This check is necessary - * to avoid a buffer overrun when rx is exactly on a pixel - * boundary. - */ - if (rxs != 0) - AddAlpha (rxs); - } - } -#endif - } - - if (y == b) - break; - -#if N_BITS > 1 - if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS)) - { - RenderEdgeStepSmall (l); - RenderEdgeStepSmall (r); - y += STEP_Y_SMALL(N_BITS); - } - else -#endif - { - RenderEdgeStepBig (l); - RenderEdgeStepBig (r); - y += STEP_Y_BIG(N_BITS); - line += stride; - } - } -} - -#undef rasterizeSpan diff --git a/fb/fbfill.c b/fb/fbfill.c index 7ef3a70f9..4f13a023a 100644 --- a/fb/fbfill.c +++ b/fb/fbfill.c @@ -49,10 +49,13 @@ fbFill (DrawablePtr pDrawable, case FillSolid: #ifdef USE_MMX if (!pPriv->and && fbHaveMMX()) - if (fbSolidFillmmx (pDrawable, x, y, width, height, pPriv->xor)) { + { + if (fbFillmmx (dst, dstStride, dstBpp, x + dstXoff, y + dstYoff, width, height, pPriv->xor)) + { fbFinishAccess (pDrawable); return; } + } #endif fbSolid (dst + (y + dstYoff) * dstStride, dstStride, @@ -218,13 +221,13 @@ fbSolidBoxClipped (DrawablePtr pDrawable, #ifdef USE_MMX if (!and && fbHaveMMX()) { - if (fbSolidFillmmx (pDrawable, - partX1, partY1, - (partX2 - partX1), (partY2 - partY1), - xor)) { - fbFinishAccess (pDrawable); - return; - } + if (fbFillmmx (dst, dstStride, dstBpp, + partX1 + dstXoff, partX2 + dstYoff, (partX2 - partX1), (partY2 - partY1), + xor)) + { + fbFinishAccess (pDrawable); + return; + } } #endif fbSolid (dst + (partY1 + dstYoff) * dstStride, diff --git a/fb/fbmmx.c b/fb/fbmmx.c index 53459a000..3522a0075 100644 --- a/fb/fbmmx.c +++ b/fb/fbmmx.c @@ -62,26 +62,6 @@ #define CHECKPOINT() #endif -/* Notes about writing mmx code - * - * give memory operands as the second operand. If you give it as the - * first, gcc will first load it into a register, then use that - * register - * - * ie. use - * - * _mm_mullo_pi16 (x, mmx_constant); - * - * not - * - * _mm_mullo_pi16 (mmx_constant, x); - * - * Also try to minimize dependencies. i.e. when you need a value, try - * to calculate it from a value that was calculated as early as - * possible. - */ - -/* --------------- MMX primitivess ------------------------------------ */ typedef unsigned long long ullong; @@ -93,1586 +73,24 @@ typedef unsigned __int64 ullong; typedef __m64 mmxdatafield; #endif -typedef struct -{ - mmxdatafield mmx_4x00ff; - mmxdatafield mmx_4x0080; - mmxdatafield mmx_565_rgb; - mmxdatafield mmx_565_unpack_multiplier; - mmxdatafield mmx_565_r; - mmxdatafield mmx_565_g; - mmxdatafield mmx_565_b; - mmxdatafield mmx_mask_0; - mmxdatafield mmx_mask_1; - mmxdatafield mmx_mask_2; - mmxdatafield mmx_mask_3; - mmxdatafield mmx_full_alpha; - mmxdatafield mmx_ffff0000ffff0000; - mmxdatafield mmx_0000ffff00000000; - mmxdatafield mmx_000000000000ffff; -} MMXData; - -static const MMXData c = -{ -#ifdef __GNUC__ - .mmx_4x00ff = 0x00ff00ff00ff00ffULL, - .mmx_4x0080 = 0x0080008000800080ULL, - .mmx_565_rgb = 0x000001f0003f001fULL, - .mmx_565_unpack_multiplier = 0x0000008404100840ULL, - .mmx_565_r = 0x000000f800000000ULL, - .mmx_565_g = 0x0000000000fc0000ULL, - .mmx_565_b = 0x00000000000000f8ULL, - .mmx_mask_0 = 0xffffffffffff0000ULL, - .mmx_mask_1 = 0xffffffff0000ffffULL, - .mmx_mask_2 = 0xffff0000ffffffffULL, - .mmx_mask_3 = 0x0000ffffffffffffULL, - .mmx_full_alpha = 0x00ff000000000000ULL, - .mmx_ffff0000ffff0000 = 0xffff0000ffff0000ULL, - .mmx_0000ffff00000000 = 0x0000ffff00000000ULL, - .mmx_000000000000ffff = 0x000000000000ffffULL, -#endif -#ifdef _MSC_VER - { 0x00ff00ff00ff00ffUI64 }, - { 0x0080008000800080UI64 }, - { 0x000001f0003f001fUI64 }, - { 0x0000008404100840UI64 }, - { 0x000000f800000000UI64 }, - { 0x0000000000fc0000UI64 }, - { 0x00000000000000f8UI64 }, - { 0xffffffffffff0000UI64 }, - { 0xffffffff0000ffffUI64 }, - { 0xffff0000ffffffffUI64 }, - { 0x0000ffffffffffffUI64 }, - { 0x00ff000000000000UI64 }, - { 0xffff0000ffff0000UI64 }, - { 0x0000ffff00000000UI64 }, - { 0x000000000000ffffUI64 }, -#endif -}; - -#ifdef _MSC_VER -#undef inline -#define inline __forceinline -#endif - -#ifdef __GNUC__ -#define MC(x) ((__m64) c.mmx_##x) -#endif -#ifdef _MSC_VER -#define MC(x) c.mmx_##x -#endif - -static inline __m64 -shift (__m64 v, int s) -{ - if (s > 0) - return _mm_slli_si64 (v, s); - else if (s < 0) - return _mm_srli_si64 (v, -s); - else - return v; -} - -static inline __m64 -negate (__m64 mask) -{ - return _mm_xor_si64 (mask, MC(4x00ff)); -} - -static inline __m64 -pix_multiply (__m64 a, __m64 b) -{ - __m64 res; - - res = _mm_mullo_pi16 (a, b); - res = _mm_adds_pu16 (res, MC(4x0080)); - res = _mm_adds_pu16 (res, _mm_srli_pi16 (res, 8)); - res = _mm_srli_pi16 (res, 8); - - return res; -} - -static inline __m64 -pix_add (__m64 a, __m64 b) -{ - return _mm_adds_pu8 (a, b); -} - -#ifdef USE_SSE - -static inline __m64 -expand_alpha (__m64 pixel) -{ - return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 3, 3, 3)); -} - -static inline __m64 -expand_alpha_rev (__m64 pixel) -{ - return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(0, 0, 0, 0)); -} - -static inline __m64 -invert_colors (__m64 pixel) -{ - return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 0, 1, 2)); -} - -#else - -static inline __m64 -expand_alpha (__m64 pixel) -{ - __m64 t1, t2; - - t1 = shift (pixel, -48); - t2 = shift (t1, 16); - t1 = _mm_or_si64 (t1, t2); - t2 = shift (t1, 32); - t1 = _mm_or_si64 (t1, t2); - - return t1; -} - -static inline __m64 -expand_alpha_rev (__m64 pixel) -{ - __m64 t1, t2; - - /* move alpha to low 16 bits and zero the rest */ - t1 = shift (pixel, 48); - t1 = shift (t1, -48); - - t2 = shift (t1, 16); - t1 = _mm_or_si64 (t1, t2); - t2 = shift (t1, 32); - t1 = _mm_or_si64 (t1, t2); - - return t1; -} - -static inline __m64 -invert_colors (__m64 pixel) -{ - __m64 x, y, z; - - x = y = z = pixel; - - x = _mm_and_si64 (x, MC(ffff0000ffff0000)); - y = _mm_and_si64 (y, MC(000000000000ffff)); - z = _mm_and_si64 (z, MC(0000ffff00000000)); - - y = shift (y, 32); - z = shift (z, -32); - - x = _mm_or_si64 (x, y); - x = _mm_or_si64 (x, z); - - return x; -} - -#endif - -static inline __m64 -over (__m64 src, __m64 srca, __m64 dest) -{ - return _mm_adds_pu8 (src, pix_multiply(dest, negate(srca))); -} - -static inline __m64 -over_rev_non_pre (__m64 src, __m64 dest) -{ - __m64 srca = expand_alpha (src); - __m64 srcfaaa = _mm_or_si64 (srca, MC(full_alpha)); - - return over(pix_multiply(invert_colors(src), srcfaaa), srca, dest); -} - -static inline __m64 -in (__m64 src, - __m64 mask) -{ - return pix_multiply (src, mask); -} - -static inline __m64 -in_over_full_src_alpha (__m64 src, __m64 mask, __m64 dest) -{ - src = _mm_or_si64 (src, MC(full_alpha)); - - return over(in (src, mask), mask, dest); -} - -#ifndef _MSC_VER -static inline __m64 -in_over (__m64 src, - __m64 srca, - __m64 mask, - __m64 dest) -{ - return over(in(src, mask), pix_multiply(srca, mask), dest); -} -#else -#define in_over(src, srca, mask, dest) over(in(src, mask), pix_multiply(srca, mask), dest) -#endif - -static inline __m64 -load8888 (CARD32 v) -{ - return _mm_unpacklo_pi8 (_mm_cvtsi32_si64 (v), _mm_setzero_si64()); -} - -static inline __m64 -pack8888 (__m64 lo, __m64 hi) -{ - return _mm_packs_pu16 (lo, hi); -} - -static inline CARD32 -store8888 (__m64 v) -{ - return _mm_cvtsi64_si32(pack8888(v, _mm_setzero_si64())); -} - -/* Expand 16 bits positioned at @pos (0-3) of a mmx register into - * - * 00RR00GG00BB - * - * --- Expanding 565 in the low word --- - * - * m = (m << (32 - 3)) | (m << (16 - 5)) | m; - * m = m & (01f0003f001f); - * m = m * (008404100840); - * m = m >> 8; - * - * Note the trick here - the top word is shifted by another nibble to - * avoid it bumping into the middle word - */ -static inline __m64 -expand565 (__m64 pixel, int pos) -{ - __m64 p = pixel; - __m64 t1, t2; - - /* move pixel to low 16 bit and zero the rest */ - p = shift (shift (p, (3 - pos) * 16), -48); - - t1 = shift (p, 36 - 11); - t2 = shift (p, 16 - 5); - - p = _mm_or_si64 (t1, p); - p = _mm_or_si64 (t2, p); - p = _mm_and_si64 (p, MC(565_rgb)); - - pixel = _mm_mullo_pi16 (p, MC(565_unpack_multiplier)); - return _mm_srli_pi16 (pixel, 8); -} - -static inline __m64 -expand8888 (__m64 in, int pos) -{ - if (pos == 0) - return _mm_unpacklo_pi8 (in, _mm_setzero_si64()); - else - return _mm_unpackhi_pi8 (in, _mm_setzero_si64()); -} - -static inline __m64 -pack565 (__m64 pixel, __m64 target, int pos) -{ - __m64 p = pixel; - __m64 t = target; - __m64 r, g, b; - - r = _mm_and_si64 (p, MC(565_r)); - g = _mm_and_si64 (p, MC(565_g)); - b = _mm_and_si64 (p, MC(565_b)); - - r = shift (r, - (32 - 8) + pos * 16); - g = shift (g, - (16 - 3) + pos * 16); - b = shift (b, - (0 + 3) + pos * 16); - - if (pos == 0) - t = _mm_and_si64 (t, MC(mask_0)); - else if (pos == 1) - t = _mm_and_si64 (t, MC(mask_1)); - else if (pos == 2) - t = _mm_and_si64 (t, MC(mask_2)); - else if (pos == 3) - t = _mm_and_si64 (t, MC(mask_3)); - - p = _mm_or_si64 (r, t); - p = _mm_or_si64 (g, p); - - return _mm_or_si64 (b, p); -} - -#ifndef _MSC_VER -static inline __m64 -pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b) -{ - x = _mm_mullo_pi16 (x, a); - y = _mm_mullo_pi16 (y, b); - x = _mm_adds_pu16 (x, MC(4x0080)); - x = _mm_adds_pu16 (x, y); - x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); - x = _mm_srli_pi16 (x, 8); - - return x; -} -#else -#define pix_add_mul(x, a, y, b) \ -( x = _mm_mullo_pi16 (x, a), \ - y = _mm_mullo_pi16 (y, b), \ - x = _mm_adds_pu16 (x, MC(4x0080)), \ - x = _mm_adds_pu16 (x, y), \ - x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)), \ - _mm_srli_pi16 (x, 8) ) -#endif - -/* --------------- MMX code patch for fbcompose.c --------------------- */ - -static FASTCALL void -mmxCombineMaskU (CARD32 *src, const CARD32 *mask, int width) -{ - const CARD32 *end = mask + width; - while (mask < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - a = expand_alpha(a); - s = pix_multiply(s, a); - *src = store8888(s); - ++src; - ++mask; - } - _mm_empty(); -} - - -static FASTCALL void -mmxCombineOverU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 s, sa; - s = load8888(*src); - sa = expand_alpha(s); - *dest = store8888(over(s, sa, load8888(*dest))); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 d, da; - d = load8888(*dest); - da = expand_alpha(d); - *dest = store8888(over (d, da, load8888(*src))); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineInU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 x, a; - x = load8888(*src); - a = load8888(*dest); - a = expand_alpha(a); - x = pix_multiply(x, a); - *dest = store8888(x); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineInReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 x, a; - x = load8888(*dest); - a = load8888(*src); - a = expand_alpha(a); - x = pix_multiply(x, a); - *dest = store8888(x); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOutU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 x, a; - x = load8888(*src); - a = load8888(*dest); - a = expand_alpha(a); - a = negate(a); - x = pix_multiply(x, a); - *dest = store8888(x); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 x, a; - x = load8888(*dest); - a = load8888(*src); - a = expand_alpha(a); - a = negate(a); - x = pix_multiply(x, a); - *dest = store8888(x); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineAtopU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 s, da, d, sia; - s = load8888(*src); - d = load8888(*dest); - sia = expand_alpha(s); - sia = negate(sia); - da = expand_alpha(d); - s = pix_add_mul (s, da, d, sia); - *dest = store8888(s); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end; - - end = dest + width; - - while (dest < end) { - __m64 s, dia, d, sa; - s = load8888(*src); - d = load8888(*dest); - sa = expand_alpha(s); - dia = expand_alpha(d); - dia = negate(dia); - s = pix_add_mul (s, dia, d, sa); - *dest = store8888(s); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineXorU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - - while (dest < end) { - __m64 s, dia, d, sia; - s = load8888(*src); - d = load8888(*dest); - sia = expand_alpha(s); - dia = expand_alpha(d); - sia = negate(sia); - dia = negate(dia); - s = pix_add_mul (s, dia, d, sia); - *dest = store8888(s); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineAddU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - while (dest < end) { - __m64 s, d; - s = load8888(*src); - d = load8888(*dest); - s = pix_add(s, d); - *dest = store8888(s); - ++dest; - ++src; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineSaturateU (CARD32 *dest, const CARD32 *src, int width) -{ - const CARD32 *end = dest + width; - while (dest < end) { - CARD32 s = *src; - CARD32 d = *dest; - __m64 ms = load8888(s); - __m64 md = load8888(d); - CARD32 sa = s >> 24; - CARD32 da = ~d >> 24; - - if (sa > da) { - __m64 msa = load8888(FbIntDiv(da, sa) << 24); - msa = expand_alpha(msa); - ms = pix_multiply(ms, msa); - } - md = pix_add(md, ms); - *dest = store8888(md); - ++src; - ++dest; - } - _mm_empty(); -} - - -static FASTCALL void -mmxCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - s = pix_multiply(s, a); - *dest = store8888(s); - ++src; - ++mask; - ++dest; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 sa = expand_alpha(s); - - *dest = store8888(in_over (s, sa, a, d)); - - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 da = expand_alpha(d); - - *dest = store8888(over (d, da, in (s, a))); - - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - - -static FASTCALL void -mmxCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 da = expand_alpha(d); - s = pix_multiply(s, a); - s = pix_multiply(s, da); - *dest = store8888(s); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 sa = expand_alpha(s); - a = pix_multiply(a, sa); - d = pix_multiply(d, a); - *dest = store8888(d); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 da = expand_alpha(d); - da = negate(da); - s = pix_multiply(s, a); - s = pix_multiply(s, da); - *dest = store8888(s); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 sa = expand_alpha(s); - a = pix_multiply(a, sa); - a = negate(a); - d = pix_multiply(d, a); - *dest = store8888(d); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 da = expand_alpha(d); - __m64 sa = expand_alpha(s); - s = pix_multiply(s, a); - a = pix_multiply(a, sa); - a = negate(a); - d = pix_add_mul (d, a, s, da); - *dest = store8888(d); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 da = expand_alpha(d); - __m64 sa = expand_alpha(s); - s = pix_multiply(s, a); - a = pix_multiply(a, sa); - da = negate(da); - d = pix_add_mul (d, a, s, da); - *dest = store8888(d); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - __m64 da = expand_alpha(d); - __m64 sa = expand_alpha(s); - s = pix_multiply(s, a); - a = pix_multiply(a, sa); - da = negate(da); - a = negate(a); - d = pix_add_mul (d, a, s, da); - *dest = store8888(d); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -static FASTCALL void -mmxCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - const CARD32 *end = src + width; - while (src < end) { - __m64 a = load8888(*mask); - __m64 s = load8888(*src); - __m64 d = load8888(*dest); - s = pix_multiply(s, a); - d = pix_add(s, d); - *dest = store8888(d); - ++src; - ++dest; - ++mask; - } - _mm_empty(); -} - -#if 0 -/* FIXME: this should be reinstated after adding fbmmx to pixman */ -extern FbComposeFunctions composeFunctions; -#endif - -void fbComposeSetupMMX(void) -{ -#if 0 -/* FIXME: this should be reinstated after adding fbmmx to pixman */ - /* check if we have MMX support and initialize accordingly */ - if (fbHaveMMX()) { - composeFunctions.combineU[PictOpOver] = mmxCombineOverU; - composeFunctions.combineU[PictOpOverReverse] = mmxCombineOverReverseU; - composeFunctions.combineU[PictOpIn] = mmxCombineInU; - composeFunctions.combineU[PictOpInReverse] = mmxCombineInReverseU; - composeFunctions.combineU[PictOpOut] = mmxCombineOutU; - composeFunctions.combineU[PictOpOutReverse] = mmxCombineOutReverseU; - composeFunctions.combineU[PictOpAtop] = mmxCombineAtopU; - composeFunctions.combineU[PictOpAtopReverse] = mmxCombineAtopReverseU; - composeFunctions.combineU[PictOpXor] = mmxCombineXorU; - composeFunctions.combineU[PictOpAdd] = mmxCombineAddU; - composeFunctions.combineU[PictOpSaturate] = mmxCombineSaturateU; - - composeFunctions.combineC[PictOpSrc] = mmxCombineSrcC; - composeFunctions.combineC[PictOpOver] = mmxCombineOverC; - composeFunctions.combineC[PictOpOverReverse] = mmxCombineOverReverseC; - composeFunctions.combineC[PictOpIn] = mmxCombineInC; - composeFunctions.combineC[PictOpInReverse] = mmxCombineInReverseC; - composeFunctions.combineC[PictOpOut] = mmxCombineOutC; - composeFunctions.combineC[PictOpOutReverse] = mmxCombineOutReverseC; - composeFunctions.combineC[PictOpAtop] = mmxCombineAtopC; - composeFunctions.combineC[PictOpAtopReverse] = mmxCombineAtopReverseC; - composeFunctions.combineC[PictOpXor] = mmxCombineXorC; - composeFunctions.combineC[PictOpAdd] = mmxCombineAddC; - - composeFunctions.combineMaskU = mmxCombineMaskU; - } -#endif -} - - -/* ------------------ MMX code paths called from fbpict.c ----------------------- */ - -void -fbCompositeSolid_nx8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src; - CARD32 *dstLine, *dst; - CARD16 w; - FbStride dstStride; - __m64 vsrc, vsrca; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - if (src >> 24 == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - - vsrc = load8888 (src); - vsrca = expand_alpha (vsrc); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - *dst = store8888(over(vsrc, vsrca, load8888(*dst))); - - w--; - dst++; - } - - while (w >= 2) - { - __m64 vdest; - __m64 dest0, dest1; - - vdest = *(__m64 *)dst; - - dest0 = over(vsrc, vsrca, expand8888(vdest, 0)); - dest1 = over(vsrc, vsrca, expand8888(vdest, 1)); - - *(__m64 *)dst = pack8888(dest0, dest1); - - dst += 2; - w -= 2; - } - - CHECKPOINT(); - - while (w) - { - *dst = store8888(over(vsrc, vsrca, load8888(*dst))); - - w--; - dst++; - } - } - - _mm_empty(); -} - -void -fbCompositeSolid_nx0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src; - CARD16 *dstLine, *dst; - CARD16 w; - FbStride dstStride; - __m64 vsrc, vsrca; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - if (src >> 24 == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - - vsrc = load8888 (src); - vsrca = expand_alpha (vsrc); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - ullong d = *dst; - __m64 vdest = expand565 ((__m64)d, 0); - vdest = pack565(over(vsrc, vsrca, vdest), vdest, 0); - *dst = (ullong)vdest; - - w--; - dst++; - } - - while (w >= 4) - { - __m64 vdest; - - vdest = *(__m64 *)dst; - - vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 0)), vdest, 0); - vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 1)), vdest, 1); - vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 2)), vdest, 2); - vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 3)), vdest, 3); - - *(__m64 *)dst = vdest; - - dst += 4; - w -= 4; - } - - CHECKPOINT(); - - while (w) - { - ullong d = *dst; - __m64 vdest = expand565 ((__m64)d, 0); - vdest = pack565(over(vsrc, vsrca, vdest), vdest, 0); - *dst = (ullong)vdest; - - w--; - dst++; - } - } - - _mm_empty(); -} - -void -fbCompositeSolidMask_nx8888x8888Cmmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD32 *dstLine; - CARD32 *maskLine; - FbStride dstStride, maskStride; - __m64 vsrc, vsrca; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (srca == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1); - - vsrc = load8888(src); - vsrca = expand_alpha(vsrc); - - while (height--) - { - int twidth = width; - CARD32 *p = (CARD32 *)maskLine; - CARD32 *q = (CARD32 *)dstLine; - - while (twidth && (unsigned long)q & 7) - { - CARD32 m = *(CARD32 *)p; - - if (m) - { - __m64 vdest = load8888(*q); - vdest = in_over(vsrc, vsrca, load8888(m), vdest); - *q = store8888(vdest); - } - - twidth--; - p++; - q++; - } - - while (twidth >= 2) - { - CARD32 m0, m1; - m0 = *p; - m1 = *(p + 1); - - if (m0 | m1) - { - __m64 dest0, dest1; - __m64 vdest = *(__m64 *)q; - - dest0 = in_over(vsrc, vsrca, load8888(m0), - expand8888 (vdest, 0)); - dest1 = in_over(vsrc, vsrca, load8888(m1), - expand8888 (vdest, 1)); - - *(__m64 *)q = pack8888(dest0, dest1); - } - - p += 2; - q += 2; - twidth -= 2; - } - - while (twidth) - { - CARD32 m = *(CARD32 *)p; - - if (m) - { - __m64 vdest = load8888(*q); - vdest = in_over(vsrc, vsrca, load8888(m), vdest); - *q = store8888(vdest); - } - - twidth--; - p++; - q++; - } - - dstLine += dstStride; - maskLine += maskStride; - } - - _mm_empty(); -} - -void -fbCompositeSrc_8888x8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst; - CARD32 *srcLine, *src; - CARD32 mask; - __m64 vmask; - FbStride dstStride, srcStride; - CARD16 w; - __m64 srca; - - CHECKPOINT(); - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - fbComposeGetSolid (pMask, mask, pDst->format); - mask = mask | mask >> 8 | mask >> 16 | mask >> 24; - vmask = load8888 (mask); - srca = MC(4x00ff); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w && (unsigned long)dst & 7) - { - __m64 s = load8888 (*src); - __m64 d = load8888 (*dst); - - *dst = store8888 (in_over (s, expand_alpha (s), vmask, d)); - - w--; - dst++; - src++; - } - - while (w >= 2) - { - __m64 vs = *(__m64 *)src; - __m64 vd = *(__m64 *)dst; - __m64 vsrc0 = expand8888 (vs, 0); - __m64 vsrc1 = expand8888 (vs, 1); - - *(__m64 *)dst = pack8888 ( - in_over (vsrc0, expand_alpha (vsrc0), vmask, expand8888 (vd, 0)), - in_over (vsrc1, expand_alpha (vsrc1), vmask, expand8888 (vd, 1))); - - w -= 2; - dst += 2; - src += 2; - } - - while (w) - { - __m64 s = load8888 (*src); - __m64 d = load8888 (*dst); - - *dst = store8888 (in_over (s, expand_alpha (s), vmask, d)); - - w--; - dst++; - src++; - } - } - - _mm_empty(); -} - -void -fbCompositeSrc_x888x8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst; - CARD32 *srcLine, *src; - CARD32 mask; - __m64 vmask; - FbStride dstStride, srcStride; - CARD16 w; - __m64 srca; - - CHECKPOINT(); - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - fbComposeGetSolid (pMask, mask, pDst->format); - - mask = mask | mask >> 8 | mask >> 16 | mask >> 24; - vmask = load8888 (mask); - srca = MC(4x00ff); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w && (unsigned long)dst & 7) - { - __m64 s = load8888 (*src | 0xff000000); - __m64 d = load8888 (*dst); - - *dst = store8888 (in_over (s, srca, vmask, d)); - - w--; - dst++; - src++; - } - - while (w >= 2) - { - - __m64 vd0 = *(__m64 *)(dst); - __m64 vs0 = *(__m64 *)(src); - - vd0 = pack8888 ( - in_over_full_src_alpha (expand8888 (vs0, 0), vmask, expand8888 (vd0, 0)), - in_over_full_src_alpha (expand8888 (vs0, 1), vmask, expand8888 (vd0, 1))); - - *(__m64 *)(dst) = vd0; - - w -= 2; - dst += 2; - src += 2; - } - - while (w) - { - __m64 s = load8888 (*src | 0xff000000); - __m64 d = load8888 (*dst); - - *dst = store8888 (in_over (s, srca, vmask, d)); - - w--; - dst++; - src++; - } - } - - _mm_empty(); -} - -void -fbCompositeSrc_8888x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst; - CARD32 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - __m64 srca; - - CHECKPOINT(); - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - srca = MC (4x00ff); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w && (unsigned long)dst & 7) - { - __m64 s = load8888 (*src); - __m64 d = load8888 (*dst); - - *dst = store8888 (over (s, expand_alpha (s), d)); - - w--; - dst++; - src++; - } - - while (w >= 2) - { - __m64 vd = *(__m64 *)(dst + 0); - __m64 vs = *(__m64 *)(src + 0); - __m64 vs0 = expand8888 (vs, 0); - __m64 vs1 = expand8888 (vs, 1); - - *(__m64 *)dst = (__m64)pack8888 ( - over (vs0, expand_alpha (vs0), expand8888 (vd, 0)), - over (vs1, expand_alpha (vs1), expand8888 (vd, 1))); - - w -= 2; - dst += 2; - src += 2; - } - - while (w) - { - __m64 s = load8888 (*src); - __m64 d = load8888 (*dst); - - *dst = store8888 (over (s, expand_alpha (s), d)); - - w--; - dst++; - src++; - } - } - - _mm_empty(); -} - -void -fbCompositeSrc_8888x0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD16 *dstLine, *dst; - CARD32 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - - CHECKPOINT(); - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - assert (pSrc->pDrawable == pMask->pDrawable); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - __m64 vsrc = load8888 (*src); - ullong d = *dst; - __m64 vdest = expand565 ((__m64)d, 0); - - vdest = pack565(over(vsrc, expand_alpha(vsrc), vdest), vdest, 0); - - *dst = (ullong)vdest; - - w--; - dst++; - src++; - } - - CHECKPOINT(); - - while (w >= 4) - { - __m64 vsrc0, vsrc1, vsrc2, vsrc3; - __m64 vdest; - - vsrc0 = load8888(*(src + 0)); - vsrc1 = load8888(*(src + 1)); - vsrc2 = load8888(*(src + 2)); - vsrc3 = load8888(*(src + 3)); - - vdest = *(__m64 *)dst; - - vdest = pack565(over(vsrc0, expand_alpha(vsrc0), expand565(vdest, 0)), vdest, 0); - vdest = pack565(over(vsrc1, expand_alpha(vsrc1), expand565(vdest, 1)), vdest, 1); - vdest = pack565(over(vsrc2, expand_alpha(vsrc2), expand565(vdest, 2)), vdest, 2); - vdest = pack565(over(vsrc3, expand_alpha(vsrc3), expand565(vdest, 3)), vdest, 3); - - *(__m64 *)dst = vdest; - - w -= 4; - dst += 4; - src += 4; - } - - CHECKPOINT(); - - while (w) - { - __m64 vsrc = load8888 (*src); - ullong d = *dst; - __m64 vdest = expand565 ((__m64)d, 0); - - vdest = pack565(over(vsrc, expand_alpha(vsrc), vdest), vdest, 0); - - *dst = (ullong)vdest; - - w--; - dst++; - src++; - } - } - - _mm_empty(); -} - -void -fbCompositeSolidMask_nx8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD32 *dstLine, *dst; - CARD8 *maskLine, *mask; - FbStride dstStride, maskStride; - CARD16 w; - __m64 vsrc, vsrca; - ullong srcsrc; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (srca == 0) - return; - - srcsrc = (unsigned long long)src << 32 | src; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - vsrc = load8888 (src); - vsrca = expand_alpha (vsrc); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - ullong m = *mask; - - if (m) - { - __m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), load8888(*dst)); - *dst = store8888(vdest); - } - - w--; - mask++; - dst++; - } - - CHECKPOINT(); - - while (w >= 2) - { - ullong m0, m1; - m0 = *mask; - m1 = *(mask + 1); - - if (srca == 0xff && (m0 & m1) == 0xff) - { - *(unsigned long long *)dst = srcsrc; - } - else if (m0 | m1) - { - __m64 vdest; - __m64 dest0, dest1; - - vdest = *(__m64 *)dst; - - dest0 = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m0), expand8888(vdest, 0)); - dest1 = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m1), expand8888(vdest, 1)); - - *(__m64 *)dst = pack8888(dest0, dest1); - } - - mask += 2; - dst += 2; - w -= 2; - } - - CHECKPOINT(); - - while (w) - { - ullong m = *mask; - - if (m) - { - __m64 vdest = load8888(*dst); - vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), vdest); - *dst = store8888(vdest); - } - - w--; - mask++; - dst++; - } - } - - _mm_empty(); -} - - Bool -fbSolidFillmmx (DrawablePtr pDraw, - int x, - int y, - int width, - int height, - FbBits xor) -{ - FbStride stride; - int bpp; +fbFillmmx (FbBits *bits, + FbStride stride, + int bpp, + int x, + int y, + int width, + int height, + FbBits xor) +{ ullong fill; __m64 vfill; CARD32 byte_width; CARD8 *byte_line; - FbBits *bits; - int xoff, yoff; #ifdef __GNUC__ __m64 v1, v2, v3, v4, v5, v6, v7; #endif - CHECKPOINT(); - - fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff); - if (bpp == 16 && (xor >> 16 != (xor & 0xffff))) return FALSE; @@ -1682,14 +100,14 @@ fbSolidFillmmx (DrawablePtr pDraw, if (bpp == 16) { stride = stride * sizeof (FbBits) / 2; - byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff)); + byte_line = (CARD8 *)(((CARD16 *)bits) + stride * y + x); byte_width = 2 * width; stride *= 2; } else { stride = stride * sizeof (FbBits) / 4; - byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff)); + byte_line = (CARD8 *)(((CARD32 *)bits) + stride * y + x); byte_width = 4 * width; stride *= 4; } @@ -1783,973 +201,21 @@ fbSolidFillmmx (DrawablePtr pDraw, return TRUE; } -void -fbCompositeSolidMaskSrc_nx8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD32 *dstLine, *dst; - CARD8 *maskLine, *mask; - FbStride dstStride, maskStride; - CARD16 w; - __m64 vsrc, vsrca; - ullong srcsrc; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (srca == 0) - { - fbSolidFillmmx (pDst->pDrawable, xDst, yDst, width, height, 0); - return; - } - - srcsrc = (ullong)src << 32 | src; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - vsrc = load8888 (src); - vsrca = expand_alpha (vsrc); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - ullong m = *mask; - - if (m) - { - __m64 vdest = in(vsrc, expand_alpha_rev ((__m64)m)); - *dst = store8888(vdest); - } - else - { - *dst = 0; - } - - w--; - mask++; - dst++; - } - - CHECKPOINT(); - - while (w >= 2) - { - ullong m0, m1; - m0 = *mask; - m1 = *(mask + 1); - - if (srca == 0xff && (m0 & m1) == 0xff) - { - *(ullong *)dst = srcsrc; - } - else if (m0 | m1) - { - __m64 vdest; - __m64 dest0, dest1; - - vdest = *(__m64 *)dst; - - dest0 = in(vsrc, expand_alpha_rev ((__m64)m0)); - dest1 = in(vsrc, expand_alpha_rev ((__m64)m1)); - - *(__m64 *)dst = pack8888(dest0, dest1); - } - else - { - *(ullong *)dst = 0; - } - - mask += 2; - dst += 2; - w -= 2; - } - - CHECKPOINT(); - - while (w) - { - ullong m = *mask; - - if (m) - { - __m64 vdest = load8888(*dst); - vdest = in(vsrc, expand_alpha_rev ((__m64)m)); - *dst = store8888(vdest); - } - else - { - *dst = 0; - } - - w--; - mask++; - dst++; - } - } - - _mm_empty(); -} - -void -fbCompositeSolidMask_nx8x0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD16 *dstLine, *dst; - CARD8 *maskLine, *mask; - FbStride dstStride, maskStride; - CARD16 w; - __m64 vsrc, vsrca; - unsigned long long srcsrcsrcsrc, src16; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (srca == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - vsrc = load8888 (src); - vsrca = expand_alpha (vsrc); - - src16 = (ullong)pack565(vsrc, _mm_setzero_si64(), 0); - - srcsrcsrcsrc = (ullong)src16 << 48 | (ullong)src16 << 32 | - (ullong)src16 << 16 | (ullong)src16; - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - ullong m = *mask; - - if (m) - { - ullong d = *dst; - __m64 vd = (__m64)d; - __m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), expand565(vd, 0)); - *dst = (ullong)pack565(vdest, _mm_setzero_si64(), 0); - } - - w--; - mask++; - dst++; - } - - CHECKPOINT(); - - while (w >= 4) - { - ullong m0, m1, m2, m3; - m0 = *mask; - m1 = *(mask + 1); - m2 = *(mask + 2); - m3 = *(mask + 3); - - if (srca == 0xff && (m0 & m1 & m2 & m3) == 0xff) - { - *(unsigned long long *)dst = srcsrcsrcsrc; - } - else if (m0 | m1 | m2 | m3) - { - __m64 vdest; - __m64 vm0, vm1, vm2, vm3; - - vdest = *(__m64 *)dst; - - vm0 = (__m64)m0; - vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm0), expand565(vdest, 0)), vdest, 0); - vm1 = (__m64)m1; - vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm1), expand565(vdest, 1)), vdest, 1); - vm2 = (__m64)m2; - vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm2), expand565(vdest, 2)), vdest, 2); - vm3 = (__m64)m3; - vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm3), expand565(vdest, 3)), vdest, 3); - - *(__m64 *)dst = vdest; - } - - w -= 4; - mask += 4; - dst += 4; - } - - CHECKPOINT(); - - while (w) - { - ullong m = *mask; - - if (m) - { - ullong d = *dst; - __m64 vd = (__m64)d; - __m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), expand565(vd, 0)); - *dst = (ullong)pack565(vdest, _mm_setzero_si64(), 0); - } - - w--; - mask++; - dst++; - } - } - - _mm_empty(); -} - -void -fbCompositeSrc_8888RevNPx0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD16 *dstLine, *dst; - CARD32 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - - CHECKPOINT(); - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - assert (pSrc->pDrawable == pMask->pDrawable); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - CHECKPOINT(); - - while (w && (unsigned long)dst & 7) - { - __m64 vsrc = load8888 (*src); - ullong d = *dst; - __m64 vdest = expand565 ((__m64)d, 0); - - vdest = pack565(over_rev_non_pre(vsrc, vdest), vdest, 0); - - *dst = (ullong)vdest; - - w--; - dst++; - src++; - } - - CHECKPOINT(); - - while (w >= 4) - { - CARD32 s0, s1, s2, s3; - unsigned char a0, a1, a2, a3; - - s0 = *src; - s1 = *(src + 1); - s2 = *(src + 2); - s3 = *(src + 3); - - a0 = (s0 >> 24); - a1 = (s1 >> 24); - a2 = (s2 >> 24); - a3 = (s3 >> 24); - - if ((a0 & a1 & a2 & a3) == 0xFF) - { - __m64 vdest; - vdest = pack565(invert_colors(load8888(s0)), _mm_setzero_si64(), 0); - vdest = pack565(invert_colors(load8888(s1)), vdest, 1); - vdest = pack565(invert_colors(load8888(s2)), vdest, 2); - vdest = pack565(invert_colors(load8888(s3)), vdest, 3); - - *(__m64 *)dst = vdest; - } - else if (a0 | a1 | a2 | a3) - { - __m64 vdest = *(__m64 *)dst; - - vdest = pack565(over_rev_non_pre(load8888(s0), expand565(vdest, 0)), vdest, 0); - vdest = pack565(over_rev_non_pre(load8888(s1), expand565(vdest, 1)), vdest, 1); - vdest = pack565(over_rev_non_pre(load8888(s2), expand565(vdest, 2)), vdest, 2); - vdest = pack565(over_rev_non_pre(load8888(s3), expand565(vdest, 3)), vdest, 3); - - *(__m64 *)dst = vdest; - } - - w -= 4; - dst += 4; - src += 4; - } - - CHECKPOINT(); - - while (w) - { - __m64 vsrc = load8888 (*src); - ullong d = *dst; - __m64 vdest = expand565 ((__m64)d, 0); - - vdest = pack565(over_rev_non_pre(vsrc, vdest), vdest, 0); - - *dst = (ullong)vdest; - - w--; - dst++; - src++; - } - } - - _mm_empty(); -} - -/* "8888RevNP" is GdkPixbuf's format: ABGR, non premultiplied */ - -void -fbCompositeSrc_8888RevNPx8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst; - CARD32 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - - CHECKPOINT(); - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - assert (pSrc->pDrawable == pMask->pDrawable); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w && (unsigned long)dst & 7) - { - __m64 s = load8888 (*src); - __m64 d = load8888 (*dst); - - *dst = store8888 (over_rev_non_pre (s, d)); - - w--; - dst++; - src++; - } - - while (w >= 2) - { - ullong s0, s1; - unsigned char a0, a1; - __m64 d0, d1; - - s0 = *src; - s1 = *(src + 1); - - a0 = (s0 >> 24); - a1 = (s1 >> 24); - - if ((a0 & a1) == 0xFF) - { - d0 = invert_colors(load8888(s0)); - d1 = invert_colors(load8888(s1)); - - *(__m64 *)dst = pack8888 (d0, d1); - } - else if (a0 | a1) - { - __m64 vdest = *(__m64 *)dst; - - d0 = over_rev_non_pre (load8888(s0), expand8888 (vdest, 0)); - d1 = over_rev_non_pre (load8888(s1), expand8888 (vdest, 1)); - - *(__m64 *)dst = pack8888 (d0, d1); - } - - w -= 2; - dst += 2; - src += 2; - } - - while (w) - { - __m64 s = load8888 (*src); - __m64 d = load8888 (*dst); - - *dst = store8888 (over_rev_non_pre (s, d)); - - w--; - dst++; - src++; - } - } - - _mm_empty(); -} - -void -fbCompositeSolidMask_nx8888x0565Cmmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD16 *dstLine; - CARD32 *maskLine; - FbStride dstStride, maskStride; - __m64 vsrc, vsrca; - - CHECKPOINT(); - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (srca == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1); - - vsrc = load8888 (src); - vsrca = expand_alpha (vsrc); - - while (height--) - { - int twidth = width; - CARD32 *p = (CARD32 *)maskLine; - CARD16 *q = (CARD16 *)dstLine; - - while (twidth && ((unsigned long)q & 7)) - { - CARD32 m = *(CARD32 *)p; - - if (m) - { - ullong d = *q; - __m64 vdest = expand565 ((__m64)d, 0); - vdest = pack565 (in_over (vsrc, vsrca, load8888 (m), vdest), vdest, 0); - *q = (ullong)vdest; - } - - twidth--; - p++; - q++; - } - - while (twidth >= 4) - { - CARD32 m0, m1, m2, m3; - - m0 = *p; - m1 = *(p + 1); - m2 = *(p + 2); - m3 = *(p + 3); - - if ((m0 | m1 | m2 | m3)) - { - __m64 vdest = *(__m64 *)q; - - vdest = pack565(in_over(vsrc, vsrca, load8888(m0), expand565(vdest, 0)), vdest, 0); - vdest = pack565(in_over(vsrc, vsrca, load8888(m1), expand565(vdest, 1)), vdest, 1); - vdest = pack565(in_over(vsrc, vsrca, load8888(m2), expand565(vdest, 2)), vdest, 2); - vdest = pack565(in_over(vsrc, vsrca, load8888(m3), expand565(vdest, 3)), vdest, 3); - - *(__m64 *)q = vdest; - } - twidth -= 4; - p += 4; - q += 4; - } - - while (twidth) - { - CARD32 m; - - m = *(CARD32 *)p; - if (m) - { - ullong d = *q; - __m64 vdest = expand565((__m64)d, 0); - vdest = pack565 (in_over(vsrc, vsrca, load8888(m), vdest), vdest, 0); - *q = (ullong)vdest; - } - - twidth--; - p++; - q++; - } - - maskLine += maskStride; - dstLine += dstStride; - } - - _mm_empty (); -} - -void -fbCompositeIn_nx8x8mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD8 *dstLine, *dst; - CARD8 *maskLine, *mask; - FbStride dstStride, maskStride; - CARD16 w; - CARD32 src; - CARD8 sa; - __m64 vsrc, vsrca; - - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - fbComposeGetSolid(pSrc, src, pDst->format); - - sa = src >> 24; - if (sa == 0) - return; - - vsrc = load8888(src); - vsrca = expand_alpha(vsrc); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - if ((((unsigned long)pDst & 3) == 0) && - (((unsigned long)pSrc & 3) == 0)) - { - while (w >= 4) - { - CARD32 m; - __m64 vmask; - __m64 vdest; - - m = 0; - - vmask = load8888 (*(CARD32 *)mask); - vdest = load8888 (*(CARD32 *)dst); - - *(CARD32 *)dst = store8888 (in (in (vsrca, vmask), vdest)); - - dst += 4; - mask += 4; - w -= 4; - } - } - - while (w--) - { - CARD16 tmp; - CARD8 a; - CARD32 m, d; - CARD32 r; - - a = *mask++; - d = *dst; - - m = FbInU (sa, 0, a, tmp); - r = FbInU (m, 0, d, tmp); - - *dst++ = r; - } - } - - _mm_empty(); -} - -void -fbCompositeIn_8x8mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD8 *dstLine, *dst; - CARD8 *srcLine, *src; - FbStride srcStride, dstStride; - CARD16 w; - - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - if ((((unsigned long)pDst & 3) == 0) && - (((unsigned long)pSrc & 3) == 0)) - { - while (w >= 4) - { - CARD32 *s = (CARD32 *)src; - CARD32 *d = (CARD32 *)dst; - - *d = store8888 (in (load8888 (*s), load8888 (*d))); - - w -= 4; - dst += 4; - src += 4; - } - } - - while (w--) - { - CARD8 s, d; - CARD16 tmp; - - s = *src; - d = *dst; - - *dst = FbInU (s, 0, d, tmp); - - src++; - dst++; - } - } - - _mm_empty (); -} - -void -fbCompositeSrcAdd_8888x8x8mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD8 *dstLine, *dst; - CARD8 *maskLine, *mask; - FbStride dstStride, maskStride; - CARD16 w; - CARD32 src; - CARD8 sa; - __m64 vsrc, vsrca; - - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - fbComposeGetSolid(pSrc, src, pDst->format); - - sa = src >> 24; - if (sa == 0) - return; - - vsrc = load8888(src); - vsrca = expand_alpha(vsrc); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - if ((((unsigned long)pMask & 3) == 0) && - (((unsigned long)pDst & 3) == 0)) - { - while (w >= 4) - { - __m64 vmask = load8888 (*(CARD32 *)mask); - __m64 vdest = load8888 (*(CARD32 *)dst); - - *(CARD32 *)dst = store8888 (_mm_adds_pu8 (in (vsrca, vmask), vdest)); - - w -= 4; - dst += 4; - mask += 4; - } - } - - while (w--) - { - CARD16 tmp; - CARD16 a; - CARD32 m, d; - CARD32 r; - - a = *mask++; - d = *dst; - - m = FbInU (sa, 0, a, tmp); - r = FbAdd (m, d, 0, tmp); - - *dst++ = r; - } - } - - _mm_empty(); -} - -void -fbCompositeSrcAdd_8000x8000mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD8 *dstLine, *dst; - CARD8 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - CARD8 s, d; - CARD16 t; - - CHECKPOINT(); - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1); - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w && (unsigned long)dst & 7) - { - s = *src; - d = *dst; - t = d + s; - s = t | (0 - (t >> 8)); - *dst = s; - - dst++; - src++; - w--; - } - - while (w >= 8) - { - *(__m64*)dst = _mm_adds_pu8(*(__m64*)src, *(__m64*)dst); - dst += 8; - src += 8; - w -= 8; - } - - while (w) - { - s = *src; - d = *dst; - t = d + s; - s = t | (0 - (t >> 8)); - *dst = s; - - dst++; - src++; - w--; - } - } - - _mm_empty(); -} - -void -fbCompositeSrcAdd_8888x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst; - CARD32 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - - CHECKPOINT(); - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w && (unsigned long)dst & 7) - { - *dst = _mm_cvtsi64_si32(_mm_adds_pu8(_mm_cvtsi32_si64(*src), - _mm_cvtsi32_si64(*dst))); - dst++; - src++; - w--; - } - - while (w >= 2) - { - *(ullong*)dst = (ullong) _mm_adds_pu8(*(__m64*)src, *(__m64*)dst); - dst += 2; - src += 2; - w -= 2; - } - - if (w) - { - *dst = _mm_cvtsi64_si32(_mm_adds_pu8(_mm_cvtsi32_si64(*src), - _mm_cvtsi32_si64(*dst))); - - } - } - - _mm_empty(); -} - Bool -fbCopyAreammx (DrawablePtr pSrc, - DrawablePtr pDst, - int src_x, - int src_y, - int dst_x, - int dst_y, - int width, - int height) +fbBltmmx (FbBits *src_bits, + FbBits *dst_bits, + FbStride src_stride, + FbStride dst_stride, + int src_bpp, + int dst_bpp, + int src_x, int src_y, + int dst_x, int dst_y, + int width, int height) { - FbBits * src_bits; - FbStride src_stride; - int src_bpp; - int src_xoff; - int src_yoff; - - FbBits * dst_bits; - FbStride dst_stride; - int dst_bpp; - int dst_xoff; - int dst_yoff; - CARD8 * src_bytes; CARD8 * dst_bytes; int byte_width; - fbGetDrawable(pSrc, src_bits, src_stride, src_bpp, src_xoff, src_yoff); - fbGetDrawable(pDst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff); - if (src_bpp != dst_bpp) return FALSE; @@ -2757,16 +223,16 @@ fbCopyAreammx (DrawablePtr pSrc, { src_stride = src_stride * sizeof (FbBits) / 2; dst_stride = dst_stride * sizeof (FbBits) / 2; - src_bytes = (CARD8 *)(((CARD16 *)src_bits) + src_stride * (src_y + src_yoff) + (src_x + src_xoff)); - dst_bytes = (CARD8 *)(((CARD16 *)dst_bits) + dst_stride * (dst_y + dst_yoff) + (dst_x + dst_xoff)); + src_bytes = (CARD8 *)(((CARD16 *)src_bits) + src_stride * (src_y) + (src_x)); + dst_bytes = (CARD8 *)(((CARD16 *)dst_bits) + dst_stride * (dst_y) + (dst_x)); byte_width = 2 * width; src_stride *= 2; dst_stride *= 2; } else if (src_bpp == 32) { src_stride = src_stride * sizeof (FbBits) / 4; dst_stride = dst_stride * sizeof (FbBits) / 4; - src_bytes = (CARD8 *)(((CARD32 *)src_bits) + src_stride * (src_y + src_yoff) + (src_x + src_xoff)); - dst_bytes = (CARD8 *)(((CARD32 *)dst_bits) + dst_stride * (dst_y + dst_yoff) + (dst_x + dst_xoff)); + src_bytes = (CARD8 *)(((CARD32 *)src_bits) + src_stride * (src_y) + (src_x)); + dst_bytes = (CARD8 *)(((CARD32 *)dst_bits) + dst_stride * (dst_y) + (dst_x)); byte_width = 4 * width; src_stride *= 4; dst_stride *= 4; @@ -2867,32 +333,9 @@ fbCopyAreammx (DrawablePtr pSrc, } _mm_empty(); - return TRUE; -} -void -fbCompositeCopyAreammx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - fbCopyAreammx (pSrc->pDrawable, - pDst->pDrawable, - xSrc, ySrc, - xDst, yDst, - width, height); + return TRUE; } - - - #endif /* RENDER */ #endif /* USE_MMX */ diff --git a/fb/fbmmx.h b/fb/fbmmx.h index ca9c7e796..7d32a382b 100644 --- a/fb/fbmmx.h +++ b/fb/fbmmx.h @@ -44,251 +44,21 @@ Bool fbHaveMMX(void); #ifdef USE_MMX -void fbComposeSetupMMX(void); - -void fbCompositeSolidMask_nx8888x0565Cmmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrcAdd_8888x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrc_8888x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void -fbCompositeSolidMaskSrc_nx8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void -fbCompositeSrc_x888x8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSolidMask_nx8888x8888Cmmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSolidMask_nx8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeIn_nx8x8mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeIn_8x8mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrcAdd_8888x8x8mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrcAdd_8000x8000mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrc_8888RevNPx8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrc_8888x0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrc_8888RevNPx0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSolid_nx8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSolid_nx0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSolidMask_nx8x0565mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -void fbCompositeSrc_8888x8x8888mmx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -Bool fbCopyAreammx (DrawablePtr pSrc, - DrawablePtr pDst, - int src_x, - int src_y, - int dst_x, - int dst_y, - int width, - int height); -void fbCompositeCopyAreammx (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); -Bool fbSolidFillmmx (DrawablePtr pDraw, - int x, - int y, - int width, - int height, - FbBits xor); - +Bool fbBltmmx (FbBits *src_bits, + FbBits *dst_bits, + FbStride src_stride, + FbStride dst_stride, + int src_bpp, + int dst_bpp, + int src_x, int src_y, + int dst_x, int dst_y, + int width, int height); +Bool fbFillmmx (FbBits *bits, + FbStride stride, + int bpp, + int x, + int y, + int width, + int height, + FbBits xor); #endif /* USE_MMX */ diff --git a/fb/fbpict.c b/fb/fbpict.c index eb78ceda6..0a42f12d9 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -30,7 +30,6 @@ #include <string.h> #include "fb.h" -#include <pixman/pixman.h> #ifdef RENDER @@ -39,6 +38,186 @@ #include "fbpict.h" #include "fbmmx.h" +#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) + +void +fbWalkCompositeRegion (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height, + Bool srcRepeat, + Bool maskRepeat, + CompositeFunc compositeRect) +{ + RegionRec region; + int n; + BoxPtr pbox; + int w, h, w_this, h_this; + int x_msk, y_msk, x_src, y_src, x_dst, y_dst; + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + if (pSrc->pDrawable) + { + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + } + if (pMask && pMask->pDrawable) + { + xMask += pMask->pDrawable->x; + yMask += pMask->pDrawable->y; + } + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height)) + return; + + n = REGION_NUM_RECTS (®ion); + pbox = REGION_RECTS (®ion); + while (n--) + { + h = pbox->y2 - pbox->y1; + y_src = pbox->y1 - yDst + ySrc; + y_msk = pbox->y1 - yDst + yMask; + y_dst = pbox->y1; + while (h) + { + h_this = h; + w = pbox->x2 - pbox->x1; + x_src = pbox->x1 - xDst + xSrc; + x_msk = pbox->x1 - xDst + xMask; + x_dst = pbox->x1; + if (maskRepeat) + { + y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height); + if (h_this > pMask->pDrawable->height - y_msk) + h_this = pMask->pDrawable->height - y_msk; + y_msk += pMask->pDrawable->y; + } + if (srcRepeat) + { + y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height); + if (h_this > pSrc->pDrawable->height - y_src) + h_this = pSrc->pDrawable->height - y_src; + y_src += pSrc->pDrawable->y; + } + while (w) + { + w_this = w; + if (maskRepeat) + { + x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width); + if (w_this > pMask->pDrawable->width - x_msk) + w_this = pMask->pDrawable->width - x_msk; + x_msk += pMask->pDrawable->x; + } + if (srcRepeat) + { + x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width); + if (w_this > pSrc->pDrawable->width - x_src) + w_this = pSrc->pDrawable->width - x_src; + x_src += pSrc->pDrawable->x; + } + (*compositeRect) (op, pSrc, pMask, pDst, + x_src, y_src, x_msk, y_msk, x_dst, y_dst, + w_this, h_this); + w -= w_this; + x_src += w_this; + x_msk += w_this; + x_dst += w_this; + } + h -= h_this; + y_src += h_this; + y_msk += h_this; + y_dst += h_this; + } + pbox++; + } + REGION_UNINIT (pDst->pDrawable->pScreen, ®ion); +} + +void +fbComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + pixman_image_t *src, *mask, *dest; + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + if (pSrc->pDrawable) + { + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + } + if (pMask && pMask->pDrawable) + { + xMask += pMask->pDrawable->x; + yMask += pMask->pDrawable->y; + } + + miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height); + if (pMask) + miCompositeSourceValidate (pMask, xMask, yMask, width, height); + + src = image_from_pict (pSrc, TRUE); + mask = image_from_pict (pMask, TRUE); + dest = image_from_pict (pDst, TRUE); + + if (src && dest && !(pMask && !mask)) + { + pixman_image_composite (op, src, mask, dest, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); + + } + + if (src) + pixman_image_unref (src); + if (mask) + pixman_image_unref (mask); + if (dest) + pixman_image_unref (dest); +} + +void +fbCompositeGeneral (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + return fbComposite (op, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); +} + +#endif /* RENDER */ + static pixman_image_t * create_solid_fill_image (PicturePtr pict) { @@ -108,7 +287,8 @@ create_conical_gradient_image (PictGradient *gradient) } static pixman_image_t * -create_bits_picture (PicturePtr pict) +create_bits_picture (PicturePtr pict, + Bool has_clip) { FbBits *bits; FbStride stride; @@ -142,7 +322,13 @@ create_bits_picture (PicturePtr pict) /* pCompositeClip is undefined for source pictures, so * only set the clip region for pictures with drawables */ - pixman_image_set_clip_region (image, pict->pCompositeClip); + if (has_clip) + { + if (pict->clientClipType != CT_NONE) + pixman_image_set_has_client_clip (image, TRUE); + + pixman_image_set_clip_region (image, pict->pCompositeClip); + } /* Indexed table */ if (pict->pFormat->index.devPrivate) @@ -153,8 +339,6 @@ create_bits_picture (PicturePtr pict) return image; } -static pixman_image_t *image_from_pict (PicturePtr pict); - static void set_image_properties (pixman_image_t *image, PicturePtr pict) { @@ -191,7 +375,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict) if (pict->alphaMap) { - pixman_image_t *alpha_map = image_from_pict (pict->alphaMap); + pixman_image_t *alpha_map = image_from_pict (pict->alphaMap, TRUE); pixman_image_set_alpha_map ( image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y); @@ -222,8 +406,9 @@ set_image_properties (pixman_image_t *image, PicturePtr pict) pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams); } -static pixman_image_t * -image_from_pict (PicturePtr pict) +pixman_image_t * +image_from_pict (PicturePtr pict, + Bool has_clip) { pixman_image_t *image = NULL; @@ -232,7 +417,7 @@ image_from_pict (PicturePtr pict) if (pict->pDrawable) { - image = create_bits_picture (pict); + image = create_bits_picture (pict, has_clip); } else if (pict->pSourcePict) { @@ -261,175 +446,6 @@ image_from_pict (PicturePtr pict) return image; } -#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - -void -fbWalkCompositeRegion (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height, - Bool srcRepeat, - Bool maskRepeat, - CompositeFunc compositeRect) -{ - RegionRec region; - int n; - BoxPtr pbox; - int w, h, w_this, h_this; - int x_msk, y_msk, x_src, y_src, x_dst, y_dst; - - xDst += pDst->pDrawable->x; - yDst += pDst->pDrawable->y; - if (pSrc->pDrawable) - { - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->pDrawable->y; - } - if (pMask && pMask->pDrawable) - { - xMask += pMask->pDrawable->x; - yMask += pMask->pDrawable->y; - } - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height)) - return; - - n = REGION_NUM_RECTS (®ion); - pbox = REGION_RECTS (®ion); - while (n--) - { - h = pbox->y2 - pbox->y1; - y_src = pbox->y1 - yDst + ySrc; - y_msk = pbox->y1 - yDst + yMask; - y_dst = pbox->y1; - while (h) - { - h_this = h; - w = pbox->x2 - pbox->x1; - x_src = pbox->x1 - xDst + xSrc; - x_msk = pbox->x1 - xDst + xMask; - x_dst = pbox->x1; - if (maskRepeat) - { - y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height); - if (h_this > pMask->pDrawable->height - y_msk) - h_this = pMask->pDrawable->height - y_msk; - y_msk += pMask->pDrawable->y; - } - if (srcRepeat) - { - y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height); - if (h_this > pSrc->pDrawable->height - y_src) - h_this = pSrc->pDrawable->height - y_src; - y_src += pSrc->pDrawable->y; - } - while (w) - { - w_this = w; - if (maskRepeat) - { - x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width); - if (w_this > pMask->pDrawable->width - x_msk) - w_this = pMask->pDrawable->width - x_msk; - x_msk += pMask->pDrawable->x; - } - if (srcRepeat) - { - x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width); - if (w_this > pSrc->pDrawable->width - x_src) - w_this = pSrc->pDrawable->width - x_src; - x_src += pSrc->pDrawable->x; - } - (*compositeRect) (op, pSrc, pMask, pDst, - x_src, y_src, x_msk, y_msk, x_dst, y_dst, - w_this, h_this); - w -= w_this; - x_src += w_this; - x_msk += w_this; - x_dst += w_this; - } - h -= h_this; - y_src += h_this; - y_msk += h_this; - y_dst += h_this; - } - pbox++; - } - REGION_UNINIT (pDst->pDrawable->pScreen, ®ion); -} - -void -fbComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - pixman_region16_t region; - pixman_image_t *src, *mask, *dest; - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height)) - return; - - src = image_from_pict (pSrc); - mask = image_from_pict (pMask); - dest = image_from_pict (pDst); - - if (src && dest && !(pMask && !mask)) - { - pixman_image_composite (op, src, mask, dest, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height, ®ion); - } - - pixman_region_fini (®ion); - - if (src) - pixman_image_unref (src); - if (mask) - pixman_image_unref (mask); - if (dest) - pixman_image_unref (dest); -} - -void -fbCompositeGeneral (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - return fbComposite (op, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height); -} - -#endif /* RENDER */ - Bool fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) { diff --git a/fb/fbpict.h b/fb/fbpict.h index 3bd0a78a3..b4c1dcf12 100644 --- a/fb/fbpict.h +++ b/fb/fbpict.h @@ -412,18 +412,6 @@ fbCompositeGeneral (CARD8 op, CARD16 width, CARD16 height); - -/* fbedge.c */ -void -fbRasterizeEdges (FbBits *buf, - int bpp, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b); - /* fbpict.c */ void fbComposite (CARD8 op, diff --git a/fb/fbtrap.c b/fb/fbtrap.c index 478a80f4f..831306869 100644 --- a/fb/fbtrap.c +++ b/fb/fbtrap.c @@ -42,61 +42,16 @@ fbAddTraps (PicturePtr pPicture, int ntrap, xTrap *traps) { - FbBits *buf; - int bpp; - int width; - int stride; - int height; - int pxoff, pyoff; - - xFixed x_off_fixed; - xFixed y_off_fixed; - RenderEdge l, r; - xFixed t, b; - - fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff); - - width = pPicture->pDrawable->width; - height = pPicture->pDrawable->height; - x_off += pxoff; - y_off += pyoff; - - x_off_fixed = IntToxFixed(y_off); - y_off_fixed = IntToxFixed(y_off); + pixman_image_t *image = image_from_pict (pPicture, FALSE); - while (ntrap--) - { - t = traps->top.y + y_off_fixed; - if (t < 0) - t = 0; - t = RenderSampleCeilY (t, bpp); + if (!image) + return; - b = traps->bot.y + y_off_fixed; - if (xFixedToInt (b) >= height) - b = IntToxFixed (height) - 1; - b = RenderSampleFloorY (b, bpp); - - if (b >= t) - { - /* initialize edge walkers */ - RenderEdgeInit (&l, bpp, t, - traps->top.l + x_off_fixed, - traps->top.y + y_off_fixed, - traps->bot.l + x_off_fixed, - traps->bot.y + y_off_fixed); - - RenderEdgeInit (&r, bpp, t, - traps->top.r + x_off_fixed, - traps->top.y + y_off_fixed, - traps->bot.r + x_off_fixed, - traps->bot.y + y_off_fixed); - - fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b); - } - traps++; - } + pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps); fbFinishAccess (pPicture->pDrawable); + + pixman_image_unref (image); } void @@ -105,50 +60,16 @@ fbRasterizeTrapezoid (PicturePtr pPicture, int x_off, int y_off) { - FbBits *buf; - int bpp; - int width; - int stride; - int height; - int pxoff, pyoff; - - xFixed x_off_fixed; - xFixed y_off_fixed; - RenderEdge l, r; - xFixed t, b; - - if (!xTrapezoidValid (trap)) - return; + pixman_image_t *image = image_from_pict (pPicture, FALSE); - fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff); + if (!image) + return; - width = pPicture->pDrawable->width; - height = pPicture->pDrawable->height; - x_off += pxoff; - y_off += pyoff; - - x_off_fixed = IntToxFixed(x_off); - y_off_fixed = IntToxFixed(y_off); - t = trap->top + y_off_fixed; - if (t < 0) - t = 0; - t = RenderSampleCeilY (t, bpp); - - b = trap->bottom + y_off_fixed; - if (xFixedToInt (b) >= height) - b = IntToxFixed (height) - 1; - b = RenderSampleFloorY (b, bpp); - - if (b >= t) - { - /* initialize edge walkers */ - RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off); - RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off); - - fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b); - } + pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off); fbFinishAccess (pPicture->pDrawable); + + pixman_image_unref (image); } static int diff --git a/fb/fbwindow.c b/fb/fbwindow.c index cac662cc7..5b3f446b1 100644 --- a/fb/fbwindow.c +++ b/fb/fbwindow.c @@ -233,26 +233,27 @@ fbFillRegionSolid (DrawablePtr pDrawable, while (n--) { #ifdef USE_MMX - if (!has_mmx || !fbSolidFillmmx (pDrawable, - pbox->x1, - pbox->y1, - (pbox->x2 - pbox->x1), - (pbox->y2 - pbox->y1), xor)) { + if (!has_mmx || !fbFillmmx (dst, dstStride, dstBpp, + pbox->x1 + dstXoff, pbox->y1 + dstYoff, + (pbox->x2 - pbox->x1), + (pbox->y2 - pbox->y1), + xor)) + { #endif - fbSolid (dst + (pbox->y1 + dstYoff) * dstStride, - dstStride, - (pbox->x1 + dstXoff) * dstBpp, - dstBpp, - (pbox->x2 - pbox->x1) * dstBpp, - pbox->y2 - pbox->y1, - and, xor); + fbSolid (dst + (pbox->y1 + dstYoff) * dstStride, + dstStride, + (pbox->x1 + dstXoff) * dstBpp, + dstBpp, + (pbox->x2 - pbox->x1) * dstBpp, + pbox->y2 - pbox->y1, + and, xor); #ifdef USE_MMX } #endif fbValidateDrawable (pDrawable); pbox++; } - + fbFinishAccess (pDrawable); } diff --git a/fb/wfbrename.h b/fb/wfbrename.h index 8f875c88b..952512ecc 100644 --- a/fb/wfbrename.h +++ b/fb/wfbrename.h @@ -184,9 +184,11 @@ #define fbUnmapWindow wfbUnmapWindow #define fbUnrealizeFont wfbUnrealizeFont #define fbValidateGC wfbValidateGC +#define fbWalkCompositeRegion wfbWalkCompositeRegion #define fbWinPrivateIndex wfbWinPrivateIndex #define fbZeroLine wfbZeroLine #define fbZeroSegment wfbZeroSegment +#define image_from_pict wfb_image_from_pict #define xxScrPrivateIndex wfbxxScrPrivateIndex #define xxGCPrivateIndex wfbxxGCPrivateIndex #define xxColormapPrivateIndex wfbxxColormapPrivateIndex |