Mercurial > sdl-ios-xcode
annotate src/video/SDL_blit_A.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 14717b52abc0 |
children | 4da1ee79c9af |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1240
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
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 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 #include "SDL_video.h" | |
25 #include "SDL_blit.h" | |
26 | |
1542 | 27 #if SDL_ASSEMBLY_ROUTINES |
28 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
29 #define MMX_ASMBLIT 1 |
1542 | 30 #define GCC_ASMBLIT 1 |
31 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86) | |
32 #define MMX_ASMBLIT 1 | |
33 #define MSVC_ASMBLIT 1 | |
880
9ef41050100c
Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
34 #endif |
1542 | 35 #endif /* SDL_ASSEMBLY_ROUTINES */ |
880
9ef41050100c
Date: Tue, 30 Mar 2004 21:26:47 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
36 |
739
22dbf364c017
Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
Sam Lantinga <slouken@libsdl.org>
parents:
720
diff
changeset
|
37 /* 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
|
38 #include "SDL_cpuinfo.h" |
1542 | 39 #if GCC_ASMBLIT |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
40 #include "mmx.h" |
1542 | 41 #elif MSVC_ASMBLIT |
42 #include <mmintrin.h> | |
43 #include <mm3dnow.h> | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
44 #endif |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
45 |
0 | 46 /* Functions to perform alpha blended blitting */ |
47 | |
48 /* N->1 blending with per-surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
49 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
50 BlitNto1SurfaceAlpha (SDL_BlitInfo * info) |
0 | 51 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
52 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
53 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
54 Uint8 *src = info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
55 int srcskip = info->s_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
56 Uint8 *dst = info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
57 int dstskip = info->d_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
58 Uint8 *palmap = info->table; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
59 SDL_PixelFormat *srcfmt = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
60 SDL_PixelFormat *dstfmt = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
61 int srcbpp = srcfmt->BytesPerPixel; |
0 | 62 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
63 const unsigned A = srcfmt->alpha; |
0 | 64 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
65 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
66 /* *INDENT-OFF* */ |
0 | 67 DUFFS_LOOP4( |
68 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
69 Uint32 Pixel; |
0 | 70 unsigned sR; |
71 unsigned sG; | |
72 unsigned sB; | |
73 unsigned dR; | |
74 unsigned dG; | |
75 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
|
76 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); |
0 | 77 dR = dstfmt->palette->colors[*dst].r; |
78 dG = dstfmt->palette->colors[*dst].g; | |
79 dB = dstfmt->palette->colors[*dst].b; | |
80 ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB); | |
81 dR &= 0xff; | |
82 dG &= 0xff; | |
83 dB &= 0xff; | |
84 /* Pack RGB into 8bit pixel */ | |
85 if ( palmap == NULL ) { | |
86 *dst =((dR>>5)<<(3+2))| | |
87 ((dG>>5)<<(2))| | |
88 ((dB>>6)<<(0)); | |
89 } else { | |
90 *dst = palmap[((dR>>5)<<(3+2))| | |
91 ((dG>>5)<<(2)) | | |
92 ((dB>>6)<<(0))]; | |
93 } | |
94 dst++; | |
95 src += srcbpp; | |
96 }, | |
97 width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
98 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
99 src += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
100 dst += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
101 } |
0 | 102 } |
103 | |
104 /* N->1 blending with pixel alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
105 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
106 BlitNto1PixelAlpha (SDL_BlitInfo * info) |
0 | 107 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
108 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
109 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
110 Uint8 *src = info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
111 int srcskip = info->s_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
112 Uint8 *dst = info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
113 int dstskip = info->d_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
114 Uint8 *palmap = info->table; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
115 SDL_PixelFormat *srcfmt = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
116 SDL_PixelFormat *dstfmt = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
117 int srcbpp = srcfmt->BytesPerPixel; |
0 | 118 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
119 /* FIXME: fix alpha bit field expansion here too? */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
120 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
121 /* *INDENT-OFF* */ |
0 | 122 DUFFS_LOOP4( |
123 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
124 Uint32 Pixel; |
0 | 125 unsigned sR; |
126 unsigned sG; | |
127 unsigned sB; | |
128 unsigned sA; | |
129 unsigned dR; | |
130 unsigned dG; | |
131 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
|
132 DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA); |
0 | 133 dR = dstfmt->palette->colors[*dst].r; |
134 dG = dstfmt->palette->colors[*dst].g; | |
135 dB = dstfmt->palette->colors[*dst].b; | |
136 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); | |
137 dR &= 0xff; | |
138 dG &= 0xff; | |
139 dB &= 0xff; | |
140 /* Pack RGB into 8bit pixel */ | |
141 if ( palmap == NULL ) { | |
142 *dst =((dR>>5)<<(3+2))| | |
143 ((dG>>5)<<(2))| | |
144 ((dB>>6)<<(0)); | |
145 } else { | |
146 *dst = palmap[((dR>>5)<<(3+2))| | |
147 ((dG>>5)<<(2)) | | |
148 ((dB>>6)<<(0)) ]; | |
149 } | |
150 dst++; | |
151 src += srcbpp; | |
152 }, | |
153 width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
154 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
155 src += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
156 dst += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
157 } |
0 | 158 } |
159 | |
160 /* colorkeyed N->1 blending with per-surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
161 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
162 BlitNto1SurfaceAlphaKey (SDL_BlitInfo * info) |
0 | 163 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
164 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
165 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
166 Uint8 *src = info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
167 int srcskip = info->s_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
168 Uint8 *dst = info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
169 int dstskip = info->d_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
170 Uint8 *palmap = info->table; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
171 SDL_PixelFormat *srcfmt = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
172 SDL_PixelFormat *dstfmt = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
173 int srcbpp = srcfmt->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
174 Uint32 ckey = srcfmt->colorkey; |
0 | 175 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
176 const int A = srcfmt->alpha; |
0 | 177 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
178 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
179 /* *INDENT-OFF* */ |
0 | 180 DUFFS_LOOP( |
181 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
182 Uint32 Pixel; |
0 | 183 unsigned sR; |
184 unsigned sG; | |
185 unsigned sB; | |
186 unsigned dR; | |
187 unsigned dG; | |
188 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
|
189 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
|
190 if ( Pixel != ckey ) { |
0 | 191 dR = dstfmt->palette->colors[*dst].r; |
192 dG = dstfmt->palette->colors[*dst].g; | |
193 dB = dstfmt->palette->colors[*dst].b; | |
194 ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB); | |
195 dR &= 0xff; | |
196 dG &= 0xff; | |
197 dB &= 0xff; | |
198 /* Pack RGB into 8bit pixel */ | |
199 if ( palmap == NULL ) { | |
200 *dst =((dR>>5)<<(3+2))| | |
201 ((dG>>5)<<(2)) | | |
202 ((dB>>6)<<(0)); | |
203 } else { | |
204 *dst = palmap[((dR>>5)<<(3+2))| | |
205 ((dG>>5)<<(2)) | | |
206 ((dB>>6)<<(0)) ]; | |
207 } | |
208 } | |
209 dst++; | |
210 src += srcbpp; | |
211 }, | |
212 width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
213 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
214 src += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
215 dst += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
216 } |
0 | 217 } |
218 | |
1542 | 219 #if GCC_ASMBLIT |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
220 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
221 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
222 BlitRGBtoRGBSurfaceAlpha128MMX (SDL_BlitInfo * info) |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
223 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
224 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
225 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
226 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
227 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
228 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
229 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
230 Uint32 dalpha = info->dst->Amask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
231 Uint8 load[8]; |
1542 | 232 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
233 *(Uint64 *) load = 0x00fefefe00fefefeULL; /* alpha128 mask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
234 movq_m2r (*load, mm4); /* alpha128 mask -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
235 *(Uint64 *) load = 0x0001010100010101ULL; /* !alpha128 mask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
236 movq_m2r (*load, mm3); /* !alpha128 mask -> mm3 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
237 movd_m2r (dalpha, mm7); /* dst alpha mask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
238 punpckldq_r2r (mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
239 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
240 /* *INDENT-OFF* */ |
1542 | 241 DUFFS_LOOP_DOUBLE2( |
242 { | |
243 Uint32 s = *srcp++; | |
244 Uint32 d = *dstp; | |
245 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) | |
246 + (s & d & 0x00010101)) | dalpha; | |
247 },{ | |
248 movq_m2r((*dstp), mm2);/* 2 x dst -> mm2(ARGBARGB) */ | |
249 movq_r2r(mm2, mm6); /* 2 x dst -> mm6(ARGBARGB) */ | |
250 | |
251 movq_m2r((*srcp), mm1);/* 2 x src -> mm1(ARGBARGB) */ | |
252 movq_r2r(mm1, mm5); /* 2 x src -> mm5(ARGBARGB) */ | |
253 | |
254 pand_r2r(mm4, mm6); /* dst & mask -> mm6 */ | |
255 pand_r2r(mm4, mm5); /* src & mask -> mm5 */ | |
256 paddd_r2r(mm6, mm5); /* mm6 + mm5 -> mm5 */ | |
257 pand_r2r(mm1, mm2); /* src & dst -> mm2 */ | |
258 psrld_i2r(1, mm5); /* mm5 >> 1 -> mm5 */ | |
259 pand_r2r(mm3, mm2); /* mm2 & !mask -> mm2 */ | |
260 paddd_r2r(mm5, mm2); /* mm5 + mm2 -> mm2 */ | |
261 | |
262 por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */ | |
263 movq_r2m(mm2, (*dstp));/* mm2 -> 2 x dst pixels */ | |
264 dstp += 2; | |
265 srcp += 2; | |
266 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
267 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
268 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
269 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
270 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
271 emms (); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
272 } |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
273 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
274 /* fast RGB888->(A)RGB888 blending with surface alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
275 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
276 BlitRGBtoRGBSurfaceAlphaMMX (SDL_BlitInfo * info) |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
277 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
278 SDL_PixelFormat *df = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
279 unsigned alpha = info->src->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
280 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
281 if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
282 /* only call a128 version when R,G,B occupy lower bits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
283 BlitRGBtoRGBSurfaceAlpha128MMX (info); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
284 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
285 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
286 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
287 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
288 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
289 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
290 int dstskip = info->d_skip >> 2; |
1542 | 291 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
292 pxor_r2r (mm5, mm5); /* 0 -> mm5 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
293 /* form the alpha mult */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
294 movd_m2r (alpha, mm4); /* 0000000A -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
295 punpcklwd_r2r (mm4, mm4); /* 00000A0A -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
296 punpckldq_r2r (mm4, mm4); /* 0A0A0A0A -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
297 alpha = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
298 (0xff << df->Rshift) | (0xff << df->Gshift) | (0xff << df-> |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
299 Bshift); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
300 movd_m2r (alpha, mm0); /* 00000FFF -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
301 punpcklbw_r2r (mm0, mm0); /* 00FFFFFF -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
302 pand_r2r (mm0, mm4); /* 0A0A0A0A -> mm4, minus 1 chan */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
303 /* at this point mm4 can be 000A0A0A or 0A0A0A00 or another combo */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
304 movd_m2r (df->Amask, mm7); /* dst alpha mask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
305 punpckldq_r2r (mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */ |
1542 | 306 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
307 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
308 /* *INDENT-OFF* */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
309 DUFFS_LOOP_DOUBLE2({ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
310 /* One Pixel Blend */ |
1542 | 311 movd_m2r((*srcp), mm1);/* src(ARGB) -> mm1 (0000ARGB)*/ |
312 movd_m2r((*dstp), mm2);/* dst(ARGB) -> mm2 (0000ARGB)*/ | |
313 punpcklbw_r2r(mm5, mm1); /* 0A0R0G0B -> mm1(src) */ | |
314 punpcklbw_r2r(mm5, mm2); /* 0A0R0G0B -> mm2(dst) */ | |
315 | |
316 psubw_r2r(mm2, mm1);/* src - dst -> mm1 */ | |
317 pmullw_r2r(mm4, mm1); /* mm1 * alpha -> mm1 */ | |
318 psrlw_i2r(8, mm1); /* mm1 >> 8 -> mm1 */ | |
319 paddb_r2r(mm1, mm2); /* mm1 + mm2(dst) -> mm2 */ | |
320 | |
321 packuswb_r2r(mm5, mm2); /* ARGBARGB -> mm2 */ | |
322 por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */ | |
323 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
|
324 ++srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
325 ++dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
326 },{ |
1542 | 327 /* Two Pixels Blend */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
328 movq_m2r((*srcp), mm0);/* 2 x src -> mm0(ARGBARGB)*/ |
1542 | 329 movq_m2r((*dstp), mm2);/* 2 x dst -> mm2(ARGBARGB) */ |
330 movq_r2r(mm0, mm1); /* 2 x src -> mm1(ARGBARGB) */ | |
331 movq_r2r(mm2, mm6); /* 2 x dst -> mm6(ARGBARGB) */ | |
332 | |
333 punpcklbw_r2r(mm5, mm0); /* low - 0A0R0G0B -> mm0(src1) */ | |
334 punpckhbw_r2r(mm5, mm1); /* high - 0A0R0G0B -> mm1(src2) */ | |
335 punpcklbw_r2r(mm5, mm2); /* low - 0A0R0G0B -> mm2(dst1) */ | |
336 punpckhbw_r2r(mm5, mm6); /* high - 0A0R0G0B -> mm6(dst2) */ | |
337 | |
338 psubw_r2r(mm2, mm0);/* src1 - dst1 -> mm0 */ | |
339 pmullw_r2r(mm4, mm0); /* mm0 * alpha -> mm0 */ | |
340 psrlw_i2r(8, mm0); /* mm0 >> 8 -> mm1 */ | |
341 paddb_r2r(mm0, mm2); /* mm0 + mm2(dst1) -> mm2 */ | |
342 | |
343 psubw_r2r(mm6, mm1);/* src2 - dst2 -> mm1 */ | |
344 pmullw_r2r(mm4, mm1); /* mm1 * alpha -> mm1 */ | |
345 psrlw_i2r(8, mm1); /* mm1 >> 8 -> mm1 */ | |
346 paddb_r2r(mm1, mm6); /* mm1 + mm6(dst2) -> mm6 */ | |
347 | |
348 packuswb_r2r(mm6, mm2); /* ARGBARGB -> mm2 */ | |
349 por_r2r(mm7, mm2); /* mm7(dst alpha) | mm2 -> mm2 */ | |
350 | |
351 movq_r2m(mm2, *dstp);/* mm2 -> 2 x pixel */ | |
352 | |
353 srcp += 2; | |
354 dstp += 2; | |
355 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
356 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
357 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
358 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
359 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
360 emms (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
361 } |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
362 } |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
363 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
364 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
365 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
366 BlitRGBtoRGBPixelAlphaMMX (SDL_BlitInfo * info) |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
367 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
368 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
369 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
370 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
371 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
372 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
373 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
374 SDL_PixelFormat *sf = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
375 Uint32 amask = sf->Amask; |
1542 | 376 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
377 pxor_r2r (mm6, mm6); /* 0 -> mm6 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
378 /* form multiplication mask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
379 movd_m2r (sf->Amask, mm7); /* 0000F000 -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
380 punpcklbw_r2r (mm7, mm7); /* FF000000 -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
381 pcmpeqb_r2r (mm0, mm0); /* FFFFFFFF -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
382 movq_r2r (mm0, mm3); /* FFFFFFFF -> mm3 (for later) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
383 pxor_r2r (mm0, mm7); /* 00FFFFFF -> mm7 (mult mask) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
384 /* form channel masks */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
385 movq_r2r (mm7, mm0); /* 00FFFFFF -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
386 packsswb_r2r (mm6, mm0); /* 00000FFF -> mm0 (channel mask) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
387 packsswb_r2r (mm6, mm3); /* 0000FFFF -> mm3 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
388 pxor_r2r (mm0, mm3); /* 0000F000 -> mm3 (~channel mask) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
389 /* get alpha channel shift */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
390 movd_m2r (sf->Ashift, mm5); /* Ashift -> mm5 */ |
1542 | 391 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
392 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
393 /* *INDENT-OFF* */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
394 DUFFS_LOOP4({ |
1542 | 395 Uint32 alpha = *srcp & amask; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
396 /* FIXME: Here we special-case opaque alpha since the |
1542 | 397 compositioning used (>>8 instead of /255) doesn't handle |
398 it correctly. Also special-case alpha=0 for speed? | |
399 Benchmark this! */ | |
400 if(alpha == 0) { | |
401 /* do nothing */ | |
402 } else if(alpha == amask) { | |
403 /* opaque alpha -- copy RGB, keep dst alpha */ | |
404 /* using MMX here to free up regular registers for other things */ | |
405 movd_m2r((*srcp), mm1);/* src(ARGB) -> mm1 (0000ARGB)*/ | |
406 movd_m2r((*dstp), mm2);/* dst(ARGB) -> mm2 (0000ARGB)*/ | |
407 pand_r2r(mm0, mm1); /* src & chanmask -> mm1 */ | |
408 pand_r2r(mm3, mm2); /* dst & ~chanmask -> mm2 */ | |
409 por_r2r(mm1, mm2); /* src | dst -> mm2 */ | |
410 movd_r2m(mm2, (*dstp)); /* mm2 -> dst */ | |
411 } else { | |
412 movd_m2r((*srcp), mm1);/* src(ARGB) -> mm1 (0000ARGB)*/ | |
413 punpcklbw_r2r(mm6, mm1); /* 0A0R0G0B -> mm1 */ | |
414 | |
415 movd_m2r((*dstp), mm2);/* dst(ARGB) -> mm2 (0000ARGB)*/ | |
416 punpcklbw_r2r(mm6, mm2); /* 0A0R0G0B -> mm2 */ | |
417 | |
418 __asm__ __volatile__ ( | |
419 "movd %0, %%mm4" | |
420 : : "r" (alpha) ); /* 0000A000 -> mm4 */ | |
421 psrld_r2r(mm5, mm4); /* mm4 >> mm5 -> mm4 (0000000A) */ | |
422 punpcklwd_r2r(mm4, mm4); /* 00000A0A -> mm4 */ | |
423 punpcklwd_r2r(mm4, mm4); /* 0A0A0A0A -> mm4 */ | |
424 pand_r2r(mm7, mm4); /* 000A0A0A -> mm4, preserve dst alpha on add */ | |
425 | |
426 /* blend */ | |
427 psubw_r2r(mm2, mm1);/* src - dst -> mm1 */ | |
428 pmullw_r2r(mm4, mm1); /* mm1 * alpha -> mm1 */ | |
429 psrlw_i2r(8, mm1); /* mm1 >> 8 -> mm1(000R0G0B) */ | |
430 paddb_r2r(mm1, mm2); /* mm1 + mm2(dst) -> mm2 */ | |
431 | |
432 packuswb_r2r(mm6, mm2); /* 0000ARGB -> mm2 */ | |
433 movd_r2m(mm2, *dstp);/* mm2 -> dst */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
434 } |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
435 ++srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
436 ++dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
437 }, width); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
438 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
439 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
440 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
441 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
442 emms (); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
443 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
444 |
1542 | 445 /* End GCC_ASMBLIT */ |
446 | |
447 #elif MSVC_ASMBLIT | |
448 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
449 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
450 BlitRGBtoRGBSurfaceAlpha128MMX (SDL_BlitInfo * info) |
1542 | 451 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
452 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
453 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
454 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
455 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
456 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
457 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
458 Uint32 dalpha = info->dst->Amask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
459 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
460 __m64 src1, src2, dst1, dst2, lmask, hmask, dsta; |
1542 | 461 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
462 hmask = _mm_set_pi32 (0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
463 lmask = _mm_set_pi32 (0x00010101, 0x00010101); /* !alpha128 mask -> lmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
464 dsta = _mm_set_pi32 (dalpha, dalpha); /* dst alpha mask -> dsta */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
465 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
466 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
467 int n = width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
468 if (n & 1) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
469 Uint32 s = *srcp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
470 Uint32 d = *dstp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
471 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
472 + (s & d & 0x00010101)) | dalpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
473 n--; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
474 } |
1542 | 475 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
476 for (n >>= 1; n > 0; --n) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
477 dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
478 dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ |
1542 | 479 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
480 src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
481 src2 = src1; /* 2 x src -> src2(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
482 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
483 dst2 = _mm_and_si64 (dst2, hmask); /* dst & mask -> dst2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
484 src2 = _mm_and_si64 (src2, hmask); /* src & mask -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
485 src2 = _mm_add_pi32 (src2, dst2); /* dst2 + src2 -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
486 src2 = _mm_srli_pi32 (src2, 1); /* src2 >> 1 -> src2 */ |
1542 | 487 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
488 dst1 = _mm_and_si64 (dst1, src1); /* src & dst -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
489 dst1 = _mm_and_si64 (dst1, lmask); /* dst1 & !mask -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
490 dst1 = _mm_add_pi32 (dst1, src2); /* src2 + dst1 -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
491 dst1 = _mm_or_si64 (dst1, dsta); /* dsta(full alpha) | dst1 -> dst1 */ |
1542 | 492 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
493 *(__m64 *) dstp = dst1; /* dst1 -> 2 x dst pixels */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
494 dstp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
495 srcp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
496 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
497 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
498 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
499 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
500 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
501 _mm_empty (); |
1542 | 502 } |
503 | |
504 /* fast RGB888->(A)RGB888 blending with surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
505 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
506 BlitRGBtoRGBSurfaceAlphaMMX (SDL_BlitInfo * info) |
1542 | 507 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
508 SDL_PixelFormat *df = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
509 Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
510 unsigned alpha = info->src->alpha; |
1542 | 511 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
512 if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
513 /* only call a128 version when R,G,B occupy lower bits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
514 BlitRGBtoRGBSurfaceAlpha128MMX (info); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
515 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
516 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
517 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
518 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
519 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
520 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
521 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
522 Uint32 dalpha = df->Amask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
523 Uint32 amult; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
524 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
525 __m64 src1, src2, dst1, dst2, mm_alpha, mm_zero, dsta; |
1542 | 526 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
527 mm_zero = _mm_setzero_si64 (); /* 0 -> mm_zero */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
528 /* form the alpha mult */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
529 amult = alpha | (alpha << 8); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
530 amult = amult | (amult << 16); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
531 chanmask = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
532 (0xff << df->Rshift) | (0xff << df->Gshift) | (0xff << df-> |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
533 Bshift); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
534 mm_alpha = _mm_set_pi32 (0, amult & chanmask); /* 0000AAAA -> mm_alpha, minus 1 chan */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
535 mm_alpha = _mm_unpacklo_pi8 (mm_alpha, mm_zero); /* 0A0A0A0A -> mm_alpha, minus 1 chan */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
536 /* at this point mm_alpha can be 000A0A0A or 0A0A0A00 or another combo */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
537 dsta = _mm_set_pi32 (dalpha, dalpha); /* dst alpha mask -> dsta */ |
1542 | 538 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
539 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
540 int n = width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
541 if (n & 1) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
542 /* One Pixel Blend */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
543 src2 = _mm_cvtsi32_si64 (*srcp); /* src(ARGB) -> src2 (0000ARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
544 src2 = _mm_unpacklo_pi8 (src2, mm_zero); /* 0A0R0G0B -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
545 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
546 dst1 = _mm_cvtsi32_si64 (*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
547 dst1 = _mm_unpacklo_pi8 (dst1, mm_zero); /* 0A0R0G0B -> dst1 */ |
1542 | 548 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
549 src2 = _mm_sub_pi16 (src2, dst1); /* src2 - dst2 -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
550 src2 = _mm_mullo_pi16 (src2, mm_alpha); /* src2 * alpha -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
551 src2 = _mm_srli_pi16 (src2, 8); /* src2 >> 8 -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
552 dst1 = _mm_add_pi8 (src2, dst1); /* src2 + dst1 -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
553 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
554 dst1 = _mm_packs_pu16 (dst1, mm_zero); /* 0000ARGB -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
555 dst1 = _mm_or_si64 (dst1, dsta); /* dsta | dst1 -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
556 *dstp = _mm_cvtsi64_si32 (dst1); /* dst1 -> pixel */ |
1542 | 557 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
558 ++srcp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
559 ++dstp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
560 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
561 n--; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
562 } |
1542 | 563 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
564 for (n >>= 1; n > 0; --n) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
565 /* Two Pixels Blend */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
566 src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
567 src2 = src1; /* 2 x src -> src2(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
568 src1 = _mm_unpacklo_pi8 (src1, mm_zero); /* low - 0A0R0G0B -> src1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
569 src2 = _mm_unpackhi_pi8 (src2, mm_zero); /* high - 0A0R0G0B -> src2 */ |
1542 | 570 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
571 dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
572 dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
573 dst1 = _mm_unpacklo_pi8 (dst1, mm_zero); /* low - 0A0R0G0B -> dst1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
574 dst2 = _mm_unpackhi_pi8 (dst2, mm_zero); /* high - 0A0R0G0B -> dst2 */ |
1542 | 575 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
576 src1 = _mm_sub_pi16 (src1, dst1); /* src1 - dst1 -> src1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
577 src1 = _mm_mullo_pi16 (src1, mm_alpha); /* src1 * alpha -> src1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
578 src1 = _mm_srli_pi16 (src1, 8); /* src1 >> 8 -> src1 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
579 dst1 = _mm_add_pi8 (src1, dst1); /* src1 + dst1(dst1) -> dst1 */ |
1542 | 580 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
581 src2 = _mm_sub_pi16 (src2, dst2); /* src2 - dst2 -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
582 src2 = _mm_mullo_pi16 (src2, mm_alpha); /* src2 * alpha -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
583 src2 = _mm_srli_pi16 (src2, 8); /* src2 >> 8 -> src2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
584 dst2 = _mm_add_pi8 (src2, dst2); /* src2 + dst2(dst2) -> dst2 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
585 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
586 dst1 = _mm_packs_pu16 (dst1, dst2); /* 0A0R0G0B(res1), 0A0R0G0B(res2) -> dst1(ARGBARGB) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
587 dst1 = _mm_or_si64 (dst1, dsta); /* dsta | dst1 -> dst1 */ |
1542 | 588 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
589 *(__m64 *) dstp = dst1; /* dst1 -> 2 x pixel */ |
1542 | 590 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
591 srcp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
592 dstp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
593 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
594 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
595 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
596 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
597 _mm_empty (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
598 } |
1542 | 599 } |
600 | |
601 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
602 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
603 BlitRGBtoRGBPixelAlphaMMX (SDL_BlitInfo * info) |
1542 | 604 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
605 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
606 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
607 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
608 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
609 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
610 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
611 SDL_PixelFormat *sf = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
612 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
613 Uint32 amask = sf->Amask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
614 Uint32 ashift = sf->Ashift; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
615 Uint64 multmask; |
1542 | 616 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
617 __m64 src1, dst1, mm_alpha, mm_zero, dmask; |
1542 | 618 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
619 mm_zero = _mm_setzero_si64 (); /* 0 -> mm_zero */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
620 multmask = ~(0xFFFFi 64 << (ashift * 2)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
621 dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ |
1542 | 622 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
623 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
624 /* *INDENT-OFF* */ |
1542 | 625 DUFFS_LOOP4({ |
626 Uint32 alpha = *srcp & amask; | |
627 if (alpha == 0) { | |
628 /* do nothing */ | |
629 } else if (alpha == amask) { | |
630 /* opaque alpha -- copy RGB, keep dst alpha */ | |
631 *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); | |
632 } else { | |
633 src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ | |
634 src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ | |
635 | |
636 dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ | |
637 dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ | |
638 | |
639 mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ | |
640 mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ | |
641 mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ | |
642 mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ | |
643 mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ | |
644 | |
645 /* blend */ | |
646 src1 = _mm_sub_pi16(src1, dst1);/* src1 - dst1 -> src1 */ | |
647 src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src1 - dst1) * alpha -> src1 */ | |
648 src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ | |
649 dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1 -> dst1(0A0R0G0B) */ | |
650 dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ | |
651 | |
652 *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ | |
653 } | |
654 ++srcp; | |
655 ++dstp; | |
656 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
657 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
658 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
659 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
660 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
661 _mm_empty (); |
1542 | 662 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
663 |
1542 | 664 /* End MSVC_ASMBLIT */ |
665 | |
666 #endif /* GCC_ASMBLIT, MSVC_ASMBLIT */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
667 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
668 #if SDL_ALTIVEC_BLITTERS |
1659 | 669 #if __MWERKS__ |
670 #pragma altivec_model on | |
671 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
672 #if HAVE_ALTIVEC_H |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
673 #include <altivec.h> |
1175
867f521591e5
Fixed Altivec support on Mac OS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
1162
diff
changeset
|
674 #endif |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
675 #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
|
676 |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
677 #if (defined(__MACOSX__) && (__GNUC__ < 4)) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
678 #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
679 (vector unsigned char) ( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p ) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
680 #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \ |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
681 (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
|
682 #else |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
683 #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
684 (vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
685 #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \ |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
686 (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
|
687 #endif |
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
688 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
689 #define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F) |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
690 #define VECPRINT(msg, v) do { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
691 vector unsigned int tmpvec = (vector unsigned int)(v); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
692 unsigned int *vp = (unsigned int *)&tmpvec; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
693 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
|
694 } while (0) |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
695 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
696 /* 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
|
697 (vector unsigned char)( |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
698 0x00, 0x10, 0x02, 0x12, |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
699 0x04, 0x14, 0x06, 0x16, |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
700 0x08, 0x18, 0x0A, 0x1A, |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
701 0x0C, 0x1C, 0x0E, 0x1E ); |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
702 */ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
703 #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
|
704 #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
|
705 #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
|
706 #define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
707 ? vec_lvsl(0, src) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
708 : vec_add(vec_lvsl(8, src), vec_splat_u8(8))) |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
709 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
710 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
711 #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
|
712 /* vtemp1 contains source AAGGAAGGAAGGAAGG */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
713 vector unsigned short vtemp1 = vec_mule(vs, valpha); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
714 /* vtemp2 contains source RRBBRRBBRRBBRRBB */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
715 vector unsigned short vtemp2 = vec_mulo(vs, valpha); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
716 /* valpha2 is 255-alpha */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
717 vector unsigned char valpha2 = vec_nor(valpha, valpha); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
718 /* vtemp3 contains dest AAGGAAGGAAGGAAGG */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
719 vector unsigned short vtemp3 = vec_mule(vd, valpha2); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
720 /* vtemp4 contains dest RRBBRRBBRRBBRRBB */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
721 vector unsigned short vtemp4 = vec_mulo(vd, valpha2); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
722 /* add source and dest */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
723 vtemp1 = vec_add(vtemp1, vtemp3); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
724 vtemp2 = vec_add(vtemp2, vtemp4); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
725 /* vtemp1 = (vtemp1 + 1) + ((vtemp1 + 1) >> 8) */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
726 vtemp1 = vec_add(vtemp1, v1_16); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
727 vtemp3 = vec_sr(vtemp1, v8_16); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
728 vtemp1 = vec_add(vtemp1, vtemp3); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
729 /* vtemp2 = (vtemp2 + 1) + ((vtemp2 + 1) >> 8) */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
730 vtemp2 = vec_add(vtemp2, v1_16); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
731 vtemp4 = vec_sr(vtemp2, v8_16); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
732 vtemp2 = vec_add(vtemp2, vtemp4); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
733 /* (>>8) and get ARGBARGBARGBARGB */ \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
734 vd = (vector unsigned char)vec_perm(vtemp1, vtemp2, mergePermute); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
735 } while (0) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
736 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
737 /* Calculate the permute vector used for 32->32 swizzling */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
738 static vector unsigned char |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
739 calc_swizzle32 (const SDL_PixelFormat * srcfmt, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
740 const SDL_PixelFormat * dstfmt) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
741 { |
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 * 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
|
744 * 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
|
745 * 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
|
746 */ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
747 /* ARGB */ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
748 const static struct SDL_PixelFormat default_pixel_format = { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
749 NULL, 0, 0, |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
750 0, 0, 0, 0, |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
751 16, 8, 0, 24, |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
752 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
753 0, 0 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
754 }; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
755 if (!srcfmt) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
756 srcfmt = &default_pixel_format; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
757 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
758 if (!dstfmt) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
759 dstfmt = &default_pixel_format; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
760 } |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
761 const vector unsigned char plus = VECUINT8_LITERAL |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
762 (0x00, 0x00, 0x00, 0x00, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
763 0x04, 0x04, 0x04, 0x04, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
764 0x08, 0x08, 0x08, 0x08, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
765 0x0C, 0x0C, 0x0C, 0x0C); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
766 vector unsigned char vswiz; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
767 vector unsigned int srcvec; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
768 #define RESHIFT(X) (3 - ((X) >> 3)) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
769 Uint32 rmask = RESHIFT (srcfmt->Rshift) << (dstfmt->Rshift); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
770 Uint32 gmask = RESHIFT (srcfmt->Gshift) << (dstfmt->Gshift); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
771 Uint32 bmask = RESHIFT (srcfmt->Bshift) << (dstfmt->Bshift); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
772 Uint32 amask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
773 /* 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
|
774 if (dstfmt->Amask) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
775 amask = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
776 ((srcfmt->Amask) ? RESHIFT (srcfmt->Ashift) : 0x10) << (dstfmt-> |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
777 Ashift); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
778 } else { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
779 amask = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
780 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
781 0xFFFFFFFF); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
782 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
783 #undef RESHIFT |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
784 ((unsigned int *) (char *) &srcvec)[0] = (rmask | gmask | bmask | amask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
785 vswiz = vec_add (plus, (vector unsigned char) vec_splat (srcvec, 0)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
786 return (vswiz); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
787 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
788 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
789 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
790 Blit32to565PixelAlphaAltivec (SDL_BlitInfo * info) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
791 { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
792 int height = info->d_height; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
793 Uint8 *src = (Uint8 *) info->s_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
794 int srcskip = info->s_skip; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
795 Uint8 *dst = (Uint8 *) info->d_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
796 int dstskip = info->d_skip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
797 SDL_PixelFormat *srcfmt = info->src; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
798 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
799 vector unsigned char v0 = vec_splat_u8 (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
800 vector unsigned short v8_16 = vec_splat_u16 (8); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
801 vector unsigned short v1_16 = vec_splat_u16 (1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
802 vector unsigned short v2_16 = vec_splat_u16 (2); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
803 vector unsigned short v3_16 = vec_splat_u16 (3); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
804 vector unsigned int v8_32 = vec_splat_u32 (8); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
805 vector unsigned int v16_32 = vec_add (v8_32, v8_32); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
806 vector unsigned short v3f = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
807 VECUINT16_LITERAL (0x003f, 0x003f, 0x003f, 0x003f, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
808 0x003f, 0x003f, 0x003f, 0x003f); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
809 vector unsigned short vfc = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
810 VECUINT16_LITERAL (0x00fc, 0x00fc, 0x00fc, 0x00fc, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
811 0x00fc, 0x00fc, 0x00fc, 0x00fc); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
812 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
813 /* |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
814 0x10 - 0x1f is the alpha |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
815 0x00 - 0x0e evens are the red |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
816 0x01 - 0x0f odds are zero |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
817 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
818 vector unsigned char vredalpha1 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
819 VECUINT8_LITERAL (0x10, 0x00, 0x01, 0x01, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
820 0x10, 0x02, 0x01, 0x01, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
821 0x10, 0x04, 0x01, 0x01, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
822 0x10, 0x06, 0x01, 0x01); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
823 vector unsigned char vredalpha2 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
824 (vector unsigned char) (vec_add ((vector unsigned int) vredalpha1, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
825 vec_sl (v8_32, v16_32)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
826 ); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
827 /* |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
828 0x00 - 0x0f is ARxx ARxx ARxx ARxx |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
829 0x11 - 0x0f odds are blue |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
830 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
831 vector unsigned char vblue1 = VECUINT8_LITERAL (0x00, 0x01, 0x02, 0x11, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
832 0x04, 0x05, 0x06, 0x13, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
833 0x08, 0x09, 0x0a, 0x15, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
834 0x0c, 0x0d, 0x0e, 0x17); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
835 vector unsigned char vblue2 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
836 (vector unsigned char) (vec_add ((vector unsigned int) vblue1, v8_32) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
837 ); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
838 /* |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
839 0x00 - 0x0f is ARxB ARxB ARxB ARxB |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
840 0x10 - 0x0e evens are green |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
841 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
842 vector unsigned char vgreen1 = VECUINT8_LITERAL (0x00, 0x01, 0x10, 0x03, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
843 0x04, 0x05, 0x12, 0x07, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
844 0x08, 0x09, 0x14, 0x0b, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
845 0x0c, 0x0d, 0x16, 0x0f); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
846 vector unsigned char vgreen2 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
847 (vector unsigned |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
848 char) (vec_add ((vector unsigned int) vgreen1, vec_sl (v8_32, v8_32)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
849 ); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
850 vector unsigned char vgmerge = VECUINT8_LITERAL (0x00, 0x02, 0x00, 0x06, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
851 0x00, 0x0a, 0x00, 0x0e, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
852 0x00, 0x12, 0x00, 0x16, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
853 0x00, 0x1a, 0x00, 0x1e); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
854 vector unsigned char mergePermute = VEC_MERGE_PERMUTE (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
855 vector unsigned char vpermute = calc_swizzle32 (srcfmt, NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
856 vector unsigned char valphaPermute = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
857 vec_and (vec_lvsl (0, (int *) NULL), vec_splat_u8 (0xC)); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
858 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
859 vector unsigned short vf800 = (vector unsigned short) vec_splat_u8 (-7); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
860 vf800 = vec_sl (vf800, vec_splat_u16 (8)); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
861 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
862 while (height--) { |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
863 int extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
864 vector unsigned char valigner; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
865 vector unsigned char vsrc; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
866 vector unsigned char voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
867 int width = info->d_width; |
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 #define ONE_PIXEL_BLEND(condition, widthvar) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
870 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
|
871 Uint32 Pixel; \ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
872 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
|
873 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
|
874 if(sA) { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
875 unsigned short dstpixel = *((unsigned short *)dst); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
876 dR = (dstpixel >> 8) & 0xf8; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
877 dG = (dstpixel >> 3) & 0xfc; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
878 dB = (dstpixel << 3) & 0xf8; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
879 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
880 *((unsigned short *)dst) = ( \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
881 ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
882 ); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
883 } \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
884 src += 4; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
885 dst += 2; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
886 widthvar--; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
887 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
888 ONE_PIXEL_BLEND ((UNALIGNED_PTR (dst)) && (width), width); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
889 extrawidth = (width % 8); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
890 valigner = VEC_ALIGNER (src); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
891 vsrc = (vector unsigned char) vec_ld (0, src); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
892 width -= extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
893 while (width) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
894 vector unsigned char valpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
895 vector unsigned char vsrc1, vsrc2; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
896 vector unsigned char vdst1, vdst2; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
897 vector unsigned short vR, vG, vB; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
898 vector unsigned short vpixel, vrpixel, vgpixel, vbpixel; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
899 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
900 /* Load 8 pixels from src as ARGB */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
901 voverflow = (vector unsigned char) vec_ld (15, src); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
902 vsrc = vec_perm (vsrc, voverflow, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
903 vsrc1 = vec_perm (vsrc, vsrc, vpermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
904 src += 16; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
905 vsrc = (vector unsigned char) vec_ld (15, src); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
906 voverflow = vec_perm (voverflow, vsrc, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
907 vsrc2 = vec_perm (voverflow, voverflow, vpermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
908 src += 16; |
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 /* Load 8 pixels from dst as XRGB */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
911 voverflow = vec_ld (0, dst); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
912 vR = vec_and ((vector unsigned short) voverflow, vf800); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
913 vB = vec_sl ((vector unsigned short) voverflow, v3_16); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
914 vG = vec_sl (vB, v2_16); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
915 vdst1 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
916 (vector unsigned char) vec_perm ((vector unsigned char) vR, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
917 (vector unsigned char) vR, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
918 vredalpha1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
919 vdst1 = vec_perm (vdst1, (vector unsigned char) vB, vblue1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
920 vdst1 = vec_perm (vdst1, (vector unsigned char) vG, vgreen1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
921 vdst2 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
922 (vector unsigned char) vec_perm ((vector unsigned char) vR, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
923 (vector unsigned char) vR, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
924 vredalpha2); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
925 vdst2 = vec_perm (vdst2, (vector unsigned char) vB, vblue2); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
926 vdst2 = vec_perm (vdst2, (vector unsigned char) vG, vgreen2); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
927 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
928 /* Alpha blend 8 pixels as ARGB */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
929 valpha = vec_perm (vsrc1, v0, valphaPermute); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
930 VEC_MULTIPLY_ALPHA (vsrc1, vdst1, valpha, mergePermute, v1_16, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
931 v8_16); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
932 valpha = vec_perm (vsrc2, v0, valphaPermute); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
933 VEC_MULTIPLY_ALPHA (vsrc2, vdst2, valpha, mergePermute, v1_16, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
934 v8_16); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
935 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
936 /* Convert 8 pixels to 565 */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
937 vpixel = (vector unsigned short) vec_packpx ((vector unsigned int) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
938 vdst1, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
939 (vector unsigned int) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
940 vdst2); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
941 vgpixel = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
942 (vector unsigned short) vec_perm (vdst1, vdst2, vgmerge); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
943 vgpixel = vec_and (vgpixel, vfc); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
944 vgpixel = vec_sl (vgpixel, v3_16); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
945 vrpixel = vec_sl (vpixel, v1_16); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
946 vrpixel = vec_and (vrpixel, vf800); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
947 vbpixel = vec_and (vpixel, v3f); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
948 vdst1 = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
949 vec_or ((vector unsigned char) vrpixel, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
950 (vector unsigned char) vgpixel); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
951 vdst1 = vec_or (vdst1, (vector unsigned char) vbpixel); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
952 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
953 /* Store 8 pixels */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
954 vec_st (vdst1, 0, dst); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
955 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
956 width -= 8; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
957 dst += 16; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
958 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
959 ONE_PIXEL_BLEND ((extrawidth), extrawidth); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
960 #undef ONE_PIXEL_BLEND |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
961 src += srcskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
962 dst += dstskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
963 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
964 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
965 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
966 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
967 Blit32to32SurfaceAlphaKeyAltivec (SDL_BlitInfo * info) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
968 { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
969 unsigned alpha = info->src->alpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
970 int height = info->d_height; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
971 Uint32 *srcp = (Uint32 *) info->s_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
972 int srcskip = info->s_skip >> 2; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
973 Uint32 *dstp = (Uint32 *) info->d_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
974 int dstskip = info->d_skip >> 2; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
975 SDL_PixelFormat *srcfmt = info->src; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
976 SDL_PixelFormat *dstfmt = info->dst; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
977 unsigned sA = srcfmt->alpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
978 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
979 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
980 Uint32 ckey = info->src->colorkey; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
981 vector unsigned char mergePermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
982 vector unsigned char vsrcPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
983 vector unsigned char vdstPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
984 vector unsigned char vsdstPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
985 vector unsigned char valpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
986 vector unsigned char valphamask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
987 vector unsigned char vbits; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
988 vector unsigned char v0; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
989 vector unsigned short v1; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
990 vector unsigned short v8; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
991 vector unsigned int vckey; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
992 vector unsigned int vrgbmask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
993 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
994 mergePermute = VEC_MERGE_PERMUTE (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
995 v0 = vec_splat_u8 (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
996 v1 = vec_splat_u16 (1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
997 v8 = vec_splat_u16 (8); |
1047
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 /* set the alpha to 255 on the destination surf */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1000 valphamask = VEC_ALPHA_MASK (); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1001 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1002 vsrcPermute = calc_swizzle32 (srcfmt, NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1003 vdstPermute = calc_swizzle32 (NULL, dstfmt); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1004 vsdstPermute = calc_swizzle32 (dstfmt, NULL); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1005 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1006 /* set a vector full of alpha and 255-alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1007 ((unsigned char *) &valpha)[0] = alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1008 valpha = vec_splat (valpha, 0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1009 vbits = (vector unsigned char) vec_splat_s8 (-1); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1010 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1011 ckey &= rgbmask; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1012 ((unsigned int *) (char *) &vckey)[0] = ckey; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1013 vckey = vec_splat (vckey, 0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1014 ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1015 vrgbmask = vec_splat (vrgbmask, 0); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1016 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1017 while (height--) { |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1018 int width = info->d_width; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1019 #define ONE_PIXEL_BLEND(condition, widthvar) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1020 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
|
1021 Uint32 Pixel; \ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1028 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1029 } \ |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
1030 dstp++; \ |
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
1031 srcp++; \ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1032 widthvar--; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1033 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1034 ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1035 if (width > 0) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1036 int extrawidth = (width % 4); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1037 vector unsigned char valigner = VEC_ALIGNER (srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1038 vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1039 width -= extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1040 while (width) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1041 vector unsigned char vsel; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1042 vector unsigned char voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1043 vector unsigned char vd; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1044 vector unsigned char vd_orig; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1045 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1046 /* s = *srcp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1047 voverflow = (vector unsigned char) vec_ld (15, srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1048 vs = vec_perm (vs, voverflow, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1049 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1050 /* vsel is set for items that match the key */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1051 vsel = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1052 (vector unsigned char) vec_and ((vector unsigned int) vs, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1053 vrgbmask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1054 vsel = (vector unsigned char) vec_cmpeq ((vector unsigned int) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1055 vsel, vckey); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1056 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1057 /* permute to source format */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1058 vs = vec_perm (vs, valpha, vsrcPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1059 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1060 /* d = *dstp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1061 vd = (vector unsigned char) vec_ld (0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1062 vd_orig = vd = vec_perm (vd, v0, vsdstPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1063 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1064 VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1065 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1066 /* set the alpha channel to full on */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1067 vd = vec_or (vd, valphamask); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1068 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1069 /* mask out color key */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1070 vd = vec_sel (vd, vd_orig, vsel); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1071 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1072 /* permute to dest format */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1073 vd = vec_perm (vd, vbits, vdstPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1074 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1075 /* *dstp = res */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1076 vec_st ((vector unsigned int) vd, 0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1077 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1078 srcp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1079 dstp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1080 width -= 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1081 vs = voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1082 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1083 ONE_PIXEL_BLEND ((extrawidth), extrawidth); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1084 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1085 #undef ONE_PIXEL_BLEND |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1086 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1087 srcp += srcskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1088 dstp += dstskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1089 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1090 } |
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 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1093 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1094 Blit32to32PixelAlphaAltivec (SDL_BlitInfo * info) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1095 { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1096 int width = info->d_width; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1097 int height = info->d_height; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1098 Uint32 *srcp = (Uint32 *) info->s_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1099 int srcskip = info->s_skip >> 2; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1100 Uint32 *dstp = (Uint32 *) info->d_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1101 int dstskip = info->d_skip >> 2; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1102 SDL_PixelFormat *srcfmt = info->src; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1103 SDL_PixelFormat *dstfmt = info->dst; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1104 vector unsigned char mergePermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1105 vector unsigned char valphaPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1106 vector unsigned char vsrcPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1107 vector unsigned char vdstPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1108 vector unsigned char vsdstPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1109 vector unsigned char valphamask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1110 vector unsigned char vpixelmask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1111 vector unsigned char v0; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1112 vector unsigned short v1; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1113 vector unsigned short v8; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1114 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1115 v0 = vec_splat_u8 (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1116 v1 = vec_splat_u16 (1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1117 v8 = vec_splat_u16 (8); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1118 mergePermute = VEC_MERGE_PERMUTE (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1119 valphamask = VEC_ALPHA_MASK (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1120 valphaPermute = vec_and (vec_lvsl (0, (int *) NULL), vec_splat_u8 (0xC)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1121 vpixelmask = vec_nor (valphamask, v0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1122 vsrcPermute = calc_swizzle32 (srcfmt, NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1123 vdstPermute = calc_swizzle32 (NULL, dstfmt); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1124 vsdstPermute = calc_swizzle32 (dstfmt, NULL); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1125 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1126 while (height--) { |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1127 width = info->d_width; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1128 #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
|
1129 Uint32 Pixel; \ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1130 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
|
1131 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
|
1132 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
|
1133 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
|
1134 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1135 ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \ |
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 ++srcp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1138 ++dstp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1139 widthvar--; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1140 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1141 ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1142 if (width > 0) { |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
1143 /* vsrcPermute */ |
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
1144 /* vdstPermute */ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1145 int extrawidth = (width % 4); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1146 vector unsigned char valigner = VEC_ALIGNER (srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1147 vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1148 width -= extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1149 while (width) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1150 vector unsigned char voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1151 vector unsigned char vd; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1152 vector unsigned char valpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1153 vector unsigned char vdstalpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1154 /* s = *srcp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1155 voverflow = (vector unsigned char) vec_ld (15, srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1156 vs = vec_perm (vs, voverflow, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1157 vs = vec_perm (vs, v0, vsrcPermute); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1158 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1159 valpha = vec_perm (vs, v0, valphaPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1160 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1161 /* d = *dstp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1162 vd = (vector unsigned char) vec_ld (0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1163 vd = vec_perm (vd, v0, vsdstPermute); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1164 vdstalpha = vec_and (vd, valphamask); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1165 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1166 VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); |
1047
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 /* set the alpha to the dest alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1169 vd = vec_and (vd, vpixelmask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1170 vd = vec_or (vd, vdstalpha); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1171 vd = vec_perm (vd, v0, vdstPermute); |
1047
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 /* *dstp = res */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1174 vec_st ((vector unsigned int) vd, 0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1175 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1176 srcp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1177 dstp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1178 width -= 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1179 vs = voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1180 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1181 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1182 ONE_PIXEL_BLEND ((extrawidth), extrawidth); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1183 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1184 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1185 dstp += dstskip; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1186 #undef ONE_PIXEL_BLEND |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1187 } |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1188 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1189 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1190 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1191 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1192 BlitRGBtoRGBPixelAlphaAltivec (SDL_BlitInfo * info) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1193 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1194 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1195 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1196 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1197 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1198 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1199 int dstskip = info->d_skip >> 2; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1200 vector unsigned char mergePermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1201 vector unsigned char valphaPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1202 vector unsigned char valphamask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1203 vector unsigned char vpixelmask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1204 vector unsigned char v0; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1205 vector unsigned short v1; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1206 vector unsigned short v8; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1207 v0 = vec_splat_u8 (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1208 v1 = vec_splat_u16 (1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1209 v8 = vec_splat_u16 (8); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1210 mergePermute = VEC_MERGE_PERMUTE (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1211 valphamask = VEC_ALPHA_MASK (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1212 valphaPermute = vec_and (vec_lvsl (0, (int *) NULL), vec_splat_u8 (0xC)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1213 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1214 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1215 vpixelmask = vec_nor (valphamask, v0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1216 while (height--) { |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1217 width = info->d_width; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1218 #define ONE_PIXEL_BLEND(condition, widthvar) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1219 while ((condition)) { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1220 Uint32 dalpha; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1221 Uint32 d; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1222 Uint32 s1; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1223 Uint32 d1; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1224 Uint32 s = *srcp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1225 Uint32 alpha = s >> 24; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1226 if(alpha) { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1227 if(alpha == SDL_ALPHA_OPAQUE) { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1228 *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1229 } else { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1230 d = *dstp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1231 dalpha = d & 0xff000000; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1232 s1 = s & 0xff00ff; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1233 d1 = d & 0xff00ff; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1234 d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1235 s &= 0xff00; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1236 d &= 0xff00; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1237 d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1238 *dstp = d1 | d | dalpha; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1239 } \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1240 } \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1241 ++srcp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1242 ++dstp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1243 widthvar--; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1244 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1245 ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1246 if (width > 0) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1247 int extrawidth = (width % 4); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1248 vector unsigned char valigner = VEC_ALIGNER (srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1249 vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1250 width -= extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1251 while (width) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1252 vector unsigned char voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1253 vector unsigned char vd; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1254 vector unsigned char valpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1255 vector unsigned char vdstalpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1256 /* s = *srcp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1257 voverflow = (vector unsigned char) vec_ld (15, srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1258 vs = vec_perm (vs, voverflow, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1259 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1260 valpha = vec_perm (vs, v0, valphaPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1261 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1262 /* d = *dstp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1263 vd = (vector unsigned char) vec_ld (0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1264 vdstalpha = vec_and (vd, valphamask); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1265 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1266 VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1267 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1268 /* set the alpha to the dest alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1269 vd = vec_and (vd, vpixelmask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1270 vd = vec_or (vd, vdstalpha); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1271 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1272 /* *dstp = res */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1273 vec_st ((vector unsigned int) vd, 0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1274 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1275 srcp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1276 dstp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1277 width -= 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1278 vs = voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1279 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1280 ONE_PIXEL_BLEND ((extrawidth), extrawidth); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1281 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1282 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1283 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1284 } |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1285 #undef ONE_PIXEL_BLEND |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1286 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1287 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1288 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1289 Blit32to32SurfaceAlphaAltivec (SDL_BlitInfo * info) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1290 { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1291 /* XXX : 6 */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1292 unsigned alpha = info->src->alpha; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1293 int height = info->d_height; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1294 Uint32 *srcp = (Uint32 *) info->s_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1295 int srcskip = info->s_skip >> 2; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1296 Uint32 *dstp = (Uint32 *) info->d_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1297 int dstskip = info->d_skip >> 2; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1298 SDL_PixelFormat *srcfmt = info->src; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1299 SDL_PixelFormat *dstfmt = info->dst; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1300 unsigned sA = srcfmt->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1301 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1302 vector unsigned char mergePermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1303 vector unsigned char vsrcPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1304 vector unsigned char vdstPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1305 vector unsigned char vsdstPermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1306 vector unsigned char valpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1307 vector unsigned char valphamask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1308 vector unsigned char vbits; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1309 vector unsigned short v1; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1310 vector unsigned short v8; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1311 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1312 mergePermute = VEC_MERGE_PERMUTE (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1313 v1 = vec_splat_u16 (1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1314 v8 = vec_splat_u16 (8); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1315 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1316 /* set the alpha to 255 on the destination surf */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1317 valphamask = VEC_ALPHA_MASK (); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1318 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1319 vsrcPermute = calc_swizzle32 (srcfmt, NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1320 vdstPermute = calc_swizzle32 (NULL, dstfmt); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1321 vsdstPermute = calc_swizzle32 (dstfmt, NULL); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1322 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1323 /* set a vector full of alpha and 255-alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1324 ((unsigned char *) &valpha)[0] = alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1325 valpha = vec_splat (valpha, 0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1326 vbits = (vector unsigned char) vec_splat_s8 (-1); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1327 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1328 while (height--) { |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1329 int width = info->d_width; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1330 #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
|
1331 Uint32 Pixel; \ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1332 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
|
1333 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
|
1334 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
|
1335 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1336 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1337 ++srcp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1338 ++dstp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1339 widthvar--; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1340 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1341 ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1342 if (width > 0) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1343 int extrawidth = (width % 4); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1344 vector unsigned char valigner = vec_lvsl (0, srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1345 vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1346 width -= extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1347 while (width) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1348 vector unsigned char voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1349 vector unsigned char vd; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1350 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1351 /* s = *srcp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1352 voverflow = (vector unsigned char) vec_ld (15, srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1353 vs = vec_perm (vs, voverflow, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1354 vs = vec_perm (vs, valpha, vsrcPermute); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1355 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1356 /* d = *dstp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1357 vd = (vector unsigned char) vec_ld (0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1358 vd = vec_perm (vd, vd, vsdstPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1359 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1360 VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1361 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1362 /* set the alpha channel to full on */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1363 vd = vec_or (vd, valphamask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1364 vd = vec_perm (vd, vbits, vdstPermute); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1365 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1366 /* *dstp = res */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1367 vec_st ((vector unsigned int) vd, 0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1368 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1369 srcp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1370 dstp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1371 width -= 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1372 vs = voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1373 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1374 ONE_PIXEL_BLEND ((extrawidth), extrawidth); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1375 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1376 #undef ONE_PIXEL_BLEND |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1377 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1378 srcp += srcskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1379 dstp += dstskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1380 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1381 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1382 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1383 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1384 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1385 /* fast RGB888->(A)RGB888 blending */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1386 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1387 BlitRGBtoRGBSurfaceAlphaAltivec (SDL_BlitInfo * info) |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1388 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1389 unsigned alpha = info->src->alpha; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1390 int height = info->d_height; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1391 Uint32 *srcp = (Uint32 *) info->s_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1392 int srcskip = info->s_skip >> 2; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1393 Uint32 *dstp = (Uint32 *) info->d_pixels; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1394 int dstskip = info->d_skip >> 2; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1395 vector unsigned char mergePermute; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1396 vector unsigned char valpha; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1397 vector unsigned char valphamask; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1398 vector unsigned short v1; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1399 vector unsigned short v8; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1400 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1401 mergePermute = VEC_MERGE_PERMUTE (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1402 v1 = vec_splat_u16 (1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1403 v8 = vec_splat_u16 (8); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1404 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1405 /* set the alpha to 255 on the destination surf */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1406 valphamask = VEC_ALPHA_MASK (); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1407 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1408 /* set a vector full of alpha and 255-alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1409 ((unsigned char *) &valpha)[0] = alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1410 valpha = vec_splat (valpha, 0); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1411 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1412 while (height--) { |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1413 int width = info->d_width; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1414 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1415 Uint32 s = *srcp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1416 Uint32 d = *dstp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1417 Uint32 s1 = s & 0xff00ff; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1418 Uint32 d1 = d & 0xff00ff; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1419 d1 = (d1 + ((s1 - d1) * alpha >> 8)) \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1420 & 0xff00ff; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1421 s &= 0xff00; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1422 d &= 0xff00; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1423 d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1424 *dstp = d1 | d | 0xff000000; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1425 ++srcp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1426 ++dstp; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1427 widthvar--; \ |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1428 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1429 ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1430 if (width > 0) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1431 int extrawidth = (width % 4); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1432 vector unsigned char valigner = VEC_ALIGNER (srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1433 vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1434 width -= extrawidth; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1435 while (width) { |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1436 vector unsigned char voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1437 vector unsigned char vd; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1438 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1439 /* s = *srcp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1440 voverflow = (vector unsigned char) vec_ld (15, srcp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1441 vs = vec_perm (vs, voverflow, valigner); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1442 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1443 /* d = *dstp */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1444 vd = (vector unsigned char) vec_ld (0, dstp); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1445 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1446 VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1447 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1448 /* set the alpha channel to full on */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1449 vd = vec_or (vd, valphamask); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1450 |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1451 /* *dstp = res */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1452 vec_st ((vector unsigned int) vd, 0, dstp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1453 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1454 srcp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1455 dstp += 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1456 width -= 4; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1457 vs = voverflow; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1458 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1459 ONE_PIXEL_BLEND ((extrawidth), extrawidth); |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1460 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1461 #undef ONE_PIXEL_BLEND |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1462 |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1463 srcp += srcskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1464 dstp += dstskip; |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1465 } |
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1466 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1467 |
1659 | 1468 #if __MWERKS__ |
1469 #pragma altivec_model off | |
1470 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
1471 #endif /* SDL_ALTIVEC_BLITTERS */ |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
1472 |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1473 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1474 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1475 BlitRGBtoRGBSurfaceAlpha128 (SDL_BlitInfo * info) |
0 | 1476 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1477 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1478 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1479 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1480 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1481 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1482 int dstskip = info->d_skip >> 2; |
0 | 1483 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1484 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1485 /* *INDENT-OFF* */ |
0 | 1486 DUFFS_LOOP4({ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1487 Uint32 s = *srcp++; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1488 Uint32 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1489 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1490 + (s & d & 0x00010101)) | 0xff000000; |
0 | 1491 }, width); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1492 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1493 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1494 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1495 } |
0 | 1496 } |
1497 | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1498 /* fast RGB888->(A)RGB888 blending with surface alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1499 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1500 BlitRGBtoRGBSurfaceAlpha (SDL_BlitInfo * info) |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1501 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1502 unsigned alpha = info->src->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1503 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1504 BlitRGBtoRGBSurfaceAlpha128 (info); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1505 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1506 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1507 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1508 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1509 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1510 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1511 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1512 Uint32 s; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1513 Uint32 d; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1514 Uint32 s1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1515 Uint32 d1; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1516 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1517 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1518 /* *INDENT-OFF* */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1519 DUFFS_LOOP_DOUBLE2({ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1520 /* One Pixel Blend */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1521 s = *srcp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1522 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1523 s1 = s & 0xff00ff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1524 d1 = d & 0xff00ff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1525 d1 = (d1 + ((s1 - d1) * alpha >> 8)) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1526 & 0xff00ff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1527 s &= 0xff00; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1528 d &= 0xff00; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1529 d = (d + ((s - d) * alpha >> 8)) & 0xff00; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1530 *dstp = d1 | d | 0xff000000; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1531 ++srcp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1532 ++dstp; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1533 },{ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1534 /* Two Pixels Blend */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1535 s = *srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1536 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1537 s1 = s & 0xff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1538 d1 = d & 0xff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1539 d1 += (s1 - d1) * alpha >> 8; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1540 d1 &= 0xff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1541 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1542 s = ((s & 0xff00) >> 8) | |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1543 ((srcp[1] & 0xff00) << 8); |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1544 d = ((d & 0xff00) >> 8) | |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1545 ((dstp[1] & 0xff00) << 8); |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1546 d += (s - d) * alpha >> 8; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1547 d &= 0x00ff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1548 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1549 *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
|
1550 ++srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1551 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1552 s1 = *srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1553 d1 = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1554 s1 &= 0xff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1555 d1 &= 0xff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1556 d1 += (s1 - d1) * alpha >> 8; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1557 d1 &= 0xff00ff; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1558 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1559 *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
|
1560 ++srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1561 ++dstp; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1562 }, width); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1563 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1564 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1565 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1566 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1567 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1568 } |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1569 |
0 | 1570 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1571 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1572 BlitRGBtoRGBPixelAlpha (SDL_BlitInfo * info) |
0 | 1573 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1574 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1575 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1576 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1577 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1578 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1579 int dstskip = info->d_skip >> 2; |
0 | 1580 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1581 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1582 /* *INDENT-OFF* */ |
0 | 1583 DUFFS_LOOP4({ |
1584 Uint32 dalpha; | |
1585 Uint32 d; | |
1586 Uint32 s1; | |
1587 Uint32 d1; | |
1588 Uint32 s = *srcp; | |
1589 Uint32 alpha = s >> 24; | |
1590 /* FIXME: Here we special-case opaque alpha since the | |
1591 compositioning used (>>8 instead of /255) doesn't handle | |
1592 it correctly. Also special-case alpha=0 for speed? | |
1593 Benchmark this! */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1594 if(alpha) { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1595 if(alpha == SDL_ALPHA_OPAQUE) { |
0 | 1596 *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
|
1597 } else { |
0 | 1598 /* |
1599 * take out the middle component (green), and process | |
1600 * the other two in parallel. One multiply less. | |
1601 */ | |
1602 d = *dstp; | |
1603 dalpha = d & 0xff000000; | |
1604 s1 = s & 0xff00ff; | |
1605 d1 = d & 0xff00ff; | |
1606 d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; | |
1607 s &= 0xff00; | |
1608 d &= 0xff00; | |
1609 d = (d + ((s - d) * alpha >> 8)) & 0xff00; | |
1610 *dstp = d1 | d | dalpha; | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1611 } |
0 | 1612 } |
1613 ++srcp; | |
1614 ++dstp; | |
1615 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1616 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1617 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1618 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1619 } |
0 | 1620 } |
1621 | |
1542 | 1622 #if GCC_ASMBLIT |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1623 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1624 inline static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1625 BlitRGBtoRGBPixelAlphaMMX3DNOW (SDL_BlitInfo * info) |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1626 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1627 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1628 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1629 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1630 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1631 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1632 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1633 SDL_PixelFormat *sf = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1634 Uint32 amask = sf->Amask; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1635 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1636 __asm__ ( |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1637 /* make mm6 all zeros. */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1638 "pxor %%mm6, %%mm6\n" |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1639 /* Make a mask to preserve the alpha. */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1640 "movd %0, %%mm7\n\t" /* 0000F000 -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1641 "punpcklbw %%mm7, %%mm7\n\t" /* FF000000 -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1642 "pcmpeqb %%mm4, %%mm4\n\t" /* FFFFFFFF -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1643 "movq %%mm4, %%mm3\n\t" /* FFFFFFFF -> mm3 (for later) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1644 "pxor %%mm4, %%mm7\n\t" /* 00FFFFFF -> mm7 (mult mask) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1645 /* form channel masks */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1646 "movq %%mm7, %%mm4\n\t" /* 00FFFFFF -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1647 "packsswb %%mm6, %%mm4\n\t" /* 00000FFF -> mm4 (channel mask) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1648 "packsswb %%mm6, %%mm3\n\t" /* 0000FFFF -> mm3 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1649 "pxor %%mm4, %%mm3\n\t" /* 0000F000 -> mm3 (~channel mask) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1650 /* get alpha channel shift */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1651 "movd %1, %%mm5\n\t" /* Ashift -> mm5 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1652 : /* nothing */ : "m" (sf->Amask), "m" (sf->Ashift)); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1653 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1654 while (height--) { |
1542 | 1655 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1656 /* *INDENT-OFF* */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1657 DUFFS_LOOP4({ |
1542 | 1658 Uint32 alpha; |
689
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 __asm__ ( |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1661 "prefetch 64(%0)\n" |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1662 "prefetch 64(%1)\n" |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1663 : : "r" (srcp), "r" (dstp) ); |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1664 |
1542 | 1665 alpha = *srcp & amask; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1666 /* 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
|
1667 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
|
1668 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
|
1669 Benchmark this! */ |
1542 | 1670 if(alpha == 0) { |
1671 /* do nothing */ | |
1672 } | |
1673 else if(alpha == amask) { | |
1674 /* opaque alpha -- copy RGB, keep dst alpha */ | |
1675 /* using MMX here to free up regular registers for other things */ | |
1676 __asm__ ( | |
1677 "movd (%0), %%mm0\n\t" /* src(ARGB) -> mm0 (0000ARGB)*/ | |
1678 "movd (%1), %%mm1\n\t" /* dst(ARGB) -> mm1 (0000ARGB)*/ | |
1679 "pand %%mm4, %%mm0\n\t" /* src & chanmask -> mm0 */ | |
1680 "pand %%mm3, %%mm1\n\t" /* dst & ~chanmask -> mm2 */ | |
1681 "por %%mm0, %%mm1\n\t" /* src | dst -> mm1 */ | |
1682 "movd %%mm1, (%1) \n\t" /* mm1 -> dst */ | |
1683 | |
1684 : : "r" (srcp), "r" (dstp) ); | |
689
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 else { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1688 __asm__ ( |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1689 /* 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
|
1690 "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
|
1691 "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
|
1692 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1693 /* 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
|
1694 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1695 /* if supporting pshufw */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1696 /*"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
|
1697 /*"psrlw $8, %%mm2\n" */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1698 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1699 /* else: */ |
1542 | 1700 "movd %2, %%mm2\n" |
1701 "psrld %%mm5, %%mm2\n" /* mm2 = 0 0 0 0 | 0 0 0 As */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1702 "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
|
1703 "punpckldq %%mm2, %%mm2\n" /* mm2 = 0 As 0 As | 0 As 0 As */ |
1542 | 1704 "pand %%mm7, %%mm2\n" /* to preserve dest alpha */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1705 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1706 /* move the colors into words. */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1707 "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
|
1708 "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
|
1709 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1710 /* src - dst */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1711 "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
|
1712 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1713 /* A * (src-dst) */ |
1542 | 1714 "pmullw %%mm2, %%mm0\n" /* mm0 = 0*As-d As*Rs-d | As*Gs-d As*Bs-d */ |
1715 "psrlw $8, %%mm0\n" /* mm0 = 0>>8 Rc>>8 | Gc>>8 Bc>>8 */ | |
1716 "paddb %%mm1, %%mm0\n" /* mm0 = 0+Ad Rc+Rd | Gc+Gd Bc+Bd */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1717 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1718 "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
|
1719 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1720 "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
|
1721 |
1542 | 1722 : : "r" (srcp), "r" (dstp), "r" (alpha) ); |
689
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 } |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1725 ++srcp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1726 ++dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1727 }, width); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1728 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1729 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1730 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1731 } |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1732 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1733 __asm__ ("emms\n":); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1734 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1735 |
1542 | 1736 /* End GCC_ASMBLIT*/ |
1737 | |
1738 #elif MSVC_ASMBLIT | |
1739 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1740 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1741 BlitRGBtoRGBPixelAlphaMMX3DNOW (SDL_BlitInfo * info) |
1542 | 1742 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1743 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1744 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1745 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1746 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1747 Uint32 *dstp = (Uint32 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1748 int dstskip = info->d_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1749 SDL_PixelFormat *sf = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1750 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1751 Uint32 amask = sf->Amask; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1752 Uint32 ashift = sf->Ashift; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1753 Uint64 multmask; |
1542 | 1754 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1755 __m64 src1, dst1, mm_alpha, mm_zero, dmask; |
1542 | 1756 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1757 mm_zero = _mm_setzero_si64 (); /* 0 -> mm_zero */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1758 multmask = ~(0xFFFFi 64 << (ashift * 2)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1759 dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1760 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1761 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1762 /* *INDENT-OFF* */ |
1542 | 1763 DUFFS_LOOP4({ |
1764 Uint32 alpha; | |
1765 | |
1766 _m_prefetch(srcp + 16); | |
1767 _m_prefetch(dstp + 16); | |
1768 | |
1769 alpha = *srcp & amask; | |
1770 if (alpha == 0) { | |
1771 /* do nothing */ | |
1772 } else if (alpha == amask) { | |
1773 /* copy RGB, keep dst alpha */ | |
1774 *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); | |
1775 } else { | |
1776 src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ | |
1777 src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ | |
1778 | |
1779 dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ | |
1780 dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ | |
1781 | |
1782 mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ | |
1783 mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ | |
1784 mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ | |
1785 mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ | |
1786 mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ | |
1787 | |
1788 /* blend */ | |
1789 src1 = _mm_sub_pi16(src1, dst1);/* src - dst -> src1 */ | |
1790 src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src - dst) * alpha -> src1 */ | |
1791 src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ | |
1792 dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst) -> dst1(0A0R0G0B) */ | |
1793 dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ | |
1794 | |
1795 *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ | |
1796 } | |
1797 ++srcp; | |
1798 ++dstp; | |
1799 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1800 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1801 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1802 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1803 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1804 _mm_empty (); |
1542 | 1805 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1806 |
1542 | 1807 /* End MSVC_ASMBLIT */ |
1808 | |
1809 #endif /* GCC_ASMBLIT, MSVC_ASMBLIT */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1810 |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1811 /* 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
|
1812 |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1813 /* 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
|
1814 #define BLEND16_50(d, s, mask) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1815 ((((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
|
1816 |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1817 /* blend two 16 bit pixels at 50% */ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1818 #define BLEND2x16_50(d, s, mask) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1819 (((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
|
1820 + (s & d & (~(mask | mask << 16)))) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1821 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1822 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1823 Blit16to16SurfaceAlpha128 (SDL_BlitInfo * info, Uint16 mask) |
0 | 1824 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1825 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1826 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1827 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1828 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1829 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1830 int dstskip = info->d_skip >> 1; |
0 | 1831 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1832 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1833 if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1834 /* |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1835 * Source and destination not aligned, pipeline it. |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1836 * This is mostly a win for big blits but no loss for |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1837 * small ones |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1838 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1839 Uint32 prev_sw; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1840 int w = width; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1841 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1842 /* handle odd destination */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1843 if ((uintptr_t) dstp & 2) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1844 Uint16 d = *dstp, s = *srcp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1845 *dstp = BLEND16_50 (d, s, mask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1846 dstp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1847 srcp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1848 w--; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1849 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1850 srcp++; /* srcp is now 32-bit aligned */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1851 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1852 /* bootstrap pipeline with first halfword */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1853 prev_sw = ((Uint32 *) srcp)[-1]; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1854 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1855 while (w > 1) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1856 Uint32 sw, dw, s; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1857 sw = *(Uint32 *) srcp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1858 dw = *(Uint32 *) dstp; |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
1859 #if SDL_BYTEORDER == SDL_BIG_ENDIAN |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1860 s = (prev_sw << 16) + (sw >> 16); |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
1861 #else |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1862 s = (prev_sw >> 16) + (sw << 16); |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
1863 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1864 prev_sw = sw; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1865 *(Uint32 *) dstp = BLEND2x16_50 (dw, s, mask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1866 dstp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1867 srcp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1868 w -= 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1869 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1870 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1871 /* final pixel if any */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1872 if (w) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1873 Uint16 d = *dstp, s; |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
1874 #if SDL_BYTEORDER == SDL_BIG_ENDIAN |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1875 s = (Uint16) prev_sw; |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
1876 #else |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1877 s = (Uint16) (prev_sw >> 16); |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
1878 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1879 *dstp = BLEND16_50 (d, s, mask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1880 srcp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1881 dstp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1882 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1883 srcp += srcskip - 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1884 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1885 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1886 /* source and destination are aligned */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1887 int w = width; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1888 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1889 /* first odd pixel? */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1890 if ((uintptr_t) srcp & 2) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1891 Uint16 d = *dstp, s = *srcp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1892 *dstp = BLEND16_50 (d, s, mask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1893 srcp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1894 dstp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1895 w--; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1896 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1897 /* srcp and dstp are now 32-bit aligned */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1898 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1899 while (w > 1) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1900 Uint32 sw = *(Uint32 *) srcp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1901 Uint32 dw = *(Uint32 *) dstp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1902 *(Uint32 *) dstp = BLEND2x16_50 (dw, sw, mask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1903 srcp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1904 dstp += 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1905 w -= 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1906 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1907 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1908 /* last odd pixel? */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1909 if (w) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1910 Uint16 d = *dstp, s = *srcp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1911 *dstp = BLEND16_50 (d, s, mask); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1912 srcp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1913 dstp++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1914 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1915 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1916 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1917 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1918 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1919 } |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1920 |
1542 | 1921 #if GCC_ASMBLIT |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1922 /* fast RGB565->RGB565 blending with surface alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1923 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1924 Blit565to565SurfaceAlphaMMX (SDL_BlitInfo * info) |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1925 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1926 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1927 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1928 Blit16to16SurfaceAlpha128 (info, 0xf7de); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1929 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1930 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1931 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1932 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1933 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1934 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1935 int dstskip = info->d_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1936 Uint32 s, d; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1937 Uint8 load[8]; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1938 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1939 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1940 *(Uint64 *) load = alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1941 alpha >>= 3; /* downscale alpha to 5 bits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1942 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1943 movq_m2r (*load, mm0); /* alpha(0000000A) -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1944 punpcklwd_r2r (mm0, mm0); /* 00000A0A -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1945 punpcklwd_r2r (mm0, mm0); /* 0A0A0A0A -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1946 /* position alpha to allow for mullo and mulhi on diff channels |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1947 to reduce the number of operations */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1948 psllq_i2r (3, mm0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1949 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1950 /* Setup the 565 color channel masks */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1951 *(Uint64 *) load = 0x07E007E007E007E0ULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1952 movq_m2r (*load, mm4); /* MASKGREEN -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1953 *(Uint64 *) load = 0x001F001F001F001FULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1954 movq_m2r (*load, mm7); /* MASKBLUE -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1955 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
1956 /* *INDENT-OFF* */ |
1542 | 1957 DUFFS_LOOP_QUATRO2( |
1958 { | |
1959 s = *srcp++; | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1960 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1961 /* |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1962 * 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
|
1963 * 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
|
1964 * components at the same time. |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1965 */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1966 s = (s | s << 16) & 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1967 d = (d | d << 16) & 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1968 d += (s - d) * alpha >> 5; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1969 d &= 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1970 *dstp++ = d | d >> 16; |
1542 | 1971 },{ |
1972 s = *srcp++; | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1973 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1974 /* |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1975 * 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
|
1976 * 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
|
1977 * components at the same time. |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1978 */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1979 s = (s | s << 16) & 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1980 d = (d | d << 16) & 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1981 d += (s - d) * alpha >> 5; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1982 d &= 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1983 *dstp++ = d | d >> 16; |
1542 | 1984 s = *srcp++; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1985 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1986 /* |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1987 * 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
|
1988 * 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
|
1989 * components at the same time. |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1990 */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1991 s = (s | s << 16) & 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1992 d = (d | d << 16) & 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1993 d += (s - d) * alpha >> 5; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1994 d &= 0x07e0f81f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1995 *dstp++ = d | d >> 16; |
1542 | 1996 },{ |
1997 movq_m2r((*srcp), mm2);/* 4 src pixels -> mm2 */ | |
1998 movq_m2r((*dstp), mm3);/* 4 dst pixels -> mm3 */ | |
1999 | |
2000 /* red -- does not need a mask since the right shift clears | |
2001 the uninteresting bits */ | |
2002 movq_r2r(mm2, mm5); /* src -> mm5 */ | |
2003 movq_r2r(mm3, mm6); /* dst -> mm6 */ | |
2004 psrlw_i2r(11, mm5); /* mm5 >> 11 -> mm5 [000r 000r 000r 000r] */ | |
2005 psrlw_i2r(11, mm6); /* mm6 >> 11 -> mm6 [000r 000r 000r 000r] */ | |
2006 | |
2007 /* blend */ | |
2008 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */ | |
2009 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */ | |
2010 /* alpha used is actually 11 bits | |
2011 11 + 5 = 16 bits, so the sign bits are lost */ | |
2012 psrlw_i2r(11, mm5); /* mm5 >> 11 -> mm5 */ | |
2013 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */ | |
2014 psllw_i2r(11, mm6); /* mm6 << 11 -> mm6 */ | |
2015 | |
2016 movq_r2r(mm6, mm1); /* save new reds in dsts */ | |
2017 | |
2018 /* green -- process the bits in place */ | |
2019 movq_r2r(mm2, mm5); /* src -> mm5 */ | |
2020 movq_r2r(mm3, mm6); /* dst -> mm6 */ | |
2021 pand_r2r(mm4, mm5); /* src & MASKGREEN -> mm5 */ | |
2022 pand_r2r(mm4, mm6); /* dst & MASKGREEN -> mm6 */ | |
2023 | |
2024 /* blend */ | |
2025 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */ | |
2026 pmulhw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */ | |
2027 /* 11 + 11 - 16 = 6 bits, so all the lower uninteresting | |
2028 bits are gone and the sign bits present */ | |
2029 psllw_i2r(5, mm5); /* mm5 << 5 -> mm5 */ | |
2030 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */ | |
2031 | |
2032 por_r2r(mm6, mm1); /* save new greens in dsts */ | |
2033 | |
2034 /* blue */ | |
2035 movq_r2r(mm2, mm5); /* src -> mm5 */ | |
2036 movq_r2r(mm3, mm6); /* dst -> mm6 */ | |
2037 pand_r2r(mm7, mm5); /* src & MASKBLUE -> mm5[000b 000b 000b 000b] */ | |
2038 pand_r2r(mm7, mm6); /* dst & MASKBLUE -> mm6[000b 000b 000b 000b] */ | |
2039 | |
2040 /* blend */ | |
2041 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */ | |
2042 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */ | |
2043 /* 11 + 5 = 16 bits, so the sign bits are lost and | |
2044 the interesting bits will need to be MASKed */ | |
2045 psrlw_i2r(11, mm5); /* mm5 >> 11 -> mm5 */ | |
2046 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */ | |
2047 pand_r2r(mm7, mm6); /* mm6 & MASKBLUE -> mm6[000b 000b 000b 000b] */ | |
2048 | |
2049 por_r2r(mm6, mm1); /* save new blues in dsts */ | |
2050 | |
2051 movq_r2m(mm1, *dstp); /* mm1 -> 4 dst pixels */ | |
2052 | |
2053 srcp += 4; | |
2054 dstp += 4; | |
2055 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2056 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2057 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2058 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2059 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2060 emms (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2061 } |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2062 } |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2063 |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2064 /* fast RGB555->RGB555 blending with surface alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2065 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2066 Blit555to555SurfaceAlphaMMX (SDL_BlitInfo * info) |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2067 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2068 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2069 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2070 Blit16to16SurfaceAlpha128 (info, 0xfbde); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2071 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2072 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2073 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2074 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2075 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2076 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2077 int dstskip = info->d_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2078 Uint32 s, d; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2079 Uint8 load[8]; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2080 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2081 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2082 *(Uint64 *) load = alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2083 alpha >>= 3; /* downscale alpha to 5 bits */ |
1542 | 2084 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2085 movq_m2r (*load, mm0); /* alpha(0000000A) -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2086 punpcklwd_r2r (mm0, mm0); /* 00000A0A -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2087 punpcklwd_r2r (mm0, mm0); /* 0A0A0A0A -> mm0 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2088 /* position alpha to allow for mullo and mulhi on diff channels |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2089 to reduce the number of operations */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2090 psllq_i2r (3, mm0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2091 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2092 /* Setup the 555 color channel masks */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2093 *(Uint64 *) load = 0x03E003E003E003E0ULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2094 movq_m2r (*load, mm4); /* MASKGREEN -> mm4 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2095 *(Uint64 *) load = 0x001F001F001F001FULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2096 movq_m2r (*load, mm7); /* MASKBLUE -> mm7 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2097 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2098 /* *INDENT-OFF* */ |
1542 | 2099 DUFFS_LOOP_QUATRO2( |
2100 { | |
2101 s = *srcp++; | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2102 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2103 /* |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2104 * 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
|
2105 * 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
|
2106 * components at the same time. |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2107 */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2108 s = (s | s << 16) & 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2109 d = (d | d << 16) & 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2110 d += (s - d) * alpha >> 5; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2111 d &= 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2112 *dstp++ = d | d >> 16; |
1542 | 2113 },{ |
2114 s = *srcp++; | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2115 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2116 /* |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2117 * 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
|
2118 * 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
|
2119 * components at the same time. |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2120 */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2121 s = (s | s << 16) & 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2122 d = (d | d << 16) & 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2123 d += (s - d) * alpha >> 5; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2124 d &= 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2125 *dstp++ = d | d >> 16; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2126 s = *srcp++; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2127 d = *dstp; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2128 /* |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2129 * 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
|
2130 * 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
|
2131 * components at the same time. |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2132 */ |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2133 s = (s | s << 16) & 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2134 d = (d | d << 16) & 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2135 d += (s - d) * alpha >> 5; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2136 d &= 0x03e07c1f; |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2137 *dstp++ = d | d >> 16; |
1542 | 2138 },{ |
2139 movq_m2r((*srcp), mm2);/* 4 src pixels -> mm2 */ | |
2140 movq_m2r((*dstp), mm3);/* 4 dst pixels -> mm3 */ | |
2141 | |
2142 /* red -- process the bits in place */ | |
2143 psllq_i2r(5, mm4); /* turn MASKGREEN into MASKRED */ | |
2144 /* by reusing the GREEN mask we free up another mmx | |
2145 register to accumulate the result */ | |
2146 | |
2147 movq_r2r(mm2, mm5); /* src -> mm5 */ | |
2148 movq_r2r(mm3, mm6); /* dst -> mm6 */ | |
2149 pand_r2r(mm4, mm5); /* src & MASKRED -> mm5 */ | |
2150 pand_r2r(mm4, mm6); /* dst & MASKRED -> mm6 */ | |
2151 | |
2152 /* blend */ | |
2153 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */ | |
2154 pmulhw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */ | |
2155 /* 11 + 15 - 16 = 10 bits, uninteresting bits will be | |
2156 cleared by a MASK below */ | |
2157 psllw_i2r(5, mm5); /* mm5 << 5 -> mm5 */ | |
2158 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */ | |
2159 pand_r2r(mm4, mm6); /* mm6 & MASKRED -> mm6 */ | |
2160 | |
2161 psrlq_i2r(5, mm4); /* turn MASKRED back into MASKGREEN */ | |
2162 | |
2163 movq_r2r(mm6, mm1); /* save new reds in dsts */ | |
2164 | |
2165 /* green -- process the bits in place */ | |
2166 movq_r2r(mm2, mm5); /* src -> mm5 */ | |
2167 movq_r2r(mm3, mm6); /* dst -> mm6 */ | |
2168 pand_r2r(mm4, mm5); /* src & MASKGREEN -> mm5 */ | |
2169 pand_r2r(mm4, mm6); /* dst & MASKGREEN -> mm6 */ | |
2170 | |
2171 /* blend */ | |
2172 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */ | |
2173 pmulhw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */ | |
2174 /* 11 + 10 - 16 = 5 bits, so all the lower uninteresting | |
2175 bits are gone and the sign bits present */ | |
2176 psllw_i2r(5, mm5); /* mm5 << 5 -> mm5 */ | |
2177 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */ | |
2178 | |
2179 por_r2r(mm6, mm1); /* save new greens in dsts */ | |
2180 | |
2181 /* blue */ | |
2182 movq_r2r(mm2, mm5); /* src -> mm5 */ | |
2183 movq_r2r(mm3, mm6); /* dst -> mm6 */ | |
2184 pand_r2r(mm7, mm5); /* src & MASKBLUE -> mm5[000b 000b 000b 000b] */ | |
2185 pand_r2r(mm7, mm6); /* dst & MASKBLUE -> mm6[000b 000b 000b 000b] */ | |
2186 | |
2187 /* blend */ | |
2188 psubw_r2r(mm6, mm5);/* src - dst -> mm5 */ | |
2189 pmullw_r2r(mm0, mm5); /* mm5 * alpha -> mm5 */ | |
2190 /* 11 + 5 = 16 bits, so the sign bits are lost and | |
2191 the interesting bits will need to be MASKed */ | |
2192 psrlw_i2r(11, mm5); /* mm5 >> 11 -> mm5 */ | |
2193 paddw_r2r(mm5, mm6); /* mm5 + mm6(dst) -> mm6 */ | |
2194 pand_r2r(mm7, mm6); /* mm6 & MASKBLUE -> mm6[000b 000b 000b 000b] */ | |
2195 | |
2196 por_r2r(mm6, mm1); /* save new blues in dsts */ | |
2197 | |
2198 movq_r2m(mm1, *dstp);/* mm1 -> 4 dst pixels */ | |
2199 | |
2200 srcp += 4; | |
2201 dstp += 4; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2202 }, width); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2203 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2204 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2205 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2206 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2207 emms (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2208 } |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2209 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2210 |
1542 | 2211 /* End GCC_ASMBLIT */ |
2212 | |
2213 #elif MSVC_ASMBLIT | |
2214 /* fast RGB565->RGB565 blending with surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2215 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2216 Blit565to565SurfaceAlphaMMX (SDL_BlitInfo * info) |
1542 | 2217 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2218 unsigned alpha = info->src->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2219 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2220 Blit16to16SurfaceAlpha128 (info, 0xf7de); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2221 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2222 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2223 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2224 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2225 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2226 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2227 int dstskip = info->d_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2228 Uint32 s, d; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2229 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2230 __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha; |
1542 | 2231 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2232 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2233 mm_alpha = _mm_set_pi32 (0, alpha); /* 0000000A -> mm_alpha */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2234 alpha >>= 3; /* downscale alpha to 5 bits */ |
1542 | 2235 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2236 mm_alpha = _mm_unpacklo_pi16 (mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2237 mm_alpha = _mm_unpacklo_pi32 (mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2238 /* position alpha to allow for mullo and mulhi on diff channels |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2239 to reduce the number of operations */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2240 mm_alpha = _mm_slli_si64 (mm_alpha, 3); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2241 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2242 /* Setup the 565 color channel masks */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2243 gmask = _mm_set_pi32 (0x07E007E0, 0x07E007E0); /* MASKGREEN -> gmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2244 bmask = _mm_set_pi32 (0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2245 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2246 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2247 /* *INDENT-OFF* */ |
1542 | 2248 DUFFS_LOOP_QUATRO2( |
2249 { | |
2250 s = *srcp++; | |
2251 d = *dstp; | |
2252 /* | |
2253 * shift out the middle component (green) to | |
2254 * the high 16 bits, and process all three RGB | |
2255 * components at the same time. | |
2256 */ | |
2257 s = (s | s << 16) & 0x07e0f81f; | |
2258 d = (d | d << 16) & 0x07e0f81f; | |
2259 d += (s - d) * alpha >> 5; | |
2260 d &= 0x07e0f81f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
2261 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 2262 },{ |
2263 s = *srcp++; | |
2264 d = *dstp; | |
2265 /* | |
2266 * shift out the middle component (green) to | |
2267 * the high 16 bits, and process all three RGB | |
2268 * components at the same time. | |
2269 */ | |
2270 s = (s | s << 16) & 0x07e0f81f; | |
2271 d = (d | d << 16) & 0x07e0f81f; | |
2272 d += (s - d) * alpha >> 5; | |
2273 d &= 0x07e0f81f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
2274 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 2275 s = *srcp++; |
2276 d = *dstp; | |
2277 /* | |
2278 * shift out the middle component (green) to | |
2279 * the high 16 bits, and process all three RGB | |
2280 * components at the same time. | |
2281 */ | |
2282 s = (s | s << 16) & 0x07e0f81f; | |
2283 d = (d | d << 16) & 0x07e0f81f; | |
2284 d += (s - d) * alpha >> 5; | |
2285 d &= 0x07e0f81f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
2286 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 2287 },{ |
2288 src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ | |
2289 dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ | |
2290 | |
2291 /* red */ | |
2292 src2 = src1; | |
2293 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 [000r 000r 000r 000r] */ | |
2294 | |
2295 dst2 = dst1; | |
2296 dst2 = _mm_srli_pi16(dst2, 11); /* dst2 >> 11 -> dst2 [000r 000r 000r 000r] */ | |
2297 | |
2298 /* blend */ | |
2299 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
2300 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
2301 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ | |
2302 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
2303 dst2 = _mm_slli_pi16(dst2, 11); /* dst2 << 11 -> dst2 */ | |
2304 | |
2305 mm_res = dst2; /* RED -> mm_res */ | |
2306 | |
2307 /* green -- process the bits in place */ | |
2308 src2 = src1; | |
2309 src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ | |
2310 | |
2311 dst2 = dst1; | |
2312 dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ | |
2313 | |
2314 /* blend */ | |
2315 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
2316 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
2317 src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ | |
2318 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
2319 | |
2320 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN -> mm_res */ | |
2321 | |
2322 /* blue */ | |
2323 src2 = src1; | |
2324 src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ | |
2325 | |
2326 dst2 = dst1; | |
2327 dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ | |
2328 | |
2329 /* blend */ | |
2330 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
2331 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
2332 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ | |
2333 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
2334 dst2 = _mm_and_si64(dst2, bmask); /* dst2 & MASKBLUE -> dst2 */ | |
2335 | |
2336 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN | BLUE -> mm_res */ | |
2337 | |
2338 *(__m64*)dstp = mm_res; /* mm_res -> 4 dst pixels */ | |
2339 | |
2340 srcp += 4; | |
2341 dstp += 4; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2342 }, width); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2343 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2344 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2345 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2346 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2347 _mm_empty (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2348 } |
1542 | 2349 } |
2350 | |
2351 /* fast RGB555->RGB555 blending with surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2352 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2353 Blit555to555SurfaceAlphaMMX (SDL_BlitInfo * info) |
1542 | 2354 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2355 unsigned alpha = info->src->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2356 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2357 Blit16to16SurfaceAlpha128 (info, 0xfbde); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2358 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2359 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2360 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2361 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2362 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2363 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2364 int dstskip = info->d_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2365 Uint32 s, d; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2366 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2367 __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha; |
1542 | 2368 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2369 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2370 mm_alpha = _mm_set_pi32 (0, alpha); /* 0000000A -> mm_alpha */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2371 alpha >>= 3; /* downscale alpha to 5 bits */ |
1542 | 2372 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2373 mm_alpha = _mm_unpacklo_pi16 (mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2374 mm_alpha = _mm_unpacklo_pi32 (mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2375 /* position alpha to allow for mullo and mulhi on diff channels |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2376 to reduce the number of operations */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2377 mm_alpha = _mm_slli_si64 (mm_alpha, 3); |
1542 | 2378 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2379 /* Setup the 555 color channel masks */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2380 rmask = _mm_set_pi32 (0x7C007C00, 0x7C007C00); /* MASKRED -> rmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2381 gmask = _mm_set_pi32 (0x03E003E0, 0x03E003E0); /* MASKGREEN -> gmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2382 bmask = _mm_set_pi32 (0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2383 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2384 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2385 /* *INDENT-OFF* */ |
1542 | 2386 DUFFS_LOOP_QUATRO2( |
2387 { | |
2388 s = *srcp++; | |
2389 d = *dstp; | |
2390 /* | |
2391 * shift out the middle component (green) to | |
2392 * the high 16 bits, and process all three RGB | |
2393 * components at the same time. | |
2394 */ | |
2395 s = (s | s << 16) & 0x03e07c1f; | |
2396 d = (d | d << 16) & 0x03e07c1f; | |
2397 d += (s - d) * alpha >> 5; | |
2398 d &= 0x03e07c1f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
2399 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 2400 },{ |
2401 s = *srcp++; | |
2402 d = *dstp; | |
2403 /* | |
2404 * shift out the middle component (green) to | |
2405 * the high 16 bits, and process all three RGB | |
2406 * components at the same time. | |
2407 */ | |
2408 s = (s | s << 16) & 0x03e07c1f; | |
2409 d = (d | d << 16) & 0x03e07c1f; | |
2410 d += (s - d) * alpha >> 5; | |
2411 d &= 0x03e07c1f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
2412 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 2413 s = *srcp++; |
2414 d = *dstp; | |
2415 /* | |
2416 * shift out the middle component (green) to | |
2417 * the high 16 bits, and process all three RGB | |
2418 * components at the same time. | |
2419 */ | |
2420 s = (s | s << 16) & 0x03e07c1f; | |
2421 d = (d | d << 16) & 0x03e07c1f; | |
2422 d += (s - d) * alpha >> 5; | |
2423 d &= 0x03e07c1f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
2424 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 2425 },{ |
2426 src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ | |
2427 dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ | |
2428 | |
2429 /* red -- process the bits in place */ | |
2430 src2 = src1; | |
2431 src2 = _mm_and_si64(src2, rmask); /* src & MASKRED -> src2 */ | |
2432 | |
2433 dst2 = dst1; | |
2434 dst2 = _mm_and_si64(dst2, rmask); /* dst & MASKRED -> dst2 */ | |
2435 | |
2436 /* blend */ | |
2437 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
2438 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
2439 src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ | |
2440 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
2441 dst2 = _mm_and_si64(dst2, rmask); /* dst2 & MASKRED -> dst2 */ | |
2442 | |
2443 mm_res = dst2; /* RED -> mm_res */ | |
2444 | |
2445 /* green -- process the bits in place */ | |
2446 src2 = src1; | |
2447 src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ | |
2448 | |
2449 dst2 = dst1; | |
2450 dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ | |
2451 | |
2452 /* blend */ | |
2453 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
2454 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
2455 src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ | |
2456 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
2457 | |
2458 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN -> mm_res */ | |
2459 | |
2460 /* blue */ | |
2461 src2 = src1; /* src -> src2 */ | |
2462 src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ | |
2463 | |
2464 dst2 = dst1; /* dst -> dst2 */ | |
2465 dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ | |
2466 | |
2467 /* blend */ | |
2468 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
2469 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
2470 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ | |
2471 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
2472 dst2 = _mm_and_si64(dst2, bmask); /* dst2 & MASKBLUE -> dst2 */ | |
2473 | |
2474 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN | BLUE -> mm_res */ | |
2475 | |
2476 *(__m64*)dstp = mm_res; /* mm_res -> 4 dst pixels */ | |
2477 | |
2478 srcp += 4; | |
2479 dstp += 4; | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2480 }, width); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2481 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2482 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2483 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2484 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2485 _mm_empty (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2486 } |
1542 | 2487 } |
2488 #endif /* GCC_ASMBLIT, MSVC_ASMBLIT */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2489 |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2490 /* fast RGB565->RGB565 blending with surface alpha */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2491 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2492 Blit565to565SurfaceAlpha (SDL_BlitInfo * info) |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2493 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2494 unsigned alpha = info->src->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2495 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2496 Blit16to16SurfaceAlpha128 (info, 0xf7de); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2497 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2498 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2499 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2500 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2501 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2502 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2503 int dstskip = info->d_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2504 alpha >>= 3; /* downscale alpha to 5 bits */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2505 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2506 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2507 /* *INDENT-OFF* */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2508 DUFFS_LOOP4({ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2509 Uint32 s = *srcp++; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2510 Uint32 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2511 /* |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2512 * shift out the middle component (green) to |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2513 * 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
|
2514 * components at the same time. |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2515 */ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2516 s = (s | s << 16) & 0x07e0f81f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2517 d = (d | d << 16) & 0x07e0f81f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2518 d += (s - d) * alpha >> 5; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2519 d &= 0x07e0f81f; |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
2520 *dstp++ = (Uint16)(d | d >> 16); |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2521 }, width); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2522 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2523 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2524 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2525 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2526 } |
0 | 2527 } |
2528 | |
2529 /* fast RGB555->RGB555 blending with surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2530 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2531 Blit555to555SurfaceAlpha (SDL_BlitInfo * info) |
0 | 2532 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2533 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2534 if (alpha == 128) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2535 Blit16to16SurfaceAlpha128 (info, 0xfbde); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2536 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2537 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2538 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2539 Uint16 *srcp = (Uint16 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2540 int srcskip = info->s_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2541 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2542 int dstskip = info->d_skip >> 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2543 alpha >>= 3; /* downscale alpha to 5 bits */ |
0 | 2544 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2545 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2546 /* *INDENT-OFF* */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2547 DUFFS_LOOP4({ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2548 Uint32 s = *srcp++; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2549 Uint32 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2550 /* |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2551 * shift out the middle component (green) to |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2552 * 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
|
2553 * components at the same time. |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2554 */ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2555 s = (s | s << 16) & 0x03e07c1f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2556 d = (d | d << 16) & 0x03e07c1f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2557 d += (s - d) * alpha >> 5; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2558 d &= 0x03e07c1f; |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
2559 *dstp++ = (Uint16)(d | d >> 16); |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
2560 }, width); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2561 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2562 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2563 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2564 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2565 } |
0 | 2566 } |
2567 | |
2568 /* fast ARGB8888->RGB565 blending with pixel alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2569 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2570 BlitARGBto565PixelAlpha (SDL_BlitInfo * info) |
0 | 2571 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2572 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2573 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2574 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2575 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2576 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2577 int dstskip = info->d_skip >> 1; |
0 | 2578 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2579 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2580 /* *INDENT-OFF* */ |
0 | 2581 DUFFS_LOOP4({ |
2582 Uint32 s = *srcp; | |
2583 unsigned alpha = s >> 27; /* downscale alpha to 5 bits */ | |
2584 /* FIXME: Here we special-case opaque alpha since the | |
2585 compositioning used (>>8 instead of /255) doesn't handle | |
2586 it correctly. Also special-case alpha=0 for speed? | |
2587 Benchmark this! */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2588 if(alpha) { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2589 if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
2590 *dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f)); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2591 } else { |
0 | 2592 Uint32 d = *dstp; |
2593 /* | |
2594 * convert source and destination to G0RAB65565 | |
2595 * and blend all components at the same time | |
2596 */ | |
2597 s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) | |
2598 + (s >> 3 & 0x1f); | |
2599 d = (d | d << 16) & 0x07e0f81f; | |
2600 d += (s - d) * alpha >> 5; | |
2601 d &= 0x07e0f81f; | |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
2602 *dstp = (Uint16)(d | d >> 16); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2603 } |
0 | 2604 } |
2605 srcp++; | |
2606 dstp++; | |
2607 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2608 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2609 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2610 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2611 } |
0 | 2612 } |
2613 | |
2614 /* fast ARGB8888->RGB555 blending with pixel alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2615 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2616 BlitARGBto555PixelAlpha (SDL_BlitInfo * info) |
0 | 2617 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2618 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2619 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2620 Uint32 *srcp = (Uint32 *) info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2621 int srcskip = info->s_skip >> 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2622 Uint16 *dstp = (Uint16 *) info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2623 int dstskip = info->d_skip >> 1; |
0 | 2624 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2625 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2626 /* *INDENT-OFF* */ |
0 | 2627 DUFFS_LOOP4({ |
2628 unsigned alpha; | |
2629 Uint32 s = *srcp; | |
2630 alpha = s >> 27; /* downscale alpha to 5 bits */ | |
2631 /* FIXME: Here we special-case opaque alpha since the | |
2632 compositioning used (>>8 instead of /255) doesn't handle | |
2633 it correctly. Also special-case alpha=0 for speed? | |
2634 Benchmark this! */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2635 if(alpha) { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2636 if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
2637 *dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f)); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2638 } else { |
0 | 2639 Uint32 d = *dstp; |
2640 /* | |
2641 * convert source and destination to G0RAB65565 | |
2642 * and blend all components at the same time | |
2643 */ | |
2644 s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) | |
2645 + (s >> 3 & 0x1f); | |
2646 d = (d | d << 16) & 0x03e07c1f; | |
2647 d += (s - d) * alpha >> 5; | |
2648 d &= 0x03e07c1f; | |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
2649 *dstp = (Uint16)(d | d >> 16); |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2650 } |
0 | 2651 } |
2652 srcp++; | |
2653 dstp++; | |
2654 }, width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2655 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2656 srcp += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2657 dstp += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2658 } |
0 | 2659 } |
2660 | |
2661 /* General (slow) N->N blending with per-surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2662 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2663 BlitNtoNSurfaceAlpha (SDL_BlitInfo * info) |
0 | 2664 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2665 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2666 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2667 Uint8 *src = info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2668 int srcskip = info->s_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2669 Uint8 *dst = info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2670 int dstskip = info->d_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2671 SDL_PixelFormat *srcfmt = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2672 SDL_PixelFormat *dstfmt = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2673 int srcbpp = srcfmt->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2674 int dstbpp = dstfmt->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2675 unsigned sA = srcfmt->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2676 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; |
0 | 2677 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2678 if (sA) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2679 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2680 /* *INDENT-OFF* */ |
0 | 2681 DUFFS_LOOP4( |
2682 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
2683 Uint32 Pixel; |
0 | 2684 unsigned sR; |
2685 unsigned sG; | |
2686 unsigned sB; | |
2687 unsigned dR; | |
2688 unsigned dG; | |
2689 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
|
2690 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
|
2691 DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB); |
0 | 2692 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); |
2693 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); | |
2694 src += srcbpp; | |
2695 dst += dstbpp; | |
2696 }, | |
2697 width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2698 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2699 src += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2700 dst += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2701 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2702 } |
0 | 2703 } |
2704 | |
2705 /* General (slow) colorkeyed N->N blending with per-surface alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2706 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2707 BlitNtoNSurfaceAlphaKey (SDL_BlitInfo * info) |
0 | 2708 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2709 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2710 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2711 Uint8 *src = info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2712 int srcskip = info->s_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2713 Uint8 *dst = info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2714 int dstskip = info->d_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2715 SDL_PixelFormat *srcfmt = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2716 SDL_PixelFormat *dstfmt = info->dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2717 Uint32 ckey = srcfmt->colorkey; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2718 int srcbpp = srcfmt->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2719 int dstbpp = dstfmt->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2720 unsigned sA = srcfmt->alpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2721 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; |
0 | 2722 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2723 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2724 /* *INDENT-OFF* */ |
0 | 2725 DUFFS_LOOP4( |
2726 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
2727 Uint32 Pixel; |
0 | 2728 unsigned sR; |
2729 unsigned sG; | |
2730 unsigned sB; | |
2731 unsigned dR; | |
2732 unsigned dG; | |
2733 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
|
2734 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
|
2735 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
|
2736 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
|
2737 DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB); |
0 | 2738 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); |
2739 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); | |
2740 } | |
2741 src += srcbpp; | |
2742 dst += dstbpp; | |
2743 }, | |
2744 width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2745 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2746 src += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2747 dst += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2748 } |
0 | 2749 } |
2750 | |
2751 /* General (slow) N->N blending with pixel alpha */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2752 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2753 BlitNtoNPixelAlpha (SDL_BlitInfo * info) |
0 | 2754 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2755 int width = info->d_width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2756 int height = info->d_height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2757 Uint8 *src = info->s_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2758 int srcskip = info->s_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2759 Uint8 *dst = info->d_pixels; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2760 int dstskip = info->d_skip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2761 SDL_PixelFormat *srcfmt = info->src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2762 SDL_PixelFormat *dstfmt = info->dst; |
0 | 2763 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2764 int srcbpp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2765 int dstbpp; |
0 | 2766 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2767 /* Set up some basic variables */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2768 srcbpp = srcfmt->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2769 dstbpp = dstfmt->BytesPerPixel; |
0 | 2770 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2771 /* FIXME: for 8bpp source alpha, this doesn't get opaque values |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2772 quite right. for <8bpp source alpha, it gets them very wrong |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2773 (check all macros!) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2774 It is unclear whether there is a good general solution that doesn't |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2775 need a branch (or a divide). */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2776 while (height--) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2777 /* *INDENT-OFF* */ |
0 | 2778 DUFFS_LOOP4( |
2779 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
2780 Uint32 Pixel; |
0 | 2781 unsigned sR; |
2782 unsigned sG; | |
2783 unsigned sB; | |
2784 unsigned dR; | |
2785 unsigned dG; | |
2786 unsigned dB; | |
2787 unsigned sA; | |
2788 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
|
2789 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
|
2790 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
|
2791 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
|
2792 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
|
2793 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
|
2794 } |
0 | 2795 src += srcbpp; |
2796 dst += dstbpp; | |
2797 }, | |
2798 width); | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2799 /* *INDENT-ON* */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2800 src += srcskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2801 dst += dstskip; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2802 } |
0 | 2803 } |
2804 | |
2805 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2806 SDL_loblit |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2807 SDL_CalculateAlphaBlit (SDL_Surface * surface, int blit_index) |
0 | 2808 { |
2809 SDL_PixelFormat *sf = surface->format; | |
2810 SDL_PixelFormat *df = surface->map->dst->format; | |
2811 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2812 if (sf->Amask == 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2813 if ((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2814 if (df->BytesPerPixel == 1) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2815 return BlitNto1SurfaceAlphaKey; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2816 else |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
2817 #if SDL_ALTIVEC_BLITTERS |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2818 if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2819 !(surface->map->dst->flags & SDL_HWSURFACE) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2820 && SDL_HasAltiVec ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2821 return Blit32to32SurfaceAlphaKeyAltivec; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2822 else |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
2823 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2824 return BlitNtoNSurfaceAlphaKey; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2825 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2826 /* Per-surface alpha blits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2827 switch (df->BytesPerPixel) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2828 case 1: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2829 return BlitNto1SurfaceAlpha; |
0 | 2830 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2831 case 2: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2832 if (surface->map->identity) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2833 if (df->Gmask == 0x7e0) { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
2834 #if MMX_ASMBLIT |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2835 if (SDL_HasMMX ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2836 return Blit565to565SurfaceAlphaMMX; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2837 else |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2838 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2839 return Blit565to565SurfaceAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2840 } else if (df->Gmask == 0x3e0) { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
2841 #if MMX_ASMBLIT |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2842 if (SDL_HasMMX ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2843 return Blit555to555SurfaceAlphaMMX; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2844 else |
1542 | 2845 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2846 return Blit555to555SurfaceAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2847 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2848 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2849 return BlitNtoNSurfaceAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2850 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2851 case 4: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2852 if (sf->Rmask == df->Rmask |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2853 && sf->Gmask == df->Gmask |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2854 && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2855 #if MMX_ASMBLIT |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2856 if (sf->Rshift % 8 == 0 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2857 && sf->Gshift % 8 == 0 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2858 && sf->Bshift % 8 == 0 && SDL_HasMMX ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2859 return BlitRGBtoRGBSurfaceAlphaMMX; |
1542 | 2860 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2861 if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) { |
1542 | 2862 #if SDL_ALTIVEC_BLITTERS |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2863 if (!(surface->map->dst->flags & SDL_HWSURFACE) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2864 && SDL_HasAltiVec ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2865 return BlitRGBtoRGBSurfaceAlphaAltivec; |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2866 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2867 return BlitRGBtoRGBSurfaceAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2868 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2869 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2870 #if SDL_ALTIVEC_BLITTERS |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2871 if ((sf->BytesPerPixel == 4) && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2872 !(surface->map->dst->flags & SDL_HWSURFACE) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2873 && SDL_HasAltiVec ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2874 return Blit32to32SurfaceAlphaAltivec; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2875 else |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2876 #endif |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2877 return BlitNtoNSurfaceAlpha; |
0 | 2878 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2879 case 3: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2880 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2881 return BlitNtoNSurfaceAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2882 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2883 } |
0 | 2884 } else { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2885 /* Per-pixel alpha blits */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2886 switch (df->BytesPerPixel) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2887 case 1: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2888 return BlitNto1PixelAlpha; |
0 | 2889 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2890 case 2: |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
2891 #if SDL_ALTIVEC_BLITTERS |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2892 if (sf->BytesPerPixel == 4 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2893 && !(surface->map->dst->flags & SDL_HWSURFACE) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2894 && df->Gmask == 0x7e0 && df->Bmask == 0x1f |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2895 && SDL_HasAltiVec ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2896 return Blit32to565PixelAlphaAltivec; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2897 else |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
2898 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2899 if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2900 && sf->Gmask == 0xff00 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2901 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2902 || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2903 if (df->Gmask == 0x7e0) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2904 return BlitARGBto565PixelAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2905 else if (df->Gmask == 0x3e0) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2906 return BlitARGBto555PixelAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2907 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2908 return BlitNtoNPixelAlpha; |
0 | 2909 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2910 case 4: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2911 if (sf->Rmask == df->Rmask |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2912 && sf->Gmask == df->Gmask |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2913 && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
2914 #if MMX_ASMBLIT |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2915 if (sf->Rshift % 8 == 0 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2916 && sf->Gshift % 8 == 0 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2917 && sf->Bshift % 8 == 0 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2918 && sf->Ashift % 8 == 0 && sf->Aloss == 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2919 if (SDL_Has3DNow ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2920 return BlitRGBtoRGBPixelAlphaMMX3DNOW; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2921 if (SDL_HasMMX ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2922 return BlitRGBtoRGBPixelAlphaMMX; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2923 } |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
2924 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2925 if (sf->Amask == 0xff000000) { |
1617
b255b4058d37
Patch from Alex to fix reverted code
Sam Lantinga <slouken@libsdl.org>
parents:
1546
diff
changeset
|
2926 #if SDL_ALTIVEC_BLITTERS |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2927 if (!(surface->map->dst->flags & SDL_HWSURFACE) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2928 && SDL_HasAltiVec ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2929 return BlitRGBtoRGBPixelAlphaAltivec; |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
2930 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2931 return BlitRGBtoRGBPixelAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2932 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2933 } |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
2934 #if SDL_ALTIVEC_BLITTERS |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2935 if (sf->Amask && sf->BytesPerPixel == 4 && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2936 !(surface->map->dst->flags & SDL_HWSURFACE) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2937 && SDL_HasAltiVec ()) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2938 return Blit32to32PixelAlphaAltivec; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2939 else |
1047
ffaaf7ecf685
Altivec-optimized blitters!
Ryan C. Gordon <icculus@icculus.org>
parents:
880
diff
changeset
|
2940 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2941 return BlitNtoNPixelAlpha; |
0 | 2942 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2943 case 3: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2944 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2945 return BlitNtoNPixelAlpha; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2946 } |
0 | 2947 } |
2948 } | |
2949 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
2950 /* vi: set ts=4 sw=4 expandtab: */ |