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 {
106 struct ao_text_metrics {
115 const uint8_t *bytes;
117 const struct ao_glyph_metrics *metrics;
124 ao_copy(struct ao_bitmap *dst,
129 const struct ao_bitmap *src,
135 ao_rect(struct ao_bitmap *dst,
144 ao_pattern(struct ao_bitmap *dst,
149 const struct ao_pattern *pattern,
155 ao_line(struct ao_bitmap *dst,
164 ao_poly(struct ao_bitmap *dst,
165 const struct ao_coord *coords,
167 const struct ao_transform *transform,
172 ao_text(struct ao_bitmap *dst,
173 const struct ao_font *font,
181 ao_text_width(const struct ao_font *font,
185 ao_logo_poly(struct ao_bitmap *dst,
186 const struct ao_transform *transform,
191 ao_logo(struct ao_bitmap *dst,
192 const struct ao_transform *transform,
193 const struct ao_font *font,
197 extern const struct ao_transform ao_identity;
200 #define AO_UNIT (1 << AO_SHIFT)
201 #define AO_MASK (AO_UNIT - 1)
202 #define AO_ALLONES ((uint32_t) -1)
215 #define AO_CLEAR 0x0 /* 0 */
216 #define AO_AND 0x1 /* src AND dst */
217 #define AO_AND_REVERSE 0x2 /* src AND NOT dst */
218 #define AO_COPY 0x3 /* src */
219 #define AO_AND_INVERTED 0x4 /* NOT src AND dst */
220 #define AO_NOOP 0x5 /* dst */
221 #define AO_XOR 0x6 /* src XOR dst */
222 #define AO_OR 0x7 /* src OR dst */
223 #define AO_NOR 0x8 /* NOT src AND NOT dst */
224 #define AO_EQUIV 0x9 /* NOT src XOR dst */
225 #define AO_INVERT 0xa /* NOT dst */
226 #define AO_OR_REVERSE 0xb /* src OR NOT dst */
227 #define AO_COPY_INVERTED 0xc /* NOT src */
228 #define AO_OR_INVERTED 0xd /* NOT src OR dst */
229 #define AO_NAND 0xe /* NOT src OR NOT dst */
230 #define AO_SET 0xf /* 1 */
232 #define AO_WHITE 0xffffffff
233 #define AO_BLACK 0x00000000
235 #endif /* _AO_DRAW_H_ */