projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Compute igniter good/bad thresholds using 3.5V value
[fw/altos]
/
src
/
draw
/
ao_line.c
diff --git
a/src/draw/ao_line.c
b/src/draw/ao_line.c
index c6b49ee0d6cb1fd71ffe83f3b1369cedeeb15896..14e1a3c1a591aec6b2cdc5341e08f57d2e01fca2 100644
(file)
--- a/
src/draw/ao_line.c
+++ b/
src/draw/ao_line.c
@@
-12,8
+12,8
@@
* General Public License for more details.
*/
* 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))
#define ao_mask(x,w) (ao_right(AO_ALLONES,(x) & AO_MASK) & \
ao_left(AO_ALLONES,(FB_UNIT - ((x)+(w))) & AO_MASK))
@@
-54,8
+54,9
@@
* adjust_x = e / e1;
*/
* adjust_x = e / e1;
*/
-
-
+#ifdef VALIDATE
+#include <stdio.h>
+#endif
static void
ao_bres(const struct ao_bitmap *dst_bitmap,
static void
ao_bres(const struct ao_bitmap *dst_bitmap,
@@
-88,9
+89,22
@@
ao_bres(const struct ao_bitmap *dst_bitmap,
while (len--) {
/* clip each point */
while (len--) {
/* clip each point */
+#ifdef VALIDATE
+ if (x1 < 0 || dst_bitmap->width <= x1) {
+ printf("bad line x %d\n", x1);
+ return;
+ }
+ if (y1 < 0 || dst_bitmap->height <= y1) {
+ printf("bad line y %d\n", y1);
+ return;
+ }
+#endif
*dst = ao_do_mask_rrop(*dst, and, xor, mask);
if (axis == X_AXIS) {
*dst = ao_do_mask_rrop(*dst, and, xor, mask);
if (axis == X_AXIS) {
+#ifdef VALIDATE
+ x1 += signdx;
+#endif
if (signdx < 0)
mask = ao_left(mask, 1);
else
if (signdx < 0)
mask = ao_left(mask, 1);
else
@@
-101,13
+115,22
@@
ao_bres(const struct ao_bitmap *dst_bitmap,
}
e += e1;
if (e >= 0) {
}
e += e1;
if (e >= 0) {
+#ifdef VALIDATE
+ y1 += signdy;
+#endif
dst += stride;
e += e3;
}
} else {
dst += stride;
e += e3;
}
} else {
+#ifdef VALIDATE
+ y1 += signdy;
+#endif
dst += stride;
e += e1;
if (e >= 0) {
dst += stride;
e += e1;
if (e >= 0) {
+#ifdef VALIDATE
+ x1 += signdx;
+#endif
if (signdx < 0)
mask = ao_left(mask, 1);
else
if (signdx < 0)
mask = ao_left(mask, 1);
else
@@
-188,16
+211,20
@@
ao_clip_line(struct ao_cc *c, struct ao_cbox *b)
*/
int32_t adj_min;
*/
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 (c->e3) {
+ 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 (adj_min < adjust_minor) {
- 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 (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;
}
@@
-207,11
+234,12
@@
ao_clip_line(struct ao_cc *c, struct ao_cbox *b)
c->major = (int16_t) (c->major + c->sign_major * adjust_major);
c->minor = (int16_t) (c->minor + c->sign_minor * adjust_minor);
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
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,
int16_t x1,
int16_t y1,
int16_t x2,
@@
-297,10
+325,17
@@
ao_line(const struct ao_bitmap *dst,
if (adx > ady) {
x1 = clip_1.major;
y1 = clip_1.minor;
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;
} 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,
ao_bres(dst,
signdx,
signdy,