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 */
31 #define AO_BITMAP_STRIDE(width) (((width) + 31) >> 5)
42 static inline float ao_t_x(float x, float y, const struct ao_transform *t)
45 return x * t->x_scale + t->x_off;
48 static inline int16_t ao_t_xi(float x, float y, const struct ao_transform *t)
50 return (int16_t) (ao_t_x(x, y, t) + 0.5f);
53 static inline float ao_t_y(float x, float y, const struct ao_transform *t)
56 return y * t->y_scale + t->y_off;
59 static inline int16_t ao_t_yi(float x, float y, const struct ao_transform *t)
61 return (int16_t) (ao_t_y(x, y, t) + 0.5f);
64 static inline float ao_t_x_c(const struct ao_coord *c,
65 const struct ao_transform *t)
67 return ao_t_x(c->x, c->y, t);
70 static inline float ao_t_y_c(const struct ao_coord *c,
71 const struct ao_transform *t)
73 return ao_t_y(c->x, c->y, t);
77 ao_stride(int16_t width)
79 return (int16_t) ((width + 31) >> 5);
83 ao_stride_bytes(int16_t width)
85 return (int16_t) ((width + 7) >> 3);
89 ao_damage_set_empty(struct ao_bitmap *dst)
91 ao_box_set_empty(&dst->damage);
98 struct ao_glyph_metrics {
107 const uint8_t *bytes;
109 const struct ao_glyph_metrics *metrics;
116 ao_copy(struct ao_bitmap *dst,
121 const struct ao_bitmap *src,
127 ao_rect(struct ao_bitmap *dst,
136 ao_pattern(struct ao_bitmap *dst,
141 const struct ao_pattern *pattern,
147 ao_line(struct ao_bitmap *dst,
156 ao_poly(struct ao_bitmap *dst,
157 const struct ao_coord *coords,
159 const struct ao_transform *transform,
164 ao_text(struct ao_bitmap *dst,
165 const struct ao_font *font,
173 ao_logo(struct ao_bitmap *dst,
174 const struct ao_transform *transform,
175 const struct ao_font *font,
179 extern const struct ao_transform ao_identity;
182 #define AO_UNIT (1 << AO_SHIFT)
183 #define AO_MASK (AO_UNIT - 1)
184 #define AO_ALLONES ((uint32_t) -1)
197 #define AO_CLEAR 0x0 /* 0 */
198 #define AO_AND 0x1 /* src AND dst */
199 #define AO_AND_REVERSE 0x2 /* src AND NOT dst */
200 #define AO_COPY 0x3 /* src */
201 #define AO_AND_INVERTED 0x4 /* NOT src AND dst */
202 #define AO_NOOP 0x5 /* dst */
203 #define AO_XOR 0x6 /* src XOR dst */
204 #define AO_OR 0x7 /* src OR dst */
205 #define AO_NOR 0x8 /* NOT src AND NOT dst */
206 #define AO_EQUIV 0x9 /* NOT src XOR dst */
207 #define AO_INVERT 0xa /* NOT dst */
208 #define AO_OR_REVERSE 0xb /* src OR NOT dst */
209 #define AO_COPY_INVERTED 0xc /* NOT src */
210 #define AO_OR_INVERTED 0xd /* NOT src OR dst */
211 #define AO_NAND 0xe /* NOT src OR NOT dst */
212 #define AO_SET 0xf /* 1 */
214 #define AO_WHITE 0xffffffff
215 #define AO_BLACK 0x00000000
217 #endif /* _AO_DRAW_H_ */