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.
15 #ifndef _AO_DRAW_INT_H_
16 #define _AO_DRAW_INT_H_
18 static inline uint32_t
19 ao_expand(uint32_t bits)
21 return ~((bits & 1)-1);
24 static inline uint32_t
25 ao_xor(uint8_t rop, uint32_t fg)
29 return (fg & ao_expand(rop >> 1)) |
30 (~fg & ao_expand(rop >> 3));
33 static inline uint32_t
34 ao_and(uint8_t rop, uint32_t fg)
38 return (fg & ao_expand(rop ^ (rop >> 1))) |
39 (~fg & ao_expand((rop>>2) ^ (rop>>3)));
42 static inline uint32_t
43 ao_left(uint32_t bits, int16_t shift) {
47 static inline uint32_t
48 ao_right(uint32_t bits, int16_t shift) {
52 static inline uint32_t
53 ao_right_mask(int16_t x) {
54 if ((AO_UNIT - x) & AO_MASK)
55 return ao_left(AO_ALLONES,(AO_UNIT - x) & AO_MASK);
60 static inline uint32_t
61 ao_left_mask(int16_t x) {
63 return ao_right(AO_ALLONES, x & AO_MASK);
68 static inline uint32_t
69 ao_bits_mask(int16_t x, int16_t w) {
70 return ao_right(AO_ALLONES, x & AO_MASK) &
71 ao_left(AO_ALLONES,(AO_UNIT - (x + w)) & AO_MASK);
74 #define ao_mask_bits(x,w,l,n,r) { \
76 r = ao_right_mask((x)+n); \
77 l = ao_left_mask(x); \
79 n -= AO_UNIT - ((x) & AO_MASK); \
89 #define ao_clip(val,min,max) do { \
92 } else if (val > max) { \
97 static inline uint32_t
98 ao_do_mask_rrop(uint32_t dst, uint32_t and, uint32_t xor, uint32_t mask) {
99 return (dst & (and | ~mask)) ^ (xor & mask);
102 static inline uint32_t
103 ao_do_rrop(uint32_t dst, uint32_t and, uint32_t xor) {
104 return (dst & and) ^ xor;
108 ao_blt(uint32_t *src_line,
121 ao_solid(uint32_t and,
130 ao_glyph(const struct ao_bitmap *dst,
136 #endif /* _AO_DRAW_INT_H_ */