Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit.h @ 2824:4dba7aa7ea77
Added slow but complete blit fallback
Don't try to RLE encode surfaces that have alpha channel and alpha modulation
Don't turn on blending when converting an RGB surface to RGBA format
Do turn on blending when converting colorkey to alpha channel
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 02 Dec 2008 17:14:04 +0000 |
parents | c785543d1843 |
children | 6258fa7cd300 |
comparison
equal
deleted
inserted
replaced
2823:15e1dd1fff78 | 2824:4dba7aa7ea77 |
---|---|
163 Pixel = *((Uint16 *)(buf)); \ | 163 Pixel = *((Uint16 *)(buf)); \ |
164 break; \ | 164 break; \ |
165 \ | 165 \ |
166 case 3: { \ | 166 case 3: { \ |
167 Uint8 *B = (Uint8 *)(buf); \ | 167 Uint8 *B = (Uint8 *)(buf); \ |
168 if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ | 168 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ |
169 Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ | 169 Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ |
170 } else { \ | 170 } else { \ |
171 Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ | 171 Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ |
172 } \ | 172 } \ |
173 } \ | 173 } \ |
176 case 4: \ | 176 case 4: \ |
177 Pixel = *((Uint32 *)(buf)); \ | 177 Pixel = *((Uint32 *)(buf)); \ |
178 break; \ | 178 break; \ |
179 \ | 179 \ |
180 default: \ | 180 default: \ |
181 Pixel = 0; /* appease gcc */ \ | 181 Pixel; /* stop gcc complaints */ \ |
182 break; \ | 182 break; \ |
183 } \ | 183 } \ |
184 } while(0) | 184 } while (0) |
185 | 185 |
186 #define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ | 186 #define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ |
187 do { \ | 187 do { \ |
188 switch (bpp) { \ | 188 switch (bpp) { \ |
189 case 2: \ | 189 case 2: \ |
190 Pixel = *((Uint16 *)(buf)); \ | 190 Pixel = *((Uint16 *)(buf)); \ |
191 break; \ | 191 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ |
192 \ | 192 break; \ |
193 case 3: { \ | 193 \ |
194 Uint8 *B = (Uint8 *)buf; \ | 194 case 3: { \ |
195 if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ | 195 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ |
196 Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ | 196 r = *((buf)+fmt->Rshift/8); \ |
197 g = *((buf)+fmt->Gshift/8); \ | |
198 b = *((buf)+fmt->Bshift/8); \ | |
197 } else { \ | 199 } else { \ |
198 Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ | 200 r = *((buf)+2-fmt->Rshift/8); \ |
201 g = *((buf)+2-fmt->Gshift/8); \ | |
202 b = *((buf)+2-fmt->Bshift/8); \ | |
199 } \ | 203 } \ |
200 } \ | 204 } \ |
201 break; \ | 205 break; \ |
202 \ | 206 \ |
203 case 4: \ | 207 case 4: \ |
204 Pixel = *((Uint32 *)(buf)); \ | 208 Pixel = *((Uint32 *)(buf)); \ |
205 break; \ | 209 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ |
206 \ | 210 break; \ |
207 default: \ | 211 \ |
208 Pixel = 0; /* prevent gcc from complaining */ \ | 212 default: \ |
213 Pixel; /* stop gcc complaints */ \ | |
209 break; \ | 214 break; \ |
210 } \ | 215 } \ |
211 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ | 216 } while (0) |
212 } while(0) | |
213 | 217 |
214 /* Assemble R-G-B values into a specified pixel format and store them */ | 218 /* Assemble R-G-B values into a specified pixel format and store them */ |
215 #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ | 219 #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ |
216 { \ | 220 { \ |
217 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ | 221 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ |
240 *((Uint16 *)(buf)) = Pixel; \ | 244 *((Uint16 *)(buf)) = Pixel; \ |
241 } \ | 245 } \ |
242 break; \ | 246 break; \ |
243 \ | 247 \ |
244 case 3: { \ | 248 case 3: { \ |
245 if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ | 249 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ |
246 *((buf)+fmt->Rshift/8) = r; \ | 250 *((buf)+fmt->Rshift/8) = r; \ |
247 *((buf)+fmt->Gshift/8) = g; \ | 251 *((buf)+fmt->Gshift/8) = g; \ |
248 *((buf)+fmt->Bshift/8) = b; \ | 252 *((buf)+fmt->Bshift/8) = b; \ |
249 } else { \ | 253 } else { \ |
250 *((buf)+2-fmt->Rshift/8) = r; \ | 254 *((buf)+2-fmt->Rshift/8) = r; \ |
275 *bufp = Pixel | (*bufp & Amask); \ | 279 *bufp = Pixel | (*bufp & Amask); \ |
276 } \ | 280 } \ |
277 break; \ | 281 break; \ |
278 \ | 282 \ |
279 case 3: { \ | 283 case 3: { \ |
280 if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ | 284 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ |
281 *((buf)+fmt->Rshift/8) = r; \ | 285 *((buf)+fmt->Rshift/8) = r; \ |
282 *((buf)+fmt->Gshift/8) = g; \ | 286 *((buf)+fmt->Gshift/8) = g; \ |
283 *((buf)+fmt->Bshift/8) = b; \ | 287 *((buf)+fmt->Bshift/8) = b; \ |
284 } else { \ | 288 } else { \ |
285 *((buf)+2-fmt->Rshift/8) = r; \ | 289 *((buf)+2-fmt->Rshift/8) = r; \ |
340 #define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ | 344 #define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ |
341 do { \ | 345 do { \ |
342 switch (bpp) { \ | 346 switch (bpp) { \ |
343 case 2: \ | 347 case 2: \ |
344 Pixel = *((Uint16 *)(buf)); \ | 348 Pixel = *((Uint16 *)(buf)); \ |
345 break; \ | 349 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ |
346 \ | 350 break; \ |
347 case 3: {/* FIXME: broken code (no alpha) */ \ | 351 \ |
348 Uint8 *b = (Uint8 *)buf; \ | 352 case 3: { \ |
349 if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ | 353 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ |
350 Pixel = b[0] + (b[1] << 8) + (b[2] << 16); \ | 354 r = *((buf)+fmt->Rshift/8); \ |
355 g = *((buf)+fmt->Gshift/8); \ | |
356 b = *((buf)+fmt->Bshift/8); \ | |
351 } else { \ | 357 } else { \ |
352 Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \ | 358 r = *((buf)+2-fmt->Rshift/8); \ |
359 g = *((buf)+2-fmt->Gshift/8); \ | |
360 b = *((buf)+2-fmt->Bshift/8); \ | |
353 } \ | 361 } \ |
362 a = 0xFF; \ | |
354 } \ | 363 } \ |
355 break; \ | 364 break; \ |
356 \ | 365 \ |
357 case 4: \ | 366 case 4: \ |
358 Pixel = *((Uint32 *)(buf)); \ | 367 Pixel = *((Uint32 *)(buf)); \ |
368 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ | |
359 break; \ | 369 break; \ |
360 \ | 370 \ |
361 default: \ | 371 default: \ |
362 Pixel = 0; /* stop gcc complaints */ \ | 372 Pixel; /* stop gcc complaints */ \ |
363 break; \ | 373 break; \ |
364 } \ | 374 } \ |
365 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ | 375 } while (0) |
366 Pixel &= ~fmt->Amask; \ | |
367 } while(0) | |
368 | 376 |
369 /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */ | 377 /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */ |
370 #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ | 378 #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ |
371 { \ | 379 { \ |
372 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ | 380 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ |
383 PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ | 391 PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ |
384 *((Uint16 *)(buf)) = Pixel; \ | 392 *((Uint16 *)(buf)) = Pixel; \ |
385 } \ | 393 } \ |
386 break; \ | 394 break; \ |
387 \ | 395 \ |
388 case 3: { /* FIXME: broken code (no alpha) */ \ | 396 case 3: { \ |
389 if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ | 397 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ |
390 *((buf)+fmt->Rshift/8) = r; \ | 398 *((buf)+fmt->Rshift/8) = r; \ |
391 *((buf)+fmt->Gshift/8) = g; \ | 399 *((buf)+fmt->Gshift/8) = g; \ |
392 *((buf)+fmt->Bshift/8) = b; \ | 400 *((buf)+fmt->Bshift/8) = b; \ |
393 } else { \ | 401 } else { \ |
394 *((buf)+2-fmt->Rshift/8) = r; \ | 402 *((buf)+2-fmt->Rshift/8) = r; \ |