Mercurial > sdl-ios-xcode
annotate src/video/SDL_blit_A.c @ 5264:6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Feb 2011 14:51:04 -0800 |
parents | f7b03b6838cb |
children | b530ef003506 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3697 | 3 Copyright (C) 1997-2010 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 | |
27 /* Functions to perform alpha blended blitting */ | |
28 | |
29 /* N->1 blending with per-surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
30 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
31 BlitNto1SurfaceAlpha(SDL_BlitInfo * info) |
0 | 32 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
33 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
34 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
35 Uint8 *src = info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
36 int srcskip = info->src_skip; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
37 Uint8 *dst = info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
38 int dstskip = info->dst_skip; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
39 Uint8 *palmap = info->table; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
40 SDL_PixelFormat *srcfmt = info->src_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
41 SDL_PixelFormat *dstfmt = info->dst_fmt; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
42 int srcbpp = srcfmt->BytesPerPixel; |
0 | 43 |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
44 const unsigned A = info->a; |
0 | 45 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
46 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
47 /* *INDENT-OFF* */ |
0 | 48 DUFFS_LOOP4( |
49 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
50 Uint32 Pixel; |
0 | 51 unsigned sR; |
52 unsigned sG; | |
53 unsigned sB; | |
54 unsigned dR; | |
55 unsigned dG; | |
56 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
|
57 DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); |
0 | 58 dR = dstfmt->palette->colors[*dst].r; |
59 dG = dstfmt->palette->colors[*dst].g; | |
60 dB = dstfmt->palette->colors[*dst].b; | |
61 ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB); | |
62 dR &= 0xff; | |
63 dG &= 0xff; | |
64 dB &= 0xff; | |
65 /* Pack RGB into 8bit pixel */ | |
66 if ( palmap == NULL ) { | |
67 *dst =((dR>>5)<<(3+2))| | |
68 ((dG>>5)<<(2))| | |
69 ((dB>>6)<<(0)); | |
70 } else { | |
71 *dst = palmap[((dR>>5)<<(3+2))| | |
72 ((dG>>5)<<(2)) | | |
73 ((dB>>6)<<(0))]; | |
74 } | |
75 dst++; | |
76 src += srcbpp; | |
77 }, | |
78 width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
79 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
80 src += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
81 dst += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
82 } |
0 | 83 } |
84 | |
85 /* N->1 blending with pixel alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
86 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
87 BlitNto1PixelAlpha(SDL_BlitInfo * info) |
0 | 88 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
89 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
90 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
91 Uint8 *src = info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
92 int srcskip = info->src_skip; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
93 Uint8 *dst = info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
94 int dstskip = info->dst_skip; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
95 Uint8 *palmap = info->table; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
96 SDL_PixelFormat *srcfmt = info->src_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
97 SDL_PixelFormat *dstfmt = info->dst_fmt; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
98 int srcbpp = srcfmt->BytesPerPixel; |
0 | 99 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
100 /* FIXME: fix alpha bit field expansion here too? */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
101 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
102 /* *INDENT-OFF* */ |
0 | 103 DUFFS_LOOP4( |
104 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
105 Uint32 Pixel; |
0 | 106 unsigned sR; |
107 unsigned sG; | |
108 unsigned sB; | |
109 unsigned sA; | |
110 unsigned dR; | |
111 unsigned dG; | |
112 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
|
113 DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA); |
0 | 114 dR = dstfmt->palette->colors[*dst].r; |
115 dG = dstfmt->palette->colors[*dst].g; | |
116 dB = dstfmt->palette->colors[*dst].b; | |
117 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); | |
118 dR &= 0xff; | |
119 dG &= 0xff; | |
120 dB &= 0xff; | |
121 /* Pack RGB into 8bit pixel */ | |
122 if ( palmap == NULL ) { | |
123 *dst =((dR>>5)<<(3+2))| | |
124 ((dG>>5)<<(2))| | |
125 ((dB>>6)<<(0)); | |
126 } else { | |
127 *dst = palmap[((dR>>5)<<(3+2))| | |
128 ((dG>>5)<<(2)) | | |
129 ((dB>>6)<<(0)) ]; | |
130 } | |
131 dst++; | |
132 src += srcbpp; | |
133 }, | |
134 width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
135 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
136 src += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
137 dst += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
138 } |
0 | 139 } |
140 | |
141 /* colorkeyed N->1 blending with per-surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
142 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
143 BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) |
0 | 144 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
145 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
146 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
147 Uint8 *src = info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
148 int srcskip = info->src_skip; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
149 Uint8 *dst = info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
150 int dstskip = info->dst_skip; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
151 Uint8 *palmap = info->table; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
152 SDL_PixelFormat *srcfmt = info->src_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
153 SDL_PixelFormat *dstfmt = info->dst_fmt; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
154 int srcbpp = srcfmt->BytesPerPixel; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
155 Uint32 ckey = info->colorkey; |
0 | 156 |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
157 const int A = info->a; |
0 | 158 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
159 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
160 /* *INDENT-OFF* */ |
0 | 161 DUFFS_LOOP( |
162 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
163 Uint32 Pixel; |
0 | 164 unsigned sR; |
165 unsigned sG; | |
166 unsigned sB; | |
167 unsigned dR; | |
168 unsigned dG; | |
169 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
|
170 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
|
171 if ( Pixel != ckey ) { |
0 | 172 dR = dstfmt->palette->colors[*dst].r; |
173 dG = dstfmt->palette->colors[*dst].g; | |
174 dB = dstfmt->palette->colors[*dst].b; | |
175 ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB); | |
176 dR &= 0xff; | |
177 dG &= 0xff; | |
178 dB &= 0xff; | |
179 /* Pack RGB into 8bit pixel */ | |
180 if ( palmap == NULL ) { | |
181 *dst =((dR>>5)<<(3+2))| | |
182 ((dG>>5)<<(2)) | | |
183 ((dB>>6)<<(0)); | |
184 } else { | |
185 *dst = palmap[((dR>>5)<<(3+2))| | |
186 ((dG>>5)<<(2)) | | |
187 ((dB>>6)<<(0)) ]; | |
188 } | |
189 } | |
190 dst++; | |
191 src += srcbpp; | |
192 }, | |
193 width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
194 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
195 src += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
196 dst += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
197 } |
0 | 198 } |
199 | |
2255
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
200 #ifdef __MMX__ |
1542 | 201 |
202 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
203 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
204 BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info) |
1542 | 205 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
206 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
207 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
208 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
209 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
210 Uint32 *dstp = (Uint32 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
211 int dstskip = info->dst_skip >> 2; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
212 Uint32 dalpha = info->dst_fmt->Amask; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
213 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
214 __m64 src1, src2, dst1, dst2, lmask, hmask, dsta; |
1542 | 215 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
216 hmask = _mm_set_pi32(0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
217 lmask = _mm_set_pi32(0x00010101, 0x00010101); /* !alpha128 mask -> lmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
218 dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
219 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
220 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
221 int n = width; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
222 if (n & 1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
223 Uint32 s = *srcp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
224 Uint32 d = *dstp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
225 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
226 + (s & d & 0x00010101)) | dalpha; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
227 n--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
228 } |
1542 | 229 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
230 for (n >>= 1; n > 0; --n) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
231 dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
232 dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ |
1542 | 233 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
234 src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
235 src2 = src1; /* 2 x src -> src2(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
236 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
237 dst2 = _mm_and_si64(dst2, hmask); /* dst & mask -> dst2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
238 src2 = _mm_and_si64(src2, hmask); /* src & mask -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
239 src2 = _mm_add_pi32(src2, dst2); /* dst2 + src2 -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
240 src2 = _mm_srli_pi32(src2, 1); /* src2 >> 1 -> src2 */ |
1542 | 241 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
242 dst1 = _mm_and_si64(dst1, src1); /* src & dst -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
243 dst1 = _mm_and_si64(dst1, lmask); /* dst1 & !mask -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
244 dst1 = _mm_add_pi32(dst1, src2); /* src2 + dst1 -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
245 dst1 = _mm_or_si64(dst1, dsta); /* dsta(full alpha) | dst1 -> dst1 */ |
1542 | 246 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
247 *(__m64 *) dstp = dst1; /* dst1 -> 2 x dst pixels */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
248 dstp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
249 srcp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
250 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
251 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
252 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
253 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
254 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
255 _mm_empty(); |
1542 | 256 } |
257 | |
258 /* fast RGB888->(A)RGB888 blending with surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
259 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
260 BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) |
1542 | 261 { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
262 SDL_PixelFormat *df = info->dst_fmt; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
263 Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
264 unsigned alpha = info->a; |
1542 | 265 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
266 if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
267 /* only call a128 version when R,G,B occupy lower bits */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
268 BlitRGBtoRGBSurfaceAlpha128MMX(info); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
269 } else { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
270 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
271 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
272 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
273 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
274 Uint32 *dstp = (Uint32 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
275 int dstskip = info->dst_skip >> 2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
276 Uint32 dalpha = df->Amask; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
277 Uint32 amult; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
278 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
279 __m64 src1, src2, dst1, dst2, mm_alpha, mm_zero, dsta; |
1542 | 280 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
281 mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
282 /* form the alpha mult */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
283 amult = alpha | (alpha << 8); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
284 amult = amult | (amult << 16); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
285 chanmask = |
3013
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
286 (0xff << df->Rshift) | (0xff << df-> |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
287 Gshift) | (0xff << df->Bshift); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
288 mm_alpha = _mm_set_pi32(0, amult & chanmask); /* 0000AAAA -> mm_alpha, minus 1 chan */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
289 mm_alpha = _mm_unpacklo_pi8(mm_alpha, mm_zero); /* 0A0A0A0A -> mm_alpha, minus 1 chan */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
290 /* at this point mm_alpha can be 000A0A0A or 0A0A0A00 or another combo */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
291 dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ |
1542 | 292 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
293 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
294 int n = width; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
295 if (n & 1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
296 /* One Pixel Blend */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
297 src2 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src2 (0000ARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
298 src2 = _mm_unpacklo_pi8(src2, mm_zero); /* 0A0R0G0B -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
299 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
300 dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
301 dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ |
1542 | 302 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
303 src2 = _mm_sub_pi16(src2, dst1); /* src2 - dst2 -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
304 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
305 src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
306 dst1 = _mm_add_pi8(src2, dst1); /* src2 + dst1 -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
307 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
308 dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
309 dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
310 *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ |
1542 | 311 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
312 ++srcp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
313 ++dstp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
314 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
315 n--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
316 } |
1542 | 317 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
318 for (n >>= 1; n > 0; --n) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
319 /* Two Pixels Blend */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
320 src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
321 src2 = src1; /* 2 x src -> src2(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
322 src1 = _mm_unpacklo_pi8(src1, mm_zero); /* low - 0A0R0G0B -> src1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
323 src2 = _mm_unpackhi_pi8(src2, mm_zero); /* high - 0A0R0G0B -> src2 */ |
1542 | 324 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
325 dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
326 dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
327 dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* low - 0A0R0G0B -> dst1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
328 dst2 = _mm_unpackhi_pi8(dst2, mm_zero); /* high - 0A0R0G0B -> dst2 */ |
1542 | 329 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
330 src1 = _mm_sub_pi16(src1, dst1); /* src1 - dst1 -> src1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
331 src1 = _mm_mullo_pi16(src1, mm_alpha); /* src1 * alpha -> src1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
332 src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
333 dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst1) -> dst1 */ |
1542 | 334 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
335 src2 = _mm_sub_pi16(src2, dst2); /* src2 - dst2 -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
336 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
337 src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
338 dst2 = _mm_add_pi8(src2, dst2); /* src2 + dst2(dst2) -> dst2 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
339 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
340 dst1 = _mm_packs_pu16(dst1, dst2); /* 0A0R0G0B(res1), 0A0R0G0B(res2) -> dst1(ARGBARGB) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
341 dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ |
1542 | 342 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
343 *(__m64 *) dstp = dst1; /* dst1 -> 2 x pixel */ |
1542 | 344 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
345 srcp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
346 dstp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
347 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
348 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
349 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
350 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
351 _mm_empty(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
352 } |
1542 | 353 } |
354 | |
355 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
356 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
357 BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) |
1542 | 358 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
359 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
360 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
361 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
362 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
363 Uint32 *dstp = (Uint32 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
364 int dstskip = info->dst_skip >> 2; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
365 SDL_PixelFormat *sf = info->src_fmt; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
366 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
367 Uint32 amask = sf->Amask; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
368 Uint32 ashift = sf->Ashift; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
369 Uint64 multmask; |
1542 | 370 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
371 __m64 src1, dst1, mm_alpha, mm_zero, dmask; |
1542 | 372 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
373 mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ |
2260 | 374 multmask = 0xFFFF; |
2255
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
375 multmask <<= (ashift * 2); |
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
376 multmask = ~multmask; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
377 dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ |
1542 | 378 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
379 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
380 /* *INDENT-OFF* */ |
1542 | 381 DUFFS_LOOP4({ |
382 Uint32 alpha = *srcp & amask; | |
383 if (alpha == 0) { | |
384 /* do nothing */ | |
385 } else if (alpha == amask) { | |
386 /* opaque alpha -- copy RGB, keep dst alpha */ | |
387 *dstp = (*srcp & chanmask) | (*dstp & ~chanmask); | |
388 } else { | |
389 src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/ | |
390 src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */ | |
391 | |
392 dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB)*/ | |
393 dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ | |
394 | |
395 mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */ | |
396 mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */ | |
397 mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ | |
398 mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ | |
399 mm_alpha = _mm_and_si64(mm_alpha, dmask); /* 000A0A0A -> mm_alpha, preserve dst alpha on add */ | |
400 | |
401 /* blend */ | |
402 src1 = _mm_sub_pi16(src1, dst1);/* src1 - dst1 -> src1 */ | |
403 src1 = _mm_mullo_pi16(src1, mm_alpha); /* (src1 - dst1) * alpha -> src1 */ | |
404 src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1(000R0G0B) */ | |
405 dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1 -> dst1(0A0R0G0B) */ | |
406 dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ | |
407 | |
408 *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ | |
409 } | |
410 ++srcp; | |
411 ++dstp; | |
412 }, width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
413 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
414 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
415 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
416 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
417 _mm_empty(); |
1542 | 418 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
419 |
2255
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
420 #endif /* __MMX__ */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
421 |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
422 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
423 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
424 BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) |
0 | 425 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
426 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
427 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
428 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
429 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
430 Uint32 *dstp = (Uint32 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
431 int dstskip = info->dst_skip >> 2; |
0 | 432 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
433 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
434 /* *INDENT-OFF* */ |
0 | 435 DUFFS_LOOP4({ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
436 Uint32 s = *srcp++; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
437 Uint32 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
438 *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
439 + (s & d & 0x00010101)) | 0xff000000; |
0 | 440 }, width); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
441 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
442 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
443 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
444 } |
0 | 445 } |
446 | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
447 /* fast RGB888->(A)RGB888 blending with surface alpha */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
448 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
449 BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
450 { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
451 unsigned alpha = info->a; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
452 if (alpha == 128) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
453 BlitRGBtoRGBSurfaceAlpha128(info); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
454 } else { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
455 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
456 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
457 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
458 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
459 Uint32 *dstp = (Uint32 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
460 int dstskip = info->dst_skip >> 2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
461 Uint32 s; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
462 Uint32 d; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
463 Uint32 s1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
464 Uint32 d1; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
465 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
466 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
467 /* *INDENT-OFF* */ |
3035
ff602fdfdedc
Removed Rafal Bursig's MMX RLE code, at his request.
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
468 DUFFS_LOOP4({ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
469 s = *srcp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
470 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
471 s1 = s & 0xff00ff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
472 d1 = d & 0xff00ff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
473 d1 = (d1 + ((s1 - d1) * alpha >> 8)) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
474 & 0xff00ff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
475 s &= 0xff00; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
476 d &= 0xff00; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
477 d = (d + ((s - d) * alpha >> 8)) & 0xff00; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
478 *dstp = d1 | d | 0xff000000; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
479 ++srcp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
480 ++dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
481 }, width); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
482 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
483 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
484 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
485 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
486 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
487 } |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
488 |
0 | 489 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
490 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
491 BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) |
0 | 492 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
493 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
494 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
495 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
496 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
497 Uint32 *dstp = (Uint32 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
498 int dstskip = info->dst_skip >> 2; |
0 | 499 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
500 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
501 /* *INDENT-OFF* */ |
0 | 502 DUFFS_LOOP4({ |
503 Uint32 dalpha; | |
504 Uint32 d; | |
505 Uint32 s1; | |
506 Uint32 d1; | |
507 Uint32 s = *srcp; | |
508 Uint32 alpha = s >> 24; | |
509 /* FIXME: Here we special-case opaque alpha since the | |
510 compositioning used (>>8 instead of /255) doesn't handle | |
511 it correctly. Also special-case alpha=0 for speed? | |
512 Benchmark this! */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
513 if(alpha) { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
514 if(alpha == SDL_ALPHA_OPAQUE) { |
0 | 515 *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
|
516 } else { |
0 | 517 /* |
518 * take out the middle component (green), and process | |
519 * the other two in parallel. One multiply less. | |
520 */ | |
521 d = *dstp; | |
522 dalpha = d & 0xff000000; | |
523 s1 = s & 0xff00ff; | |
524 d1 = d & 0xff00ff; | |
525 d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; | |
526 s &= 0xff00; | |
527 d &= 0xff00; | |
528 d = (d + ((s - d) * alpha >> 8)) & 0xff00; | |
529 *dstp = d1 | d | dalpha; | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
530 } |
0 | 531 } |
532 ++srcp; | |
533 ++dstp; | |
534 }, width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
535 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
536 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
537 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
538 } |
0 | 539 } |
540 | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
541 /* 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
|
542 |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
543 /* 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
|
544 #define BLEND16_50(d, s, mask) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
545 ((((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
|
546 |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
547 /* blend two 16 bit pixels at 50% */ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
548 #define BLEND2x16_50(d, s, mask) \ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
549 (((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
|
550 + (s & d & (~(mask | mask << 16)))) |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
551 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
552 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
553 Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) |
0 | 554 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
555 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
556 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
557 Uint16 *srcp = (Uint16 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
558 int srcskip = info->src_skip >> 1; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
559 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
560 int dstskip = info->dst_skip >> 1; |
0 | 561 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
562 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
563 if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
564 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
565 * Source and destination not aligned, pipeline it. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
566 * This is mostly a win for big blits but no loss for |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
567 * small ones |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
568 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
569 Uint32 prev_sw; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
570 int w = width; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
571 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
572 /* handle odd destination */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
573 if ((uintptr_t) dstp & 2) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
574 Uint16 d = *dstp, s = *srcp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
575 *dstp = BLEND16_50(d, s, mask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
576 dstp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
577 srcp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
578 w--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
579 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
580 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
|
581 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
582 /* bootstrap pipeline with first halfword */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
583 prev_sw = ((Uint32 *) srcp)[-1]; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
584 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
585 while (w > 1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
586 Uint32 sw, dw, s; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
587 sw = *(Uint32 *) srcp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
588 dw = *(Uint32 *) dstp; |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
589 #if SDL_BYTEORDER == SDL_BIG_ENDIAN |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
590 s = (prev_sw << 16) + (sw >> 16); |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
591 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
592 s = (prev_sw >> 16) + (sw << 16); |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
593 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
594 prev_sw = sw; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
595 *(Uint32 *) dstp = BLEND2x16_50(dw, s, mask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
596 dstp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
597 srcp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
598 w -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
599 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
600 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
601 /* final pixel if any */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
602 if (w) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
603 Uint16 d = *dstp, s; |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
604 #if SDL_BYTEORDER == SDL_BIG_ENDIAN |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
605 s = (Uint16) prev_sw; |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
606 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
607 s = (Uint16) (prev_sw >> 16); |
1443
9ebbbb4ae53b
Fixed some OpenWatcom warnings
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
608 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
609 *dstp = BLEND16_50(d, s, mask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
610 srcp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
611 dstp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
612 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
613 srcp += srcskip - 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
614 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
615 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
616 /* source and destination are aligned */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
617 int w = width; |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
618 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
619 /* first odd pixel? */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
620 if ((uintptr_t) srcp & 2) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
621 Uint16 d = *dstp, s = *srcp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
622 *dstp = BLEND16_50(d, s, mask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
623 srcp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
624 dstp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
625 w--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
626 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
627 /* 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
|
628 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
629 while (w > 1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
630 Uint32 sw = *(Uint32 *) srcp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
631 Uint32 dw = *(Uint32 *) dstp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
632 *(Uint32 *) dstp = BLEND2x16_50(dw, sw, mask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
633 srcp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
634 dstp += 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
635 w -= 2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
636 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
637 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
638 /* last odd pixel? */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
639 if (w) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
640 Uint16 d = *dstp, s = *srcp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
641 *dstp = BLEND16_50(d, s, mask); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
642 srcp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
643 dstp++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
644 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
645 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
646 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
647 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
648 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
649 } |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
650 |
2255
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
651 #ifdef __MMX__ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
652 |
1542 | 653 /* fast RGB565->RGB565 blending with surface alpha */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
654 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
655 Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) |
1542 | 656 { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
657 unsigned alpha = info->a; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
658 if (alpha == 128) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
659 Blit16to16SurfaceAlpha128(info, 0xf7de); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
660 } else { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
661 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
662 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
663 Uint16 *srcp = (Uint16 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
664 int srcskip = info->src_skip >> 1; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
665 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
666 int dstskip = info->dst_skip >> 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
667 Uint32 s, d; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
668 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
669 __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha; |
1542 | 670 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
671 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
672 mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
673 alpha >>= 3; /* downscale alpha to 5 bits */ |
1542 | 674 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
675 mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
676 mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
677 /* position alpha to allow for mullo and mulhi on diff channels |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
678 to reduce the number of operations */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
679 mm_alpha = _mm_slli_si64(mm_alpha, 3); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
680 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
681 /* Setup the 565 color channel masks */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
682 gmask = _mm_set_pi32(0x07E007E0, 0x07E007E0); /* MASKGREEN -> gmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
683 bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
684 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
685 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
686 /* *INDENT-OFF* */ |
3035
ff602fdfdedc
Removed Rafal Bursig's MMX RLE code, at his request.
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
687 DUFFS_LOOP_124( |
1542 | 688 { |
689 s = *srcp++; | |
690 d = *dstp; | |
691 /* | |
692 * shift out the middle component (green) to | |
693 * the high 16 bits, and process all three RGB | |
694 * components at the same time. | |
695 */ | |
696 s = (s | s << 16) & 0x07e0f81f; | |
697 d = (d | d << 16) & 0x07e0f81f; | |
698 d += (s - d) * alpha >> 5; | |
699 d &= 0x07e0f81f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
700 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 701 },{ |
702 s = *srcp++; | |
703 d = *dstp; | |
704 /* | |
705 * shift out the middle component (green) to | |
706 * the high 16 bits, and process all three RGB | |
707 * components at the same time. | |
708 */ | |
709 s = (s | s << 16) & 0x07e0f81f; | |
710 d = (d | d << 16) & 0x07e0f81f; | |
711 d += (s - d) * alpha >> 5; | |
712 d &= 0x07e0f81f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
713 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 714 s = *srcp++; |
715 d = *dstp; | |
716 /* | |
717 * shift out the middle component (green) to | |
718 * the high 16 bits, and process all three RGB | |
719 * components at the same time. | |
720 */ | |
721 s = (s | s << 16) & 0x07e0f81f; | |
722 d = (d | d << 16) & 0x07e0f81f; | |
723 d += (s - d) * alpha >> 5; | |
724 d &= 0x07e0f81f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
725 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 726 },{ |
727 src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ | |
728 dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ | |
729 | |
730 /* red */ | |
731 src2 = src1; | |
732 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 [000r 000r 000r 000r] */ | |
733 | |
734 dst2 = dst1; | |
735 dst2 = _mm_srli_pi16(dst2, 11); /* dst2 >> 11 -> dst2 [000r 000r 000r 000r] */ | |
736 | |
737 /* blend */ | |
738 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
739 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
740 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ | |
741 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
742 dst2 = _mm_slli_pi16(dst2, 11); /* dst2 << 11 -> dst2 */ | |
743 | |
744 mm_res = dst2; /* RED -> mm_res */ | |
745 | |
746 /* green -- process the bits in place */ | |
747 src2 = src1; | |
748 src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ | |
749 | |
750 dst2 = dst1; | |
751 dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ | |
752 | |
753 /* blend */ | |
754 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
755 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
756 src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ | |
757 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
758 | |
759 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN -> mm_res */ | |
760 | |
761 /* blue */ | |
762 src2 = src1; | |
763 src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ | |
764 | |
765 dst2 = dst1; | |
766 dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ | |
767 | |
768 /* blend */ | |
769 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
770 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
771 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ | |
772 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
773 dst2 = _mm_and_si64(dst2, bmask); /* dst2 & MASKBLUE -> dst2 */ | |
774 | |
775 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN | BLUE -> mm_res */ | |
776 | |
777 *(__m64*)dstp = mm_res; /* mm_res -> 4 dst pixels */ | |
778 | |
779 srcp += 4; | |
780 dstp += 4; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
781 }, width); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
782 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
783 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
784 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
785 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
786 _mm_empty(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
787 } |
1542 | 788 } |
789 | |
790 /* fast RGB555->RGB555 blending with surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
791 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
792 Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) |
1542 | 793 { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
794 unsigned alpha = info->a; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
795 if (alpha == 128) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
796 Blit16to16SurfaceAlpha128(info, 0xfbde); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
797 } else { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
798 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
799 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
800 Uint16 *srcp = (Uint16 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
801 int srcskip = info->src_skip >> 1; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
802 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
803 int dstskip = info->dst_skip >> 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
804 Uint32 s, d; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
805 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
806 __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha; |
1542 | 807 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
808 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
809 mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
810 alpha >>= 3; /* downscale alpha to 5 bits */ |
1542 | 811 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
812 mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
813 mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
814 /* position alpha to allow for mullo and mulhi on diff channels |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
815 to reduce the number of operations */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
816 mm_alpha = _mm_slli_si64(mm_alpha, 3); |
1542 | 817 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
818 /* Setup the 555 color channel masks */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
819 rmask = _mm_set_pi32(0x7C007C00, 0x7C007C00); /* MASKRED -> rmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
820 gmask = _mm_set_pi32(0x03E003E0, 0x03E003E0); /* MASKGREEN -> gmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
821 bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
822 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
823 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
824 /* *INDENT-OFF* */ |
3035
ff602fdfdedc
Removed Rafal Bursig's MMX RLE code, at his request.
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
825 DUFFS_LOOP_124( |
1542 | 826 { |
827 s = *srcp++; | |
828 d = *dstp; | |
829 /* | |
830 * shift out the middle component (green) to | |
831 * the high 16 bits, and process all three RGB | |
832 * components at the same time. | |
833 */ | |
834 s = (s | s << 16) & 0x03e07c1f; | |
835 d = (d | d << 16) & 0x03e07c1f; | |
836 d += (s - d) * alpha >> 5; | |
837 d &= 0x03e07c1f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
838 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 839 },{ |
840 s = *srcp++; | |
841 d = *dstp; | |
842 /* | |
843 * shift out the middle component (green) to | |
844 * the high 16 bits, and process all three RGB | |
845 * components at the same time. | |
846 */ | |
847 s = (s | s << 16) & 0x03e07c1f; | |
848 d = (d | d << 16) & 0x03e07c1f; | |
849 d += (s - d) * alpha >> 5; | |
850 d &= 0x03e07c1f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
851 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 852 s = *srcp++; |
853 d = *dstp; | |
854 /* | |
855 * shift out the middle component (green) to | |
856 * the high 16 bits, and process all three RGB | |
857 * components at the same time. | |
858 */ | |
859 s = (s | s << 16) & 0x03e07c1f; | |
860 d = (d | d << 16) & 0x03e07c1f; | |
861 d += (s - d) * alpha >> 5; | |
862 d &= 0x03e07c1f; | |
1546
4b835e36633d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1542
diff
changeset
|
863 *dstp++ = (Uint16)(d | d >> 16); |
1542 | 864 },{ |
865 src1 = *(__m64*)srcp; /* 4 src pixels -> src1 */ | |
866 dst1 = *(__m64*)dstp; /* 4 dst pixels -> dst1 */ | |
867 | |
868 /* red -- process the bits in place */ | |
869 src2 = src1; | |
870 src2 = _mm_and_si64(src2, rmask); /* src & MASKRED -> src2 */ | |
871 | |
872 dst2 = dst1; | |
873 dst2 = _mm_and_si64(dst2, rmask); /* dst & MASKRED -> dst2 */ | |
874 | |
875 /* blend */ | |
876 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
877 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
878 src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ | |
879 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
880 dst2 = _mm_and_si64(dst2, rmask); /* dst2 & MASKRED -> dst2 */ | |
881 | |
882 mm_res = dst2; /* RED -> mm_res */ | |
883 | |
884 /* green -- process the bits in place */ | |
885 src2 = src1; | |
886 src2 = _mm_and_si64(src2, gmask); /* src & MASKGREEN -> src2 */ | |
887 | |
888 dst2 = dst1; | |
889 dst2 = _mm_and_si64(dst2, gmask); /* dst & MASKGREEN -> dst2 */ | |
890 | |
891 /* blend */ | |
892 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
893 src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
894 src2 = _mm_slli_pi16(src2, 5); /* src2 << 5 -> src2 */ | |
895 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
896 | |
897 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN -> mm_res */ | |
898 | |
899 /* blue */ | |
900 src2 = src1; /* src -> src2 */ | |
901 src2 = _mm_and_si64(src2, bmask); /* src & MASKBLUE -> src2[000b 000b 000b 000b] */ | |
902 | |
903 dst2 = dst1; /* dst -> dst2 */ | |
904 dst2 = _mm_and_si64(dst2, bmask); /* dst & MASKBLUE -> dst2[000b 000b 000b 000b] */ | |
905 | |
906 /* blend */ | |
907 src2 = _mm_sub_pi16(src2, dst2);/* src - dst -> src2 */ | |
908 src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ | |
909 src2 = _mm_srli_pi16(src2, 11); /* src2 >> 11 -> src2 */ | |
910 dst2 = _mm_add_pi16(src2, dst2); /* src2 + dst2 -> dst2 */ | |
911 dst2 = _mm_and_si64(dst2, bmask); /* dst2 & MASKBLUE -> dst2 */ | |
912 | |
913 mm_res = _mm_or_si64(mm_res, dst2); /* RED | GREEN | BLUE -> mm_res */ | |
914 | |
915 *(__m64*)dstp = mm_res; /* mm_res -> 4 dst pixels */ | |
916 | |
917 srcp += 4; | |
918 dstp += 4; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
919 }, width); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
920 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
921 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
922 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
923 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
924 _mm_empty(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
925 } |
1542 | 926 } |
2255
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
927 |
17b2369756be
Use MMX intrinsics over GCC inline assembly
Sam Lantinga <slouken@libsdl.org>
parents:
2232
diff
changeset
|
928 #endif /* __MMX__ */ |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
929 |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
930 /* fast RGB565->RGB565 blending with surface alpha */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
931 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
932 Blit565to565SurfaceAlpha(SDL_BlitInfo * info) |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
933 { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
934 unsigned alpha = info->a; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
935 if (alpha == 128) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
936 Blit16to16SurfaceAlpha128(info, 0xf7de); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
937 } else { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
938 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
939 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
940 Uint16 *srcp = (Uint16 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
941 int srcskip = info->src_skip >> 1; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
942 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
943 int dstskip = info->dst_skip >> 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
944 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
|
945 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
946 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
947 /* *INDENT-OFF* */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
948 DUFFS_LOOP4({ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
949 Uint32 s = *srcp++; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
950 Uint32 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
951 /* |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
952 * shift out the middle component (green) to |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
953 * 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
|
954 * components at the same time. |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
955 */ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
956 s = (s | s << 16) & 0x07e0f81f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
957 d = (d | d << 16) & 0x07e0f81f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
958 d += (s - d) * alpha >> 5; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
959 d &= 0x07e0f81f; |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
960 *dstp++ = (Uint16)(d | d >> 16); |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
961 }, width); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
962 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
963 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
964 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
965 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
966 } |
0 | 967 } |
968 | |
969 /* fast RGB555->RGB555 blending with surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
970 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
971 Blit555to555SurfaceAlpha(SDL_BlitInfo * info) |
0 | 972 { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
973 unsigned alpha = info->a; /* downscale alpha to 5 bits */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
974 if (alpha == 128) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
975 Blit16to16SurfaceAlpha128(info, 0xfbde); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
976 } else { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
977 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
978 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
979 Uint16 *srcp = (Uint16 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
980 int srcskip = info->src_skip >> 1; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
981 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
982 int dstskip = info->dst_skip >> 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
983 alpha >>= 3; /* downscale alpha to 5 bits */ |
0 | 984 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
985 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
986 /* *INDENT-OFF* */ |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
987 DUFFS_LOOP4({ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
988 Uint32 s = *srcp++; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
989 Uint32 d = *dstp; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
990 /* |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
991 * shift out the middle component (green) to |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
992 * 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
|
993 * components at the same time. |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
994 */ |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
995 s = (s | s << 16) & 0x03e07c1f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
996 d = (d | d << 16) & 0x03e07c1f; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
997 d += (s - d) * alpha >> 5; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
998 d &= 0x03e07c1f; |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
999 *dstp++ = (Uint16)(d | d >> 16); |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
1000 }, width); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1001 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1002 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1003 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1004 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1005 } |
0 | 1006 } |
1007 | |
1008 /* fast ARGB8888->RGB565 blending with pixel alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1009 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1010 BlitARGBto565PixelAlpha(SDL_BlitInfo * info) |
0 | 1011 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1012 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1013 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1014 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1015 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1016 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1017 int dstskip = info->dst_skip >> 1; |
0 | 1018 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1019 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1020 /* *INDENT-OFF* */ |
0 | 1021 DUFFS_LOOP4({ |
1022 Uint32 s = *srcp; | |
1023 unsigned alpha = s >> 27; /* downscale alpha to 5 bits */ | |
1024 /* FIXME: Here we special-case opaque alpha since the | |
1025 compositioning used (>>8 instead of /255) doesn't handle | |
1026 it correctly. Also special-case alpha=0 for speed? | |
1027 Benchmark this! */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1028 if(alpha) { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1029 if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
1030 *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
|
1031 } else { |
0 | 1032 Uint32 d = *dstp; |
1033 /* | |
1034 * convert source and destination to G0RAB65565 | |
1035 * and blend all components at the same time | |
1036 */ | |
1037 s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) | |
1038 + (s >> 3 & 0x1f); | |
1039 d = (d | d << 16) & 0x07e0f81f; | |
1040 d += (s - d) * alpha >> 5; | |
1041 d &= 0x07e0f81f; | |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
1042 *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
|
1043 } |
0 | 1044 } |
1045 srcp++; | |
1046 dstp++; | |
1047 }, width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1048 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1049 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1050 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1051 } |
0 | 1052 } |
1053 | |
1054 /* fast ARGB8888->RGB555 blending with pixel alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1055 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1056 BlitARGBto555PixelAlpha(SDL_BlitInfo * info) |
0 | 1057 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1058 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1059 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1060 Uint32 *srcp = (Uint32 *) info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1061 int srcskip = info->src_skip >> 2; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1062 Uint16 *dstp = (Uint16 *) info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1063 int dstskip = info->dst_skip >> 1; |
0 | 1064 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1065 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1066 /* *INDENT-OFF* */ |
0 | 1067 DUFFS_LOOP4({ |
1068 unsigned alpha; | |
1069 Uint32 s = *srcp; | |
1070 alpha = s >> 27; /* downscale alpha to 5 bits */ | |
1071 /* FIXME: Here we special-case opaque alpha since the | |
1072 compositioning used (>>8 instead of /255) doesn't handle | |
1073 it correctly. Also special-case alpha=0 for speed? | |
1074 Benchmark this! */ | |
689
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1075 if(alpha) { |
5bb080d35049
Date: Tue, 19 Aug 2003 17:57:00 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
1076 if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
1077 *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
|
1078 } else { |
0 | 1079 Uint32 d = *dstp; |
1080 /* | |
1081 * convert source and destination to G0RAB65565 | |
1082 * and blend all components at the same time | |
1083 */ | |
1084 s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) | |
1085 + (s >> 3 & 0x1f); | |
1086 d = (d | d << 16) & 0x03e07c1f; | |
1087 d += (s - d) * alpha >> 5; | |
1088 d &= 0x03e07c1f; | |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
1089 *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
|
1090 } |
0 | 1091 } |
1092 srcp++; | |
1093 dstp++; | |
1094 }, width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1095 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1096 srcp += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1097 dstp += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1098 } |
0 | 1099 } |
1100 | |
1101 /* General (slow) N->N blending with per-surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1102 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1103 BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) |
0 | 1104 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1105 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1106 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1107 Uint8 *src = info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1108 int srcskip = info->src_skip; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1109 Uint8 *dst = info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1110 int dstskip = info->dst_skip; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1111 SDL_PixelFormat *srcfmt = info->src_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1112 SDL_PixelFormat *dstfmt = info->dst_fmt; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1113 int srcbpp = srcfmt->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1114 int dstbpp = dstfmt->BytesPerPixel; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1115 unsigned sA = info->a; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1116 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; |
0 | 1117 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1118 if (sA) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1119 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1120 /* *INDENT-OFF* */ |
0 | 1121 DUFFS_LOOP4( |
1122 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
1123 Uint32 Pixel; |
0 | 1124 unsigned sR; |
1125 unsigned sG; | |
1126 unsigned sB; | |
1127 unsigned dR; | |
1128 unsigned dG; | |
1129 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
|
1130 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
|
1131 DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB); |
0 | 1132 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); |
1133 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); | |
1134 src += srcbpp; | |
1135 dst += dstbpp; | |
1136 }, | |
1137 width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1138 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1139 src += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1140 dst += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1141 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1142 } |
0 | 1143 } |
1144 | |
1145 /* General (slow) colorkeyed N->N blending with per-surface alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1146 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1147 BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) |
0 | 1148 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1149 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1150 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1151 Uint8 *src = info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1152 int srcskip = info->src_skip; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1153 Uint8 *dst = info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1154 int dstskip = info->dst_skip; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1155 SDL_PixelFormat *srcfmt = info->src_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1156 SDL_PixelFormat *dstfmt = info->dst_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1157 Uint32 ckey = info->colorkey; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1158 int srcbpp = srcfmt->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1159 int dstbpp = dstfmt->BytesPerPixel; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1160 unsigned sA = info->a; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1161 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; |
0 | 1162 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1163 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1164 /* *INDENT-OFF* */ |
0 | 1165 DUFFS_LOOP4( |
1166 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
1167 Uint32 Pixel; |
0 | 1168 unsigned sR; |
1169 unsigned sG; | |
1170 unsigned sB; | |
1171 unsigned dR; | |
1172 unsigned dG; | |
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB); |
0 | 1178 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); |
1179 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); | |
1180 } | |
1181 src += srcbpp; | |
1182 dst += dstbpp; | |
1183 }, | |
1184 width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1185 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1186 src += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1187 dst += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1188 } |
0 | 1189 } |
1190 | |
1191 /* General (slow) N->N blending with pixel alpha */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1192 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1193 BlitNtoNPixelAlpha(SDL_BlitInfo * info) |
0 | 1194 { |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1195 int width = info->dst_w; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1196 int height = info->dst_h; |
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1197 Uint8 *src = info->src; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1198 int srcskip = info->src_skip; |
2262
bee005ace1bf
Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
2261
diff
changeset
|
1199 Uint8 *dst = info->dst; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1200 int dstskip = info->dst_skip; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1201 SDL_PixelFormat *srcfmt = info->src_fmt; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1202 SDL_PixelFormat *dstfmt = info->dst_fmt; |
0 | 1203 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1204 int srcbpp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1205 int dstbpp; |
0 | 1206 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1207 /* Set up some basic variables */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1208 srcbpp = srcfmt->BytesPerPixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1209 dstbpp = dstfmt->BytesPerPixel; |
0 | 1210 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1211 /* FIXME: for 8bpp source alpha, this doesn't get opaque values |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1212 quite right. for <8bpp source alpha, it gets them very wrong |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1213 (check all macros!) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1214 It is unclear whether there is a good general solution that doesn't |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1215 need a branch (or a divide). */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1216 while (height--) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1217 /* *INDENT-OFF* */ |
0 | 1218 DUFFS_LOOP4( |
1219 { | |
1162
2651158f59b8
Enable altivec blitters on PowerPC Linux, and some fixes for recent
Ryan C. Gordon <icculus@icculus.org>
parents:
1047
diff
changeset
|
1220 Uint32 Pixel; |
0 | 1221 unsigned sR; |
1222 unsigned sG; | |
1223 unsigned sB; | |
1224 unsigned dR; | |
1225 unsigned dG; | |
1226 unsigned dB; | |
1227 unsigned sA; | |
1228 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
|
1229 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
|
1230 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
|
1231 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
|
1232 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
|
1233 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
|
1234 } |
0 | 1235 src += srcbpp; |
1236 dst += dstbpp; | |
1237 }, | |
1238 width); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1239 /* *INDENT-ON* */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1240 src += srcskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1241 dst += dstskip; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1242 } |
0 | 1243 } |
1244 | |
1245 | |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1246 SDL_BlitFunc |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1247 SDL_CalculateBlitA(SDL_Surface * surface) |
0 | 1248 { |
1249 SDL_PixelFormat *sf = surface->format; | |
1250 SDL_PixelFormat *df = surface->map->dst->format; | |
1251 | |
2853
6258fa7cd300
Fixed picking blit function when RLE fails
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
1252 switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1253 case SDL_COPY_BLEND: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1254 /* Per-pixel alpha blits */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1255 switch (df->BytesPerPixel) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1256 case 1: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1257 return BlitNto1PixelAlpha; |
0 | 1258 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1259 case 2: |
5264
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1260 if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 |
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1261 && sf->Gmask == 0xff00 |
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1262 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) |
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1263 || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1264 if (df->Gmask == 0x7e0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1265 return BlitARGBto565PixelAlpha; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1266 else if (df->Gmask == 0x3e0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1267 return BlitARGBto555PixelAlpha; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1268 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1269 return BlitNtoNPixelAlpha; |
0 | 1270 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1271 case 4: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1272 if (sf->Rmask == df->Rmask |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1273 && sf->Gmask == df->Gmask |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1274 && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { |
5264
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1275 #if defined(__MMX__) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1276 if (sf->Rshift % 8 == 0 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1277 && sf->Gshift % 8 == 0 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1278 && sf->Bshift % 8 == 0 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1279 && sf->Ashift % 8 == 0 && sf->Aloss == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1280 if (SDL_HasMMX()) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1281 return BlitRGBtoRGBPixelAlphaMMX; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1282 } |
5264
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1283 #endif /* __MMX__ */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1284 if (sf->Amask == 0xff000000) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1285 return BlitRGBtoRGBPixelAlpha; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1286 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1287 } |
5264
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1288 return BlitNtoNPixelAlpha; |
0 | 1289 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1290 case 3: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1291 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1292 return BlitNtoNPixelAlpha; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1293 } |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1294 break; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1295 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1296 case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1297 if (sf->Amask == 0) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1298 /* Per-surface alpha blits */ |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1299 switch (df->BytesPerPixel) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1300 case 1: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1301 return BlitNto1SurfaceAlpha; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1302 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1303 case 2: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1304 if (surface->map->identity) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1305 if (df->Gmask == 0x7e0) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1306 #ifdef __MMX__ |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1307 if (SDL_HasMMX()) |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1308 return Blit565to565SurfaceAlphaMMX; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1309 else |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1310 #endif |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1311 return Blit565to565SurfaceAlpha; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1312 } else if (df->Gmask == 0x3e0) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1313 #ifdef __MMX__ |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1314 if (SDL_HasMMX()) |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1315 return Blit555to555SurfaceAlphaMMX; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1316 else |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1317 #endif |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1318 return Blit555to555SurfaceAlpha; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1319 } |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1320 } |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1321 return BlitNtoNSurfaceAlpha; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1322 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1323 case 4: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1324 if (sf->Rmask == df->Rmask |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1325 && sf->Gmask == df->Gmask |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1326 && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1327 #ifdef __MMX__ |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1328 if (sf->Rshift % 8 == 0 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1329 && sf->Gshift % 8 == 0 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1330 && sf->Bshift % 8 == 0 && SDL_HasMMX()) |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1331 return BlitRGBtoRGBSurfaceAlphaMMX; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1332 #endif |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1333 if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1334 return BlitRGBtoRGBSurfaceAlpha; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1335 } |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1336 } |
5264
6a65c1fc07af
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1337 return BlitNtoNSurfaceAlpha; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1338 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1339 case 3: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1340 default: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1341 return BlitNtoNSurfaceAlpha; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1342 } |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1343 } |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1344 break; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1345 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1346 case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1347 if (sf->Amask == 0) { |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1348 if (df->BytesPerPixel == 1) |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1349 return BlitNto1SurfaceAlphaKey; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1350 else |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1351 return BlitNtoNSurfaceAlphaKey; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1352 } |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1353 break; |
0 | 1354 } |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1355 |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
1356 return NULL; |
0 | 1357 } |
1358 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1795
diff
changeset
|
1359 /* vi: set ts=4 sw=4 expandtab: */ |