31 #include "../../SDL_internal.h" 33 #if defined(__WIN32__) 34 #include "../../core/windows/SDL_windows.h" 65 #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 77 #define GUARD_ROWS (2) 105 int *dstwidth,
int *dstheight,
106 double *cangle,
double *sangle)
109 int angle90 = (int)(angle/90);
110 if(angle90 == angle/90) {
112 if(angle90 < 0) angle90 += 4;
117 *sangle = angle90 == 1 ? -1 : 1;
121 *cangle = angle90 == 0 ? 1 : -1;
125 double x,
y, cx, cy, sx, sy;
127 int dstwidthhalf, dstheighthalf;
131 radangle = angle * (M_PI / -180.0);
134 x = (double)(width / 2);
135 y = (double)(height / 2);
141 dstwidthhalf =
MAX((
int)
143 dstheighthalf =
MAX((
int)
145 *dstwidth = 2 * dstwidthhalf;
146 *dstheight = 2 * dstheighthalf;
153 int *sincx,
int *sincy,
int *signx,
int *signy)
160 case 0: *sincx = bpp; *sincy = pitch - src->
w * *sincx; *signx = *signy = 1;
break;
161 case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->
h; *signx = 1; *signy = -1;
break;
162 case 2: *sincx = -bpp; *sincy = -src->
w * *sincx - pitch; *signx = *signy = -1;
break;
163 case 3:
default: *sincx = pitch; *sincy = -*sincx * src->
h - bpp; *signx = -1; *signy = 1;
break;
174 #define TRANSFORM_SURFACE_90(pixelType) \ 175 int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \ 176 Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \ 178 computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \ 179 if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \ 180 if (signy < 0) sp += (src->h-1)*src->pitch; \ 182 for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \ 183 if (sincx == sizeof(pixelType)) { \ 184 SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \ 185 sp += dst->w*sizeof(pixelType); \ 186 dp += dst->w*sizeof(pixelType); \ 188 for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \ 189 *(pixelType*)dp = *(pixelType*)sp; \ 206 #undef TRANSFORM_SURFACE_90 230 int x,
y,
t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
238 xd = ((src->
w - dst->
w) << 15);
239 yd = ((src->
h - dst->
h) << 15);
240 ax = (cx << 16) - (icos * cx);
241 ay = (cy << 16) - (isin * cx);
245 gap = dst->
pitch - dst->
w * 4;
251 for (y = 0; y < dst->
h; y++) {
253 sdx = (ax + (isin * dy)) + xd;
254 sdy = (ay - (icos * dy)) + yd;
255 for (x = 0; x < dst->
w; x++) {
258 if (flipx) dx = sw - dx;
259 if (flipy) dy = sh - dy;
260 if ((dx > -1) && (dy > -1) && (dx < (src->
w-1)) && (dy < (src->
h-1))) {
265 sp += (src->
pitch/4);
270 cswap = c00; c00=c01; c01=cswap;
271 cswap = c10; c10=c11; c11=cswap;
274 cswap = c00; c00=c10; c10=cswap;
275 cswap = c01; c01=c11; c11=cswap;
282 t1 = ((((c01.
r - c00.
r) * ex) >> 16) + c00.
r) & 0xff;
283 t2 = ((((c11.
r - c10.
r) * ex) >> 16) + c10.
r) & 0xff;
284 pc->
r = (((t2 -
t1) * ey) >> 16) + t1;
285 t1 = ((((c01.
g - c00.
g) * ex) >> 16) + c00.
g) & 0xff;
286 t2 = ((((c11.
g - c10.
g) * ex) >> 16) + c10.
g) & 0xff;
287 pc->
g = (((t2 -
t1) * ey) >> 16) + t1;
288 t1 = ((((c01.
b - c00.
b) * ex) >> 16) + c00.
b) & 0xff;
289 t2 = ((((c11.
b - c10.
b) * ex) >> 16) + c10.
b) & 0xff;
290 pc->
b = (((t2 -
t1) * ey) >> 16) + t1;
291 t1 = ((((c01.
a - c00.
a) * ex) >> 16) + c00.
a) & 0xff;
292 t2 = ((((c11.
a - c10.
a) * ex) >> 16) + c10.
a) & 0xff;
293 pc->
a = (((t2 -
t1) * ey) >> 16) + t1;
302 for (y = 0; y < dst->
h; y++) {
304 sdx = (ax + (isin * dy)) + xd;
305 sdy = (ay - (icos * dy)) + yd;
306 for (x = 0; x < dst->
w; x++) {
309 if ((
unsigned)dx < (unsigned)src->
w && (
unsigned)dy < (unsigned)src->
h) {
310 if(flipx) dx = sw - dx;
311 if(flipy) dy = sh - dy;
344 int x,
y, dx, dy, xd, yd, sdx, sdy, ax, ay;
351 xd = ((src->
w - dst->
w) << 15);
352 yd = ((src->
h - dst->
h) << 15);
353 ax = (cx << 16) - (icos * cx);
354 ay = (cy << 16) - (isin * cx);
356 gap = dst->
pitch - dst->
w;
364 for (y = 0; y < dst->
h; y++) {
366 sdx = (ax + (isin * dy)) + xd;
367 sdy = (ay - (icos * dy)) + yd;
368 for (x = 0; x < dst->
w; x++) {
371 if ((
unsigned)dx < (unsigned)src->
w && (
unsigned)dy < (unsigned)src->
h) {
372 if (flipx) dx = (src->
w-1)-dx;
373 if (flipy) dy = (src->
h-1)-dy;
413 SDLgfx_rotateSurface(
SDL_Surface *
src,
double angle,
int centerx,
int centery,
int smooth,
int flipx,
int flipy,
int dstwidth,
int dstheight,
double cangle,
double sangle)
421 double sangleinv, cangleinv;
437 sangleinv = sangle*65536.0;
438 cangleinv = cangle*65536.0;
445 if (rz_dst !=
NULL) {
463 rz_dst->
h = dstheight;
467 if (colorKeyAvailable ==
SDL_TRUE) {
497 angle90 = (int)(angle/90);
498 if (angle90 == angle/90) {
500 if (angle90 < 0) angle90 += 4;
519 flipx, flipy, smooth);
#define SDL_UnlockSurface
GLint GLint GLint GLint GLint x
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy, int *sincx, int *sincy, int *signx, int *signy)
A collection of pixels used in software blitting.
static void transformSurfaceRGBA90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
GLint GLint GLsizei width
#define SDL_GetSurfaceBlendMode
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
GLint GLint GLint GLint GLint GLint y
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define TRANSFORM_SURFACE_90(pixelType)
GLint GLint GLsizei GLsizei height
#define SDL_CreateRGBSurface
#define SDL_SetSurfaceBlendMode
static Uint32 _colorkey(SDL_Surface *src)
SDL_Surface * SDLgfx_rotateSurface(SDL_Surface *src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle)
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle)
static void _transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)