Skip to content

Commit 74e76ef

Browse files
committed
Improving logic when a single slice is needed
1 parent 8f23633 commit 74e76ef

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/render/psp/SDL_render_psp.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,28 @@ static inline int calculateBestSliceSizeForSprite(SDL_Renderer *renderer, const
246246
return 0;
247247
}
248248

249+
static inline void fillSingleSliceVertices(VertTV *vertices, const SDL_Rect *srcrect, const SDL_FRect *dstrect) {
250+
vertices[0].x = dstrect->x;
251+
vertices[0].y = dstrect->y;
252+
vertices[0].z = 0.0f;
253+
vertices[0].u = srcrect->x;
254+
vertices[0].v = srcrect->y;
255+
256+
vertices[1].x = dstrect->x + dstrect->w;
257+
vertices[1].y = dstrect->y + dstrect->h;
258+
vertices[1].z = 0.0f;
259+
vertices[1].u = srcrect->x + srcrect->w;
260+
vertices[1].v = srcrect->y + srcrect->h;
261+
}
262+
249263
static inline void fillSpriteVertices(VertTV *vertices, SliceSize *dimensions, SliceSize *sliceSize,
250264
const SDL_Rect *srcrect, const SDL_FRect *dstrect)
251265
{
266+
// For avoiding division by zero
267+
if (dimensions->width == 1 && dimensions->height == 1) {
268+
fillSingleSliceVertices((VertV *)vertices, srcrect, dstrect);
269+
return;
270+
}
252271
int i, j;
253272
int remainingWidth = (int)dstrect->w % sliceSize->width;
254273
int remainingHeight = (int)dstrect->h % sliceSize->height;

0 commit comments

Comments
 (0)