summaryrefslogtreecommitdiff
path: root/rcache.h
blob: ff24f0c16d9d30c996b5e0cb7aa9a08635665f3f (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef rcache_h
#define rcache_h

#include "render.h"

#if rcache_enable
typedef enum {
	rc_cmd_bmp,
	rc_cmd_bmp_mod,
	rc_cmd_bmp_cp,
	rc_cmd_bmp_cp_mod,
	rc_cmd_rfont_text,
	rc_cmd_rfont_text_col,
	rc_cmd_set_clip,
	rc_cmd_reset_clip,
	rc_cmd_rect
} RC_Cmd_Type;

typedef struct {
	RC_Cmd_Type type;
	int size;
	int x, y, w, h;
} RC_Cmd;

typedef struct {
	RC_Cmd cmd;
	const Bitmap* bmp;
	int sx, sy;
} RC_Cmd_Bmp;

typedef struct {
	RC_Cmd cmd;
	const Bitmap* bmp;
	int sx, sy;
	Colour col;
} RC_Cmd_Bmp_Mod;

typedef struct {
	RC_Cmd cmd;
	Bitmap bmp;
	int sx, sy;
} RC_Cmd_Bmp_Cp;

typedef struct {
	RC_Cmd cmd;
	Bitmap bmp;
	int sx, sy;
	Colour col;
} RC_Cmd_Bmp_Cp_Mod;

typedef struct {
	RC_Cmd cmd;
	Font* font;
} RC_Cmd_RFont_Text;

typedef struct {
	RC_Cmd cmd;
	Colour col;
	Font* font;
} RC_Cmd_RFont_Text_Col;

typedef struct {
	RC_Cmd cmd;
	Colour col;
} RC_Cmd_Rect;

typedef RC_Cmd RC_Cmd_Set_Clip;
typedef RC_Cmd RC_Cmd_Reset_Clip;

void rc_init(void);
RC_Cmd* rc_add_cmd(RC_Cmd* cmd);
void rc_add_cmd_bmp(
	const Bitmap* bmp,
	int x,
	int y,
	const Rectangle* src
);
void rc_add_cmd_bmp_col(
	const Bitmap* bmp,
	int x,
	int y,
	const Rectangle* src,
	Colour col
);
void rc_add_cmd_bmp_cp(
	const Bitmap* bmp,
	int x,
	int y,
	const Rectangle* src
);
void rc_add_cmd_bmp_cp_col(
	const Bitmap* bmp,
	int x,
	int y,
	const Rectangle* src,
	Colour col
);
void rc_add_cmd_rfont_text(
	Font* font,
	int x,
	int y,
	const char* text
);
void rc_add_cmd_rfont_text_col(
	Font* font,
	int x,
	int y,
	const char* text,
	Colour col
);
void rc_add_cmd_clip(
	const Rectangle* rect
);
void rc_add_cmd_reset_clip(void);
void rc_add_cmd_rect(
	const Rectangle* r,
	Colour col
);
void rc_begin(void);
void rc_flush(void);
void rc_invalidate(const Rectangle* r);

#else
void rc_init(void);
#define rc_add_cmd_bmp(bmp, x, y, src) \
	render_bitmap(bmp, x, y, src)
#define rc_add_cmd_bmp_col(bmp, x, y, src, col) \
	render_bitmap_col(bmp, x, y, src, col)
#define rc_add_cmd_bmp_cp(bmp, x, y, src) \
	render_bitmap(bmp, x, y, src)
#define rc_add_cmd_bmp_cp_col(bmp, x, y, src, col) \
	render_bitmap_col(bmp, x, y, src, col)
#define rc_add_cmd_rfont_text(font, x, y, text) \
	rfont_text(font, x, y, text)
#define rc_add_cmd_rfont_text_col(font, x, y, text, col) \
	rfont_text_col(font, x, y, text, col)
#define rc_add_cmd_clip(rect) \
	render_clip(rect)
#define rc_add_cmd_reset_clip() \
	render_reset_clip()
#define rc_add_cmd_rect(r, col) \
	render_rect(r, col)
#define rc_invalidate(r)
#define rc_begin()
void rc_flush(void);
#endif

#endif