mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-17 02:08:27 +00:00
Fixed gaps in scaled 9-grid texture rendering
This commit is contained in:
parent
458f616c53
commit
6823e3f005
1 changed files with 21 additions and 21 deletions
|
@ -4264,15 +4264,28 @@ bool SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scale <= 0.0f || scale == 1.0f) {
|
if (scale <= 0.0f || scale == 1.0f) {
|
||||||
dst_left_width = left_width;
|
dst_left_width = SDL_ceilf(left_width);
|
||||||
dst_right_width = right_width;
|
dst_right_width = SDL_ceilf(right_width);
|
||||||
dst_top_height = top_height;
|
dst_top_height = SDL_ceilf(top_height);
|
||||||
dst_bottom_height = bottom_height;
|
dst_bottom_height = SDL_ceilf(bottom_height);
|
||||||
} else {
|
} else {
|
||||||
dst_left_width = (left_width * scale);
|
dst_left_width = SDL_ceilf(left_width * scale);
|
||||||
dst_right_width = (right_width * scale);
|
dst_right_width = SDL_ceilf(right_width * scale);
|
||||||
dst_top_height = (top_height * scale);
|
dst_top_height = SDL_ceilf(top_height * scale);
|
||||||
dst_bottom_height = (bottom_height * scale);
|
dst_bottom_height = SDL_ceilf(bottom_height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Center
|
||||||
|
curr_src.x = srcrect->x + left_width;
|
||||||
|
curr_src.y = srcrect->y + top_height;
|
||||||
|
curr_src.w = srcrect->w - left_width - right_width;
|
||||||
|
curr_src.h = srcrect->h - top_height - bottom_height;
|
||||||
|
curr_dst.x = dstrect->x + dst_left_width;
|
||||||
|
curr_dst.y = dstrect->y + dst_top_height;
|
||||||
|
curr_dst.w = dstrect->w - dst_left_width - dst_right_width;
|
||||||
|
curr_dst.h = dstrect->h - dst_top_height - dst_bottom_height;
|
||||||
|
if (!SDL_RenderTexture(renderer, texture, &curr_src, &curr_dst)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upper-left corner
|
// Upper-left corner
|
||||||
|
@ -4353,19 +4366,6 @@ bool SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center
|
|
||||||
curr_src.x = srcrect->x + left_width;
|
|
||||||
curr_src.y = srcrect->y + top_height;
|
|
||||||
curr_src.w = srcrect->w - left_width - right_width;
|
|
||||||
curr_src.h = srcrect->h - top_height - bottom_height;
|
|
||||||
curr_dst.x = dstrect->x + dst_left_width;
|
|
||||||
curr_dst.y = dstrect->y + dst_top_height;
|
|
||||||
curr_dst.w = dstrect->w - dst_left_width - dst_right_width;
|
|
||||||
curr_dst.h = dstrect->h - dst_top_height - dst_bottom_height;
|
|
||||||
if (!SDL_RenderTexture(renderer, texture, &curr_src, &curr_dst)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue