00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _SDL_gfxBlitFunc_h
00010 #define _SDL_gfxBlitFunc_h
00011
00012
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016
00017 #include <stdio.h>
00018 #include <stdlib.h>
00019
00020 #include <SDL.h>
00021 #include <SDL_video.h>
00022
00023
00024
00025 #if defined(WIN32) || defined(WIN64)
00026 # if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
00027 # define SDL_GFXBLITFUNC_SCOPE __declspec(dllexport)
00028 # else
00029 # ifdef LIBSDL_GFX_DLL_IMPORT
00030 # define SDL_GFXBLITFUNC_SCOPE __declspec(dllimport)
00031 # endif
00032 # endif
00033 #endif
00034 #ifndef SDL_GFXBLITFUNC_SCOPE
00035 # define SDL_GFXBLITFUNC_SCOPE extern
00036 #endif
00037
00038
00039 SDL_GFXBLITFUNC_SCOPE int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect);
00040
00041 SDL_GFXBLITFUNC_SCOPE int SDL_gfxSetAlpha(SDL_Surface * src, Uint8 a);
00042
00043 SDL_GFXBLITFUNC_SCOPE int SDL_gfxMultiplyAlpha(SDL_Surface * src, Uint8 a);
00044
00045
00046
00047
00048
00049
00053 typedef struct {
00054 Uint8 *s_pixels;
00055 int s_width;
00056 int s_height;
00057 int s_skip;
00058 Uint8 *d_pixels;
00059 int d_width;
00060 int d_height;
00061 int d_skip;
00062 void *aux_data;
00063 SDL_PixelFormat *src;
00064 Uint8 *table;
00065 SDL_PixelFormat *dst;
00066 } SDL_gfxBlitInfo;
00067
00071 #define GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \
00072 { \
00073 r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
00074 g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
00075 b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
00076 a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
00077 }
00078
00082 #define GFX_DISEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \
00083 do { \
00084 pixel = *((Uint32 *)(buf)); \
00085 GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \
00086 pixel &= ~fmt->Amask; \
00087 } while(0)
00088
00092 #define GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \
00093 { \
00094 pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
00095 ((g>>fmt->Gloss)<<fmt->Gshift)| \
00096 ((b>>fmt->Bloss)<<fmt->Bshift)| \
00097 ((a<<fmt->Aloss)<<fmt->Ashift); \
00098 }
00099
00103 #define GFX_ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
00104 { \
00105 Uint32 pixel; \
00106 \
00107 GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
00108 *((Uint32 *)(buf)) = pixel; \
00109 }
00110
00114 #define GFX_ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
00115 do { \
00116 dR = (((sR-dR)*(A))/255)+dR; \
00117 dG = (((sG-dG)*(A))/255)+dG; \
00118 dB = (((sB-dB)*(A))/255)+dB; \
00119 } while(0)
00120
00126 #define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \
00127 { int n = (width+3)/4; \
00128 switch (width & 3) { \
00129 case 0: do { pixel_copy_increment; \
00130 case 3: pixel_copy_increment; \
00131 case 2: pixel_copy_increment; \
00132 case 1: pixel_copy_increment; \
00133 } while ( --n > 0 ); \
00134 } \
00135 }
00136
00137
00138
00139
00140 #ifdef __cplusplus
00141 }
00142 #endif
00143
00144 #endif