diff mbox series

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

Message ID 20240722040742.11513-6-yaoxt.fnst@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series make range overlap check more readable | expand

Commit Message

Xingtao Yao (Fujitsu) July 22, 2024, 4:07 a.m. UTC
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 mbox series

Patch

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))) {