qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 05/13] display/sm501: make range overlap check more readable


From: Yao Xingtao
Subject: [PATCH 05/13] display/sm501: make range overlap check more readable
Date: Mon, 22 Jul 2024 00:07:34 -0400

use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.

Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
---
 hw/display/sm501.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 26dc8170d89b..c25b2574e447 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -823,15 +823,15 @@ static void sm501_2d_operation(SM501State *s)
             }
             /* If reverse blit do simple check for overlaps */
             if (rtl && src_base == dst_base && src_pitch == dst_pitch) {
-                overlap = (src_x < dst_x + width && src_x + width > dst_x &&
-                           src_y < dst_y + height && src_y + height > dst_y);
+                overlap = (ranges_overlap(src_x, width, dst_x, width) &&
+                           ranges_overlap(src_y, height, dst_y, height));
             } else if (rtl) {
-                unsigned int sb, se, db, de;
+                unsigned int sb, sl, db, dl;
                 sb = src_base + (src_x + src_y * src_pitch) * bypp;
-                se = sb + (width + (height - 1) * src_pitch) * bypp;
+                sl = (width + (height - 1) * src_pitch) * bypp;
                 db = dst_base + (dst_x + dst_y * dst_pitch) * bypp;
-                de = db + (width + (height - 1) * dst_pitch) * bypp;
-                overlap = (db < se && sb < de);
+                dl = (width + (height - 1) * dst_pitch) * bypp;
+                overlap = ranges_overlap(sb, sl, db, dl);
             }
 #ifdef CONFIG_PIXMAN
             if (overlap && (s->use_pixman & BIT(2))) {
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]