ref: afb3c834a77f7da8a27afc5fd2926792e0227f81
parent: f55450d14180a201eed910c04602605531f876d8
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Apr 21 10:54:29 EDT 2020
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).
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -419,6 +419,10 @@
scaled_rect.right = rect->right * 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);
}
@@ -454,6 +458,10 @@
rcWork.right *= 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);
}
@@ -489,6 +497,10 @@
rcWork.right *= 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);
}
@@ -501,6 +513,10 @@
rcWork.right = rect->right * 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);
}
@@ -522,6 +538,10 @@
const unsigned char green = (col >> 8) & 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);
}
@@ -538,6 +558,10 @@
const unsigned char red = col & 0xFF;
const unsigned char green = (col >> 8) & 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);
}