Feature #909 ยป 0056-Update-SDL3_rotozoom.c-to-sdl3-changes.patch
| dependencies/SDL3_gfx/SDL3_rotozoom.c | ||
|---|---|---|
|
Uint8* srcBuf;
|
||
|
Uint8* dstBuf;
|
||
|
int normalizedClockwiseTurns;
|
||
|
const SDL_PixelFormatDetails *details;
|
||
|
/* Has to be a valid surface pointer and be a Nbit surface where n is divisible by 8 */
|
||
|
if (!src ||
|
||
|
!src->format) {
|
||
|
if (!src) {
|
||
|
SDL_SetError("NULL source surface or source surface format");
|
||
|
return NULL;
|
||
|
}
|
||
|
if ((src->format->bits_per_pixel % 8) != 0) {
|
||
|
details = SDL_GetPixelFormatDetails(src->format);
|
||
|
if ((details->bits_per_pixel % 8) != 0) {
|
||
|
SDL_SetError("Invalid source surface bit depth");
|
||
|
return NULL;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
/* Calculate byte-per-pixel */
|
||
|
bpp = src->format->bits_per_pixel / 8;
|
||
|
bpp = details->bits_per_pixel / 8;
|
||
|
switch(normalizedClockwiseTurns) {
|
||
|
case 0: /* Make a copy of the surface */
|
||
| ... | ... | |
|
int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
|
||
|
int src_converted;
|
||
|
int flipx,flipy;
|
||
|
const SDL_PixelFormatDetails *details;
|
||
|
/*
|
||
|
* Sanity check
|
||
| ... | ... | |
|
return (NULL);
|
||
|
}
|
||
|
details = SDL_GetPixelFormatDetails(src->format);
|
||
|
/*
|
||
|
* Determine if source surface is 32bit or 8bit
|
||
|
*/
|
||
|
if ((src->format->bits_per_pixel == 32)
|
||
|
|| (src->format->bits_per_pixel == 8)) {
|
||
|
if ((details->bits_per_pixel == 32)
|
||
|
|| (details->bits_per_pixel == 8)) {
|
||
|
/*
|
||
|
* Use source surface 'as is'
|
||
|
*/
|
||
| ... | ... | |
|
*/
|
||
|
rz_dst =
|
||
|
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
|
rz_src->format->format);
|
||
|
rz_src->format);
|
||
|
/* Check target */
|
||
|
if (rz_dst == NULL)
|
||
| ... | ... | |
|
*/
|
||
|
rz_dst =
|
||
|
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
|
rz_src->format->format);
|
||
|
rz_src->format);
|
||
|
/* Check target */
|
||
|
if (rz_dst == NULL)
|
||
| ... | ... | |
|
int dstwidth, dstheight;
|
||
|
int src_converted;
|
||
|
int flipx, flipy;
|
||
|
const SDL_PixelFormatDetails *details;
|
||
|
/*
|
||
|
* Sanity check
|
||
| ... | ... | |
|
if (src == NULL)
|
||
|
return (NULL);
|
||
|
details = SDL_GetPixelFormatDetails(src->format);
|
||
|
/*
|
||
|
* Determine if source surface is 32bit or 8bit
|
||
|
*/
|
||
|
if ((src->format->bits_per_pixel == 32)
|
||
|
|| (src->format->bits_per_pixel == 8)) {
|
||
|
if ((details->bits_per_pixel == 32)
|
||
|
|| (details->bits_per_pixel == 8)) {
|
||
|
/*
|
||
|
* Use source surface 'as is'
|
||
|
*/
|
||
| ... | ... | |
|
*/
|
||
|
rz_dst =
|
||
|
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
|
rz_src->format->format);
|
||
|
rz_src->format);
|
||
|
/* Check target */
|
||
|
if (rz_dst == NULL) {
|
||
| ... | ... | |
|
int dstwidth, dstheight;
|
||
|
int src_converted;
|
||
|
int haveError = 0;
|
||
|
const SDL_PixelFormatDetails *details;
|
||
|
/*
|
||
|
* Sanity check
|
||
| ... | ... | |
|
return (NULL);
|
||
|
}
|
||
|
details = SDL_GetPixelFormatDetails(src->format);
|
||
|
/*
|
||
|
* Determine if source surface is 32bit or 8bit
|
||
|
*/
|
||
|
if ((src->format->bits_per_pixel == 32)
|
||
|
|| (src->format->bits_per_pixel == 8)) {
|
||
|
if ((details->bits_per_pixel == 32)
|
||
|
|| (details->bits_per_pixel == 8)) {
|
||
|
/*
|
||
|
* Use source surface 'as is'
|
||
|
*/
|
||
| ... | ... | |
|
* Lock the surface
|
||
|
*/
|
||
|
if (SDL_MUSTLOCK(rz_src)) {
|
||
|
if (SDL_LockSurface(rz_src) < 0) {
|
||
|
if (!SDL_LockSurface(rz_src)) {
|
||
|
haveError = 1;
|
||
|
goto exitShrinkSurface;
|
||
|
}
|
||
| ... | ... | |
|
*/
|
||
|
rz_dst =
|
||
|
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
|
rz_src->format->format);
|
||
|
rz_src->format);
|
||
|
/* Check target */
|
||
|
if (rz_dst == NULL) {
|
||