forked from libretro/libretro-lutro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
painter.h
96 lines (79 loc) · 2.4 KB
/
painter.h
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
#ifndef PAINTER_H
#define PAINTER_H
#include <stddef.h>
#include <stdint.h>
#include <boolean.h>
enum {
FONT_FREETYPE = 1 << 1,
FONT_BOLD = 1 << 2,
FONT_ITALICS = 1 << 3,
FONT_STRIKE = 1 << 4
};
typedef struct
{
uint32_t *data;
unsigned width, height;
size_t pitch;
} bitmap_t;
typedef struct
{
bitmap_t atlas; /* atlas.data is owned by the font */
unsigned flags;
unsigned pxsize;
int separators[256];
char characters[256];
} font_t;
typedef struct
{
int x, y, width, height;
} rect_t;
typedef struct
{
/* translation */
int tx;
int ty;
/* rotation */
float r;
/* scale */
float sx;
float sy;
} painter_transform_t;
typedef struct painter_s painter_t;
struct painter_s
{
uint32_t foreground;
uint32_t background;
bitmap_t *target;
font_t *font;
rect_t clip;
painter_transform_t *trans;
painter_transform_t stack[64];
size_t stack_pos;
painter_t *parent;
};
void pntr_reset(painter_t *p);
void pntr_clear(painter_t *p);
void pntr_sanitize_clip(painter_t *p);
void pntr_strike_line(painter_t *p, int x1, int y1, int x2, int y2);
void pntr_strike_rect(painter_t *p, const rect_t *rect);
void pntr_fill_rect(painter_t *p, const rect_t *rect);
void pntr_strike_poly(painter_t *p, const int *points, int nb_points);
void pntr_fill_poly(painter_t *p, const int *points, int nb_points);
void pntr_strike_ellipse(painter_t *p, int x, int y, int radius_x, int radius_y, int nb_segments);
void pntr_fill_ellipse(painter_t *p, int x, int y, int radius_x, int radius_y, int nb_segments);
void pntr_draw(painter_t *p, const bitmap_t *bmp, const rect_t *src_rect, const rect_t *dst_rect);
void pntr_print(painter_t *p, int x, int y, const char *text, int limit);
int pntr_text_width(painter_t *p, const char *text);
void pntr_printf(painter_t *p, int x, int y, const char *format, ...);
/* Transformations */
bool pntr_push(painter_t *p);
bool pntr_pop(painter_t *p);
void pntr_origin(painter_t *p, bool reset_stack);
void pntr_scale(painter_t *p, float x, float y);
void pntr_rotate(painter_t *p, float rad);
void pntr_translate(painter_t *p, int x, int y);
font_t *font_load_filename(const char *filename, const char *characters, unsigned flags);
font_t *font_load_bitmap(const bitmap_t *bmp, const char *characters, unsigned flags);
rect_t rect_intersect(const rect_t *a, const rect_t *b);
int rect_is_null(const rect_t *r);
#endif // PAINTER_H