1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | #define SKIP_PIXEL(to) to += deststep |
22 | #if DEPTH == 8 |
23 | # define PIXEL_TYPE uint8_t |
24 | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to) |
25 | # define COPY_PIXEL1(to, from) *to ++ = from |
26 | #elif DEPTH == 15 || DEPTH == 16 |
27 | # define PIXEL_TYPE uint16_t |
28 | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to) |
29 | # define COPY_PIXEL1(to, from) *to ++ = from |
30 | #elif DEPTH == 24 |
31 | # define PIXEL_TYPE uint8_t |
32 | # define COPY_PIXEL(to, from) \ |
33 | to[0] = from; to[1] = (from) >> 8; to[2] = (from) >> 16; SKIP_PIXEL(to) |
34 | # define COPY_PIXEL1(to, from) \ |
35 | *to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16 |
36 | #elif DEPTH == 32 |
37 | # define PIXEL_TYPE uint32_t |
38 | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to) |
39 | # define COPY_PIXEL1(to, from) *to ++ = from |
40 | #else |
41 | # error unknown bit depth |
42 | #endif |
43 | |
44 | #ifdef HOST_WORDS_BIGENDIAN |
45 | # define SWAP_WORDS 1 |
46 | #endif |
47 | |
48 | static void glue(blizzard_draw_line16_, DEPTH)blizzard_draw_line16_DEPTH(PIXEL_TYPE *dest, |
49 | const uint16_t *src, unsigned int width) |
50 | { |
51 | #if !defined(SWAP_WORDS) && DEPTH == 16 |
52 | memcpy(dest, src, width); |
53 | #else |
54 | uint16_t data; |
55 | unsigned int r, g, b; |
56 | const uint16_t *end = (const void *) src + width; |
57 | while (src < end) { |
58 | data = *src ++; |
59 | b = (data & 0x1f) << 3; |
60 | data >>= 5; |
61 | g = (data & 0x3f) << 2; |
62 | data >>= 6; |
63 | r = (data & 0x1f) << 3; |
64 | data >>= 5; |
| Value stored to 'data' is never read |
65 | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)rgb_to_pixelDEPTH(r, g, b)); |
66 | } |
67 | #endif |
68 | } |
69 | |
70 | static void glue(blizzard_draw_line24mode1_, DEPTH)blizzard_draw_line24mode1_DEPTH(PIXEL_TYPE *dest, |
71 | const uint8_t *src, unsigned int width) |
72 | { |
73 | |
74 | |
75 | unsigned int r[2], g[2], b[2]; |
76 | const uint8_t *end = src + width; |
77 | while (src < end) { |
78 | g[0] = *src ++; |
79 | r[0] = *src ++; |
80 | r[1] = *src ++; |
81 | b[0] = *src ++; |
82 | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)rgb_to_pixelDEPTH(r[0], g[0], b[0])); |
83 | b[1] = *src ++; |
84 | g[1] = *src ++; |
85 | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)rgb_to_pixelDEPTH(r[1], g[1], b[1])); |
86 | } |
87 | } |
88 | |
89 | static void glue(blizzard_draw_line24mode2_, DEPTH)blizzard_draw_line24mode2_DEPTH(PIXEL_TYPE *dest, |
90 | const uint8_t *src, unsigned int width) |
91 | { |
92 | unsigned int r, g, b; |
93 | const uint8_t *end = src + width; |
94 | while (src < end) { |
95 | r = *src ++; |
96 | src ++; |
97 | b = *src ++; |
98 | g = *src ++; |
99 | COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)rgb_to_pixelDEPTH(r, g, b)); |
100 | } |
101 | } |
102 | |
103 | |
104 | static blizzard_fn_t glue(blizzard_draw_fn_, DEPTH)blizzard_draw_fn_DEPTH[0x10] = { |
105 | NULL((void*)0), |
106 | |
107 | (blizzard_fn_t) glue(blizzard_draw_line16_, DEPTH)blizzard_draw_line16_DEPTH, |
108 | |
109 | (blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH)blizzard_draw_line24mode1_DEPTH, |
110 | |
111 | (blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH)blizzard_draw_line24mode1_DEPTH, |
112 | NULL((void*)0), NULL((void*)0), |
113 | |
114 | (blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH)blizzard_draw_line24mode2_DEPTH, |
115 | |
116 | (blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH)blizzard_draw_line24mode2_DEPTH, |
117 | |
118 | NULL((void*)0), |
119 | |
120 | NULL((void*)0), |
121 | NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), |
122 | }; |
123 | |
124 | |
125 | static blizzard_fn_t glue(blizzard_draw_fn_r_, DEPTH)blizzard_draw_fn_r_DEPTH[0x10] = { |
126 | |
127 | [0 ... 0xf] = NULL((void*)0), |
128 | }; |
129 | |
130 | #undef DEPTH |
131 | #undef SKIP_PIXEL |
132 | #undef COPY_PIXEL |
133 | #undef COPY_PIXEL1 |
134 | #undef PIXEL_TYPE |
135 | |
136 | #undef SWAP_WORDS |