Do not draw sprites with backwards/empty RECTs

Previously, each backend had to guard against it, which is messy,
results in duplication, and leaves new backends open to the risk
of not guarding against it (the Wii U GX2 renderer didn't).
This commit is contained in:
Clownacy 2020-04-21 14:54:29 +01:00
parent f55450d141
commit afb3c834a7

View file

@ -419,6 +419,10 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect)
scaled_rect.right = rect->right * magnification; scaled_rect.right = rect->right * magnification;
scaled_rect.bottom = rect->bottom * magnification; scaled_rect.bottom = rect->bottom * magnification;
// Do not draw invalid RECTs
if (rcWork->right <= rcWork->left || rcWork->bottom <= rcWork->top)
return;
RenderBackend_Blit(framebuffer, &scaled_rect, surf[surf_no], scaled_rect.left, scaled_rect.top, FALSE); RenderBackend_Blit(framebuffer, &scaled_rect, surf[surf_no], scaled_rect.left, scaled_rect.top, FALSE);
} }
@ -454,6 +458,10 @@ void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
rcWork.right *= magnification; rcWork.right *= magnification;
rcWork.bottom *= magnification; rcWork.bottom *= magnification;
// Do not draw invalid RECTs
if (rcWork->right <= rcWork->left || rcWork->bottom <= rcWork->top)
return;
RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, TRUE); RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, TRUE);
} }
@ -489,6 +497,10 @@ void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
rcWork.right *= magnification; rcWork.right *= magnification;
rcWork.bottom *= magnification; rcWork.bottom *= magnification;
// Do not draw invalid RECTs
if (rcWork->right <= rcWork->left || rcWork->bottom <= rcWork->top)
return;
RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, FALSE); RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, FALSE);
} }
@ -501,6 +513,10 @@ void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
rcWork.right = rect->right * magnification; rcWork.right = rect->right * magnification;
rcWork.bottom = rect->bottom * magnification; rcWork.bottom = rect->bottom * magnification;
// Do not draw invalid RECTs
if (rcWork->right <= rcWork->left || rcWork->bottom <= rcWork->top)
return;
RenderBackend_Blit(surf[from], &rcWork, surf[to], x * magnification, y * magnification, TRUE); RenderBackend_Blit(surf[from], &rcWork, surf[to], x * magnification, y * magnification, TRUE);
} }
@ -522,6 +538,10 @@ void CortBox(const RECT *rect, unsigned long col)
const unsigned char green = (col >> 8) & 0xFF; const unsigned char green = (col >> 8) & 0xFF;
const unsigned char blue = (col >> 16) & 0xFF; const unsigned char blue = (col >> 16) & 0xFF;
// Do not draw invalid RECTs
if (dst_rect->right <= dst_rect->left || dst_rect->bottom <= dst_rect->top)
return;
RenderBackend_ColourFill(framebuffer, &dst_rect, red, green, blue); RenderBackend_ColourFill(framebuffer, &dst_rect, red, green, blue);
} }
@ -539,6 +559,10 @@ void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
const unsigned char green = (col >> 8) & 0xFF; const unsigned char green = (col >> 8) & 0xFF;
const unsigned char blue = (col >> 16) & 0xFF; const unsigned char blue = (col >> 16) & 0xFF;
// Do not draw invalid RECTs
if (dst_rect->right <= dst_rect->left || dst_rect->bottom <= dst_rect->top)
return;
RenderBackend_ColourFill(surf[surf_no], &dst_rect, red, green, blue); RenderBackend_ColourFill(surf[surf_no], &dst_rect, red, green, blue);
} }