moved over the polyfiller code and implemented blending
[bootcensus] / src / census / gfxutil.h
1 #ifndef GFXUTIL_H_
2 #define GFXUTIL_H_
3
4 #include "inttypes.h"
5
6 #define PACK_RGB16(r, g, b) \
7         ((((uint16_t)(r) << 8) & 0xf800) | \
8          (((uint16_t)(g) << 3) & 0x7e0) | \
9          (((uint16_t)(b) >> 3) & 0x1f))
10
11 #define UNPACK_R16(c)   (((c) >> 8) & 0xf8)
12 #define UNPACK_G16(c)   (((c) >> 3) & 0xfc)
13 #define UNPACK_B16(c)   (((c) << 3) & 0xf8)
14
15 #define PACK_RGB32(r, g, b) \
16         ((((uint32_t)(r) & 0xff) << 16) | \
17          (((uint32_t)(g) & 0xff) << 8) | \
18          ((uint32_t)(b) & 0xff))
19
20 #define UNPACK_R32(c)   (((c) >> 16) & 0xff)
21 #define UNPACK_G32(c)   (((c) >> 8) & 0xff)
22 #define UNPACK_B32(c)   ((c) & 0xff)
23
24 int clip_line(int *x0, int *y0, int *x1, int *y1, int xmin, int ymin, int xmax, int ymax);
25 void draw_line(int x0, int y0, int x1, int y1, uint32_t color);
26
27 /* scale in 24.8 fixed point */
28 void blur_grey_horiz(uint32_t *dest, uint32_t *src, int xsz, int ysz, int radius, int scale);
29 void blur_grey_vert(uint32_t *dest, uint32_t *src, int xsz, int ysz, int radius, int scale);
30
31 void convimg_rgb24_rgb16(uint16_t *dest, unsigned char *src, int xsz, int ysz);
32
33 #endif  /* GFXUTIL_H_ */