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.
19 ao_blt(uint32_t *src_line,
32 ao_solid(uint32_t and,
46 #define AO_ROP_CLEAR 0x0
47 #define AO_ROP_COPY 0x3
48 #define AO_ROP_SET 0xf
51 #define AO_UNIT (1 << AO_SHIFT)
52 #define AO_MASK (AO_UNIT - 1)
53 #define AO_ALLONES ((uint32_t) -1)
55 static inline uint32_t
56 ao_left(uint32_t bits, int16_t shift) {
60 static inline uint32_t
61 ao_right(uint32_t bits, int16_t shift) {
65 static inline uint32_t
66 ao_right_mask(int16_t x) {
67 if ((AO_UNIT - x) & AO_MASK)
68 return ao_left(AO_ALLONES,(AO_UNIT - x) & AO_MASK);
73 static inline uint32_t
74 ao_left_mask(int16_t x) {
76 return ao_right(AO_ALLONES, x & AO_MASK);
81 static inline uint32_t
82 ao_bits_mask(int16_t x, int16_t w) {
83 return ao_right(AO_ALLONES, x & AO_MASK) &
84 ao_left(AO_ALLONES,(AO_UNIT - (x + w)) & AO_MASK);
87 #define ao_mask_bits(x,w,l,n,r) { \
89 r = ao_right_mask((x)+n); \
90 l = ao_left_mask(x); \
92 n -= AO_UNIT - ((x) & AO_MASK); \
102 static inline uint32_t
103 ao_do_mask_rrop(uint32_t dst, uint32_t and, uint32_t xor, uint32_t mask) {
104 return (dst & (and | ~mask)) ^ (xor & mask);
107 static inline uint32_t
108 ao_do_rrop(uint32_t dst, uint32_t and, uint32_t xor) {
109 return (dst & and) ^ xor;
112 #define AO_CLEAR 0x0 /* 0 */
113 #define AO_AND 0x1 /* src AND dst */
114 #define AO_AND_REVERSE 0x2 /* src AND NOT dst */
115 #define AO_COPY 0x3 /* src */
116 #define AO_AND_INVERTED 0x4 /* NOT src AND dst */
117 #define AO_NOOP 0x5 /* dst */
118 #define AO_XOR 0x6 /* src XOR dst */
119 #define AO_OR 0x7 /* src OR dst */
120 #define AO_NOR 0x8 /* NOT src AND NOT dst */
121 #define AO_EQUIV 0x9 /* NOT src XOR dst */
122 #define AO_INVERT 0xa /* NOT dst */
123 #define AO_OR_REVERSE 0xb /* src OR NOT dst */
124 #define AO_COPY_INVERTED 0xc /* NOT src */
125 #define AO_OR_INVERTED 0xd /* NOT src OR dst */
126 #define AO_NAND 0xe /* NOT src OR NOT dst */
127 #define AO_SET 0xf /* 1 */
129 #endif /* _AO_DRAW_H_ */