From c4ec06d6aba8c08a212b2e7de00b5f5d70fc5325 Mon Sep 17 00:00:00 2001 From: Lephe Date: Fri, 30 Apr 2021 09:42:01 +0200 Subject: [PATCH] display: fix bound checking in drect_border (#14) Bounds would be moved before drawing the border, therefore displacing the border. Since drect() already performs all the necessary checks, this change doesn't try to save a couple of function calls and drops the redundant checks. --- src/render/drect_border.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/render/drect_border.c b/src/render/drect_border.c index 65ac289..88adbe4 100644 --- a/src/render/drect_border.c +++ b/src/render/drect_border.c @@ -8,12 +8,7 @@ void drect_border(int x1, int y1, int x2, int y2, int fill, int width, if(x1 > x2) swap(x1, x2); if(y1 > y2) swap(y1, y2); - /* Order and bounds */ - if(x1 >= 396 || x2 < 0 || y1 >= 224 || y2 < 0) return; - if(x1 < 0) x1 = 0; - if(x2 >= 396) x2 = 395; - if(y1 < 0) y1 = 0; - if(y2 >= 224) y2 = 223; + if(x1 >= DWIDTH || x2 < 0 || y1 >= DHEIGHT || y2 < 0) return; drect(x1, y1, x2, y1 + (width-1), border); drect(x1, y2 - (width-1), x2, y2, border);