21 #include "../SDL_internal.h" 34 #define SDL_COPY_MODULATE_COLOR 0x00000001 35 #define SDL_COPY_MODULATE_ALPHA 0x00000002 36 #define SDL_COPY_BLEND 0x00000010 37 #define SDL_COPY_ADD 0x00000020 38 #define SDL_COPY_MOD 0x00000040 39 #define SDL_COPY_COLORKEY 0x00000100 40 #define SDL_COPY_NEAREST 0x00000200 41 #define SDL_COPY_RLE_DESIRED 0x00001000 42 #define SDL_COPY_RLE_COLORKEY 0x00002000 43 #define SDL_COPY_RLE_ALPHAKEY 0x00004000 44 #define SDL_COPY_RLE_MASK (SDL_COPY_RLE_DESIRED|SDL_COPY_RLE_COLORKEY|SDL_COPY_RLE_ALPHAKEY) 47 #define SDL_CPU_ANY 0x00000000 48 #define SDL_CPU_MMX 0x00000001 49 #define SDL_CPU_3DNOW 0x00000002 50 #define SDL_CPU_SSE 0x00000004 51 #define SDL_CPU_SSE2 0x00000008 52 #define SDL_CPU_ALTIVEC_PREFETCH 0x00000010 53 #define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000020 113 #if defined(__GNUC__) 114 #define DECLARE_ALIGNED(t,v,a) t __attribute__((aligned(a))) v 115 #elif defined(_MSC_VER) 116 #define DECLARE_ALIGNED(t,v,a) __declspec(align(a)) t v 118 #define DECLARE_ALIGNED(t,v,a) t v 122 #define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ 124 r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ 125 g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ 126 b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ 128 #define RGB_FROM_RGB565(Pixel, r, g, b) \ 130 r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \ 131 g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \ 132 b = SDL_expand_byte[3][(Pixel&0x001F)]; \ 134 #define RGB_FROM_RGB555(Pixel, r, g, b) \ 136 r = SDL_expand_byte[3][((Pixel&0x7C00)>>10)]; \ 137 g = SDL_expand_byte[3][((Pixel&0x03E0)>>5)]; \ 138 b = SDL_expand_byte[3][(Pixel&0x001F)]; \ 140 #define RGB_FROM_RGB888(Pixel, r, g, b) \ 142 r = ((Pixel&0xFF0000)>>16); \ 143 g = ((Pixel&0xFF00)>>8); \ 146 #define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \ 150 Pixel = *((Uint8 *)(buf)); \ 154 Pixel = *((Uint16 *)(buf)); \ 158 Uint8 *B = (Uint8 *)(buf); \ 159 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ 160 Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ 162 Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ 168 Pixel = *((Uint32 *)(buf)); \ 177 #define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ 181 Pixel = *((Uint8 *)(buf)); \ 182 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ 186 Pixel = *((Uint16 *)(buf)); \ 187 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ 192 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ 193 r = *((buf)+fmt->Rshift/8); \ 194 g = *((buf)+fmt->Gshift/8); \ 195 b = *((buf)+fmt->Bshift/8); \ 197 r = *((buf)+2-fmt->Rshift/8); \ 198 g = *((buf)+2-fmt->Gshift/8); \ 199 b = *((buf)+2-fmt->Bshift/8); \ 205 Pixel = *((Uint32 *)(buf)); \ 206 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ 218 #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ 220 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ 221 ((g>>fmt->Gloss)<<fmt->Gshift)| \ 222 ((b>>fmt->Bloss)<<fmt->Bshift)| \ 225 #define RGB565_FROM_RGB(Pixel, r, g, b) \ 227 Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \ 229 #define RGB555_FROM_RGB(Pixel, r, g, b) \ 231 Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \ 233 #define RGB888_FROM_RGB(Pixel, r, g, b) \ 235 Pixel = (r<<16)|(g<<8)|b; \ 237 #define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \ 239 Pixel = (a<<24)|(r<<16)|(g<<8)|b; \ 241 #define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \ 243 Pixel = (r<<24)|(g<<16)|(b<<8)|a; \ 245 #define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \ 247 Pixel = (a<<24)|(b<<16)|(g<<8)|r; \ 249 #define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \ 251 Pixel = (b<<24)|(g<<16)|(r<<8)|a; \ 253 #define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a) \ 255 r = r ? ((r << 2) | 0x3) : 0; \ 256 g = g ? ((g << 2) | 0x3) : 0; \ 257 b = b ? ((b << 2) | 0x3) : 0; \ 259 Pixel = (a<<30)|(r<<20)|(g<<10)|b; \ 261 #define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ 267 PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ 268 *((Uint8 *)(buf)) = Pixel; \ 275 PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ 276 *((Uint16 *)(buf)) = Pixel; \ 281 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ 282 *((buf)+fmt->Rshift/8) = r; \ 283 *((buf)+fmt->Gshift/8) = g; \ 284 *((buf)+fmt->Bshift/8) = b; \ 286 *((buf)+2-fmt->Rshift/8) = r; \ 287 *((buf)+2-fmt->Gshift/8) = g; \ 288 *((buf)+2-fmt->Bshift/8) = b; \ 296 PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ 297 *((Uint32 *)(buf)) = Pixel; \ 304 #define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ 306 r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ 307 g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ 308 b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ 309 a = SDL_expand_byte[fmt->Aloss][((Pixel&fmt->Amask)>>fmt->Ashift)]; \ 311 #define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ 313 r = (Pixel&fmt->Rmask)>>fmt->Rshift; \ 314 g = (Pixel&fmt->Gmask)>>fmt->Gshift; \ 315 b = (Pixel&fmt->Bmask)>>fmt->Bshift; \ 316 a = (Pixel&fmt->Amask)>>fmt->Ashift; \ 318 #define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \ 321 g = ((Pixel>>16)&0xFF); \ 322 b = ((Pixel>>8)&0xFF); \ 325 #define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \ 327 r = ((Pixel>>16)&0xFF); \ 328 g = ((Pixel>>8)&0xFF); \ 332 #define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \ 335 g = ((Pixel>>8)&0xFF); \ 336 b = ((Pixel>>16)&0xFF); \ 339 #define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \ 341 r = ((Pixel>>8)&0xFF); \ 342 g = ((Pixel>>16)&0xFF); \ 346 #define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a) \ 348 r = ((Pixel>>22)&0xFF); \ 349 g = ((Pixel>>12)&0xFF); \ 350 b = ((Pixel>>2)&0xFF); \ 351 a = SDL_expand_byte[6][(Pixel>>30)]; \ 353 #define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ 357 Pixel = *((Uint8 *)(buf)); \ 358 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ 362 Pixel = *((Uint16 *)(buf)); \ 363 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ 368 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ 369 r = *((buf)+fmt->Rshift/8); \ 370 g = *((buf)+fmt->Gshift/8); \ 371 b = *((buf)+fmt->Bshift/8); \ 373 r = *((buf)+2-fmt->Rshift/8); \ 374 g = *((buf)+2-fmt->Gshift/8); \ 375 b = *((buf)+2-fmt->Bshift/8); \ 382 Pixel = *((Uint32 *)(buf)); \ 383 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ 395 #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ 397 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ 398 ((g>>fmt->Gloss)<<fmt->Gshift)| \ 399 ((b>>fmt->Bloss)<<fmt->Bshift)| \ 400 ((a>>fmt->Aloss)<<fmt->Ashift); \ 402 #define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ 408 PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ 409 *((Uint8 *)(buf)) = _pixel; \ 416 PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ 417 *((Uint16 *)(buf)) = _pixel; \ 422 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ 423 *((buf)+fmt->Rshift/8) = r; \ 424 *((buf)+fmt->Gshift/8) = g; \ 425 *((buf)+fmt->Bshift/8) = b; \ 427 *((buf)+2-fmt->Rshift/8) = r; \ 428 *((buf)+2-fmt->Gshift/8) = g; \ 429 *((buf)+2-fmt->Bshift/8) = b; \ 437 PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ 438 *((Uint32 *)(buf)) = _pixel; \ 445 #define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ 447 dR = (Uint8)((((int)(sR-dR)*(int)A)/255)+dR); \ 448 dG = (Uint8)((((int)(sG-dG)*(int)A)/255)+dG); \ 449 dB = (Uint8)((((int)(sB-dB)*(int)A)/255)+dB); \ 454 #define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ 456 dR = (Uint8)((((int)(sR-dR)*(int)sA)/255)+dR); \ 457 dG = (Uint8)((((int)(sG-dG)*(int)sA)/255)+dG); \ 458 dB = (Uint8)((((int)(sB-dB)*(int)sA)/255)+dB); \ 459 dA = (Uint8)((int)sA+dA-((int)sA*dA)/255); \ 464 #if defined(_MSC_VER) && (_MSC_VER == 1300) 467 #define USE_DUFFS_LOOP 469 #ifdef USE_DUFFS_LOOP 472 #define DUFFS_LOOP8(pixel_copy_increment, width) \ 473 { int n = (width+7)/8; \ 474 switch (width & 7) { \ 475 case 0: do { pixel_copy_increment; \ 476 case 7: pixel_copy_increment; \ 477 case 6: pixel_copy_increment; \ 478 case 5: pixel_copy_increment; \ 479 case 4: pixel_copy_increment; \ 480 case 3: pixel_copy_increment; \ 481 case 2: pixel_copy_increment; \ 482 case 1: pixel_copy_increment; \ 483 } while ( --n > 0 ); \ 488 #define DUFFS_LOOP4(pixel_copy_increment, width) \ 489 { int n = (width+3)/4; \ 490 switch (width & 3) { \ 491 case 0: do { pixel_copy_increment; \ 492 case 3: pixel_copy_increment; \ 493 case 2: pixel_copy_increment; \ 494 case 1: pixel_copy_increment; \ 500 #define DUFFS_LOOP(pixel_copy_increment, width) \ 501 DUFFS_LOOP8(pixel_copy_increment, width) 504 #define DUFFS_LOOP_124(pixel_copy_increment1, \ 505 pixel_copy_increment2, \ 506 pixel_copy_increment4, width) \ 509 pixel_copy_increment1; n -= 1; \ 512 pixel_copy_increment2; n -= 2; \ 515 pixel_copy_increment4; n -= 4; \ 520 pixel_copy_increment4; \ 521 pixel_copy_increment4; \ 529 #define DUFFS_LOOP(pixel_copy_increment, width) \ 531 for ( n=width; n > 0; --n ) { \ 532 pixel_copy_increment; \ 535 #define DUFFS_LOOP8(pixel_copy_increment, width) \ 536 DUFFS_LOOP(pixel_copy_increment, width) 537 #define DUFFS_LOOP4(pixel_copy_increment, width) \ 538 DUFFS_LOOP(pixel_copy_increment, width) 539 #define DUFFS_LOOP_124(pixel_copy_increment1, \ 540 pixel_copy_increment2, \ 541 pixel_copy_increment4, width) \ 542 DUFFS_LOOP(pixel_copy_increment1, width) 547 #if defined(_MSC_VER) && (_MSC_VER >= 600) 548 #pragma warning(disable: 4550)
SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
int(* SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, struct SDL_Surface *dst, SDL_Rect *dstrect)
The type of function used for surface blitting functions.
SDL_PixelFormat * src_fmt
A collection of pixels used in software blitting.
int SDL_CalculateBlit(SDL_Surface *surface)
Uint32 dst_palette_version
Uint32 src_palette_version
Uint8 * SDL_expand_byte[9]
SDL_PixelFormat * dst_fmt
SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
void(* SDL_BlitFunc)(SDL_BlitInfo *info)
SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b