summaryrefslogtreecommitdiff
path: root/src/draw/ao_draw.h
blob: 92150fc1aa9a0f8a772d3d6daed2b8e4434dc8a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright © 2016 Keith Packard <keithp@keithp.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

#ifndef _AO_DRAW_H_
#define _AO_DRAW_H_

struct ao_bitmap {
	uint32_t	*base;
	int16_t		stride;	/* in units */
	int16_t		width;	/* in pixels */
	int16_t		height;	/* in pixels */
};

struct ao_pattern {
	uint8_t		pattern[8];
};

void
ao_copy(const struct ao_bitmap	*dst,
	int16_t			dst_x,
	int16_t			dst_y,
	int16_t			width,
	int16_t			height,
	const struct ao_bitmap	*src,
	int16_t			src_x,
	int16_t			src_y,
	uint8_t			rop);

void
ao_rect(const struct ao_bitmap	*dst,
	int16_t			x,
	int16_t			y,
	int16_t			width,
	int16_t			height,
	uint32_t		fill,
	uint8_t			rop);

void
ao_pattern(const struct ao_bitmap	*dst,
	   int16_t			x,
	   int16_t			y,
	   int16_t			width,
	   int16_t			height,
	   const struct ao_pattern	*pattern,
	   int16_t			pat_x,
	   int16_t			pat_y,
	   uint8_t			rop);

void
ao_line(const struct ao_bitmap	*dst,
	int16_t			x1,
	int16_t			y1,
	int16_t			x2,
	int16_t			y2,
	uint32_t		fill,
	uint8_t			rop);

void
ao_text(const struct ao_bitmap	*dst,
	int16_t			x,
	int16_t			y,
	char			*string,
	uint32_t		fill,
	uint8_t			rop);

struct ao_font {
	int	width;
	int	height;
	int	ascent;
	int	descent;
};

extern const struct ao_font ao_font;

#define AO_SHIFT	5
#define AO_UNIT		(1 << AO_SHIFT)
#define AO_MASK		(AO_UNIT - 1)
#define AO_ALLONES	((uint32_t) -1)

/*
 *	    dst
 *	   0   1
 *
 *	0  a   b
 *  src
 *	1  c   d
 *
 *	ROP = abcd
 */

#define AO_CLEAR         0x0	/* 0 */
#define AO_AND           0x1	/* src AND dst */
#define AO_AND_REVERSE   0x2	/* src AND NOT dst */
#define AO_COPY          0x3	/* src */
#define AO_AND_INVERTED  0x4	/* NOT src AND dst */
#define AO_NOOP          0x5	/* dst */
#define AO_XOR           0x6	/* src XOR dst */
#define AO_OR            0x7	/* src OR dst */
#define AO_NOR           0x8	/* NOT src AND NOT dst */
#define AO_EQUIV         0x9	/* NOT src XOR dst */
#define AO_INVERT        0xa	/* NOT dst */
#define AO_OR_REVERSE    0xb	/* src OR NOT dst */
#define AO_COPY_INVERTED 0xc	/* NOT src */
#define AO_OR_INVERTED   0xd	/* NOT src OR dst */
#define AO_NAND          0xe	/* NOT src OR NOT dst */
#define AO_SET           0xf	/* 1 */

#endif /* _AO_DRAW_H_ */