-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrendering.h
More file actions
61 lines (50 loc) · 1.77 KB
/
rendering.h
File metadata and controls
61 lines (50 loc) · 1.77 KB
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
#ifndef _RENDERING_H_
#define _RENDERING_H_
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <fontconfig/fontconfig.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef __cplusplus
extern "C" {
#endif
struct __attribute__((packed)) color {
float r, g, b, a;
};
static int colors_equal(struct color * a, struct color * b) {
return a->r == b->r && \
a->g == b->g && \
a->b == b->b && \
a->a == b->a;
}
struct glyph_spec {
FT_UInt glyph;
struct color * c;
struct atlas * font;
bool dirty;
int x, y;
};
/** Keeps track of the things that need to be rendered */
struct render_context;
/** Font atlas. One atlas per font */
struct atlas;
struct render_context * render_init(void);
void render_destroy(struct render_context * rc);
void render_do_render(struct render_context * rc);
void render_resize(struct render_context * rc, int w, int h);
void render_set_y_nudge(struct render_context * rc, int nudge);
void render_set_clear_color(struct render_context * rc, struct color * c);
void render_send_keypress(struct render_context * rc, const TCursor c, const char * const buf, const int buf_len);
/** Create an atlas. Takes ownership of the font */
struct atlas * atlas_create_from_face(FT_Face f);
struct atlas * atlas_create_from_pattern(FT_Library lib, FcPattern * pat, FT_UInt size);
/** Destroy an atlas. Second parameter is true if we should also destroy the face */
void atlas_destroy(struct atlas * a, bool);
FT_Face atlas_get_face(struct atlas * a);
void render_rune(struct render_context * rc, const struct glyph_spec * spec);
void render_rect(struct render_context * rc, const struct color * const c, int x, int y, int w, int h);
#ifdef __cplusplus
}
#endif
#endif