altos/draw: Skip line adjustment for vertical/horizontal
[fw/altos] / src / draw / ao_line.c
index 832a916c76aed9dbe1042f7a024febe071ae93c6..38314542386f42f503a42699765743bd6785ce47 100644 (file)
@@ -12,8 +12,8 @@
  * General Public License for more details.
  */
 
-#include "ao_draw.h"
-#include "ao_draw_int.h"
+#include <ao_draw.h>
+#include <ao_draw_int.h>
 
 #define ao_mask(x,w)   (ao_right(AO_ALLONES,(x) & AO_MASK) & \
                         ao_left(AO_ALLONES,(FB_UNIT - ((x)+(w))) & AO_MASK))
@@ -209,32 +209,36 @@ 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->first)
-                       adjust_major = div_ceil(c->e - adjust_minor * c->e3, c->e1);
+               if (!c->first)
+                       adj_min = div_ceil(c->e + adjust_major * c->e1, -c->e3);
                else
-                       adjust_major = div_floor_plus_one(c->e - adjust_minor * c->e3, c->e1);
-       } else {
-               adjust_minor = adj_min;
-       }
+                       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);
+                       }
+               } 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);
        c->minor = (int16_t) (c->minor + c->sign_minor * adjust_minor);
 
+       c->first = true;        /* signal to extend len */
        return true;
 }
 
 void
-ao_line(const struct ao_bitmap *dst,
+ao_line(struct ao_bitmap       *dst,
        int16_t                 x1,
        int16_t                 y1,
        int16_t                 x2,
@@ -320,10 +324,17 @@ ao_line(const struct ao_bitmap    *dst,
        if (adx > ady) {
                x1 = clip_1.major;
                y1 = clip_1.minor;
+               x2 = clip_2.major;
+               y2 = clip_2.minor;
        } else {
                x1 = clip_1.minor;
                y1 = clip_1.major;
+               x2 = clip_2.minor;
+               y2 = clip_2.major;
        }
+
+       ao_damage(dst, ao_min16(x1, x2), ao_max16(x1, x2), ao_min16(y1, y2), ao_max16(y1, y2));
+
        ao_bres(dst,
                signdx,
                signdy,