projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/easytimer-v2: Initialize logging too
[fw/altos]
/
src
/
draw
/
ao_poly.c
diff --git
a/src/draw/ao_poly.c
b/src/draw/ao_poly.c
index 994f0a366811da18eecd7bbc64c1f40b701309ba..546f0db5ab71685d25490673862f15c0879d38fc 100644
(file)
--- a/
src/draw/ao_poly.c
+++ b/
src/draw/ao_poly.c
@@
-16,8
+16,8
@@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include
"ao_draw.h"
-#include
"ao_draw_int.h"
+#include
<ao_draw.h>
+#include
<ao_draw_int.h>
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <stdio.h>
#include <math.h>
#include <float.h>
@@
-145,7
+145,16
@@
ao_span(const struct ao_bitmap *dst,
int16_t ix1 = (int16_t) floorf(x1 + 0.5f);
int16_t ix2 = (int16_t) floorf(x2 + 0.5f);
int16_t iy = (int16_t) y;
int16_t ix1 = (int16_t) floorf(x1 + 0.5f);
int16_t ix2 = (int16_t) floorf(x2 + 0.5f);
int16_t iy = (int16_t) y;
- ao_rect(dst, ix1, iy, ix2 - ix1, 1, fill, rop);
+
+ ao_clip(ix1, 0, dst->width);
+ ao_clip(ix2, 0, dst->width);
+ ao_solid(ao_and(rop, fill),
+ ao_xor(rop, fill),
+ dst->base + iy * dst->stride,
+ dst->stride,
+ ix1,
+ ix2 - ix1,
+ 1);
}
/*
}
/*
@@
-166,7
+175,7
@@
ao_wind(const struct ao_coord *coords,
* Fill the specified polygon with non-zero winding rule
*/
void
* Fill the specified polygon with non-zero winding rule
*/
void
-ao_poly(
const struct ao_bitmap
*dst,
+ao_poly(
struct ao_bitmap
*dst,
const struct ao_coord *coords,
uint16_t ncoords,
const struct ao_transform *transform,
const struct ao_coord *coords,
uint16_t ncoords,
const struct ao_transform *transform,
@@
-174,6
+183,7
@@
ao_poly(const struct ao_bitmap *dst,
uint8_t rop)
{
float y_min, y_max;
uint8_t rop)
{
float y_min, y_max;
+ float x_min, x_max;
uint16_t edge;
float y;
float x;
uint16_t edge;
float y;
float x;
@@
-184,10
+194,16
@@
ao_poly(const struct ao_bitmap *dst,
transform = &ao_identity;
/*
transform = &ao_identity;
/*
- * Find the
y
limits of the polygon
+ * Find the limits of the polygon
*/
*/
+ x_min = x_max = _x(coords, transform, 0);
y_min = y_max = _y(coords, transform, 0);
for (edge = 1; edge < ncoords; edge++) {
y_min = y_max = _y(coords, transform, 0);
for (edge = 1; edge < ncoords; edge++) {
+ x = _x(coords, transform, edge);
+ if (x < x_min)
+ x_min = x;
+ else if (x > x_max)
+ x_max = x;
y = _y(coords, transform, edge);
if (y < y_min)
y_min = y;
y = _y(coords, transform, edge);
if (y < y_min)
y_min = y;
@@
-195,8
+211,17
@@
ao_poly(const struct ao_bitmap *dst,
y_max = y;
}
y_max = y;
}
+ x_min = floorf(x_min);
+ x_max = ceilf(x_max);
+ ao_clip(x_min, 0, dst->width);
+ ao_clip(x_max, 0, dst->width);
+
y_min = floorf(y_min);
y_max = ceilf(y_max);
y_min = floorf(y_min);
y_max = ceilf(y_max);
+ ao_clip(y_min, 0, dst->height);
+ ao_clip(y_max, 0, dst->height);
+
+ ao_damage(dst, (int16_t) x_min, (int16_t) y_min, (int16_t) x_max, (int16_t) y_max);
/*
* Walk each scanline in the range and fill included spans
/*
* Walk each scanline in the range and fill included spans