From cd5b0ac6f2b0c709fe3d419c4c090aa5638d09e1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 26 Feb 2023 18:48:54 -0800 Subject: [PATCH] altos/draw: Inline span fill for polygons Instead of calling ao_rect, do the clipping by hand and call ao_solid instead. Signed-off-by: Keith Packard --- src/draw/ao_poly.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/draw/ao_poly.c b/src/draw/ao_poly.c index 994f0a36..a546e043 100644 --- a/src/draw/ao_poly.c +++ b/src/draw/ao_poly.c @@ -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; - 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); } /* @@ -198,6 +207,9 @@ ao_poly(const struct ao_bitmap *dst, y_min = floorf(y_min); y_max = ceilf(y_max); + ao_clip(y_min, 0, dst->height); + ao_clip(y_max, 0, dst->height); + /* * Walk each scanline in the range and fill included spans */ -- 2.30.2