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
112 #if defined(__GNUC__)
113 #define DECLARE_ALIGNED(t,v,a) t __attribute__((aligned(a))) v
114 #elif defined(_MSC_VER)
115 #define DECLARE_ALIGNED(t,v,a) __declspec(align(a)) t v
117 #define DECLARE_ALIGNED(t,v,a) t v
121 #define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \
123 r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \
124 g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \
125 b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \
127 #define RGB_FROM_RGB565(Pixel, r, g, b) \
129 r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \
130 g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \
131 b = SDL_expand_byte[3][(Pixel&0x001F)]; \
133 #define RGB_FROM_RGB555(Pixel, r, g, b) \
135 r = SDL_expand_byte[3][((Pixel&0x7C00)>>10)]; \
136 g = SDL_expand_byte[3][((Pixel&0x03E0)>>5)]; \
137 b = SDL_expand_byte[3][(Pixel&0x001F)]; \
139 #define RGB_FROM_RGB888(Pixel, r, g, b) \
141 r = ((Pixel&0xFF0000)>>16); \
142 g = ((Pixel&0xFF00)>>8); \
145 #define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \
149 Pixel = *((Uint8 *)(buf)); \
153 Pixel = *((Uint16 *)(buf)); \
157 Uint8 *B = (Uint8 *)(buf); \
158 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
159 Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
161 Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
167 Pixel = *((Uint32 *)(buf)); \
176 #define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
180 Pixel = *((Uint8 *)(buf)); \
181 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
185 Pixel = *((Uint16 *)(buf)); \
186 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
191 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
192 r = *((buf)+fmt->Rshift/8); \
193 g = *((buf)+fmt->Gshift/8); \
194 b = *((buf)+fmt->Bshift/8); \
196 r = *((buf)+2-fmt->Rshift/8); \
197 g = *((buf)+2-fmt->Gshift/8); \
198 b = *((buf)+2-fmt->Bshift/8); \
204 Pixel = *((Uint32 *)(buf)); \
205 RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
217 #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \
219 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
220 ((g>>fmt->Gloss)<<fmt->Gshift)| \
221 ((b>>fmt->Bloss)<<fmt->Bshift)| \
224 #define RGB565_FROM_RGB(Pixel, r, g, b) \
226 Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \
228 #define RGB555_FROM_RGB(Pixel, r, g, b) \
230 Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \
232 #define RGB888_FROM_RGB(Pixel, r, g, b) \
234 Pixel = (r<<16)|(g<<8)|b; \
236 #define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \
238 Pixel = (a<<24)|(r<<16)|(g<<8)|b; \
240 #define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \
242 Pixel = (r<<24)|(g<<16)|(b<<8)|a; \
244 #define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \
246 Pixel = (a<<24)|(b<<16)|(g<<8)|r; \
248 #define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \
250 Pixel = (b<<24)|(g<<16)|(r<<8)|a; \
252 #define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a) \
254 r = r ? ((r << 2) | 0x3) : 0; \
255 g = g ? ((g << 2) | 0x3) : 0; \
256 b = b ? ((b << 2) | 0x3) : 0; \
258 Pixel = (a<<30)|(r<<20)|(g<<10)|b; \
260 #define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
266 PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
267 *((Uint8 *)(buf)) = Pixel; \
274 PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
275 *((Uint16 *)(buf)) = Pixel; \
280 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
281 *((buf)+fmt->Rshift/8) = r; \
282 *((buf)+fmt->Gshift/8) = g; \
283 *((buf)+fmt->Bshift/8) = b; \
285 *((buf)+2-fmt->Rshift/8) = r; \
286 *((buf)+2-fmt->Gshift/8) = g; \
287 *((buf)+2-fmt->Bshift/8) = b; \
295 PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
296 *((Uint32 *)(buf)) = Pixel; \
303 #define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \
305 r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \
306 g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \
307 b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \
308 a = SDL_expand_byte[fmt->Aloss][((Pixel&fmt->Amask)>>fmt->Ashift)]; \
310 #define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \
312 r = (Pixel&fmt->Rmask)>>fmt->Rshift; \
313 g = (Pixel&fmt->Gmask)>>fmt->Gshift; \
314 b = (Pixel&fmt->Bmask)>>fmt->Bshift; \
315 a = (Pixel&fmt->Amask)>>fmt->Ashift; \
317 #define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \
320 g = ((Pixel>>16)&0xFF); \
321 b = ((Pixel>>8)&0xFF); \
324 #define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \
326 r = ((Pixel>>16)&0xFF); \
327 g = ((Pixel>>8)&0xFF); \
331 #define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \
334 g = ((Pixel>>8)&0xFF); \
335 b = ((Pixel>>16)&0xFF); \
338 #define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \
340 r = ((Pixel>>8)&0xFF); \
341 g = ((Pixel>>16)&0xFF); \
345 #define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a) \
347 r = ((Pixel>>22)&0xFF); \
348 g = ((Pixel>>12)&0xFF); \
349 b = ((Pixel>>2)&0xFF); \
350 a = SDL_expand_byte[6][(Pixel>>30)]; \
352 #define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \
356 Pixel = *((Uint8 *)(buf)); \
357 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
361 Pixel = *((Uint16 *)(buf)); \
362 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
367 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
368 r = *((buf)+fmt->Rshift/8); \
369 g = *((buf)+fmt->Gshift/8); \
370 b = *((buf)+fmt->Bshift/8); \
372 r = *((buf)+2-fmt->Rshift/8); \
373 g = *((buf)+2-fmt->Gshift/8); \
374 b = *((buf)+2-fmt->Bshift/8); \
381 Pixel = *((Uint32 *)(buf)); \
382 RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
394 #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
396 Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
397 ((g>>fmt->Gloss)<<fmt->Gshift)| \
398 ((b>>fmt->Bloss)<<fmt->Bshift)| \
399 ((a>>fmt->Aloss)<<fmt->Ashift); \
401 #define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
407 PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
408 *((Uint8 *)(buf)) = Pixel; \
415 PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
416 *((Uint16 *)(buf)) = Pixel; \
421 if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
422 *((buf)+fmt->Rshift/8) = r; \
423 *((buf)+fmt->Gshift/8) = g; \
424 *((buf)+fmt->Bshift/8) = b; \
426 *((buf)+2-fmt->Rshift/8) = r; \
427 *((buf)+2-fmt->Gshift/8) = g; \
428 *((buf)+2-fmt->Bshift/8) = b; \
436 PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
437 *((Uint32 *)(buf)) = Pixel; \
444 #define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \
446 dR = ((((unsigned)(sR-dR)*(unsigned)A)/255)+dR); \
447 dG = ((((unsigned)(sG-dG)*(unsigned)A)/255)+dG); \
448 dB = ((((unsigned)(sB-dB)*(unsigned)A)/255)+dB); \
453 #define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \
455 dR = ((((unsigned)(sR-dR)*(unsigned)sA)/255)+dR); \
456 dG = ((((unsigned)(sG-dG)*(unsigned)sA)/255)+dG); \
457 dB = ((((unsigned)(sB-dB)*(unsigned)sA)/255)+dB); \
458 dA = ((unsigned)sA+(unsigned)dA-((unsigned)sA*dA)/255); \
463 #if defined(_MSC_VER) && (_MSC_VER == 1300)
466 #define USE_DUFFS_LOOP
468 #ifdef USE_DUFFS_LOOP
471 #define DUFFS_LOOP8(pixel_copy_increment, width) \
472 { int n = (width+7)/8; \
473 switch (width & 7) { \
474 case 0: do { pixel_copy_increment; \
475 case 7: pixel_copy_increment; \
476 case 6: pixel_copy_increment; \
477 case 5: pixel_copy_increment; \
478 case 4: pixel_copy_increment; \
479 case 3: pixel_copy_increment; \
480 case 2: pixel_copy_increment; \
481 case 1: pixel_copy_increment; \
482 } while ( --n > 0 ); \
487 #define DUFFS_LOOP4(pixel_copy_increment, width) \
488 { int n = (width+3)/4; \
489 switch (width & 3) { \
490 case 0: do { pixel_copy_increment; \
491 case 3: pixel_copy_increment; \
492 case 2: pixel_copy_increment; \
493 case 1: pixel_copy_increment; \
499 #define DUFFS_LOOP(pixel_copy_increment, width) \
500 DUFFS_LOOP8(pixel_copy_increment, width)
503 #define DUFFS_LOOP_124(pixel_copy_increment1, \
504 pixel_copy_increment2, \
505 pixel_copy_increment4, width) \
508 pixel_copy_increment1; n -= 1; \
511 pixel_copy_increment2; n -= 2; \
514 pixel_copy_increment4; n -= 4; \
519 pixel_copy_increment4; \
520 pixel_copy_increment4; \
528 #define DUFFS_LOOP(pixel_copy_increment, width) \
530 for ( n=width; n > 0; --n ) { \
531 pixel_copy_increment; \
534 #define DUFFS_LOOP8(pixel_copy_increment, width) \
535 DUFFS_LOOP(pixel_copy_increment, width)
536 #define DUFFS_LOOP4(pixel_copy_increment, width) \
537 DUFFS_LOOP(pixel_copy_increment, width)
538 #define DUFFS_LOOP_124(pixel_copy_increment1, \
539 pixel_copy_increment2, \
540 pixel_copy_increment4, width) \
541 DUFFS_LOOP(pixel_copy_increment1, width)
546 #if defined(_MSC_VER) && (_MSC_VER >= 600)
547 #pragma warning(disable: 4550)
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
SDL_PixelFormat * src_fmt
A collection of pixels used in software blitting.
GLboolean GLboolean GLboolean GLboolean a
Uint32 dst_palette_version
Uint32 src_palette_version
uint32_t Uint32
An unsigned 32-bit integer type.
Uint8 * SDL_expand_byte[9]
int SDL_CalculateBlit(SDL_Surface *surface)
SDL_PixelFormat * dst_fmt
SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
struct SDL_BlitMap SDL_BlitMap
uint8_t Uint8
An unsigned 8-bit integer type.
SDL_BlitFunc SDL_CalculateBlit1(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.
GLdouble GLdouble GLdouble b
SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)