annotate src/video/SDL_blit_A.c @ 1164:10b3fb28c86b

Date: Mon, 31 Oct 2005 14:23:34 +0100 From: Thomas Omilian <paccy@arcor.de> To: sdl@libsdl.org Subject: [SDL] SDL_SoftStretch() fixed! Ok, after debugging the night I found the error: in video/SDL_stretch.c in Line 81 /* See if we need to regenerate the copy buffer */ if ( (src_w == last.src_w) && (dst_w == last.src_w) && (bpp == last.bpp) ) { return(0); } the second comparison should be (dst_w == last dst_w). Perhaps someone could apply it to the source... Regards, Thomas Omilian
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 01 Nov 2005 04:14:24 +0000
parents 2651158f59b8
children 867f521591e5
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 739
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 1
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 static char rcsid =
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 "@(#) $Id$";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include "SDL_types.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include "SDL_video.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 #include "SDL_blit.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
34 #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
35 #define MMX_ASMBLIT
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
36 #endif
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
37
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
38 /* Function to check the CPU flags */
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
39 #include "SDL_cpuinfo.h"
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
40 #ifdef MMX_ASMBLIT
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
41 #include "mmx.h"
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
42 #endif
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
43
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 /* Functions to perform alpha blended blitting */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 /* N->1 blending with per-surface alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 Uint8 *src = info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 int srcskip = info->s_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 Uint8 *dst = info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 int dstskip = info->d_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 Uint8 *palmap = info->table;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 SDL_PixelFormat *srcfmt = info->src;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 SDL_PixelFormat *dstfmt = info->dst;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 int srcbpp = srcfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 const unsigned A = srcfmt->alpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 while ( height-- ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 DUFFS_LOOP4(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
65 Uint32 Pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 unsigned sR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 unsigned sG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 unsigned sB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 unsigned dR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 unsigned dG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 unsigned dB;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
72 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 dR = dstfmt->palette->colors[*dst].r;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 dG = dstfmt->palette->colors[*dst].g;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 dB = dstfmt->palette->colors[*dst].b;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 dR &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 dG &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 dB &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 /* Pack RGB into 8bit pixel */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 if ( palmap == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 *dst =((dR>>5)<<(3+2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 ((dG>>5)<<(2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 ((dB>>6)<<(0));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 *dst = palmap[((dR>>5)<<(3+2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 ((dG>>5)<<(2)) |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 ((dB>>6)<<(0))];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 dst++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 src += srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 },
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 src += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 dst += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 /* N->1 blending with pixel alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 Uint8 *src = info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 int srcskip = info->s_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 Uint8 *dst = info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 int dstskip = info->d_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 Uint8 *palmap = info->table;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 SDL_PixelFormat *srcfmt = info->src;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 SDL_PixelFormat *dstfmt = info->dst;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 int srcbpp = srcfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 /* FIXME: fix alpha bit field expansion here too? */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 while ( height-- ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 DUFFS_LOOP4(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
117 Uint32 Pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 unsigned sR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 unsigned sG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 unsigned sB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 unsigned sA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 unsigned dR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 unsigned dG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 unsigned dB;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
125 DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 dR = dstfmt->palette->colors[*dst].r;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 dG = dstfmt->palette->colors[*dst].g;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 dB = dstfmt->palette->colors[*dst].b;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 dR &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 dG &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 dB &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 /* Pack RGB into 8bit pixel */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 if ( palmap == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 *dst =((dR>>5)<<(3+2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 ((dG>>5)<<(2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 ((dB>>6)<<(0));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 *dst = palmap[((dR>>5)<<(3+2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 ((dG>>5)<<(2)) |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 ((dB>>6)<<(0)) ];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 dst++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 src += srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 },
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 src += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 dst += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 /* colorkeyed N->1 blending with per-surface alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 Uint8 *src = info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 int srcskip = info->s_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 Uint8 *dst = info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 int dstskip = info->d_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 Uint8 *palmap = info->table;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 SDL_PixelFormat *srcfmt = info->src;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 SDL_PixelFormat *dstfmt = info->dst;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 int srcbpp = srcfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 Uint32 ckey = srcfmt->colorkey;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 const int A = srcfmt->alpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 while ( height-- ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 DUFFS_LOOP(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
172 Uint32 Pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 unsigned sR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 unsigned sG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 unsigned sB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 unsigned dR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 unsigned dG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 unsigned dB;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
179 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
180 if ( Pixel != ckey ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 dR = dstfmt->palette->colors[*dst].r;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 dG = dstfmt->palette->colors[*dst].g;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 dB = dstfmt->palette->colors[*dst].b;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 dR &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 dG &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 dB &= 0xff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 /* Pack RGB into 8bit pixel */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 if ( palmap == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 *dst =((dR>>5)<<(3+2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 ((dG>>5)<<(2)) |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 ((dB>>6)<<(0));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 *dst = palmap[((dR>>5)<<(3+2))|
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 ((dG>>5)<<(2)) |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 ((dB>>6)<<(0)) ];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 dst++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 src += srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 },
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 src += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 dst += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
208 #ifdef MMX_ASMBLIT
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
209 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
210 static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
211 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
212 int width = info->d_width;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
213 int height = info->d_height;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
214 Uint32 *srcp = (Uint32 *)info->s_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
215 int srcskip = info->s_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
216 Uint32 *dstp = (Uint32 *)info->d_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
217 int dstskip = info->d_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
218 Uint8 load[8];
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
219
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
220 *(Uint64 *)load = 0x00fefefe00fefefeULL;/* alpha128 mask */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
221 movq_m2r(*load, mm4); /* alpha128 mask -> mm4 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
222 *(Uint64 *)load = 0x0001010100010101ULL;/* !alpha128 mask */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
223 movq_m2r(*load, mm3); /* !alpha128 mask -> mm3 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
224 *(Uint64 *)load = 0xFF000000FF000000ULL;/* dst alpha mask */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
225 movq_m2r(*load, mm7); /* dst alpha mask -> mm7 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
226 while(height--) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
227 DUFFS_LOOP_DOUBLE2(
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
228 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
229 Uint32 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
230 Uint32 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
231 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
232 + (s & d & 0x00010101)) | 0xff000000;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
233 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
234 movq_m2r((*dstp), mm2);/* 2 x dst -> mm2(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
235 movq_r2r(mm2, mm6); /* 2 x dst -> mm6(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
236
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
237 movq_m2r((*srcp), mm1);/* 2 x src -> mm1(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
238 movq_r2r(mm1, mm5); /* 2 x src -> mm5(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
239
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
240 pand_r2r(mm4, mm6); /* dst & mask -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
241 pand_r2r(mm4, mm5); /* src & mask -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
242 paddd_r2r(mm6, mm5); /* mm6 + mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
243 psrld_i2r(1, mm5); /* mm5 >> 1 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
244
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
245 pand_r2r(mm1, mm2); /* src & dst -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
246 pand_r2r(mm3, mm2); /* mm2 & !mask -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
247 paddd_r2r(mm5, mm2); /* mm5 + mm2 -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
248 por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
249 movq_r2m(mm2, (*dstp));/* mm2 -> 2 x dst pixels */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
250 dstp += 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
251 srcp += 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
252 }, width);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
253 srcp += srcskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
254 dstp += dstskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
255 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
256 emms();
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
257 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
258
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
259 /* fast RGB888->(A)RGB888 blending with surface alpha */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
260 static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
261 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
262 unsigned alpha = info->src->alpha;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
263 if(alpha == 128) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
264 BlitRGBtoRGBSurfaceAlpha128MMX(info);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
265 } else {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
266 int width = info->d_width;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
267 int height = info->d_height;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
268 Uint32 *srcp = (Uint32 *)info->s_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
269 int srcskip = info->s_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
270 Uint32 *dstp = (Uint32 *)info->d_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
271 int dstskip = info->d_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
272 Uint8 load[8] = {alpha, alpha, alpha, alpha,
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
273 alpha, alpha, alpha, alpha};
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
274
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
275 movq_m2r(*load, mm4); /* alpha -> mm4 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
276 *(Uint64 *)load = 0x00FF00FF00FF00FFULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
277 movq_m2r(*load, mm3); /* mask -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
278 pand_r2r(mm3, mm4); /* mm4 & mask -> 0A0A0A0A -> mm4 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
279 *(Uint64 *)load = 0xFF000000FF000000ULL;/* dst alpha mask */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
280 movq_m2r(*load, mm7); /* dst alpha mask -> mm7 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
281
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
282 while(height--) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
283 DUFFS_LOOP_DOUBLE2({
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
284 /* One Pixel Blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
285 movd_m2r((*srcp), mm1);/* src(ARGB) -> mm1 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
286 punpcklbw_r2r(mm1, mm1); /* AARRGGBB -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
287 pand_r2r(mm3, mm1); /* 0A0R0G0B -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
288
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
289 movd_m2r((*dstp), mm2);/* dst(ARGB) -> mm2 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
290 movq_r2r(mm2, mm6);/* dst(ARGB) -> mm6 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
291 punpcklbw_r2r(mm2, mm2); /* AARRGGBB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
292 pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
293
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
294 psubw_r2r(mm2, mm1);/* src - dst -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
295 pmullw_r2r(mm4, mm1); /* mm1 * alpha -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
296 psrlw_i2r(8, mm1); /* mm1 >> 8 -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
297 paddw_r2r(mm1, mm2); /* mm1 + mm2(dst) -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
298 pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
299 packuswb_r2r(mm2, mm2); /* ARGBARGB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
300 por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
301 movd_r2m(mm2, *dstp);/* mm2 -> Pixel */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
302 ++srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
303 ++dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
304 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
305 /* Two Pixels Blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
306 movq_m2r((*srcp), mm0);/* 2 x src -> mm0(ARGBARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
307 movq_r2r(mm0, mm1); /* 2 x src -> mm1(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
308 punpcklbw_r2r(mm0, mm0); /* low - AARRGGBB -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
309 pand_r2r(mm3, mm0); /* 0A0R0G0B -> mm0(src1) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
310 punpckhbw_r2r(mm1, mm1); /* high - AARRGGBB -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
311 pand_r2r(mm3, mm1); /* 0A0R0G0B -> mm1(src2) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
312
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
313 movq_m2r((*dstp), mm2);/* 2 x dst -> mm2(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
314 movq_r2r(mm2, mm5); /* 2 x dst -> mm5(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
315 movq_r2r(mm2, mm6); /* 2 x dst -> mm6(ARGBARGB) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
316 punpcklbw_r2r(mm2, mm2); /* low - AARRGGBB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
317 punpckhbw_r2r(mm6, mm6); /* high - AARRGGBB -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
318 pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2(dst1) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
319
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
320 psubw_r2r(mm2, mm0);/* src1 - dst1 -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
321 pmullw_r2r(mm4, mm0); /* mm0 * alpha -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
322 pand_r2r(mm3, mm6); /* 0A0R0G0B -> mm6(dst2) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
323 psrlw_i2r(8, mm0); /* mm0 >> 8 -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
324 psubw_r2r(mm6, mm1);/* src2 - dst2 -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
325 pmullw_r2r(mm4, mm1); /* mm1 * alpha -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
326 paddw_r2r(mm0, mm2); /* mm0 + mm2(dst1) -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
327 psrlw_i2r(8, mm1); /* mm1 >> 8 -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
328 pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
329 paddw_r2r(mm1, mm6); /* mm1 + mm6(dst2) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
330 pand_r2r(mm3, mm6); /* 0A0R0G0B -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
331 packuswb_r2r(mm2, mm2); /* ARGBARGB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
332 packuswb_r2r(mm6, mm6); /* ARGBARGB -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
333 psrlq_i2r(32, mm2); /* mm2 >> 32 -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
334 psllq_i2r(32, mm6); /* mm6 << 32 -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
335 por_r2r(mm6, mm2); /* mm6 | mm2 -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
336 por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
337 movq_r2m(mm2, *dstp);/* mm2 -> 2 x Pixel */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
338 srcp += 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
339 dstp += 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
340 }, width);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
341 srcp += srcskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
342 dstp += dstskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
343 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
344 emms();
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
345 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
346 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
347
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
348 /* fast ARGB888->(A)RGB888 blending with pixel alpha */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
349 static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
350 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
351 int width = info->d_width;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
352 int height = info->d_height;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
353 Uint32 *srcp = (Uint32 *)info->s_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
354 int srcskip = info->s_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
355 Uint32 *dstp = (Uint32 *)info->d_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
356 int dstskip = info->d_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
357 Uint32 alpha = 0;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
358 Uint8 load[8];
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
359
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
360 *(Uint64 *)load = 0x00FF00FF00FF00FFULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
361 movq_m2r(*load, mm3); /* mask -> mm2 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
362 *(Uint64 *)load = 0x00FF000000000000ULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
363 movq_m2r(*load, mm7); /* dst alpha mask -> mm2 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
364 *(Uint64 *)load = 0x00FFFFFF00FFFFFFULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
365 movq_m2r(*load, mm0); /* alpha 255 mask -> mm0 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
366 *(Uint64 *)load = 0xFF000000FF000000ULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
367 movq_m2r(*load, mm6); /* alpha 255 !mask -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
368 while(height--) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
369 DUFFS_LOOP4({
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
370 alpha = *srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
371 alpha >>= 24;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
372 /* FIXME: Here we special-case opaque alpha since the
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
373 compositioning used (>>8 instead of /255) doesn't handle
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
374 it correctly. Also special-case alpha=0 for speed?
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
375 Benchmark this! */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
376 if(alpha) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
377 if(alpha == SDL_ALPHA_OPAQUE) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
378 movd_m2r((*srcp), mm1);/* src(ARGB) -> mm1 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
379 movd_m2r((*dstp), mm2);/* dst(ARGB) -> mm2 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
380 pand_r2r(mm0, mm1);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
381 pand_r2r(mm6, mm2);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
382 por_r2r(mm1, mm2);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
383 movd_r2m(mm2, (*dstp));
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
384 } else {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
385 movd_m2r((*srcp), mm1);/* src(ARGB) -> mm1 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
386 punpcklbw_r2r(mm1, mm1); /* AARRGGBB -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
387 pand_r2r(mm3, mm1); /* 0A0R0G0B -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
388
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
389 movd_m2r((*dstp), mm2);/* dst(ARGB) -> mm2 (0000ARGB)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
390 punpcklbw_r2r(mm2, mm2); /* AARRGGBB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
391 pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
392
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
393 movq_r2r(mm2, mm5);/* mm2(0A0R0G0B) -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
394 pand_r2r(mm7, mm5); /* mm5 & dst alpha mask -> mm5(0A000000) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
395 psrlq_i2r(24, mm5); /* mm5 >> 24 -> mm5 (0000A000)*/
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
396
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
397 movq_r2r(mm1, mm4);/* mm1(0A0R0G0B) -> mm4 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
398 psrlq_i2r(48, mm4); /* mm4 >> 48 -> mm4(0000000A) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
399 punpcklwd_r2r(mm4, mm4); /* 00000A0A -> mm4 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
400 punpcklwd_r2r(mm4, mm4); /* 0A0A0A0A -> mm4 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
401
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
402 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
403 psubw_r2r(mm2, mm1);/* src - dst -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
404 pmullw_r2r(mm4, mm1); /* mm1 * alpha -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
405 psrlw_i2r(8, mm1); /* mm1 >> 8 -> mm1 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
406 paddw_r2r(mm1, mm2); /* mm1 + mm2(dst) -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
407 pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
408 packuswb_r2r(mm2, mm2); /* ARGBARGB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
409 pand_r2r(mm0, mm2); /* 0RGB0RGB -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
410 por_r2r(mm5, mm2); /* dst alpha | mm2 -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
411 movd_r2m(mm2, *dstp);/* mm2 -> dst */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
412 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
413 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
414 ++srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
415 ++dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
416 }, width);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
417 srcp += srcskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
418 dstp += dstskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
419 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
420 emms();
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
421 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
422 #endif
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
423
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
424 #ifdef USE_ALTIVEC_BLITTERS
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
425 #include <altivec.h>
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
426 #include <assert.h>
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
427
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
428 #if ((defined MACOSX) && (__GNUC__ < 4))
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
429 #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
430 (vector unsigned char) ( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p )
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
431 #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
432 (vector unsigned short) ( a,b,c,d,e,f,g,h )
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
433 #else
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
434 #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
435 (vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p }
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
436 #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
437 (vector unsigned short) { a,b,c,d,e,f,g,h }
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
438 #endif
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
439
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
440 #define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
441 #define VECPRINT(msg, v) do { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
442 vector unsigned int tmpvec = (vector unsigned int)(v); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
443 unsigned int *vp = (unsigned int *)&tmpvec; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
444 printf("%s = %08X %08X %08X %08X\n", msg, vp[0], vp[1], vp[2], vp[3]); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
445 } while (0)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
446
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
447 /* the permuation vector that takes the high bytes out of all the appropriate shorts
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
448 (vector unsigned char)(
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
449 0x00, 0x10, 0x02, 0x12,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
450 0x04, 0x14, 0x06, 0x16,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
451 0x08, 0x18, 0x0A, 0x1A,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
452 0x0C, 0x1C, 0x0E, 0x1E );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
453 */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
454 #define VEC_MERGE_PERMUTE() (vec_add(vec_lvsl(0, (int*)NULL), (vector unsigned char)vec_splat_u16(0x0F)))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
455 #define VEC_U32_24() (vec_add(vec_splat_u32(12), vec_splat_u32(12)))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
456 #define VEC_ALPHA_MASK() ((vector unsigned char)vec_sl((vector unsigned int)vec_splat_s8(-1), VEC_U32_24()))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
457 #define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
458 ? vec_lvsl(0, src) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
459 : vec_add(vec_lvsl(8, src), vec_splat_u8(8)))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
460
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
461
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
462 #define VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1_16, v8_16) do { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
463 /* vtemp1 contains source AAGGAAGGAAGGAAGG */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
464 vector unsigned short vtemp1 = vec_mule(vs, valpha); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
465 /* vtemp2 contains source RRBBRRBBRRBBRRBB */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
466 vector unsigned short vtemp2 = vec_mulo(vs, valpha); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
467 /* valpha2 is 255-alpha */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
468 vector unsigned char valpha2 = vec_nor(valpha, valpha); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
469 /* vtemp3 contains dest AAGGAAGGAAGGAAGG */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
470 vector unsigned short vtemp3 = vec_mule(vd, valpha2); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
471 /* vtemp4 contains dest RRBBRRBBRRBBRRBB */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
472 vector unsigned short vtemp4 = vec_mulo(vd, valpha2); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
473 /* add source and dest */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
474 vtemp1 = vec_add(vtemp1, vtemp3); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
475 vtemp2 = vec_add(vtemp2, vtemp4); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
476 /* vtemp1 = (vtemp1 + 1) + ((vtemp1 + 1) >> 8) */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
477 vtemp1 = vec_add(vtemp1, v1_16); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
478 vtemp3 = vec_sr(vtemp1, v8_16); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
479 vtemp1 = vec_add(vtemp1, vtemp3); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
480 /* vtemp2 = (vtemp2 + 1) + ((vtemp2 + 1) >> 8) */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
481 vtemp2 = vec_add(vtemp2, v1_16); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
482 vtemp4 = vec_sr(vtemp2, v8_16); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
483 vtemp2 = vec_add(vtemp2, vtemp4); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
484 /* (>>8) and get ARGBARGBARGBARGB */ \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
485 vd = (vector unsigned char)vec_perm(vtemp1, vtemp2, mergePermute); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
486 } while (0)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
487
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
488 /* Calculate the permute vector used for 32->32 swizzling */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
489 static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
490 const SDL_PixelFormat *dstfmt)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
491 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
492 /*
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
493 * We have to assume that the bits that aren't used by other
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
494 * colors is alpha, and it's one complete byte, since some formats
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
495 * leave alpha with a zero mask, but we should still swizzle the bits.
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
496 */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
497 /* ARGB */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
498 const static struct SDL_PixelFormat default_pixel_format = {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
499 NULL, 0, 0,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
500 0, 0, 0, 0,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
501 16, 8, 0, 24,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
502 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
503 0, 0};
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
504 if (!srcfmt) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
505 srcfmt = &default_pixel_format;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
506 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
507 if (!dstfmt) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
508 dstfmt = &default_pixel_format;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
509 }
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
510 vector unsigned char plus = VECUINT8_LITERAL
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
511 ( 0x00, 0x00, 0x00, 0x00,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
512 0x04, 0x04, 0x04, 0x04,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
513 0x08, 0x08, 0x08, 0x08,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
514 0x0C, 0x0C, 0x0C, 0x0C );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
515 vector unsigned char vswiz;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
516 vector unsigned int srcvec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
517 #define RESHIFT(X) (3 - ((X) >> 3))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
518 Uint32 rmask = RESHIFT(srcfmt->Rshift) << (dstfmt->Rshift);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
519 Uint32 gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
520 Uint32 bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
521 Uint32 amask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
522 /* Use zero for alpha if either surface doesn't have alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
523 if (dstfmt->Amask) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
524 amask = ((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt->Ashift);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
525 } else {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
526 amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
527 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
528 #undef RESHIFT
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
529 ((unsigned int *)(char*)&srcvec)[0] = (rmask | gmask | bmask | amask);
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
530 vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0));
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
531 return(vswiz);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
532 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
533
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
534 static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
535 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
536 int height = info->d_height;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
537 Uint8 *src = (Uint8 *)info->s_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
538 int srcskip = info->s_skip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
539 Uint8 *dst = (Uint8 *)info->d_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
540 int dstskip = info->d_skip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
541 SDL_PixelFormat *srcfmt = info->src;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
542
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
543 vector unsigned char v0 = vec_splat_u8(0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
544 vector unsigned short v8_16 = vec_splat_u16(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
545 vector unsigned short v1_16 = vec_splat_u16(1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
546 vector unsigned short v2_16 = vec_splat_u16(2);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
547 vector unsigned short v3_16 = vec_splat_u16(3);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
548 vector unsigned int v8_32 = vec_splat_u32(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
549 vector unsigned int v16_32 = vec_add(v8_32, v8_32);
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
550 vector unsigned short v3f = VECUINT16_LITERAL(
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
551 0x003f, 0x003f, 0x003f, 0x003f,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
552 0x003f, 0x003f, 0x003f, 0x003f);
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
553 vector unsigned short vfc = VECUINT16_LITERAL(
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
554 0x00fc, 0x00fc, 0x00fc, 0x00fc,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
555 0x00fc, 0x00fc, 0x00fc, 0x00fc);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
556
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
557 /*
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
558 0x10 - 0x1f is the alpha
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
559 0x00 - 0x0e evens are the red
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
560 0x01 - 0x0f odds are zero
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
561 */
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
562 vector unsigned char vredalpha1 = VECUINT8_LITERAL(
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
563 0x10, 0x00, 0x01, 0x01,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
564 0x10, 0x02, 0x01, 0x01,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
565 0x10, 0x04, 0x01, 0x01,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
566 0x10, 0x06, 0x01, 0x01
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
567 );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
568 vector unsigned char vredalpha2 = (vector unsigned char)(
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
569 vec_add((vector unsigned int)vredalpha1, vec_sl(v8_32, v16_32))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
570 );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
571 /*
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
572 0x00 - 0x0f is ARxx ARxx ARxx ARxx
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
573 0x11 - 0x0f odds are blue
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
574 */
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
575 vector unsigned char vblue1 = VECUINT8_LITERAL(
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
576 0x00, 0x01, 0x02, 0x11,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
577 0x04, 0x05, 0x06, 0x13,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
578 0x08, 0x09, 0x0a, 0x15,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
579 0x0c, 0x0d, 0x0e, 0x17
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
580 );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
581 vector unsigned char vblue2 = (vector unsigned char)(
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
582 vec_add((vector unsigned int)vblue1, v8_32)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
583 );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
584 /*
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
585 0x00 - 0x0f is ARxB ARxB ARxB ARxB
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
586 0x10 - 0x0e evens are green
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
587 */
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
588 vector unsigned char vgreen1 = VECUINT8_LITERAL(
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
589 0x00, 0x01, 0x10, 0x03,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
590 0x04, 0x05, 0x12, 0x07,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
591 0x08, 0x09, 0x14, 0x0b,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
592 0x0c, 0x0d, 0x16, 0x0f
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
593 );
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
594 vector unsigned char vgreen2 = (vector unsigned char)(
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
595 vec_add((vector unsigned int)vgreen1, vec_sl(v8_32, v8_32))
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
596 );
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
597 vector unsigned char vgmerge = VECUINT8_LITERAL(
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
598 0x00, 0x02, 0x00, 0x06,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
599 0x00, 0x0a, 0x00, 0x0e,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
600 0x00, 0x12, 0x00, 0x16,
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
601 0x00, 0x1a, 0x00, 0x1e);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
602 vector unsigned char mergePermute = VEC_MERGE_PERMUTE();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
603 vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
604 vector unsigned char valphaPermute = vec_and(vec_lvsl(0, (int *)NULL), vec_splat_u8(0xC));
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
605
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
606 vector unsigned short vf800 = (vector unsigned short)vec_splat_u8(-7);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
607 vf800 = vec_sl(vf800, vec_splat_u16(8));
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
608
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
609 while(height--) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
610 int extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
611 vector unsigned char valigner;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
612 vector unsigned char vsrc;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
613 vector unsigned char voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
614 int width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
615
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
616 #define ONE_PIXEL_BLEND(condition, widthvar) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
617 while (condition) { \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
618 Uint32 Pixel; \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
619 unsigned sR, sG, sB, dR, dG, dB, sA; \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
620 DISEMBLE_RGBA(src, 4, srcfmt, Pixel, sR, sG, sB, sA); \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
621 if(sA) { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
622 unsigned short dstpixel = *((unsigned short *)dst); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
623 dR = (dstpixel >> 8) & 0xf8; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
624 dG = (dstpixel >> 3) & 0xfc; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
625 dB = (dstpixel << 3) & 0xf8; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
626 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
627 *((unsigned short *)dst) = ( \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
628 ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
629 ); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
630 } \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
631 src += 4; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
632 dst += 2; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
633 widthvar--; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
634 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
635 ONE_PIXEL_BLEND((UNALIGNED_PTR(dst)) && (width), width);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
636 extrawidth = (width % 8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
637 valigner = VEC_ALIGNER(src);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
638 vsrc = (vector unsigned char)vec_ld(0, src);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
639 width -= extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
640 while (width) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
641 vector unsigned char valpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
642 vector unsigned char vsrc1, vsrc2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
643 vector unsigned char vdst1, vdst2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
644 vector unsigned short vR, vG, vB;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
645 vector unsigned short vpixel, vrpixel, vgpixel, vbpixel;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
646
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
647 /* Load 8 pixels from src as ARGB */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
648 voverflow = (vector unsigned char)vec_ld(15, src);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
649 vsrc = vec_perm(vsrc, voverflow, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
650 vsrc1 = vec_perm(vsrc, vsrc, vpermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
651 src += 16;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
652 vsrc = (vector unsigned char)vec_ld(15, src);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
653 voverflow = vec_perm(voverflow, vsrc, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
654 vsrc2 = vec_perm(voverflow, voverflow, vpermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
655 src += 16;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
656
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
657 /* Load 8 pixels from dst as XRGB */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
658 voverflow = vec_ld(0, dst);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
659 vR = vec_and((vector unsigned short)voverflow, vf800);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
660 vB = vec_sl((vector unsigned short)voverflow, v3_16);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
661 vG = vec_sl(vB, v2_16);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
662 vdst1 = (vector unsigned char)vec_perm((vector unsigned char)vR, (vector unsigned char)vR, vredalpha1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
663 vdst1 = vec_perm(vdst1, (vector unsigned char)vB, vblue1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
664 vdst1 = vec_perm(vdst1, (vector unsigned char)vG, vgreen1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
665 vdst2 = (vector unsigned char)vec_perm((vector unsigned char)vR, (vector unsigned char)vR, vredalpha2);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
666 vdst2 = vec_perm(vdst2, (vector unsigned char)vB, vblue2);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
667 vdst2 = vec_perm(vdst2, (vector unsigned char)vG, vgreen2);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
668
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
669 /* Alpha blend 8 pixels as ARGB */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
670 valpha = vec_perm(vsrc1, v0, valphaPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
671 VEC_MULTIPLY_ALPHA(vsrc1, vdst1, valpha, mergePermute, v1_16, v8_16);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
672 valpha = vec_perm(vsrc2, v0, valphaPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
673 VEC_MULTIPLY_ALPHA(vsrc2, vdst2, valpha, mergePermute, v1_16, v8_16);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
674
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
675 /* Convert 8 pixels to 565 */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
676 vpixel = (vector unsigned short)vec_packpx((vector unsigned int)vdst1, (vector unsigned int)vdst2);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
677 vgpixel = (vector unsigned short)vec_perm(vdst1, vdst2, vgmerge);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
678 vgpixel = vec_and(vgpixel, vfc);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
679 vgpixel = vec_sl(vgpixel, v3_16);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
680 vrpixel = vec_sl(vpixel, v1_16);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
681 vrpixel = vec_and(vrpixel, vf800);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
682 vbpixel = vec_and(vpixel, v3f);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
683 vdst1 = vec_or((vector unsigned char)vrpixel, (vector unsigned char)vgpixel);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
684 vdst1 = vec_or(vdst1, (vector unsigned char)vbpixel);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
685
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
686 /* Store 8 pixels */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
687 vec_st(vdst1, 0, dst);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
688
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
689 width -= 8;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
690 dst += 16;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
691 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
692 ONE_PIXEL_BLEND((extrawidth), extrawidth);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
693 #undef ONE_PIXEL_BLEND
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
694 src += srcskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
695 dst += dstskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
696 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
697 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
698
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
699 static void Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo *info)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
700 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
701 unsigned alpha = info->src->alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
702 int height = info->d_height;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
703 Uint32 *srcp = (Uint32 *)info->s_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
704 int srcskip = info->s_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
705 Uint32 *dstp = (Uint32 *)info->d_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
706 int dstskip = info->d_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
707 SDL_PixelFormat *srcfmt = info->src;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
708 SDL_PixelFormat *dstfmt = info->dst;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
709 unsigned sA = srcfmt->alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
710 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
711 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
712 Uint32 ckey = info->src->colorkey;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
713 vector unsigned char mergePermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
714 vector unsigned char vsrcPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
715 vector unsigned char vdstPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
716 vector unsigned char vsdstPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
717 vector unsigned char valpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
718 vector unsigned char valphamask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
719 vector unsigned char vbits;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
720 vector unsigned char v0;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
721 vector unsigned short v1;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
722 vector unsigned short v8;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
723 vector unsigned int vckey;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
724 vector unsigned int vrgbmask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
725
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
726 mergePermute = VEC_MERGE_PERMUTE();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
727 v0 = vec_splat_u8(0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
728 v1 = vec_splat_u16(1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
729 v8 = vec_splat_u16(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
730
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
731 /* set the alpha to 255 on the destination surf */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
732 valphamask = VEC_ALPHA_MASK();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
733
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
734 vsrcPermute = calc_swizzle32(srcfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
735 vdstPermute = calc_swizzle32(NULL, dstfmt);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
736 vsdstPermute = calc_swizzle32(dstfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
737
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
738 /* set a vector full of alpha and 255-alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
739 ((unsigned char *)&valpha)[0] = alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
740 valpha = vec_splat(valpha, 0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
741 vbits = (vector unsigned char)vec_splat_s8(-1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
742
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
743 ckey &= rgbmask;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
744 ((unsigned int *)(char*)&vckey)[0] = ckey;
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
745 vckey = vec_splat(vckey, 0);
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
746 ((unsigned int *)(char*)&vrgbmask)[0] = rgbmask;
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
747 vrgbmask = vec_splat(vrgbmask, 0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
748
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
749 while(height--) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
750 int width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
751 #define ONE_PIXEL_BLEND(condition, widthvar) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
752 while (condition) { \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
753 Uint32 Pixel; \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
754 unsigned sR, sG, sB, dR, dG, dB; \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
755 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
756 if(sA && Pixel != ckey) { \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
757 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
758 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
759 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
760 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
761 } \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
762 dstp++; \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
763 srcp++; \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
764 widthvar--; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
765 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
766 ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
767 if (width > 0) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
768 int extrawidth = (width % 4);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
769 vector unsigned char valigner = VEC_ALIGNER(srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
770 vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
771 width -= extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
772 while (width) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
773 vector unsigned char vsel;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
774 vector unsigned char voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
775 vector unsigned char vd;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
776 vector unsigned char vd_orig;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
777
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
778 /* s = *srcp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
779 voverflow = (vector unsigned char)vec_ld(15, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
780 vs = vec_perm(vs, voverflow, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
781
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
782 /* vsel is set for items that match the key */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
783 vsel = (vector unsigned char)vec_and((vector unsigned int)vs, vrgbmask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
784 vsel = (vector unsigned char)vec_cmpeq((vector unsigned int)vsel, vckey);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
785
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
786 /* permute to source format */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
787 vs = vec_perm(vs, valpha, vsrcPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
788
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
789 /* d = *dstp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
790 vd = (vector unsigned char)vec_ld(0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
791 vd_orig = vd = vec_perm(vd, v0, vsdstPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
792
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
793 VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
794
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
795 /* set the alpha channel to full on */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
796 vd = vec_or(vd, valphamask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
797
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
798 /* mask out color key */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
799 vd = vec_sel(vd, vd_orig, vsel);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
800
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
801 /* permute to dest format */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
802 vd = vec_perm(vd, vbits, vdstPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
803
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
804 /* *dstp = res */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
805 vec_st((vector unsigned int)vd, 0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
806
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
807 srcp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
808 dstp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
809 width -= 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
810 vs = voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
811 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
812 ONE_PIXEL_BLEND((extrawidth), extrawidth);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
813 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
814 #undef ONE_PIXEL_BLEND
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
815
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
816 srcp += srcskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
817 dstp += dstskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
818 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
819 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
820
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
821
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
822 static void Blit32to32PixelAlphaAltivec(SDL_BlitInfo *info)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
823 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
824 int width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
825 int height = info->d_height;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
826 Uint32 *srcp = (Uint32 *)info->s_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
827 int srcskip = info->s_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
828 Uint32 *dstp = (Uint32 *)info->d_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
829 int dstskip = info->d_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
830 SDL_PixelFormat *srcfmt = info->src;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
831 SDL_PixelFormat *dstfmt = info->dst;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
832 vector unsigned char mergePermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
833 vector unsigned char valphaPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
834 vector unsigned char vsrcPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
835 vector unsigned char vdstPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
836 vector unsigned char vsdstPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
837 vector unsigned char valphamask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
838 vector unsigned char vpixelmask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
839 vector unsigned char v0;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
840 vector unsigned short v1;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
841 vector unsigned short v8;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
842
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
843 v0 = vec_splat_u8(0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
844 v1 = vec_splat_u16(1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
845 v8 = vec_splat_u16(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
846 mergePermute = VEC_MERGE_PERMUTE();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
847 valphamask = VEC_ALPHA_MASK();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
848 valphaPermute = vec_and(vec_lvsl(0, (int *)NULL), vec_splat_u8(0xC));
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
849 vpixelmask = vec_nor(valphamask, v0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
850 vsrcPermute = calc_swizzle32(srcfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
851 vdstPermute = calc_swizzle32(NULL, dstfmt);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
852 vsdstPermute = calc_swizzle32(dstfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
853
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
854 while ( height-- ) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
855 width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
856 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
857 Uint32 Pixel; \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
858 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
859 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
860 if(sA) { \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
861 DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
862 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
863 ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
864 } \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
865 ++srcp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
866 ++dstp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
867 widthvar--; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
868 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
869 ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
870 if (width > 0) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
871 // vsrcPermute
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
872 // vdstPermute
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
873 int extrawidth = (width % 4);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
874 vector unsigned char valigner = VEC_ALIGNER(srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
875 vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
876 width -= extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
877 while (width) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
878 vector unsigned char voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
879 vector unsigned char vd;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
880 vector unsigned char valpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
881 vector unsigned char vdstalpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
882 /* s = *srcp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
883 voverflow = (vector unsigned char)vec_ld(15, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
884 vs = vec_perm(vs, voverflow, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
885 vs = vec_perm(vs, v0, vsrcPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
886
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
887 valpha = vec_perm(vs, v0, valphaPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
888
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
889 /* d = *dstp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
890 vd = (vector unsigned char)vec_ld(0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
891 vd = vec_perm(vd, v0, vsdstPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
892 vdstalpha = vec_and(vd, valphamask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
893
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
894 VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
895
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
896 /* set the alpha to the dest alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
897 vd = vec_and(vd, vpixelmask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
898 vd = vec_or(vd, vdstalpha);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
899 vd = vec_perm(vd, v0, vdstPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
900
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
901 /* *dstp = res */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
902 vec_st((vector unsigned int)vd, 0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
903
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
904 srcp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
905 dstp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
906 width -= 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
907 vs = voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
908
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
909 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
910 ONE_PIXEL_BLEND((extrawidth), extrawidth);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
911 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
912 srcp += srcskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
913 dstp += dstskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
914 #undef ONE_PIXEL_BLEND
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
915 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
916 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
917
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
918 /* fast ARGB888->(A)RGB888 blending with pixel alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
919 static void BlitRGBtoRGBPixelAlphaAltivec(SDL_BlitInfo *info)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
920 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
921 int width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
922 int height = info->d_height;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
923 Uint32 *srcp = (Uint32 *)info->s_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
924 int srcskip = info->s_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
925 Uint32 *dstp = (Uint32 *)info->d_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
926 int dstskip = info->d_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
927 vector unsigned char mergePermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
928 vector unsigned char valphaPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
929 vector unsigned char valphamask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
930 vector unsigned char vpixelmask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
931 vector unsigned char v0;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
932 vector unsigned short v1;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
933 vector unsigned short v8;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
934 v0 = vec_splat_u8(0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
935 v1 = vec_splat_u16(1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
936 v8 = vec_splat_u16(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
937 mergePermute = VEC_MERGE_PERMUTE();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
938 valphamask = VEC_ALPHA_MASK();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
939 valphaPermute = vec_and(vec_lvsl(0, (int *)NULL), vec_splat_u8(0xC));
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
940
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
941
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
942 vpixelmask = vec_nor(valphamask, v0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
943 while(height--) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
944 width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
945 #define ONE_PIXEL_BLEND(condition, widthvar) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
946 while ((condition)) { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
947 Uint32 dalpha; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
948 Uint32 d; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
949 Uint32 s1; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
950 Uint32 d1; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
951 Uint32 s = *srcp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
952 Uint32 alpha = s >> 24; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
953 if(alpha) { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
954 if(alpha == SDL_ALPHA_OPAQUE) { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
955 *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
956 } else { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
957 d = *dstp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
958 dalpha = d & 0xff000000; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
959 s1 = s & 0xff00ff; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
960 d1 = d & 0xff00ff; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
961 d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
962 s &= 0xff00; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
963 d &= 0xff00; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
964 d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
965 *dstp = d1 | d | dalpha; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
966 } \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
967 } \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
968 ++srcp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
969 ++dstp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
970 widthvar--; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
971 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
972 ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
973 if (width > 0) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
974 int extrawidth = (width % 4);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
975 vector unsigned char valigner = VEC_ALIGNER(srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
976 vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
977 width -= extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
978 while (width) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
979 vector unsigned char voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
980 vector unsigned char vd;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
981 vector unsigned char valpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
982 vector unsigned char vdstalpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
983 /* s = *srcp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
984 voverflow = (vector unsigned char)vec_ld(15, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
985 vs = vec_perm(vs, voverflow, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
986
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
987 valpha = vec_perm(vs, v0, valphaPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
988
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
989 /* d = *dstp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
990 vd = (vector unsigned char)vec_ld(0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
991 vdstalpha = vec_and(vd, valphamask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
992
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
993 VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
994
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
995 /* set the alpha to the dest alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
996 vd = vec_and(vd, vpixelmask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
997 vd = vec_or(vd, vdstalpha);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
998
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
999 /* *dstp = res */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1000 vec_st((vector unsigned int)vd, 0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1001
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1002 srcp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1003 dstp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1004 width -= 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1005 vs = voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1006 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1007 ONE_PIXEL_BLEND((extrawidth), extrawidth);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1008 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1009 srcp += srcskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1010 dstp += dstskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1011 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1012 #undef ONE_PIXEL_BLEND
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1013 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1014
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1015 static void Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo *info)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1016 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1017 /* XXX : 6 */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1018 unsigned alpha = info->src->alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1019 int height = info->d_height;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1020 Uint32 *srcp = (Uint32 *)info->s_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1021 int srcskip = info->s_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1022 Uint32 *dstp = (Uint32 *)info->d_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1023 int dstskip = info->d_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1024 SDL_PixelFormat *srcfmt = info->src;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1025 SDL_PixelFormat *dstfmt = info->dst;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1026 unsigned sA = srcfmt->alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1027 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1028 vector unsigned char mergePermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1029 vector unsigned char vsrcPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1030 vector unsigned char vdstPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1031 vector unsigned char vsdstPermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1032 vector unsigned char valpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1033 vector unsigned char valphamask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1034 vector unsigned char vbits;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1035 vector unsigned short v1;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1036 vector unsigned short v8;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1037
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1038 mergePermute = VEC_MERGE_PERMUTE();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1039 v1 = vec_splat_u16(1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1040 v8 = vec_splat_u16(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1041
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1042 /* set the alpha to 255 on the destination surf */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1043 valphamask = VEC_ALPHA_MASK();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1044
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1045 vsrcPermute = calc_swizzle32(srcfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1046 vdstPermute = calc_swizzle32(NULL, dstfmt);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1047 vsdstPermute = calc_swizzle32(dstfmt, NULL);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1048
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1049 /* set a vector full of alpha and 255-alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1050 ((unsigned char *)&valpha)[0] = alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1051 valpha = vec_splat(valpha, 0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1052 vbits = (vector unsigned char)vec_splat_s8(-1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1053
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1054 while(height--) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1055 int width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1056 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
1057 Uint32 Pixel; \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1058 unsigned sR, sG, sB, dR, dG, dB; \
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
1059 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
1060 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1061 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1062 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1063 ++srcp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1064 ++dstp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1065 widthvar--; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1066 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1067 ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1068 if (width > 0) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1069 int extrawidth = (width % 4);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1070 vector unsigned char valigner = vec_lvsl(0, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1071 vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1072 width -= extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1073 while (width) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1074 vector unsigned char voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1075 vector unsigned char vd;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1076
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1077 /* s = *srcp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1078 voverflow = (vector unsigned char)vec_ld(15, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1079 vs = vec_perm(vs, voverflow, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1080 vs = vec_perm(vs, valpha, vsrcPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1081
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1082 /* d = *dstp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1083 vd = (vector unsigned char)vec_ld(0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1084 vd = vec_perm(vd, vd, vsdstPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1085
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1086 VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1087
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1088 /* set the alpha channel to full on */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1089 vd = vec_or(vd, valphamask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1090 vd = vec_perm(vd, vbits, vdstPermute);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1091
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1092 /* *dstp = res */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1093 vec_st((vector unsigned int)vd, 0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1094
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1095 srcp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1096 dstp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1097 width -= 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1098 vs = voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1099 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1100 ONE_PIXEL_BLEND((extrawidth), extrawidth);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1101 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1102 #undef ONE_PIXEL_BLEND
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1103
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1104 srcp += srcskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1105 dstp += dstskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1106 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1107
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1108 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1109
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1110
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1111 /* fast RGB888->(A)RGB888 blending */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1112 static void BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo *info)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1113 {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1114 unsigned alpha = info->src->alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1115 int height = info->d_height;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1116 Uint32 *srcp = (Uint32 *)info->s_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1117 int srcskip = info->s_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1118 Uint32 *dstp = (Uint32 *)info->d_pixels;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1119 int dstskip = info->d_skip >> 2;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1120 vector unsigned char mergePermute;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1121 vector unsigned char valpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1122 vector unsigned char valphamask;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1123 vector unsigned short v1;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1124 vector unsigned short v8;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1125
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1126 mergePermute = VEC_MERGE_PERMUTE();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1127 v1 = vec_splat_u16(1);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1128 v8 = vec_splat_u16(8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1129
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1130 /* set the alpha to 255 on the destination surf */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1131 valphamask = VEC_ALPHA_MASK();
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1132
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1133 /* set a vector full of alpha and 255-alpha */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1134 ((unsigned char *)&valpha)[0] = alpha;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1135 valpha = vec_splat(valpha, 0);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1136
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1137 while(height--) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1138 int width = info->d_width;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1139 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1140 Uint32 s = *srcp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1141 Uint32 d = *dstp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1142 Uint32 s1 = s & 0xff00ff; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1143 Uint32 d1 = d & 0xff00ff; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1144 d1 = (d1 + ((s1 - d1) * alpha >> 8)) \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1145 & 0xff00ff; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1146 s &= 0xff00; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1147 d &= 0xff00; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1148 d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1149 *dstp = d1 | d | 0xff000000; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1150 ++srcp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1151 ++dstp; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1152 widthvar--; \
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1153 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1154 ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1155 if (width > 0) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1156 int extrawidth = (width % 4);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1157 vector unsigned char valigner = VEC_ALIGNER(srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1158 vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1159 width -= extrawidth;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1160 while (width) {
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1161 vector unsigned char voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1162 vector unsigned char vd;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1163
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1164 /* s = *srcp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1165 voverflow = (vector unsigned char)vec_ld(15, srcp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1166 vs = vec_perm(vs, voverflow, valigner);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1167
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1168 /* d = *dstp */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1169 vd = (vector unsigned char)vec_ld(0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1170
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1171 VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1172
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1173 /* set the alpha channel to full on */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1174 vd = vec_or(vd, valphamask);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1175
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1176 /* *dstp = res */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1177 vec_st((vector unsigned int)vd, 0, dstp);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1178
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1179 srcp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1180 dstp += 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1181 width -= 4;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1182 vs = voverflow;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1183 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1184 ONE_PIXEL_BLEND((extrawidth), extrawidth);
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1185 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1186 #undef ONE_PIXEL_BLEND
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1187
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1188 srcp += srcskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1189 dstp += dstskip;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1190 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1191 }
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1192 #endif /* USE_ALTIVEC_BLITTERS */
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
1193
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1194 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1195 static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1196 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1197 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1198 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1199 Uint32 *srcp = (Uint32 *)info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1200 int srcskip = info->s_skip >> 2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1201 Uint32 *dstp = (Uint32 *)info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1202 int dstskip = info->d_skip >> 2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1203
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1204 while(height--) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1205 DUFFS_LOOP4({
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1206 Uint32 s = *srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1207 Uint32 d = *dstp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1208 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1209 + (s & d & 0x00010101)) | 0xff000000;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1210 }, width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1211 srcp += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1212 dstp += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1213 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1214 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1215
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1216 /* fast RGB888->(A)RGB888 blending with surface alpha */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1217 static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1218 {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1219 unsigned alpha = info->src->alpha;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1220 if(alpha == 128) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1221 BlitRGBtoRGBSurfaceAlpha128(info);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1222 } else {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1223 int width = info->d_width;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1224 int height = info->d_height;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1225 Uint32 *srcp = (Uint32 *)info->s_pixels;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1226 int srcskip = info->s_skip >> 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1227 Uint32 *dstp = (Uint32 *)info->d_pixels;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1228 int dstskip = info->d_skip >> 2;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1229 Uint32 s;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1230 Uint32 d;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1231 Uint32 s1;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1232 Uint32 d1;
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1233
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1234 while(height--) {
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1235 DUFFS_LOOP_DOUBLE2({
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1236 /* One Pixel Blend */
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1237 s = *srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1238 d = *dstp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1239 s1 = s & 0xff00ff;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1240 d1 = d & 0xff00ff;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1241 d1 = (d1 + ((s1 - d1) * alpha >> 8))
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1242 & 0xff00ff;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1243 s &= 0xff00;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1244 d &= 0xff00;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1245 d = (d + ((s - d) * alpha >> 8)) & 0xff00;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1246 *dstp = d1 | d | 0xff000000;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1247 ++srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1248 ++dstp;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1249 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1250 /* Two Pixels Blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1251 s = *srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1252 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1253 s1 = s & 0xff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1254 d1 = d & 0xff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1255 d1 += (s1 - d1) * alpha >> 8;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1256 d1 &= 0xff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1257
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1258 s = ((s & 0xff00) >> 8) |
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1259 ((srcp[1] & 0xff00) << 8);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1260 d = ((d & 0xff00) >> 8) |
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1261 ((dstp[1] & 0xff00) << 8);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1262 d += (s - d) * alpha >> 8;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1263 d &= 0x00ff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1264
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1265 *dstp++ = d1 | ((d << 8) & 0xff00) | 0xff000000;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1266 ++srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1267
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1268 s1 = *srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1269 d1 = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1270 s1 &= 0xff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1271 d1 &= 0xff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1272 d1 += (s1 - d1) * alpha >> 8;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1273 d1 &= 0xff00ff;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1274
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1275 *dstp = d1 | ((d >> 8) & 0xff00) | 0xff000000;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1276 ++srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1277 ++dstp;
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1278 }, width);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1279 srcp += srcskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1280 dstp += dstskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1281 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1282 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1283 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1284
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1285 /* fast ARGB888->(A)RGB888 blending with pixel alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1286 static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1287 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1288 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1289 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1290 Uint32 *srcp = (Uint32 *)info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1291 int srcskip = info->s_skip >> 2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1292 Uint32 *dstp = (Uint32 *)info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1293 int dstskip = info->d_skip >> 2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1294
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1295 while(height--) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1296 DUFFS_LOOP4({
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1297 Uint32 dalpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1298 Uint32 d;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1299 Uint32 s1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1300 Uint32 d1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1301 Uint32 s = *srcp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1302 Uint32 alpha = s >> 24;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1303 /* FIXME: Here we special-case opaque alpha since the
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1304 compositioning used (>>8 instead of /255) doesn't handle
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1305 it correctly. Also special-case alpha=0 for speed?
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1306 Benchmark this! */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1307 if(alpha) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1308 if(alpha == SDL_ALPHA_OPAQUE) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1309 *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000);
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1310 } else {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1311 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1312 * take out the middle component (green), and process
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1313 * the other two in parallel. One multiply less.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1314 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1315 d = *dstp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1316 dalpha = d & 0xff000000;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1317 s1 = s & 0xff00ff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1318 d1 = d & 0xff00ff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1319 d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1320 s &= 0xff00;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1321 d &= 0xff00;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1322 d = (d + ((s - d) * alpha >> 8)) & 0xff00;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1323 *dstp = d1 | d | dalpha;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1324 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1325 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1326 ++srcp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1327 ++dstp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1328 }, width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1329 srcp += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1330 dstp += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1331 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1332 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1333
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
1334 #ifdef MMX_ASMBLIT
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1335 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1336 inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1337 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1338 int width = info->d_width;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1339 int height = info->d_height;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1340 Uint32 *srcp = (Uint32 *)info->s_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1341 int srcskip = info->s_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1342 Uint32 *dstp = (Uint32 *)info->d_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1343 int dstskip = info->d_skip >> 2;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1344
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1345 Uint32 s;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1346 Uint32 alpha;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1347
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1348 __asm__ (
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1349 /* make mm6 all zeros. */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1350 "pxor %%mm6, %%mm6\n"
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1351
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1352 /* Make a mask to preserve the alpha. */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1353 "pcmpeqb %%mm7, %%mm7\n\t" /* mm7(s) = FF FF FF FF | FF FF FF FF */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1354 "psrlq $16, %%mm7\n\t" /* mm7(s) = 00 00 FF FF | FF FF FF FF */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1355
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1356 : );
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1357
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1358 while(height--) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1359
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1360 DUFFS_LOOP4({
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1361
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1362 __asm__ (
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1363 "prefetch 64(%0)\n"
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1364 "prefetch 64(%1)\n"
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1365 : : "r" (srcp), "r" (dstp) );
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1366
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1367 s = *srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1368 alpha = s >> 24;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1369 /* FIXME: Here we special-case opaque alpha since the
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1370 compositioning used (>>8 instead of /255) doesn't handle
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1371 it correctly. Also special-case alpha=0 for speed?
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1372 Benchmark this! */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1373
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1374 if(alpha == SDL_ALPHA_OPAQUE) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1375 *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1376 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1377
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1378 else {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1379 __asm__ (
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1380 /* load in the source, and dst. */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1381 "movd (%0), %%mm0\n" /* mm0(s) = 0 0 0 0 | As Rs Gs Bs */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1382 "movd (%1), %%mm1\n" /* mm1(d) = 0 0 0 0 | Ad Rd Gd Bd */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1383
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1384 /* Move the src alpha into mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1385
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1386 /* if supporting pshufw */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1387 /*"pshufw $0x55, %%mm0, %%mm2\n" */ /* mm2 = 0 As 0 As | 0 As 0 As */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1388 /*"psrlw $8, %%mm2\n" */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1389
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1390 /* else: */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1391 "movq %%mm0, %%mm2\n"
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1392 "psrld $24, %%mm2\n" /* mm2 = 0 0 0 0 | 0 0 0 As */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1393 "punpcklwd %%mm2, %%mm2\n" /* mm2 = 0 0 0 0 | 0 As 0 As */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1394 "punpckldq %%mm2, %%mm2\n" /* mm2 = 0 As 0 As | 0 As 0 As */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1395
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1396 /* move the colors into words. */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1397 "punpcklbw %%mm6, %%mm0\n" /* mm0 = 0 As 0 Rs | 0 Gs 0 Bs */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1398 "punpcklbw %%mm6, %%mm1\n" /* mm0 = 0 Ad 0 Rd | 0 Gd 0 Bd */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1399
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1400 /* src - dst */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1401 "psubw %%mm1, %%mm0\n" /* mm0 = As-Ad Rs-Rd | Gs-Gd Bs-Bd */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1402
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1403 /* A * (src-dst) */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1404 "pmullw %%mm2, %%mm0\n" /* mm0 = As*As-d As*Rs-d | As*Gs-d As*Bs-d */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1405 "pand %%mm7, %%mm0\n" /* to preserve dest alpha */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1406 "psrlw $8, %%mm0\n" /* mm0 = Ac>>8 Rc>>8 | Gc>>8 Bc>>8 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1407 "paddb %%mm1, %%mm0\n" /* mm0 = Ac+Ad Rc+Rd | Gc+Gd Bc+Bd */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1408
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1409 "packuswb %%mm0, %%mm0\n" /* mm0 = | Ac Rc Gc Bc */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1410
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1411 "movd %%mm0, (%1)\n" /* result in mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1412
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1413 : : "r" (srcp), "r" (dstp) );
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1414
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1415 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1416 ++srcp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1417 ++dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1418 }, width);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1419 srcp += srcskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1420 dstp += dstskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1421 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1422
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1423 __asm__ (
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1424 "emms\n"
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1425 : );
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1426 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1427 #endif
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1428
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1429 /* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1430
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1431 /* blend a single 16 bit pixel at 50% */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1432 #define BLEND16_50(d, s, mask) \
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1433 ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff)))
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1434
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1435 /* blend two 16 bit pixels at 50% */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1436 #define BLEND2x16_50(d, s, mask) \
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1437 (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1438 + (s & d & (~(mask | mask << 16))))
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1439
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1440 static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1441 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1442 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1443 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1444 Uint16 *srcp = (Uint16 *)info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1445 int srcskip = info->s_skip >> 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1446 Uint16 *dstp = (Uint16 *)info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1447 int dstskip = info->d_skip >> 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1448
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1449 while(height--) {
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1450 if(((unsigned long)srcp ^ (unsigned long)dstp) & 2) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1451 /*
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1452 * Source and destination not aligned, pipeline it.
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1453 * This is mostly a win for big blits but no loss for
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1454 * small ones
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1455 */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1456 Uint32 prev_sw;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1457 int w = width;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1458
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1459 /* handle odd destination */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1460 if((unsigned long)dstp & 2) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1461 Uint16 d = *dstp, s = *srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1462 *dstp = BLEND16_50(d, s, mask);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1463 dstp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1464 srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1465 w--;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1466 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1467 srcp++; /* srcp is now 32-bit aligned */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1468
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1469 /* bootstrap pipeline with first halfword */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1470 prev_sw = ((Uint32 *)srcp)[-1];
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1471
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1472 while(w > 1) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1473 Uint32 sw, dw, s;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1474 sw = *(Uint32 *)srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1475 dw = *(Uint32 *)dstp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1476 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1477 s = (prev_sw << 16) + (sw >> 16);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1478 else
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1479 s = (prev_sw >> 16) + (sw << 16);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1480 prev_sw = sw;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1481 *(Uint32 *)dstp = BLEND2x16_50(dw, s, mask);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1482 dstp += 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1483 srcp += 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1484 w -= 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1485 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1486
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1487 /* final pixel if any */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1488 if(w) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1489 Uint16 d = *dstp, s;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1490 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1491 s = prev_sw;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1492 else
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1493 s = prev_sw >> 16;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1494 *dstp = BLEND16_50(d, s, mask);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1495 srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1496 dstp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1497 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1498 srcp += srcskip - 1;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1499 dstp += dstskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1500 } else {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1501 /* source and destination are aligned */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1502 int w = width;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1503
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1504 /* first odd pixel? */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1505 if((unsigned long)srcp & 2) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1506 Uint16 d = *dstp, s = *srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1507 *dstp = BLEND16_50(d, s, mask);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1508 srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1509 dstp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1510 w--;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1511 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1512 /* srcp and dstp are now 32-bit aligned */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1513
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1514 while(w > 1) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1515 Uint32 sw = *(Uint32 *)srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1516 Uint32 dw = *(Uint32 *)dstp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1517 *(Uint32 *)dstp = BLEND2x16_50(dw, sw, mask);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1518 srcp += 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1519 dstp += 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1520 w -= 2;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1521 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1522
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1523 /* last odd pixel? */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1524 if(w) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1525 Uint16 d = *dstp, s = *srcp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1526 *dstp = BLEND16_50(d, s, mask);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1527 srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1528 dstp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1529 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1530 srcp += srcskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1531 dstp += dstskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1532 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1533 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1534 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1535
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
1536 #ifdef MMX_ASMBLIT
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1537 /* fast RGB565->RGB565 blending with surface alpha */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1538 static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1539 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1540 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1541 if(alpha == 128) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1542 Blit16to16SurfaceAlpha128(info, 0xf7de);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1543 } else {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1544 int width = info->d_width;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1545 int height = info->d_height;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1546 Uint16 *srcp = (Uint16 *)info->s_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1547 int srcskip = info->s_skip >> 1;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1548 Uint16 *dstp = (Uint16 *)info->d_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1549 int dstskip = info->d_skip >> 1;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1550 Uint32 s, d;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1551 Uint8 load[8];
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1552
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1553 alpha &= ~(1+2+4); /* cut alpha to get the exact same behaviour */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1554 *(Uint64 *)load = alpha;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1555 alpha >>= 3; /* downscale alpha to 5 bits */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1556
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1557 movq_m2r(*load, mm0); /* alpha(0000000A) -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1558 punpcklwd_r2r(mm0, mm0); /* 00000A0A -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1559 punpcklwd_r2r(mm0, mm0); /* 0A0A0A0A -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1560
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1561 /* Setup the 565 color channel masks */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
1562 *(Uint64 *)load = 0xF800F800F800F800ULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1563 movq_m2r(*load, mm1); /* MASKRED -> mm1 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
1564 *(Uint64 *)load = 0x07E007E007E007E0ULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1565 movq_m2r(*load, mm4); /* MASKGREEN -> mm4 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
1566 *(Uint64 *)load = 0x001F001F001F001FULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1567 movq_m2r(*load, mm7); /* MASKBLUE -> mm7 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1568 while(height--) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1569 DUFFS_LOOP_QUATRO2(
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1570 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1571 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1572 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1573 /*
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1574 * shift out the middle component (green) to
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1575 * the high 16 bits, and process all three RGB
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1576 * components at the same time.
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1577 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1578 s = (s | s << 16) & 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1579 d = (d | d << 16) & 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1580 d += (s - d) * alpha >> 5;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1581 d &= 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1582 *dstp++ = d | d >> 16;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1583 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1584 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1585 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1586 /*
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1587 * shift out the middle component (green) to
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1588 * the high 16 bits, and process all three RGB
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1589 * components at the same time.
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1590 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1591 s = (s | s << 16) & 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1592 d = (d | d << 16) & 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1593 d += (s - d) * alpha >> 5;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1594 d &= 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1595 *dstp++ = d | d >> 16;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1596 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1597 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1598 /*
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1599 * shift out the middle component (green) to
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1600 * the high 16 bits, and process all three RGB
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1601 * components at the same time.
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1602 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1603 s = (s | s << 16) & 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1604 d = (d | d << 16) & 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1605 d += (s - d) * alpha >> 5;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1606 d &= 0x07e0f81f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1607 *dstp++ = d | d >> 16;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1608 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1609 movq_m2r((*dstp), mm3);/* 4 dst pixels -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1610 movq_m2r((*srcp), mm2);/* 4 src pixels -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1611
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1612 /* RED */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1613 movq_r2r(mm2, mm5); /* src -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1614 pand_r2r(mm1 , mm5); /* src & MASKRED -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1615 psrlq_i2r(11, mm5); /* mm5 >> 11 -> mm5 [000r 000r 000r 000r] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1616
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1617 movq_r2r(mm3, mm6); /* dst -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1618 pand_r2r(mm1 , mm6); /* dst & MASKRED -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1619 psrlq_i2r(11, mm6); /* mm6 >> 11 -> mm6 [000r 000r 000r 000r] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1620
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1621 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1622 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1623 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1624 psrlw_i2r(8, mm5); /* mm5 >> 8 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1625 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1626 psllq_i2r(11, mm6); /* mm6 << 11 -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1627 pand_r2r(mm1, mm6); /* mm6 & MASKRED -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1628
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1629 movq_r2r(mm4, mm5); /* MASKGREEN -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1630 por_r2r(mm7, mm5); /* MASKBLUE | mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1631 pand_r2r(mm5, mm3); /* mm3 & mm5(!MASKRED) -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1632 por_r2r(mm6, mm3); /* save new reds in dsts */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1633
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1634 /* green */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1635 movq_r2r(mm2, mm5); /* src -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1636 pand_r2r(mm4 , mm5); /* src & MASKGREEN -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1637 psrlq_i2r(5, mm5); /* mm5 >> 5 -> mm5 [000g 000g 000g 000g] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1638
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1639 movq_r2r(mm3, mm6); /* dst -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1640 pand_r2r(mm4 , mm6); /* dst & MASKGREEN -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1641 psrlq_i2r(5, mm6); /* mm6 >> 5 -> mm6 [000g 000g 000g 000g] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1642
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1643 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1644 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1645 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1646 psrlw_i2r(8, mm5); /* mm5 >> 8 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1647 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1648 psllq_i2r(5, mm6); /* mm6 << 5 -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1649 pand_r2r(mm4, mm6); /* mm6 & MASKGREEN -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1650
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1651 movq_r2r(mm1, mm5); /* MASKRED -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1652 por_r2r(mm7, mm5); /* MASKBLUE | mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1653 pand_r2r(mm5, mm3); /* mm3 & mm5(!MASKGREEN) -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1654 por_r2r(mm6, mm3); /* save new greens in dsts */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1655
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1656 /* blue */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1657 movq_r2r(mm2, mm5); /* src -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1658 pand_r2r(mm7 , mm5); /* src & MASKRED -> mm5[000b 000b 000b 000b] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1659
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1660 movq_r2r(mm3, mm6); /* dst -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1661 pand_r2r(mm7 , mm6); /* dst & MASKBLUE -> mm6[000b 000b 000b 000b] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1662
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1663 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1664 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1665 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1666 psrlw_i2r(8, mm5); /* mm5 >> 8 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1667 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1668 pand_r2r(mm7, mm6); /* mm6 & MASKBLUE -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1669
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1670 movq_r2r(mm1, mm5); /* MASKRED -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1671 por_r2r(mm4, mm5); /* MASKGREEN | mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1672 pand_r2r(mm5, mm3); /* mm3 & mm5(!MASKBLUE) -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1673 por_r2r(mm6, mm3); /* save new blues in dsts */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1674
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1675 movq_r2m(mm3, *dstp);/* mm3 -> 4 dst pixels */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1676
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1677 srcp += 4;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1678 dstp += 4;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1679 }, width);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1680 srcp += srcskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1681 dstp += dstskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1682 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1683 emms();
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1684 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1685 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1686
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1687 /* fast RGB555->RGB555 blending with surface alpha */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1688 static void Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info)
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1689 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1690 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1691 if(alpha == 128) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1692 Blit16to16SurfaceAlpha128(info, 0xfbde);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1693 } else {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1694 int width = info->d_width;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1695 int height = info->d_height;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1696 Uint16 *srcp = (Uint16 *)info->s_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1697 int srcskip = info->s_skip >> 1;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1698 Uint16 *dstp = (Uint16 *)info->d_pixels;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1699 int dstskip = info->d_skip >> 1;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1700 Uint32 s, d;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1701 Uint8 load[8];
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1702
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1703 alpha &= ~(1+2+4); /* cut alpha to get the exact same behaviour */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1704 *(Uint64 *)load = alpha;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1705 alpha >>= 3; /* downscale alpha to 5 bits */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1706
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1707 movq_m2r(*load, mm0); /* alpha(0000000A) -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1708 punpcklwd_r2r(mm0, mm0); /* 00000A0A -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1709 punpcklwd_r2r(mm0, mm0); /* 0A0A0A0A -> mm0 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1710
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1711 /* Setup the 555 color channel masks */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
1712 *(Uint64 *)load = 0x7C007C007C007C00ULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1713 movq_m2r(*load, mm1); /* MASKRED -> mm1 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
1714 *(Uint64 *)load = 0x03E003E003E003E0ULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1715 movq_m2r(*load, mm4); /* MASKGREEN -> mm4 */
720
f90d80d68071 N Sep 17 8791 Sam Lantinga Re: tks source released
Sam Lantinga <slouken@libsdl.org>
parents: 689
diff changeset
1716 *(Uint64 *)load = 0x001F001F001F001FULL;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1717 movq_m2r(*load, mm7); /* MASKBLUE -> mm7 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1718 while(height--) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1719 DUFFS_LOOP_QUATRO2(
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1720 {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1721 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1722 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1723 /*
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1724 * shift out the middle component (green) to
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1725 * the high 16 bits, and process all three RGB
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1726 * components at the same time.
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1727 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1728 s = (s | s << 16) & 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1729 d = (d | d << 16) & 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1730 d += (s - d) * alpha >> 5;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1731 d &= 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1732 *dstp++ = d | d >> 16;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1733 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1734 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1735 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1736 /*
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1737 * shift out the middle component (green) to
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1738 * the high 16 bits, and process all three RGB
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1739 * components at the same time.
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1740 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1741 s = (s | s << 16) & 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1742 d = (d | d << 16) & 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1743 d += (s - d) * alpha >> 5;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1744 d &= 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1745 *dstp++ = d | d >> 16;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1746 s = *srcp++;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1747 d = *dstp;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1748 /*
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1749 * shift out the middle component (green) to
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1750 * the high 16 bits, and process all three RGB
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1751 * components at the same time.
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1752 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1753 s = (s | s << 16) & 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1754 d = (d | d << 16) & 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1755 d += (s - d) * alpha >> 5;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1756 d &= 0x03e07c1f;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1757 *dstp++ = d | d >> 16;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1758 },{
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1759 movq_m2r((*dstp), mm3);/* 4 dst pixels -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1760 movq_m2r((*srcp), mm2);/* 4 src pixels -> mm2 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1761
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1762 /* RED */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1763 movq_r2r(mm2, mm5); /* src -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1764 pand_r2r(mm1 , mm5); /* src & MASKRED -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1765 psrlq_i2r(10, mm5); /* mm5 >> 10 -> mm5 [000r 000r 000r 000r] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1766
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1767 movq_r2r(mm3, mm6); /* dst -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1768 pand_r2r(mm1 , mm6); /* dst & MASKRED -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1769 psrlq_i2r(10, mm6); /* mm6 >> 10 -> mm6 [000r 000r 000r 000r] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1770
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1771 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1772 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1773 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1774 psrlw_i2r(8, mm5); /* mm5 >> 8 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1775 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1776 psllq_i2r(10, mm6); /* mm6 << 10 -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1777 pand_r2r(mm1, mm6); /* mm6 & MASKRED -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1778
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1779 movq_r2r(mm4, mm5); /* MASKGREEN -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1780 por_r2r(mm7, mm5); /* MASKBLUE | mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1781 pand_r2r(mm5, mm3); /* mm3 & mm5(!MASKRED) -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1782 por_r2r(mm6, mm3); /* save new reds in dsts */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1783
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1784 /* green */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1785 movq_r2r(mm2, mm5); /* src -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1786 pand_r2r(mm4 , mm5); /* src & MASKGREEN -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1787 psrlq_i2r(5, mm5); /* mm5 >> 5 -> mm5 [000g 000g 000g 000g] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1788
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1789 movq_r2r(mm3, mm6); /* dst -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1790 pand_r2r(mm4 , mm6); /* dst & MASKGREEN -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1791 psrlq_i2r(5, mm6); /* mm6 >> 5 -> mm6 [000g 000g 000g 000g] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1792
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1793 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1794 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1795 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1796 psrlw_i2r(8, mm5); /* mm5 >> 8 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1797 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1798 psllq_i2r(5, mm6); /* mm6 << 5 -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1799 pand_r2r(mm4, mm6); /* mm6 & MASKGREEN -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1800
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1801 movq_r2r(mm1, mm5); /* MASKRED -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1802 por_r2r(mm7, mm5); /* MASKBLUE | mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1803 pand_r2r(mm5, mm3); /* mm3 & mm5(!MASKGREEN) -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1804 por_r2r(mm6, mm3); /* save new greens in dsts */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1805
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1806 /* blue */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1807 movq_r2r(mm2, mm5); /* src -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1808 pand_r2r(mm7 , mm5); /* src & MASKRED -> mm5[000b 000b 000b 000b] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1809
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1810 movq_r2r(mm3, mm6); /* dst -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1811 pand_r2r(mm7 , mm6); /* dst & MASKBLUE -> mm6[000b 000b 000b 000b] */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1812
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1813 /* blend */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1814 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1815 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1816 psrlw_i2r(8, mm5); /* mm5 >> 8 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1817 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1818 pand_r2r(mm7, mm6); /* mm6 & MASKBLUE -> mm6 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1819
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1820 movq_r2r(mm1, mm5); /* MASKRED -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1821 por_r2r(mm4, mm5); /* MASKGREEN | mm5 -> mm5 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1822 pand_r2r(mm5, mm3); /* mm3 & mm5(!MASKBLUE) -> mm3 */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1823 por_r2r(mm6, mm3); /* save new blues in dsts */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1824
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1825 movq_r2m(mm3, *dstp);/* mm3 -> 4 dst pixels */
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1826
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1827 srcp += 4;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1828 dstp += 4;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1829 }, width);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1830 srcp += srcskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1831 dstp += dstskip;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1832 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1833 emms();
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1834 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1835 }
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1836 #endif
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1837
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1838 /* fast RGB565->RGB565 blending with surface alpha */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1839 static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1840 {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1841 unsigned alpha = info->src->alpha;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1842 if(alpha == 128) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1843 Blit16to16SurfaceAlpha128(info, 0xf7de);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1844 } else {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1845 int width = info->d_width;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1846 int height = info->d_height;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1847 Uint16 *srcp = (Uint16 *)info->s_pixels;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1848 int srcskip = info->s_skip >> 1;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1849 Uint16 *dstp = (Uint16 *)info->d_pixels;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1850 int dstskip = info->d_skip >> 1;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1851 alpha >>= 3; /* downscale alpha to 5 bits */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1852
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1853 while(height--) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1854 DUFFS_LOOP4({
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1855 Uint32 s = *srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1856 Uint32 d = *dstp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1857 /*
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1858 * shift out the middle component (green) to
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1859 * the high 16 bits, and process all three RGB
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1860 * components at the same time.
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1861 */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1862 s = (s | s << 16) & 0x07e0f81f;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1863 d = (d | d << 16) & 0x07e0f81f;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1864 d += (s - d) * alpha >> 5;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1865 d &= 0x07e0f81f;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1866 *dstp++ = d | d >> 16;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1867 }, width);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1868 srcp += srcskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1869 dstp += dstskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1870 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1871 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1872 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1873
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1874 /* fast RGB555->RGB555 blending with surface alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1875 static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1876 {
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1877 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1878 if(alpha == 128) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1879 Blit16to16SurfaceAlpha128(info, 0xfbde);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1880 } else {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1881 int width = info->d_width;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1882 int height = info->d_height;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1883 Uint16 *srcp = (Uint16 *)info->s_pixels;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1884 int srcskip = info->s_skip >> 1;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1885 Uint16 *dstp = (Uint16 *)info->d_pixels;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1886 int dstskip = info->d_skip >> 1;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1887 alpha >>= 3; /* downscale alpha to 5 bits */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1888
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1889 while(height--) {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1890 DUFFS_LOOP4({
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1891 Uint32 s = *srcp++;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1892 Uint32 d = *dstp;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1893 /*
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1894 * shift out the middle component (green) to
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1895 * the high 16 bits, and process all three RGB
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1896 * components at the same time.
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1897 */
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1898 s = (s | s << 16) & 0x03e07c1f;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1899 d = (d | d << 16) & 0x03e07c1f;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1900 d += (s - d) * alpha >> 5;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1901 d &= 0x03e07c1f;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1902 *dstp++ = d | d >> 16;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1903 }, width);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1904 srcp += srcskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1905 dstp += dstskip;
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
1906 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1907 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1908 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1909
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1910 /* fast ARGB8888->RGB565 blending with pixel alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1911 static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1912 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1913 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1914 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1915 Uint32 *srcp = (Uint32 *)info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1916 int srcskip = info->s_skip >> 2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1917 Uint16 *dstp = (Uint16 *)info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1918 int dstskip = info->d_skip >> 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1919
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1920 while(height--) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1921 DUFFS_LOOP4({
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1922 Uint32 s = *srcp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1923 unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1924 /* FIXME: Here we special-case opaque alpha since the
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1925 compositioning used (>>8 instead of /255) doesn't handle
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1926 it correctly. Also special-case alpha=0 for speed?
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1927 Benchmark this! */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1928 if(alpha) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1929 if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1930 *dstp = (s >> 8 & 0xf800) + (s >> 5 & 0x7e0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1931 + (s >> 3 & 0x1f);
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1932 } else {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1933 Uint32 d = *dstp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1934 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1935 * convert source and destination to G0RAB65565
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1936 * and blend all components at the same time
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1937 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1938 s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1939 + (s >> 3 & 0x1f);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1940 d = (d | d << 16) & 0x07e0f81f;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1941 d += (s - d) * alpha >> 5;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1942 d &= 0x07e0f81f;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1943 *dstp = d | d >> 16;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1944 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1945 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1946 srcp++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1947 dstp++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1948 }, width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1949 srcp += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1950 dstp += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1951 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1952 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1953
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1954 /* fast ARGB8888->RGB555 blending with pixel alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1955 static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1956 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1957 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1958 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1959 Uint32 *srcp = (Uint32 *)info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1960 int srcskip = info->s_skip >> 2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1961 Uint16 *dstp = (Uint16 *)info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1962 int dstskip = info->d_skip >> 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1963
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1964 while(height--) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1965 DUFFS_LOOP4({
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1966 unsigned alpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1967 Uint32 s = *srcp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1968 alpha = s >> 27; /* downscale alpha to 5 bits */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1969 /* FIXME: Here we special-case opaque alpha since the
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1970 compositioning used (>>8 instead of /255) doesn't handle
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1971 it correctly. Also special-case alpha=0 for speed?
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1972 Benchmark this! */
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1973 if(alpha) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1974 if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1975 *dstp = (s >> 9 & 0x7c00) + (s >> 6 & 0x3e0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1976 + (s >> 3 & 0x1f);
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1977 } else {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1978 Uint32 d = *dstp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1979 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1980 * convert source and destination to G0RAB65565
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1981 * and blend all components at the same time
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1982 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1983 s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1984 + (s >> 3 & 0x1f);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1985 d = (d | d << 16) & 0x03e07c1f;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1986 d += (s - d) * alpha >> 5;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1987 d &= 0x03e07c1f;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1988 *dstp = d | d >> 16;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
1989 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1990 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1991 srcp++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1992 dstp++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1993 }, width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1994 srcp += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1995 dstp += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1996 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1997 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1998
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1999 /* General (slow) N->N blending with per-surface alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2000 static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2001 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2002 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2003 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2004 Uint8 *src = info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2005 int srcskip = info->s_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2006 Uint8 *dst = info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2007 int dstskip = info->d_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2008 SDL_PixelFormat *srcfmt = info->src;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2009 SDL_PixelFormat *dstfmt = info->dst;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2010 int srcbpp = srcfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2011 int dstbpp = dstfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2012 unsigned sA = srcfmt->alpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2013 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2014
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2015 if(sA) {
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2016 while ( height-- ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2017 DUFFS_LOOP4(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2018 {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2019 Uint32 Pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2020 unsigned sR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2021 unsigned sG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2022 unsigned sB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2023 unsigned dR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2024 unsigned dG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2025 unsigned dB;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2026 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2027 DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2028 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2029 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2030 src += srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2031 dst += dstbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2032 },
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2033 width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2034 src += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2035 dst += dstskip;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2036 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2037 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2038 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2039
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2040 /* General (slow) colorkeyed N->N blending with per-surface alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2041 static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2042 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2043 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2044 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2045 Uint8 *src = info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2046 int srcskip = info->s_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2047 Uint8 *dst = info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2048 int dstskip = info->d_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2049 SDL_PixelFormat *srcfmt = info->src;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2050 SDL_PixelFormat *dstfmt = info->dst;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2051 Uint32 ckey = srcfmt->colorkey;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2052 int srcbpp = srcfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2053 int dstbpp = dstfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2054 unsigned sA = srcfmt->alpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2055 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2056
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2057 while ( height-- ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2058 DUFFS_LOOP4(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2059 {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2060 Uint32 Pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2061 unsigned sR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2062 unsigned sG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2063 unsigned sB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2064 unsigned dR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2065 unsigned dG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2066 unsigned dB;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2067 RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2068 if(sA && Pixel != ckey) {
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2069 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2070 DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2071 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2072 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2073 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2074 src += srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2075 dst += dstbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2076 },
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2077 width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2078 src += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2079 dst += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2080 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2081 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2082
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2083 /* General (slow) N->N blending with pixel alpha */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2084 static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2085 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2086 int width = info->d_width;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2087 int height = info->d_height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2088 Uint8 *src = info->s_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2089 int srcskip = info->s_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2090 Uint8 *dst = info->d_pixels;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2091 int dstskip = info->d_skip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2092 SDL_PixelFormat *srcfmt = info->src;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2093 SDL_PixelFormat *dstfmt = info->dst;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2094
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2095 int srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2096 int dstbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2097
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2098 /* Set up some basic variables */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2099 srcbpp = srcfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2100 dstbpp = dstfmt->BytesPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2101
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2102 /* FIXME: for 8bpp source alpha, this doesn't get opaque values
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2103 quite right. for <8bpp source alpha, it gets them very wrong
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2104 (check all macros!)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2105 It is unclear whether there is a good general solution that doesn't
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2106 need a branch (or a divide). */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2107 while ( height-- ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2108 DUFFS_LOOP4(
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2109 {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2110 Uint32 Pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2111 unsigned sR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2112 unsigned sG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2113 unsigned sB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2114 unsigned dR;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2115 unsigned dG;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2116 unsigned dB;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2117 unsigned sA;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2118 unsigned dA;
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2119 DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2120 if(sA) {
1162
2651158f59b8 Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents: 1047
diff changeset
2121 DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2122 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2123 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2124 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2125 src += srcbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2126 dst += dstbpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2127 },
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2128 width);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2129 src += srcskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2130 dst += dstskip;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2131 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2132 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2133
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2134
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2135 SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2136 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2137 SDL_PixelFormat *sf = surface->format;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2138 SDL_PixelFormat *df = surface->map->dst->format;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2139
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2140 if(sf->Amask == 0) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2141 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2142 if(df->BytesPerPixel == 1)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2143 return BlitNto1SurfaceAlphaKey;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2144 else
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2145 #ifdef USE_ALTIVEC_BLITTERS
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2146 if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && SDL_HasAltiVec())
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2147 return Blit32to32SurfaceAlphaKeyAltivec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2148 else
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2149 #endif
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2150 return BlitNtoNSurfaceAlphaKey;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2151 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2152 /* Per-surface alpha blits */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2153 switch(df->BytesPerPixel) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2154 case 1:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2155 return BlitNto1SurfaceAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2156
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2157 case 2:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2158 if(surface->map->identity) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2159 if(df->Gmask == 0x7e0)
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2160 {
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
2161 #ifdef MMX_ASMBLIT
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
2162 if(SDL_HasMMX())
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2163 return Blit565to565SurfaceAlphaMMX;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2164 else
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2165 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2166 return Blit565to565SurfaceAlpha;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2167 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2168 else if(df->Gmask == 0x3e0)
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2169 {
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
2170 #ifdef MMX_ASMBLIT
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
2171 if(SDL_HasMMX())
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2172 return Blit555to555SurfaceAlphaMMX;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2173 else
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2174 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2175 return Blit555to555SurfaceAlpha;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2176 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2177 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2178 return BlitNtoNSurfaceAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2179
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2180 case 4:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2181 if(sf->Rmask == df->Rmask
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2182 && sf->Gmask == df->Gmask
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2183 && sf->Bmask == df->Bmask
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2184 && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2185 && sf->BytesPerPixel == 4)
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2186 {
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
2187 #ifdef MMX_ASMBLIT
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
2188 if(SDL_HasMMX())
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2189 return BlitRGBtoRGBSurfaceAlphaMMX;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2190 else
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2191 #endif
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2192 #ifdef USE_ALTIVEC_BLITTERS
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2193 if(SDL_HasAltiVec())
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2194 return BlitRGBtoRGBSurfaceAlphaAltivec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2195 else
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2196 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2197 return BlitRGBtoRGBSurfaceAlpha;
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2198 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2199 else
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2200 #ifdef USE_ALTIVEC_BLITTERS
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2201 if((sf->BytesPerPixel == 4) && SDL_HasAltiVec())
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2202 return Blit32to32SurfaceAlphaAltivec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2203 else
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2204 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2205 return BlitNtoNSurfaceAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2206
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2207 case 3:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2208 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2209 return BlitNtoNSurfaceAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2210 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2211 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2212 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2213 /* Per-pixel alpha blits */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2214 switch(df->BytesPerPixel) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2215 case 1:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2216 return BlitNto1PixelAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2217
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2218 case 2:
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2219 #ifdef USE_ALTIVEC_BLITTERS
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2220 if(sf->BytesPerPixel == 4 &&
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2221 df->Gmask == 0x7e0 &&
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2222 df->Bmask == 0x1f)
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2223 return Blit32to565PixelAlphaAltivec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2224 else
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2225 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2226 if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2227 && sf->Gmask == 0xff00
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2228 && ((sf->Rmask == 0xff && df->Rmask == 0x1f)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2229 || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2230 if(df->Gmask == 0x7e0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2231 return BlitARGBto565PixelAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2232 else if(df->Gmask == 0x3e0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2233 return BlitARGBto555PixelAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2234 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2235 return BlitNtoNPixelAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2236
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2237 case 4:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2238 if(sf->Amask == 0xff000000
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2239 && sf->Rmask == df->Rmask
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2240 && sf->Gmask == df->Gmask
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2241 && sf->Bmask == df->Bmask
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2242 && sf->BytesPerPixel == 4)
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2243 {
880
9ef41050100c Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
2244 #ifdef MMX_ASMBLIT
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
2245 if(SDL_Has3DNow())
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2246 return BlitRGBtoRGBPixelAlphaMMX3DNOW;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2247 else
739
22dbf364c017 Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents: 720
diff changeset
2248 if(SDL_HasMMX())
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2249 return BlitRGBtoRGBPixelAlphaMMX;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2250 else
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2251 #endif
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2252 #ifdef USE_ALTIVEC_BLITTERS
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2253 if(SDL_HasAltiVec())
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2254 return BlitRGBtoRGBPixelAlphaAltivec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2255 else
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2256 #endif
689
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2257 return BlitRGBtoRGBPixelAlpha;
5bb080d35049 Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2258 }
1047
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2259 #ifdef USE_ALTIVEC_BLITTERS
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2260 if (sf->Amask && sf->BytesPerPixel == 4 && SDL_HasAltiVec())
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2261 return Blit32to32PixelAlphaAltivec;
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2262 else
ffaaf7ecf685 Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents: 880
diff changeset
2263 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2264 return BlitNtoNPixelAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2265
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2266 case 3:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2267 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2268 return BlitNtoNPixelAlpha;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2269 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2270 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2271 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2272