src/render/software/SDL_rotate.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 01 Jun 2012 20:31:50 -0400
changeset 6323 d3fa10b2d16e
parent 6320 6077a1310907
child 6389 43a190ad60a7
permissions -rw-r--r--
Fixed SDL_config.h build include path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
/*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
SDL_rotate.c: rotates 32bit or 8bit surfaces
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     5
Shamelessly stolen from SDL_gfx by Andreas Schiffler. Original copyright follows:
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
Copyright (C) 2001-2011  Andreas Schiffler
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
This software is provided 'as-is', without any express or implied
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
warranty. In no event will the authors be held liable for any damages
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
arising from the use of this software.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
Permission is granted to anyone to use this software for any purpose,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
including commercial applications, and to alter it and redistribute it
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
freely, subject to the following restrictions:
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
   1. The origin of this software must not be misrepresented; you must not
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
   claim that you wrote the original software. If you use this software
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
   in a product, an acknowledgment in the product documentation would be
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
   appreciated but is not required.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
   2. Altered source versions must be plainly marked as such, and must not be
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
   misrepresented as being the original software.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
   3. This notice may not be removed or altered from any source
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
   distribution.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
Andreas Schiffler -- aschiffler at ferzkopp dot net
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
*/
6323
d3fa10b2d16e Fixed SDL_config.h build include path
Sam Lantinga <slouken@libsdl.org>
parents: 6320
diff changeset
    31
#include "SDL_config.h"
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    32
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    33
#ifdef WIN32
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    34
#include <windows.h>
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
#endif
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
#include <stdlib.h>
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
#include <string.h>
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    40
#include "SDL.h"
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    41
#include "SDL_rotate.h"
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    42
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    43
/* ---- Internally used structures */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    44
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    45
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
\brief A 32 bit RGBA pixel.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
typedef struct tColorRGBA {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
    Uint8 r;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
    Uint8 g;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
    Uint8 b;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
    Uint8 a;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
} tColorRGBA;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
\brief A 8bit Y/palette pixel.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    57
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
typedef struct tColorY {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
    Uint8 y;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
} tColorY;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    61
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
\brief Returns maximum of two numbers a and b.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
#define MAX(a,b)    (((a) > (b)) ? (a) : (b))
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    67
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
\brief Number of guard rows added to destination surfaces.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
This is a simple but effective workaround for observed issues.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
These rows allocate extra memory and are then hidden from the surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
Rows are added to the end of destination surfaces when they are allocated.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
This catches any potential overflows which seem to happen with
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
just the right src image dimensions and scale/rotation and can lead
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
to a situation where the program can segfault.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
#define GUARD_ROWS (2)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
\brief Lower limit of absolute zoom factor or rotation degrees.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
#define VALUE_LIMIT 0.001
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
\brief Returns colorkey info for a surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
Uint32 _colorkey(SDL_Surface *src)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
{
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
    Uint32 key = 0;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
    SDL_GetColorKey(src, &key);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
    return key;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
}
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
\brief Internal target surface sizing function for rotations with trig result return.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
\param width The source surface width.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
\param height The source surface height.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
\param angle The angle to rotate in degrees.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   101
\param dstwidth The calculated width of the destination surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   102
\param dstheight The calculated height of the destination surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   103
\param cangle The sine of the angle
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   104
\param sangle The cosine of the angle
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
void _rotozoomSurfaceSizeTrig(int width, int height, double angle,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
                              int *dstwidth, int *dstheight,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   109
                              double *cangle, double *sangle)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
{
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
    double x, y, cx, cy, sx, sy;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   112
    double radangle;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   113
    int dstwidthhalf, dstheighthalf;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   114
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   115
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   116
    * Determine destination width and height by rotating a centered source box
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   117
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   118
    radangle = angle * (M_PI / 180.0);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   119
    *sangle = SDL_sin(radangle);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
    *cangle = SDL_cos(radangle);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
    x = (double)(width / 2);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   122
    y = (double)(height / 2);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   123
    cx = *cangle * x;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   124
    cy = *cangle * y;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   125
    sx = *sangle * x;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
    sy = *sangle * y;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
    dstwidthhalf = MAX((int)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
        SDL_ceil(MAX(MAX(MAX(SDL_fabs(cx + sy), SDL_fabs(cx - sy)), SDL_fabs(-cx + sy)), SDL_fabs(-cx - sy))), 1);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
    dstheighthalf = MAX((int)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
        SDL_ceil(MAX(MAX(MAX(SDL_fabs(sx + cy), SDL_fabs(sx - cy)), SDL_fabs(-sx + cy)), SDL_fabs(-sx - cy))), 1);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   132
    *dstwidth = 2 * dstwidthhalf;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
    *dstheight = 2 * dstheighthalf;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
}
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
\brief Internal 32 bit rotozoomer with optional anti-aliasing.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
parameters by scanning the destination surface and applying optionally anti-aliasing
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
by bilinear interpolation.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
Assumes src and dst surfaces are of 32 bit depth.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
Assumes dst surface was allocated with the correct dimensions.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   146
\param src Source surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
\param dst Destination surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
\param cx Horizontal center coordinate.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
\param cy Vertical center coordinate.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
\param isin Integer version of sine of angle.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
\param icos Integer version of cosine of angle.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   152
\param flipx Flag indicating horizontal mirroring should be applied.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   153
\param flipy Flag indicating vertical mirroring should be applied.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
\param smooth Flag indicating anti-aliasing should be used.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
void _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
{
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
    int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   159
    tColorRGBA c00, c01, c10, c11, cswap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   160
    tColorRGBA *pc, *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   161
    int gap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   162
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   163
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   164
    * Variable setup
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   165
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   166
    xd = ((src->w - dst->w) << 15);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   167
    yd = ((src->h - dst->h) << 15);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   168
    ax = (cx << 16) - (icos * cx);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   169
    ay = (cy << 16) - (isin * cx);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   170
    sw = src->w - 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   171
    sh = src->h - 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   172
    pc = (tColorRGBA*) dst->pixels;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   173
    gap = dst->pitch - dst->w * 4;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   174
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   175
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   176
    * Switch between interpolating and non-interpolating code
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   177
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   178
    if (smooth) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   179
        for (y = 0; y < dst->h; y++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   180
            dy = cy - y;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   181
            sdx = (ax + (isin * dy)) + xd;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   182
            sdy = (ay - (icos * dy)) + yd;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   183
            for (x = 0; x < dst->w; x++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   184
                dx = (sdx >> 16);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
                dy = (sdy >> 16);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
                if (flipx) dx = sw - dx;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
                if (flipy) dy = sh - dy;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   188
                if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   189
                    sp = (tColorRGBA *)src->pixels;;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   190
                    sp += ((src->pitch/4) * dy);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   191
                    sp += dx;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   192
                    c00 = *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   193
                    sp += 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   194
                    c01 = *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   195
                    sp += (src->pitch/4);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   196
                    c11 = *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   197
                    sp -= 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   198
                    c10 = *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   199
                    if (flipx) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   200
                        cswap = c00; c00=c01; c01=cswap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   201
                        cswap = c10; c10=c11; c11=cswap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   202
                    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   203
                    if (flipy) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   204
                        cswap = c00; c00=c10; c10=cswap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   205
                        cswap = c01; c01=c11; c11=cswap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   206
                    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   207
                    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   208
                    * Interpolate colors
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   209
                    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   210
                    ex = (sdx & 0xffff);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   211
                    ey = (sdy & 0xffff);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   212
                    t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   213
                    t2 = ((((c11.r - c10.r) * ex) >> 16) + c10.r) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   214
                    pc->r = (((t2 - t1) * ey) >> 16) + t1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   215
                    t1 = ((((c01.g - c00.g) * ex) >> 16) + c00.g) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   216
                    t2 = ((((c11.g - c10.g) * ex) >> 16) + c10.g) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   217
                    pc->g = (((t2 - t1) * ey) >> 16) + t1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   218
                    t1 = ((((c01.b - c00.b) * ex) >> 16) + c00.b) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   219
                    t2 = ((((c11.b - c10.b) * ex) >> 16) + c10.b) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   220
                    pc->b = (((t2 - t1) * ey) >> 16) + t1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   221
                    t1 = ((((c01.a - c00.a) * ex) >> 16) + c00.a) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   222
                    t2 = ((((c11.a - c10.a) * ex) >> 16) + c10.a) & 0xff;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   223
                    pc->a = (((t2 - t1) * ey) >> 16) + t1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   224
                }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   225
                sdx += icos;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   226
                sdy += isin;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   227
                pc++;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   228
            }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   229
            pc = (tColorRGBA *) ((Uint8 *) pc + gap);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   230
        }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   231
    } else {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   232
        for (y = 0; y < dst->h; y++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   233
            dy = cy - y;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   234
            sdx = (ax + (isin * dy)) + xd;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   235
            sdy = (ay - (icos * dy)) + yd;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   236
            for (x = 0; x < dst->w; x++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   237
                dx = (short) (sdx >> 16);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   238
                dy = (short) (sdy >> 16);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   239
                if (flipx) dx = (src->w-1)-dx;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   240
                if (flipy) dy = (src->h-1)-dy;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   241
                if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   242
                    sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   243
                    sp += dx;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   244
                    *pc = *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   245
                }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   246
                sdx += icos;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   247
                sdy += isin;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   248
                pc++;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   249
            }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   250
            pc = (tColorRGBA *) ((Uint8 *) pc + gap);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   251
        }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   252
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   253
}
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   254
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   255
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   256
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   257
\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   258
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   259
Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   260
parameters by scanning the destination surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   261
Assumes src and dst surfaces are of 8 bit depth.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   262
Assumes dst surface was allocated with the correct dimensions.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   263
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   264
\param src Source surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   265
\param dst Destination surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   266
\param cx Horizontal center coordinate.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   267
\param cy Vertical center coordinate.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   268
\param isin Integer version of sine of angle.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   269
\param icos Integer version of cosine of angle.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   270
\param flipx Flag indicating horizontal mirroring should be applied.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   271
\param flipy Flag indicating vertical mirroring should be applied.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   272
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   273
void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   274
{
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   275
    int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay, sw, sh;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   276
    tColorY *pc, *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   277
    int gap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   278
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   279
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   280
    * Variable setup
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   281
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   282
    xd = ((src->w - dst->w) << 15);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   283
    yd = ((src->h - dst->h) << 15);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   284
    ax = (cx << 16) - (icos * cx);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   285
    ay = (cy << 16) - (isin * cx);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   286
    sw = src->w - 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   287
    sh = src->h - 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   288
    pc = (tColorY*) dst->pixels;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   289
    gap = dst->pitch - dst->w;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   290
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   291
    * Clear surface to colorkey
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   292
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   293
    SDL_memset(pc, (int)(_colorkey(src) & 0xff), dst->pitch * dst->h);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   294
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   295
    * Iterate through destination surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   296
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   297
    for (y = 0; y < dst->h; y++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   298
        dy = cy - y;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   299
        sdx = (ax + (isin * dy)) + xd;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   300
        sdy = (ay - (icos * dy)) + yd;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   301
        for (x = 0; x < dst->w; x++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   302
            dx = (short) (sdx >> 16);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   303
            dy = (short) (sdy >> 16);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   304
            if (flipx) dx = (src->w-1)-dx;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   305
            if (flipy) dy = (src->h-1)-dy;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   306
            if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   307
                sp = (tColorY *) (src->pixels);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   308
                sp += (src->pitch * dy + dx);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   309
                *pc = *sp;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
            }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   311
            sdx += icos;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   312
            sdy += isin;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   313
            pc++;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   314
        }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   315
        pc += gap;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   316
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   317
}
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   318
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   319
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   321
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   322
/*!
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   323
\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   324
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   325
Rotates a 32bit or 8bit 'src' surface to newly created 'dst' surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   326
'angle' is the rotation in degrees, 'centerx' and 'centery' the rotation center. If 'smooth' is set
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   327
then the destination 32bit surface is anti-aliased. If the surface is not 8bit
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   328
or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   329
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   330
\param src The surface to rotozoom.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   331
\param angle The angle to rotate in degrees.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   332
\param centerx The horizontal coordinate of the center of rotation
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   333
\param zoomy The vertical coordinate of the center of rotation
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   334
\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   335
\param flipx Set to 1 to flip the image horizontally
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   336
\param flipy Set to 1 to flip the image vertically
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   337
\param dstwidth The destination surface width
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   338
\param dstheight The destination surface height
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   339
\param cangle The angle cosine
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   340
\param sangle The angle sine
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   341
\return The new rotated surface.
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   342
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   343
*/
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   344
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   345
SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   346
{
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   347
    SDL_Surface *rz_src;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   348
    SDL_Surface *rz_dst;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   349
    int is32bit;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   350
    int i, src_converted;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   351
    Uint8 r,g,b;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   352
    Uint32 colorkey = 0;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   353
    int colorKeyAvailable = 0;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   354
    double sangleinv, cangleinv;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   355
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   356
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   357
    * Sanity check
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   358
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   359
    if (src == NULL)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   360
        return (NULL);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   361
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   362
    if (src->flags & SDL_TRUE/*SDL_SRCCOLORKEY*/)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   363
    {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   364
        colorkey = _colorkey(src);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   365
        SDL_GetRGB(colorkey, src->format, &r, &g, &b);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   366
        colorKeyAvailable = 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   367
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   368
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   369
    * Determine if source surface is 32bit or 8bit
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   370
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   371
    is32bit = (src->format->BitsPerPixel == 32);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   372
    if ((is32bit) || (src->format->BitsPerPixel == 8)) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   373
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   374
        * Use source surface 'as is'
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   375
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   376
        rz_src = src;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   377
        src_converted = 0;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   378
    } else {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   379
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   380
        * New source surface is 32bit with a defined RGBA ordering
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   381
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   382
        rz_src =
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   383
            SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   384
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   385
            0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   386
#else
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   387
            0xff000000,  0x00ff0000, 0x0000ff00, 0x000000ff
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   388
#endif
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   389
            );
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   390
        if(colorKeyAvailable)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   391
            SDL_SetColorKey(src, 0, 0);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   392
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   393
        SDL_BlitSurface(src, NULL, rz_src, NULL);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   394
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   395
        if(colorKeyAvailable)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   396
            SDL_SetColorKey(src, SDL_TRUE /*SDL_SRCCOLORKEY*/, colorkey);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   397
        src_converted = 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   398
        is32bit = 1;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   399
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   400
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   401
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   402
    /* Determine target size */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   403
    //_rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   404
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   405
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   406
    * Calculate target factors from sin/cos and zoom
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   407
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   408
    sangleinv = sangle*65536.0;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   409
    cangleinv = cangle*65536.0;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   410
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   411
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   412
    * Alloc space to completely contain the rotated surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   413
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   414
    rz_dst = NULL;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   415
    if (is32bit) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   416
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   417
        * Target surface is 32bit with source RGBA/ABGR ordering
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   418
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   419
        rz_dst =
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   420
            SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   421
            rz_src->format->Rmask, rz_src->format->Gmask,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   422
            rz_src->format->Bmask, rz_src->format->Amask);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   423
    } else {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   424
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   425
        * Target surface is 8bit
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   426
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   427
        rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   428
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
    /* Check target */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
    if (rz_dst == NULL)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
        return NULL;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   433
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   434
    /* Adjust for guard rows */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   435
    rz_dst->h = dstheight;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
    if (colorKeyAvailable == 1){
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
        colorkey = SDL_MapRGB(rz_dst->format, r, g, b);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
        SDL_FillRect(rz_dst, NULL, colorkey );
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   443
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   444
    * Lock source surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   445
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
    if (SDL_MUSTLOCK(rz_src)) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   447
        SDL_LockSurface(rz_src);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   448
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   449
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   450
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   451
    * Check which kind of surface we have
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
    if (is32bit) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
        * Call the 32bit transformation routine to do the rotation (using alpha)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   456
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   457
        _transformSurfaceRGBA(rz_src, rz_dst, centerx, centery,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   458
            (int) (sangleinv), (int) (cangleinv),
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   459
            flipx, flipy,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
            smooth);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   461
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
        * Turn on source-alpha support
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   463
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
        //SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
        SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   466
    } else {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   467
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   468
        * Copy palette and colorkey info
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   469
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   470
        for (i = 0; i < rz_src->format->palette->ncolors; i++) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   471
            rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   472
        }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   473
        rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
        /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   475
        * Call the 8bit transformation routine to do the rotation
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
        */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
        transformSurfaceY(rz_src, rz_dst, centerx, centery,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
            (int) (sangleinv), (int) (cangleinv),
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   479
            flipx, flipy);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   480
        SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   481
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   482
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
    * Unlock source surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   485
    if (SDL_MUSTLOCK(rz_src)) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
        SDL_UnlockSurface(rz_src);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   487
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   489
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   490
    * Cleanup temp surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   491
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   492
    if (src_converted) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
        SDL_FreeSurface(rz_src);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   494
    }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   495
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   496
    /*
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   497
    * Return destination surface
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   498
    */
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   499
    return (rz_dst);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   500
}
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   501