31 #include "../../SDL_internal.h"
33 #if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
35 #if defined(__WIN32__)
36 #include "../../core/windows/SDL_windows.h"
67 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
79 #define GUARD_ROWS (2)
109 int *dstwidth,
int *dstheight,
110 double *cangle,
double *sangle)
114 if(angle90 ==
angle/90) {
116 if(angle90 < 0) angle90 += 4;
121 *sangle = angle90 == 1 ? -1 : 1;
125 *cangle = angle90 == 0 ? 1 : -1;
129 double x,
y, cx, cy, sx, sy;
131 int dstwidthhalf, dstheighthalf;
135 radangle =
angle * (M_PI / -180.0);
145 dstwidthhalf =
MAX((
int)
147 dstheighthalf =
MAX((
int)
149 *dstwidth = 2 * dstwidthhalf;
150 *dstheight = 2 * dstheighthalf;
157 int *sincx,
int *sincy,
int *signx,
int *signy)
159 int pitch = flipy ? -
src->pitch :
src->pitch;
164 case 0: *sincx =
bpp; *sincy = pitch -
src->w * *sincx; *signx = *signy = 1;
break;
165 case 1: *sincx = -pitch; *sincy =
bpp - *sincx *
src->h; *signx = 1; *signy = -1;
break;
166 case 2: *sincx = -
bpp; *sincy = -
src->w * *sincx - pitch; *signx = *signy = -1;
break;
167 case 3:
default: *sincx = pitch; *sincy = -*sincx *
src->h -
bpp; *signx = -1; *signy = 1;
break;
178 #define TRANSFORM_SURFACE_90(pixelType) \
179 int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \
180 Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \
182 computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
183 if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \
184 if (signy < 0) sp += (src->h-1)*src->pitch; \
186 for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
187 if (sincx == sizeof(pixelType)) { \
188 SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
189 sp += dst->w*sizeof(pixelType); \
190 dp += dst->w*sizeof(pixelType); \
192 for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
193 *(pixelType*)dp = *(pixelType*)sp; \
210 #undef TRANSFORM_SURFACE_90
234 int x,
y,
t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
242 xd = ((
src->w -
dst->w) << 15);
243 yd = ((
src->h -
dst->h) << 15);
244 ax = (cx << 16) - (icos * cx);
245 ay = (cy << 16) - (isin * cx);
249 gap =
dst->pitch -
dst->w * 4;
255 for (
y = 0;
y <
dst->h;
y++) {
257 sdx = (ax + (isin * dy)) + xd;
258 sdy = (ay - (icos * dy)) + yd;
259 for (
x = 0;
x <
dst->w;
x++) {
262 if (flipx) dx = sw - dx;
263 if (flipy) dy = sh - dy;
264 if ((dx > -1) && (dy > -1) && (dx < (
src->w-1)) && (dy < (
src->h-1))) {
269 sp += (
src->pitch/4);
274 cswap = c00; c00=c01; c01=cswap;
275 cswap = c10; c10=c11; c11=cswap;
278 cswap = c00; c00=c10; c10=cswap;
279 cswap = c01; c01=c11; c11=cswap;
286 t1 = ((((c01.
r - c00.
r) * ex) >> 16) + c00.
r) & 0xff;
287 t2 = ((((c11.
r - c10.
r) * ex) >> 16) + c10.
r) & 0xff;
288 pc->
r = (((t2 -
t1) * ey) >> 16) +
t1;
289 t1 = ((((c01.
g - c00.
g) * ex) >> 16) + c00.
g) & 0xff;
290 t2 = ((((c11.
g - c10.
g) * ex) >> 16) + c10.
g) & 0xff;
291 pc->
g = (((t2 -
t1) * ey) >> 16) +
t1;
292 t1 = ((((c01.
b - c00.
b) * ex) >> 16) + c00.
b) & 0xff;
293 t2 = ((((c11.
b - c10.
b) * ex) >> 16) + c10.
b) & 0xff;
294 pc->
b = (((t2 -
t1) * ey) >> 16) +
t1;
295 t1 = ((((c01.
a - c00.
a) * ex) >> 16) + c00.
a) & 0xff;
296 t2 = ((((c11.
a - c10.
a) * ex) >> 16) + c10.
a) & 0xff;
297 pc->
a = (((t2 -
t1) * ey) >> 16) +
t1;
306 for (
y = 0;
y <
dst->h;
y++) {
308 sdx = (ax + (isin * dy)) + xd;
309 sdy = (ay - (icos * dy)) + yd;
310 for (
x = 0;
x <
dst->w;
x++) {
313 if ((
unsigned)dx < (unsigned)
src->w && (
unsigned)dy < (unsigned)
src->h) {
314 if(flipx) dx = sw - dx;
315 if(flipy) dy = sh - dy;
348 int x,
y, dx, dy, xd, yd, sdx, sdy, ax, ay;
355 xd = ((
src->w -
dst->w) << 15);
356 yd = ((
src->h -
dst->h) << 15);
357 ax = (cx << 16) - (icos * cx);
358 ay = (cy << 16) - (isin * cx);
360 gap =
dst->pitch -
dst->w;
368 for (
y = 0;
y <
dst->h;
y++) {
370 sdx = (ax + (isin * dy)) + xd;
371 sdy = (ay - (icos * dy)) + yd;
372 for (
x = 0;
x <
dst->w;
x++) {
375 if ((
unsigned)dx < (unsigned)
src->w && (
unsigned)dy < (unsigned)
src->h) {
376 if (flipx) dx = (
src->w-1)-dx;
377 if (flipy) dy = (
src->h-1)-dy;
417 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)
425 double sangleinv, cangleinv;
438 is8bit =
src->format->BitsPerPixel == 8 && colorKeyAvailable;
439 if (!(is8bit || (
src->format->BitsPerPixel == 32 &&
src->format->Amask)))
443 sangleinv = sangle*65536.0;
444 cangleinv = cangle*65536.0;
451 if (rz_dst !=
NULL) {
452 for (
i = 0;
i <
src->format->palette->ncolors;
i++) {
460 src->format->Rmask,
src->format->Gmask,
461 src->format->Bmask,
src->format->Amask);
469 rz_dst->
h = dstheight;
473 if (colorKeyAvailable ==
SDL_TRUE) {
504 if (angle90 ==
angle/90) {
506 if (angle90 < 0) angle90 += 4;
525 flipx, flipy, smooth);
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
#define SDL_GetSurfaceBlendMode
#define SDL_SetSurfaceBlendMode
#define SDL_UnlockSurface
#define SDL_CreateRGBSurface
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei width
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
static void _transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)
static Uint32 _colorkey(SDL_Surface *src)
static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle)
static void transformSurfaceRGBA90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy, int *sincx, int *sincy, int *signx, int *signy)
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)
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
#define TRANSFORM_SURFACE_90(pixelType)
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)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
A collection of pixels used in software blitting.
typedef int(__stdcall *FARPROC)()