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.
24 int16_t stride; /* in units */
25 int16_t width; /* in pixels */
26 int16_t height; /* in pixels */
38 static inline float ao_t_x(float x, float y, const struct ao_transform *t)
41 return x * t->x_scale + t->x_off;
44 static inline int16_t ao_t_xi(float x, float y, const struct ao_transform *t)
46 return (int16_t) (ao_t_x(x, y, t) + 0.5f);
49 static inline float ao_t_y(float x, float y, const struct ao_transform *t)
52 return y * t->y_scale + t->y_off;
55 static inline int16_t ao_t_yi(float x, float y, const struct ao_transform *t)
57 return (int16_t) (ao_t_y(x, y, t) + 0.5f);
60 static inline float ao_t_x_c(const struct ao_coord *c,
61 const struct ao_transform *t)
63 return ao_t_x(c->x, c->y, t);
66 static inline float ao_t_y_c(const struct ao_coord *c,
67 const struct ao_transform *t)
69 return ao_t_y(c->x, c->y, t);
73 ao_stride(int16_t width)
75 return (int16_t) ((width + 31) >> 5);
79 ao_stride_bytes(int16_t width)
81 return (int16_t) ((width + 7) >> 3);
88 struct ao_glyph_metrics {
99 const struct ao_glyph_metrics *metrics;
106 ao_copy(const struct ao_bitmap *dst,
111 const struct ao_bitmap *src,
117 ao_rect(const struct ao_bitmap *dst,
126 ao_pattern(const struct ao_bitmap *dst,
131 const struct ao_pattern *pattern,
137 ao_line(const struct ao_bitmap *dst,
146 ao_poly(const struct ao_bitmap *dst,
147 const struct ao_coord *coords,
149 const struct ao_transform *transform,
154 ao_text(const struct ao_bitmap *dst,
155 const struct ao_font *font,
163 ao_logo(const struct ao_bitmap *dst,
164 const struct ao_transform *transform,
165 const struct ao_font *font,
169 extern const struct ao_transform ao_identity;
172 #define AO_UNIT (1 << AO_SHIFT)
173 #define AO_MASK (AO_UNIT - 1)
174 #define AO_ALLONES ((uint32_t) -1)
187 #define AO_CLEAR 0x0 /* 0 */
188 #define AO_AND 0x1 /* src AND dst */
189 #define AO_AND_REVERSE 0x2 /* src AND NOT dst */
190 #define AO_COPY 0x3 /* src */
191 #define AO_AND_INVERTED 0x4 /* NOT src AND dst */
192 #define AO_NOOP 0x5 /* dst */
193 #define AO_XOR 0x6 /* src XOR dst */
194 #define AO_OR 0x7 /* src OR dst */
195 #define AO_NOR 0x8 /* NOT src AND NOT dst */
196 #define AO_EQUIV 0x9 /* NOT src XOR dst */
197 #define AO_INVERT 0xa /* NOT dst */
198 #define AO_OR_REVERSE 0xb /* src OR NOT dst */
199 #define AO_COPY_INVERTED 0xc /* NOT src */
200 #define AO_OR_INVERTED 0xd /* NOT src OR dst */
201 #define AO_NAND 0xe /* NOT src OR NOT dst */
202 #define AO_SET 0xf /* 1 */
204 #endif /* _AO_DRAW_H_ */