28#ifdef SDL2_GFX_FROM_TREE
29#include "SDL2_gfx/SDL2_rotozoom.h"
31#ifdef SDL2_PLAIN_INCLUDE
32#include <SDL2_rotozoom.h>
34#include <SDL2/SDL2_rotozoom.h>
51#if defined(_MSC_VER) && (_MSC_VER == 1300)
60#define DUFFS_LOOP8(pixel_copy_increment, width) \
61{ int n = (width + 7) / 8; \
62 switch (width & 7) { \
63 case 0: do { pixel_copy_increment; \
65 case 7: pixel_copy_increment; \
67 case 6: pixel_copy_increment; \
69 case 5: pixel_copy_increment; \
71 case 4: pixel_copy_increment; \
73 case 3: pixel_copy_increment; \
75 case 2: pixel_copy_increment; \
77 case 1: pixel_copy_increment; \
78 } while ( --n > 0 ); \
83#define DUFFS_LOOP4(pixel_copy_increment, width) \
84{ int n = (width + 3) / 4; \
85 switch (width & 3) { \
86 case 0: do { pixel_copy_increment; \
88 case 3: pixel_copy_increment; \
90 case 2: pixel_copy_increment; \
92 case 1: pixel_copy_increment; \
93 } while ( --n > 0 ); \
98#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \
99 double_pixel_copy_increment, width) \
102 pixel_copy_increment; \
108 case 0: do { double_pixel_copy_increment; \
110 case 2: double_pixel_copy_increment; \
111 } while ( --n > 0 ); \
117#define DUFFS_LOOP_QUATRO2(pixel_copy_increment, \
118 double_pixel_copy_increment, \
119 quatro_pixel_copy_increment, width) \
122 pixel_copy_increment; \
126 double_pixel_copy_increment; \
132 case 0: do { quatro_pixel_copy_increment; \
133 case 4: quatro_pixel_copy_increment; \
134 } while ( --n > 0 ); \
140#define DUFFS_LOOP(pixel_copy_increment, width) \
141 DUFFS_LOOP8(pixel_copy_increment, width)
146#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \
147 double_pixel_copy_increment, width) \
150 pixel_copy_increment; \
153 for (; n > 0; --n) { \
154 double_pixel_copy_increment; \
160#define DUFFS_LOOP_QUATRO2(pixel_copy_increment, \
161 double_pixel_copy_increment, \
162 quatro_pixel_copy_increment, width) \
165 pixel_copy_increment; \
169 double_pixel_copy_increment; \
172 for (; n > 0; --n) { \
173 quatro_pixel_copy_increment; \
179#define DUFFS_LOOP(pixel_copy_increment, width) \
181 for ( n=width; n > 0; --n ) { \
182 pixel_copy_increment; \
186#define DUFFS_LOOP8(pixel_copy_increment, width) \
187 DUFFS_LOOP(pixel_copy_increment, width)
188#define DUFFS_LOOP4(pixel_copy_increment, width) \
189 DUFFS_LOOP(pixel_copy_increment, width)
195#define DEFAULT_ZOOM 0.5
196#define adj_surf(surf) zoomSurface((surf), DEFAULT_ZOOM, DEFAULT_ZOOM, 0)
198#define DEFAULT_ZOOM 1.0
200#define adj_surf(surf) copy_surface(surf)
315#define map_rgba(format, color) \
316 SDL_MapRGBA(format, (color).r, (color).g, (color).b, (color).a)
318#define crop_rect_from_screen(rect) \
319 crop_rect_from_surface(main_data.screen, &rect)
322#define FREESURFACE(ptr) \
325 SDL_FreeSurface(ptr); \
333#define lock_surf(surf) \
335 if (SDL_MUSTLOCK(surf)) { \
336 SDL_LockSurface(surf); \
344#define unlock_surf(surf) \
346 if (SDL_MUSTLOCK(surf)) { \
347 SDL_UnlockSurface(surf); \
354#define lock_screen() lock_surf(main_data.screen)
359#define unlock_screen() unlock_surf(main_data.screen)
361#define putpixel(surf, x, y, pixel) \
363 Uint8 *buf_ptr = ((Uint8 *)surf->pixels + (y * surf->pitch)); \
364 switch (surf->format->BytesPerPixel) { \
367 *(Uint8 *)buf_ptr = pixel; \
371 *((Uint16 *)buf_ptr) = pixel; \
374 buf_ptr += (x << 1) + x; \
375 if (is_bigendian()) { \
376 buf_ptr[0] = (pixel >> 16) & 0xff; \
377 buf_ptr[1] = (pixel >> 8) & 0xff; \
378 buf_ptr[2] = pixel & 0xff; \
380 buf_ptr[0] = pixel & 0xff; \
381 buf_ptr[1] = (pixel >> 8) & 0xff; \
382 buf_ptr[2] = (pixel >> 16) & 0xff; \
387 *((Uint32 *)buf_ptr) = pixel; \
393#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
395 dR = (((sR-dR)*(A))>>8)+dR; \
396 dG = (((sG-dG)*(A))>>8)+dG; \
397 dB = (((sB-dB)*(A))>>8)+dB; \
400#define ALPHA_BLEND128(sR, sG, sB, dR, dG, dB) \
402 Uint32 __Src = (sR << 16 | sG << 8 | sB); \
403 Uint32 __Dst = (dR << 16 | dG << 8 | dB); \
404 __Dst = ((((__Src & 0x00fefefe) + (__Dst & 0x00fefefe)) >> 1) \
405 + (__Src & __Dst & 0x00010101)) | 0xFF000000; \
406 dR = (__Dst >> 16) & 0xFF; \
407 dG = (__Dst >> 8 ) & 0xFF; \
408 dB = (__Dst ) & 0xFF; \
struct canvas int int struct sprite int int int int height
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
struct canvas int int struct sprite int int int width
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Uint32 getpixel(SDL_Surface *surf, Sint16 x, Sint16 y)
int main_window_width(void)
void layer_rect_to_screen_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
SDL_Surface * load_surf(const char *fname)
SDL_Surface * create_surf_with_format(SDL_PixelFormat *pf, int width, int height, Uint32 flags)
void update_main_screen(void)
void remove_gui_layer(struct gui_layer *gui_layer)
SDL_Surface * create_filled_surface(Uint16 w, Uint16 h, Uint32 flags, SDL_Color *pcolor)
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
void gui_layer_destroy(struct gui_layer **gui_layer)
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
SDL_Surface * copy_surface(SDL_Surface *src)
bool set_video_mode(unsigned width, unsigned height, unsigned flags)
SDL_Surface * mask_surface(SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
struct gui_layer * gui_layer_new(int x, int y, SDL_Surface *surface)
SDL_Surface * crop_visible_part_from_surface(SDL_Surface *psrc)
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom, SDL_Color *pcolor)
struct gui_layer * get_gui_layer(SDL_Surface *surface)
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
struct sdl2_data main_data
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Uint32 get_first_pixel(SDL_Surface *surf)
SDL_Surface * convert_surf(SDL_Surface *surf_in)
SDL_Surface * create_surf(int width, int height, Uint32 flags)
void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect)
struct gui_layer * add_gui_layer(int width, int height)
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
bool correct_rect_region(SDL_Rect *prect)
void screen_rect_to_layer_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
bool create_surfaces(int width, int height)
int main_window_height(void)
SDL_Surface * resize_surface_box(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth, bool scale_up, bool absolute_dimensions)
struct sprite int int int int struct sprite * mask
struct sprite int int int int struct sprite int mask_offset_x
struct sprite int int int int struct sprite int int mask_offset_y
SDL_Rect rects[RECT_LIMIT]