mirror of https://github.com/encounter/SDL.git
Fixed bug #2308: SDL_RenderCopyEx rotation center precision (software renderer)
This commit is contained in:
parent
66ee79bd68
commit
e366ad1288
|
@ -310,8 +310,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||||
SDL_Rect tmp_rect;
|
SDL_Rect tmp_rect;
|
||||||
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
||||||
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
||||||
int retval = 0, dstwidth, dstheight, abscenterx, abscentery;
|
int retval = 0;
|
||||||
double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
|
|
||||||
SDL_BlendMode blendmode;
|
SDL_BlendMode blendmode;
|
||||||
Uint8 alphaMod, rMod, gMod, bMod;
|
Uint8 alphaMod, rMod, gMod, bMod;
|
||||||
int applyModulation = SDL_FALSE;
|
int applyModulation = SDL_FALSE;
|
||||||
|
@ -413,6 +412,9 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||||
SDL_SetSurfaceBlendMode(src_clone, blendmode);
|
SDL_SetSurfaceBlendMode(src_clone, blendmode);
|
||||||
|
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
|
int dstwidth, dstheight;
|
||||||
|
double cangle, sangle;
|
||||||
|
|
||||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, &dstwidth, &dstheight, &cangle, &sangle);
|
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, &dstwidth, &dstheight, &cangle, &sangle);
|
||||||
src_rotated = SDLgfx_rotateSurface(src_clone, angle, dstwidth/2, dstheight/2, (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
src_rotated = SDLgfx_rotateSurface(src_clone, angle, dstwidth/2, dstheight/2, (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
||||||
if (src_rotated == NULL) {
|
if (src_rotated == NULL) {
|
||||||
|
@ -426,9 +428,12 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
|
double abscenterx, abscentery;
|
||||||
|
double px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
|
||||||
|
|
||||||
/* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
|
/* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
|
||||||
abscenterx = final_rect->x + (int)center->x;
|
abscenterx = final_rect->x + center->x;
|
||||||
abscentery = final_rect->y + (int)center->y;
|
abscentery = final_rect->y + center->y;
|
||||||
/* Compensate the angle inversion to match the behaviour of the other backends */
|
/* Compensate the angle inversion to match the behaviour of the other backends */
|
||||||
sangle = -sangle;
|
sangle = -sangle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue