| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | */ |
| | | #include "../SDL_internal.h" |
| | | |
| | | #ifndef _SDL_blit_h |
| | | #define _SDL_blit_h |
| | | #ifndef SDL_blit_h_ |
| | | #define SDL_blit_h_ |
| | | |
| | | #include "SDL_cpuinfo.h" |
| | | #include "SDL_endian.h" |
| | |
| | | Uint8 r, g, b, a; |
| | | } SDL_BlitInfo; |
| | | |
| | | typedef void (SDLCALL * SDL_BlitFunc) (SDL_BlitInfo * info); |
| | | typedef void (*SDL_BlitFunc) (SDL_BlitInfo *info); |
| | | |
| | | |
| | | typedef struct |
| | | { |
| | |
| | | /* Blend the RGB values of two pixels with an alpha value */ |
| | | #define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ |
| | | do { \ |
| | | dR = ((((unsigned)(sR-dR)*(unsigned)A)/255)+dR); \ |
| | | dG = ((((unsigned)(sG-dG)*(unsigned)A)/255)+dG); \ |
| | | dB = ((((unsigned)(sB-dB)*(unsigned)A)/255)+dB); \ |
| | | dR = (Uint8)((((int)(sR-dR)*(int)A)/255)+dR); \ |
| | | dG = (Uint8)((((int)(sG-dG)*(int)A)/255)+dG); \ |
| | | dB = (Uint8)((((int)(sB-dB)*(int)A)/255)+dB); \ |
| | | } while(0) |
| | | |
| | | |
| | | /* Blend the RGBA values of two pixels */ |
| | | #define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ |
| | | do { \ |
| | | dR = ((((unsigned)(sR-dR)*(unsigned)sA)/255)+dR); \ |
| | | dG = ((((unsigned)(sG-dG)*(unsigned)sA)/255)+dG); \ |
| | | dB = ((((unsigned)(sB-dB)*(unsigned)sA)/255)+dB); \ |
| | | dA = ((unsigned)sA+(unsigned)dA-((unsigned)sA*dA)/255); \ |
| | | dR = (Uint8)((((int)(sR-dR)*(int)sA)/255)+dR); \ |
| | | dG = (Uint8)((((int)(sG-dG)*(int)sA)/255)+dG); \ |
| | | dB = (Uint8)((((int)(sB-dB)*(int)sA)/255)+dB); \ |
| | | dA = (Uint8)((int)sA+dA-((int)sA*dA)/255); \ |
| | | } while(0) |
| | | |
| | | |
| | |
| | | #define DUFFS_LOOP8(pixel_copy_increment, width) \ |
| | | { int n = (width+7)/8; \ |
| | | switch (width & 7) { \ |
| | | case 0: do { pixel_copy_increment; \ |
| | | case 7: pixel_copy_increment; \ |
| | | case 6: pixel_copy_increment; \ |
| | | case 5: pixel_copy_increment; \ |
| | | case 4: pixel_copy_increment; \ |
| | | case 3: pixel_copy_increment; \ |
| | | case 2: pixel_copy_increment; \ |
| | | case 1: pixel_copy_increment; \ |
| | | case 0: do { pixel_copy_increment; /* fallthrough */ \ |
| | | case 7: pixel_copy_increment; /* fallthrough */ \ |
| | | case 6: pixel_copy_increment; /* fallthrough */ \ |
| | | case 5: pixel_copy_increment; /* fallthrough */ \ |
| | | case 4: pixel_copy_increment; /* fallthrough */ \ |
| | | case 3: pixel_copy_increment; /* fallthrough */ \ |
| | | case 2: pixel_copy_increment; /* fallthrough */ \ |
| | | case 1: pixel_copy_increment; /* fallthrough */ \ |
| | | } while ( --n > 0 ); \ |
| | | } \ |
| | | } |
| | |
| | | #define 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; \ |
| | | case 0: do { pixel_copy_increment; /* fallthrough */ \ |
| | | case 3: pixel_copy_increment; /* fallthrough */ \ |
| | | case 2: pixel_copy_increment; /* fallthrough */ \ |
| | | case 1: pixel_copy_increment; /* fallthrough */ \ |
| | | } while (--n > 0); \ |
| | | } \ |
| | | } |
| | |
| | | #pragma warning(disable: 4550) |
| | | #endif |
| | | |
| | | #endif /* _SDL_blit_h */ |
| | | #endif /* SDL_blit_h_ */ |
| | | |
| | | /* vi: set ts=4 sw=4 expandtab: */ |