Rename GP_Context -> GP_Pixmap
[gfxprim.git] / include / core / GP_Pixel.gen.h.t
blob50b2c8d7eeff082d0f42790a926f4ea10b643ca4
1 @ include header.t
2 /*
3  * Pixel type definitions and functions.
4  * Do not include directly, use GP_Pixel.h
5  *
6  * Copyright (C) 2011      Tomas Gavenciak <gavento@ucw.cz>
7  * Copyright (C) 2013-2014 Cyril Hrubis <metan@ucw.cz>
8  */
11  * List of all known pixel types
12  */
13 typedef enum GP_PixelType {
14 @ for pt in pixeltypes:
15         GP_PIXEL_{{ pt.name }},
16 @ end
17         GP_PIXEL_MAX,
18 } GP_PixelType;
20 @ for pt in pixeltypes:
21 #define GP_PIXEL_{{ pt.name }} GP_PIXEL_{{ pt.name }}
22 @ end
24 @ for pt in pixeltypes:
25 @     if not pt.is_unknown():
26 /* Automatically generated code for pixel type {{ pt.name }}
27  *
28  * Size (bpp): {{ pt.pixelsize.size }} ({{ pt.pixelsize.suffix }})
29  * Bit endian: {{ pt.pixelsize.bit_endian_const }}
30  * Pixel structure: {{ "".join(pt.bits) }}
31  * Channels:
32 @         for c in pt.chanslist:
33  *   {{ c[0] }}  offset:{{ c[1] }} size:{{ c[2] }}
34 @         end
35  */
38  * macros to get channels of pixel type {{ pt.name }}
39  */
40 @         for c in pt.chanslist:
41 #define GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(p) (GP_GET_BITS({{ c[1] }}, {{ c[2] }}, (p)))
42 @         end
45  * macros to get address and bit-offset of a pixel {{ pt.name }} in a pixmap
46  */
47 #define GP_PIXEL_ADDR_{{ pt.name }}(pixmap, x, y) GP_PIXEL_ADDR_{{ pt.pixelsize.suffix }}(pixmap, x, y)
48 #define GP_PIXEL_ADDR_OFFSET_{{ pt.name }}(x) GP_PIXEL_ADDR_OFFSET_{{ pt.pixelsize.suffix }}(x)
51  * macros to create GP_Pixel of pixel type {{ pt.name }} directly from given values.
52  * The values MUST be already clipped/converted to relevant value ranges.
53  */
54 #define GP_Pixel_CREATE_{{ pt.name }}({{ ', '.join(pt.chan_names) }}) (0\
55 @         for c in pt.chanslist:
56         + (({{ c[0] }}) << {{ c[1] }}) \
57 @         end
58         )
60 @ end
63  * macros for branching on PixelType (similar to GP_FnPerBpp macros)
64  */
66 @ for r in [('', ''), ('return ', 'RET_')]:
67 #define GP_FN_{{ r[1] }}PER_PIXELTYPE(FN_NAME, type, ...)\
68         switch (type) { \
69 @     for pt in pixeltypes:
70 @         if not pt.is_unknown():
71                 case GP_PIXEL_{{ pt.name }}:\
72                         {{ r[0] }}FN_NAME{{'##'}}_{{ pt.name }}(__VA_ARGS__);\
73 @             if not r[0]:
74                 break;\
75 @             end
76 @     end
77                 default: GP_ABORT("Invalid PixelType %d", type);\
78         }