00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ORDER
00013
00014 #if BITS == 8
00015 #define COPY_PIXEL(to, from) *(to++) = from
00016 #elif BITS == 15 || BITS == 16
00017 #define COPY_PIXEL(to, from) *(uint16_t *)to = from; to += 2;
00018 #elif BITS == 24
00019 #define COPY_PIXEL(to, from) \
00020 *(to++) = from; *(to++) = (from) >> 8; *(to++) = (from) >> 16
00021 #elif BITS == 32
00022 #define COPY_PIXEL(to, from) *(uint32_t *)to = from; to += 4;
00023 #else
00024 #error unknown bit depth
00025 #endif
00026
00027 #undef RGB
00028 #define BORDER bgr
00029 #define ORDER 0
00030 #include "pl110_template.h"
00031 #define ORDER 1
00032 #include "pl110_template.h"
00033 #define ORDER 2
00034 #include "pl110_template.h"
00035 #undef BORDER
00036 #define RGB
00037 #define BORDER rgb
00038 #define ORDER 0
00039 #include "pl110_template.h"
00040 #define ORDER 1
00041 #include "pl110_template.h"
00042 #define ORDER 2
00043 #include "pl110_template.h"
00044 #undef BORDER
00045
00046 static drawfn glue(pl110_draw_fn_,BITS)[36] =
00047 {
00048 glue(pl110_draw_line1_lblp_bgr,BITS),
00049 glue(pl110_draw_line2_lblp_bgr,BITS),
00050 glue(pl110_draw_line4_lblp_bgr,BITS),
00051 glue(pl110_draw_line8_lblp_bgr,BITS),
00052 glue(pl110_draw_line16_lblp_bgr,BITS),
00053 glue(pl110_draw_line32_lblp_bgr,BITS),
00054
00055 glue(pl110_draw_line1_bbbp_bgr,BITS),
00056 glue(pl110_draw_line2_bbbp_bgr,BITS),
00057 glue(pl110_draw_line4_bbbp_bgr,BITS),
00058 glue(pl110_draw_line8_bbbp_bgr,BITS),
00059 glue(pl110_draw_line16_bbbp_bgr,BITS),
00060 glue(pl110_draw_line32_bbbp_bgr,BITS),
00061
00062 glue(pl110_draw_line1_lbbp_bgr,BITS),
00063 glue(pl110_draw_line2_lbbp_bgr,BITS),
00064 glue(pl110_draw_line4_lbbp_bgr,BITS),
00065 glue(pl110_draw_line8_lbbp_bgr,BITS),
00066 glue(pl110_draw_line16_lbbp_bgr,BITS),
00067 glue(pl110_draw_line32_lbbp_bgr,BITS),
00068
00069 glue(pl110_draw_line1_lblp_rgb,BITS),
00070 glue(pl110_draw_line2_lblp_rgb,BITS),
00071 glue(pl110_draw_line4_lblp_rgb,BITS),
00072 glue(pl110_draw_line8_lblp_rgb,BITS),
00073 glue(pl110_draw_line16_lblp_rgb,BITS),
00074 glue(pl110_draw_line32_lblp_rgb,BITS),
00075
00076 glue(pl110_draw_line1_bbbp_rgb,BITS),
00077 glue(pl110_draw_line2_bbbp_rgb,BITS),
00078 glue(pl110_draw_line4_bbbp_rgb,BITS),
00079 glue(pl110_draw_line8_bbbp_rgb,BITS),
00080 glue(pl110_draw_line16_bbbp_rgb,BITS),
00081 glue(pl110_draw_line32_bbbp_rgb,BITS),
00082
00083 glue(pl110_draw_line1_lbbp_rgb,BITS),
00084 glue(pl110_draw_line2_lbbp_rgb,BITS),
00085 glue(pl110_draw_line4_lbbp_rgb,BITS),
00086 glue(pl110_draw_line8_lbbp_rgb,BITS),
00087 glue(pl110_draw_line16_lbbp_rgb,BITS),
00088 glue(pl110_draw_line32_lbbp_rgb,BITS),
00089 };
00090
00091 #undef BITS
00092 #undef COPY_PIXEL
00093
00094 #else
00095
00096 #if ORDER == 0
00097 #define NAME glue(glue(lblp_, BORDER), BITS)
00098 #ifdef WORDS_BIGENDIAN
00099 #define SWAP_WORDS 1
00100 #endif
00101 #elif ORDER == 1
00102 #define NAME glue(glue(bbbp_, BORDER), BITS)
00103 #ifndef WORDS_BIGENDIAN
00104 #define SWAP_WORDS 1
00105 #endif
00106 #else
00107 #define SWAP_PIXELS 1
00108 #define NAME glue(glue(lbbp_, BORDER), BITS)
00109 #ifdef WORDS_BIGENDIAN
00110 #define SWAP_WORDS 1
00111 #endif
00112 #endif
00113
00114 #define FN_2(x, y) FN(x, y) FN(x+1, y)
00115 #define FN_4(x, y) FN_2(x, y) FN_2(x+2, y)
00116 #define FN_8(y) FN_4(0, y) FN_4(4, y)
00117
00118 static void glue(pl110_draw_line1_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
00119 {
00120 uint32_t data;
00121 while (width > 0) {
00122 data = *(uint32_t *)src;
00123 #ifdef SWAP_PIXELS
00124 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 7 - (x))) & 1]);
00125 #else
00126 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x) + y)) & 1]);
00127 #endif
00128 #ifdef SWAP_WORDS
00129 FN_8(24)
00130 FN_8(16)
00131 FN_8(8)
00132 FN_8(0)
00133 #else
00134 FN_8(0)
00135 FN_8(8)
00136 FN_8(16)
00137 FN_8(24)
00138 #endif
00139 #undef FN
00140 width -= 32;
00141 src += 4;
00142 }
00143 }
00144
00145 static void glue(pl110_draw_line2_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
00146 {
00147 uint32_t data;
00148 while (width > 0) {
00149 data = *(uint32_t *)src;
00150 #ifdef SWAP_PIXELS
00151 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 6 - (x)*2)) & 3]);
00152 #else
00153 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x)*2 + y)) & 3]);
00154 #endif
00155 #ifdef SWAP_WORDS
00156 FN_4(0, 24)
00157 FN_4(0, 16)
00158 FN_4(0, 8)
00159 FN_4(0, 0)
00160 #else
00161 FN_4(0, 0)
00162 FN_4(0, 8)
00163 FN_4(0, 16)
00164 FN_4(0, 24)
00165 #endif
00166 #undef FN
00167 width -= 16;
00168 src += 4;
00169 }
00170 }
00171
00172 static void glue(pl110_draw_line4_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
00173 {
00174 uint32_t data;
00175 while (width > 0) {
00176 data = *(uint32_t *)src;
00177 #ifdef SWAP_PIXELS
00178 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 4 - (x)*4)) & 0xf]);
00179 #else
00180 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x)*4 + y)) & 0xf]);
00181 #endif
00182 #ifdef SWAP_WORDS
00183 FN_2(0, 24)
00184 FN_2(0, 16)
00185 FN_2(0, 8)
00186 FN_2(0, 0)
00187 #else
00188 FN_2(0, 0)
00189 FN_2(0, 8)
00190 FN_2(0, 16)
00191 FN_2(0, 24)
00192 #endif
00193 #undef FN
00194 width -= 8;
00195 src += 4;
00196 }
00197 }
00198
00199 static void glue(pl110_draw_line8_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
00200 {
00201 uint32_t data;
00202 while (width > 0) {
00203 data = *(uint32_t *)src;
00204 #define FN(x) COPY_PIXEL(d, pallette[(data >> (x)) & 0xff]);
00205 #ifdef SWAP_WORDS
00206 FN(24)
00207 FN(16)
00208 FN(8)
00209 FN(0)
00210 #else
00211 FN(0)
00212 FN(8)
00213 FN(16)
00214 FN(24)
00215 #endif
00216 #undef FN
00217 width -= 4;
00218 src += 4;
00219 }
00220 }
00221
00222 static void glue(pl110_draw_line16_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
00223 {
00224 uint32_t data;
00225 unsigned int r, g, b;
00226 while (width > 0) {
00227 data = *(uint32_t *)src;
00228 #ifdef SWAP_WORDS
00229 data = bswap32(data);
00230 #endif
00231 #ifdef RGB
00232 #define LSB r
00233 #define MSB b
00234 #else
00235 #define LSB b
00236 #define MSB r
00237 #endif
00238 #if 0
00239 LSB = data & 0x1f;
00240 data >>= 5;
00241 g = data & 0x3f;
00242 data >>= 6;
00243 MSB = data & 0x1f;
00244 data >>= 5;
00245 #else
00246 LSB = (data & 0x1f) << 3;
00247 data >>= 5;
00248 g = (data & 0x3f) << 2;
00249 data >>= 6;
00250 MSB = (data & 0x1f) << 3;
00251 data >>= 5;
00252 #endif
00253 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
00254 LSB = (data & 0x1f) << 3;
00255 data >>= 5;
00256 g = (data & 0x3f) << 2;
00257 data >>= 6;
00258 MSB = (data & 0x1f) << 3;
00259 data >>= 5;
00260 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
00261 #undef MSB
00262 #undef LSB
00263 width -= 2;
00264 src += 4;
00265 }
00266 }
00267
00268 static void glue(pl110_draw_line32_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
00269 {
00270 uint32_t data;
00271 unsigned int r, g, b;
00272 while (width > 0) {
00273 data = *(uint32_t *)src;
00274 #ifdef RGB
00275 #define LSB r
00276 #define MSB b
00277 #else
00278 #define LSB b
00279 #define MSB r
00280 #endif
00281 #ifdef SWAP_WORDS
00282 LSB = data & 0xff;
00283 g = (data >> 8) & 0xff;
00284 MSB = (data >> 16) & 0xff;
00285 #else
00286 LSB = (data >> 24) & 0xff;
00287 g = (data >> 16) & 0xff;
00288 MSB = (data >> 8) & 0xff;
00289 #endif
00290 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
00291 #undef MSB
00292 #undef LSB
00293 width--;
00294 src += 4;
00295 }
00296 }
00297
00298 #undef SWAP_PIXELS
00299 #undef NAME
00300 #undef SWAP_WORDS
00301 #undef ORDER
00302
00303 #endif