altos/draw: Inline span fill for polygons
authorKeith Packard <keithp@keithp.com>
Mon, 27 Feb 2023 02:48:54 +0000 (18:48 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 27 Feb 2023 02:48:54 +0000 (18:48 -0800)
Instead of calling ao_rect, do the clipping by hand
and call ao_solid instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/draw/ao_poly.c

index 994f0a366811da18eecd7bbc64c1f40b701309ba..a546e04341cc680392b192137d01efc09b8ee960 100644 (file)
@@ -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
         */