123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #ifndef _SDL_gfxBlitFunc_h
- #define _SDL_gfxBlitFunc_h
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #include "SDL.h"
- #include "SDL_video.h"
- extern const unsigned int GFX_ALPHA_ADJUST_ARRAY[256];
- #ifdef _MSC_VER
- # if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
- # define SDL_GFXBLITFUNC_SCOPE __declspec(dllexport)
- # else
- # ifdef LIBSDL_GFX_DLL_IMPORT
- # define SDL_GFXBLITFUNC_SCOPE __declspec(dllimport)
- # endif
- # endif
- #endif
- #ifndef SDL_GFXBLITFUNC_SCOPE
- # define SDL_GFXBLITFUNC_SCOPE extern
- #endif
- SDL_GFXBLITFUNC_SCOPE int SDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
- SDL_GFXBLITFUNC_SCOPE int SDL_gfxSetAlpha(SDL_Surface *src, Uint8 a);
- SDL_GFXBLITFUNC_SCOPE int SDL_gfxMultiplyAlpha(SDL_Surface *src, Uint8 a);
- typedef struct {
- Uint8 *s_pixels;
- int s_width;
- int s_height;
- int s_skip;
- Uint8 *d_pixels;
- int d_width;
- int d_height;
- int d_skip;
- void *aux_data;
- SDL_PixelFormat *src;
- Uint8 *table;
- SDL_PixelFormat *dst;
- } SDL_gfxBlitInfo;
- #define GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \
- { \
- r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
- g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
- b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
- a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
- }
- #define GFX_DISASSEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \
- do { \
- pixel = *((Uint32 *)(buf)); \
- GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \
- pixel &= ~fmt->Amask; \
- } while(0)
- #define GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \
- { \
- pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
- ((g>>fmt->Gloss)<<fmt->Gshift)| \
- ((b>>fmt->Bloss)<<fmt->Bshift)| \
- ((a<<fmt->Aloss)<<fmt->Ashift); \
- }
- #define GFX_ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
- { \
- Uint32 pixel; \
- \
- GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
- *((Uint32 *)(buf)) = pixel; \
- }
- #define GFX_ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
- do { \
- dR = (((sR-dR)*(A))/255)+dR; \
- dG = (((sG-dG)*(A))/255)+dG; \
- dB = (((sB-dB)*(A))/255)+dB; \
- } while(0)
- #define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \
- { int n = (width+3)/4; \
- switch (width & 3) { \
- case 0: do { pixel_copy_increment; \
- case 3: pixel_copy_increment; \
- case 2: pixel_copy_increment; \
- case 1: pixel_copy_increment; \
- } while ( --n > 0 ); \
- } \
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|