aboutsummaryrefslogtreecommitdiffstats
path: root/gfx.h
blob: 630cfd2d343f43dbd3137494cdd07cc36775949e (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
50
51
#include <stdbool.h>
#include <inttypes.h>
#include <sys/types.h>  /* dev_t */

#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 (*suspend_display)(void);
    int (*resume_display)(void);
    void (*cleanup_display)(void);
    void (*flush_display)(bool second);
};