render: Some cleanups.
Mostly setting NULL pointers to a local struct instead of copying non-NULL pointers' contents into the local struct.
This commit is contained in:
@@ -3869,9 +3869,6 @@ static bool SDL_RenderTextureInternal(SDL_Renderer *renderer, SDL_Texture *textu
|
|||||||
|
|
||||||
bool SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect)
|
bool SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect)
|
||||||
{
|
{
|
||||||
SDL_FRect real_srcrect;
|
|
||||||
SDL_FRect real_dstrect;
|
|
||||||
|
|
||||||
CHECK_RENDERER_MAGIC(renderer, false);
|
CHECK_RENDERER_MAGIC(renderer, false);
|
||||||
CHECK_TEXTURE_MAGIC(texture, false);
|
CHECK_TEXTURE_MAGIC(texture, false);
|
||||||
|
|
||||||
@@ -3886,6 +3883,7 @@ bool SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_F
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_FRect real_srcrect;
|
||||||
real_srcrect.x = 0.0f;
|
real_srcrect.x = 0.0f;
|
||||||
real_srcrect.y = 0.0f;
|
real_srcrect.y = 0.0f;
|
||||||
real_srcrect.w = (float)texture->w;
|
real_srcrect.w = (float)texture->w;
|
||||||
@@ -3896,9 +3894,10 @@ bool SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_F
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetRenderViewportSize(renderer, &real_dstrect);
|
SDL_FRect full_dstrect;
|
||||||
if (dstrect) {
|
if (!dstrect) {
|
||||||
real_dstrect = *dstrect;
|
GetRenderViewportSize(renderer, &full_dstrect);
|
||||||
|
dstrect = &full_dstrect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture->native) {
|
if (texture->native) {
|
||||||
@@ -3907,7 +3906,7 @@ bool SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_F
|
|||||||
|
|
||||||
texture->last_command_generation = renderer->render_command_generation;
|
texture->last_command_generation = renderer->render_command_generation;
|
||||||
|
|
||||||
return SDL_RenderTextureInternal(renderer, texture, &real_srcrect, &real_dstrect);
|
return SDL_RenderTextureInternal(renderer, texture, &real_srcrect, dstrect);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture,
|
bool SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||||
@@ -4032,7 +4031,6 @@ bool SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip)
|
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip)
|
||||||
{
|
{
|
||||||
SDL_FRect real_srcrect;
|
SDL_FRect real_srcrect;
|
||||||
SDL_FRect real_dstrect;
|
|
||||||
SDL_FPoint real_center;
|
SDL_FPoint real_center;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
@@ -4068,10 +4066,10 @@ bool SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we?
|
// We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we?
|
||||||
if (dstrect) {
|
SDL_FRect full_dstrect;
|
||||||
real_dstrect = *dstrect;
|
if (!dstrect) {
|
||||||
} else {
|
GetRenderViewportSize(renderer, &full_dstrect);
|
||||||
GetRenderViewportSize(renderer, &real_dstrect);
|
dstrect = &full_dstrect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture->native) {
|
if (texture->native) {
|
||||||
@@ -4081,8 +4079,8 @@ bool SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
if (center) {
|
if (center) {
|
||||||
real_center = *center;
|
real_center = *center;
|
||||||
} else {
|
} else {
|
||||||
real_center.x = real_dstrect.w / 2.0f;
|
real_center.x = dstrect->w / 2.0f;
|
||||||
real_center.y = real_dstrect.h / 2.0f;
|
real_center.y = dstrect->h / 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
texture->last_command_generation = renderer->render_command_generation;
|
texture->last_command_generation = renderer->render_command_generation;
|
||||||
@@ -4116,23 +4114,23 @@ bool SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
maxu = (real_srcrect.x + real_srcrect.w) / texture->w;
|
maxu = (real_srcrect.x + real_srcrect.w) / texture->w;
|
||||||
maxv = (real_srcrect.y + real_srcrect.h) / texture->h;
|
maxv = (real_srcrect.y + real_srcrect.h) / texture->h;
|
||||||
|
|
||||||
centerx = real_center.x + real_dstrect.x;
|
centerx = real_center.x + dstrect->x;
|
||||||
centery = real_center.y + real_dstrect.y;
|
centery = real_center.y + dstrect->y;
|
||||||
|
|
||||||
if (flip & SDL_FLIP_HORIZONTAL) {
|
if (flip & SDL_FLIP_HORIZONTAL) {
|
||||||
minx = real_dstrect.x + real_dstrect.w;
|
minx = dstrect->x + dstrect->w;
|
||||||
maxx = real_dstrect.x;
|
maxx = dstrect->x;
|
||||||
} else {
|
} else {
|
||||||
minx = real_dstrect.x;
|
minx = dstrect->x;
|
||||||
maxx = real_dstrect.x + real_dstrect.w;
|
maxx = dstrect->x + dstrect->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flip & SDL_FLIP_VERTICAL) {
|
if (flip & SDL_FLIP_VERTICAL) {
|
||||||
miny = real_dstrect.y + real_dstrect.h;
|
miny = dstrect->y + dstrect->h;
|
||||||
maxy = real_dstrect.y;
|
maxy = dstrect->y;
|
||||||
} else {
|
} else {
|
||||||
miny = real_dstrect.y;
|
miny = dstrect->y;
|
||||||
maxy = real_dstrect.y + real_dstrect.h;
|
maxy = dstrect->y + dstrect->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv[0] = minu;
|
uv[0] = minu;
|
||||||
@@ -4173,7 +4171,7 @@ bool SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
num_vertices, indices, num_indices, size_indices,
|
num_vertices, indices, num_indices, size_indices,
|
||||||
scale_x, scale_y, SDL_TEXTURE_ADDRESS_CLAMP);
|
scale_x, scale_y, SDL_TEXTURE_ADDRESS_CLAMP);
|
||||||
} else {
|
} else {
|
||||||
result = QueueCmdCopyEx(renderer, texture, &real_srcrect, &real_dstrect, angle, &real_center, flip, scale_x, scale_y);
|
result = QueueCmdCopyEx(renderer, texture, &real_srcrect, dstrect, angle, &real_center, flip, scale_x, scale_y);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user