Fixed a small bug in the clip render rect function where it doesn't
check to make sure the src rect pointer isn't NULL.
This commit is contained in:
1 parent
a87eba8db7
commit
cc052ed02c
1 file changed
+12
-2
+12
-2
@@ -225,13 +225,23 @@ void fill_rectangle(RenderRect rect, SDL_Color color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest) {
|
void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest) {
|
||||||
|
if (!dest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WindowDrawingArea area = get_window_drawing_area();
|
WindowDrawingArea area = get_window_drawing_area();
|
||||||
|
|
||||||
// If the rectangle is completely out of bounds, set its width and height to 0
|
// If the rectangle is completely out of bounds, set its width and height to 0
|
||||||
if (dest->x > area.x + area.width || dest->x + dest->width < area.x ||
|
if (dest->x > area.x + area.width || dest->x + dest->width < area.x ||
|
||||||
dest->y > area.y + area.height || dest->y + dest->height < area.y) {
|
dest->y > area.y + area.height || dest->y + dest->height < area.y) {
|
||||||
src->width = 0.0f;
|
if (src) {
|
||||||
src->height = 0.0f;
|
src->width = 0.0f;
|
||||||
|
src->height = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest->width = 0.0f;
|
||||||
|
dest->height = 0.0f;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user