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.
25 int16_t stride; /* in units */
26 int16_t width; /* in pixels */
27 int16_t height; /* in pixels */
40 static inline float ao_t_x(float x, float y, const struct ao_transform *t)
43 return x * t->x_scale + t->x_off;
46 static inline int16_t ao_t_xi(float x, float y, const struct ao_transform *t)
48 return (int16_t) (ao_t_x(x, y, t) + 0.5f);
51 static inline float ao_t_y(float x, float y, const struct ao_transform *t)
54 return y * t->y_scale + t->y_off;
57 static inline int16_t ao_t_yi(float x, float y, const struct ao_transform *t)
59 return (int16_t) (ao_t_y(x, y, t) + 0.5f);
62 static inline float ao_t_x_c(const struct ao_coord *c,
63 const struct ao_transform *t)
65 return ao_t_x(c->x, c->y, t);
68 static inline float ao_t_y_c(const struct ao_coord *c,
69 const struct ao_transform *t)
71 return ao_t_y(c->x, c->y, t);
75 ao_stride(int16_t width)
77 return (int16_t) ((width + 31) >> 5);
81 ao_stride_bytes(int16_t width)
83 return (int16_t) ((width + 7) >> 3);
87 ao_damage_set_empty(struct ao_bitmap *dst)
89 ao_box_set_empty(&dst->damage);
96 struct ao_glyph_metrics {
105 const uint8_t *bytes;
107 const struct ao_glyph_metrics *metrics;
114 ao_copy(struct ao_bitmap *dst,
119 const struct ao_bitmap *src,
125 ao_rect(struct ao_bitmap *dst,
134 ao_pattern(struct ao_bitmap *dst,
139 const struct ao_pattern *pattern,
145 ao_line(struct ao_bitmap *dst,
154 ao_poly(struct ao_bitmap *dst,
155 const struct ao_coord *coords,
157 const struct ao_transform *transform,
162 ao_text(struct ao_bitmap *dst,
163 const struct ao_font *font,
171 ao_logo(struct ao_bitmap *dst,
172 const struct ao_transform *transform,
173 const struct ao_font *font,
177 extern const struct ao_transform ao_identity;
180 #define AO_UNIT (1 << AO_SHIFT)
181 #define AO_MASK (AO_UNIT - 1)
182 #define AO_ALLONES ((uint32_t) -1)
195 #define AO_CLEAR 0x0 /* 0 */
196 #define AO_AND 0x1 /* src AND dst */
197 #define AO_AND_REVERSE 0x2 /* src AND NOT dst */
198 #define AO_COPY 0x3 /* src */
199 #define AO_AND_INVERTED 0x4 /* NOT src AND dst */
200 #define AO_NOOP 0x5 /* dst */
201 #define AO_XOR 0x6 /* src XOR dst */
202 #define AO_OR 0x7 /* src OR dst */
203 #define AO_NOR 0x8 /* NOT src AND NOT dst */
204 #define AO_EQUIV 0x9 /* NOT src XOR dst */
205 #define AO_INVERT 0xa /* NOT dst */
206 #define AO_OR_REVERSE 0xb /* src OR NOT dst */
207 #define AO_COPY_INVERTED 0xc /* NOT src */
208 #define AO_OR_INVERTED 0xd /* NOT src OR dst */
209 #define AO_NAND 0xe /* NOT src OR NOT dst */
210 #define AO_SET 0xf /* 1 */
212 #endif /* _AO_DRAW_H_ */