aboutsummaryrefslogtreecommitdiffstats
path: root/gfx.h
blob: f060d38d8f3ee828ba5755a4323fbb1d10a98925 (plain)
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
#include <stdbool.h>
#include <inttypes.h>

#include <pixman.h>
#include <cairo.h>

/* ---------------------------------------------------------------------- */

#undef  MAX
#define MAX(x,y)        ((x)>(y)?(x):(y))
#undef  MIN
#define MIN(x,y)        ((x)<(y)?(x):(y))
#define ARRAY_SIZE(x)   (sizeof(x)/sizeof(x[0]))

/* ---------------------------------------------------------------------- */

typedef struct gfxfmt gfxfmt;
typedef struct gfxstate gfxstate;

struct gfxfmt {
    uint32_t              fourcc;  /* little endian (drm) */
    cairo_format_t        cairo;   /* native endian */
    pixman_format_code_t  pixman;  /* native endian */
    uint32_t              depth;
    uint32_t              bpp;
};

extern gfxfmt fmt_list[];
extern uint32_t fmt_count;

gfxfmt *gfx_fmt_find_pixman(pixman_format_code_t  pixman);

struct gfxstate {
    /* info */
    uint32_t hdisplay;
    uint32_t vdisplay;
    uint32_t stride;
    uint8_t  *mem;
    uint8_t  *mem2;
    gfxfmt   *fmt;

    char devpath[128];
    dev_t devnum;

    /* calls */
    void (*restore_display)(void);
    void (*cleanup_display)(void);
    void (*flush_display)(bool second);
};