* 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>
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);
}
/*
* 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,
uint8_t rop)
{
float y_min, y_max;
+ float x_min, x_max;
uint16_t edge;
float y;
float x;
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++) {
+ 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_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);
+ 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