altos/draw: Skip line adjustment for vertical/horizontal
authorKeith Packard <keithp@keithp.com>
Wed, 8 Mar 2023 23:50:57 +0000 (15:50 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 1 Feb 2024 01:50:19 +0000 (17:50 -0800)
When e3 is zero, don't adjust the minor position based on
the major as it doesn't move.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/draw/ao_line.c

index 14e1a3c1a591aec6b2cdc5341e08f57d2e01fca2..38314542386f42f503a42699765743bd6785ce47 100644 (file)
@@ -209,26 +209,25 @@ ao_clip_line(struct ao_cc *c, struct ao_cbox *b)
         * isn't symmetrical when the line passes exactly between
         * two pixels, we have to pick which one gets drawn
         */
-       int32_t adj_min;
-
        if (c->e3) {
+               int32_t adj_min;
+
                if (!c->first)
                        adj_min = div_ceil(c->e + adjust_major * c->e1, -c->e3);
                else
                        adj_min = div_floor_plus_one(c->e + adjust_major * c->e1, -c->e3);
-       }
 
-       if (adj_min < adjust_minor) {
-               if (c->e1) {
-                       if (c->first)
-                               adjust_major = div_ceil(c->e - adjust_minor * c->e3, c->e1);
-                       else
-                               adjust_major = div_floor_plus_one(c->e - adjust_minor * c->e3, c->e1);
+               if (adj_min < adjust_minor) {
+                       if (c->e1) {
+                               if (c->first)
+                                       adjust_major = div_ceil(c->e - adjust_minor * c->e3, c->e1);
+                               else
+                                       adjust_major = div_floor_plus_one(c->e - adjust_minor * c->e3, c->e1);
+                       }
+               } else {
+                       adjust_minor = adj_min;
                }
-       } else {
-               adjust_minor = adj_min;
        }
-
        c->e = (int16_t) (c->e + adjust_major * c->e1 + adjust_minor * c->e3);
 
        c->major = (int16_t) (c->major + c->sign_major * adjust_major);