2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
17 #include "ao_draw_int.h"
19 #define ao_mask(x,w) (ao_right(AO_ALLONES,(x) & AO_MASK) & \
20 ao_left(AO_ALLONES,(FB_UNIT - ((x)+(w))) & AO_MASK))
23 /* out of clip region codes */
25 #define OUT_RIGHT 0x04
26 #define OUT_ABOVE 0x02
27 #define OUT_BELOW 0x01
29 /* major axis for bresenham's line */
34 ao_bres(const struct ao_bitmap *dst_bitmap,
47 int16_t stride = dst_bitmap->stride;
48 uint32_t *dst = dst_bitmap->base;
53 mask0 = ao_right(1, AO_UNIT - 1);
58 dst = dst + y1 * stride + (x1 >> AO_SHIFT);
59 mask = ao_right(1, x1 & AO_MASK);
64 if (0 <= x1 && x1 < dst_bitmap->width &&
65 0 <= y1 && y1 < dst_bitmap->height)
66 *dst = ao_do_mask_rrop(*dst, and, xor, mask);
70 mask = ao_left(mask, 1);
72 mask = ao_right(mask, 1);
90 mask = ao_left(mask, 1);
92 mask = ao_right(mask, 1);
105 #define bound(val,max) do { \
115 ao_line(const struct ao_bitmap *dst,
124 int16_t e, e1, e2, e3;
125 int16_t signdx = 1, signdy = 1;
129 if ((adx = x2 - x1) < 0) {
133 if ((ady = y2 - y1) < 0) {
141 e2 = e1 - (adx << 1);
147 e2 = e1 - (ady << 1);