Changeset 30885b9 in mainline for uspace/srv
- Timestamp:
- 2009-07-31T19:11:54Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a405563
- Parents:
- 646b996
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fb/fb.c
r646b996 r30885b9 58 58 #include <bool.h> 59 59 #include <stdio.h> 60 #include <byteorder.h> 60 61 61 62 #include "font-8x16.h" … … 213 214 214 215 215 #define RED(x, bits) (( x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))216 #define GREEN(x, bits) (( x >> (8 + 8 - bits)) & ((1 << bits) - 1))217 #define BLUE(x, bits) (( x >> (8 - bits)) & ((1 << bits) - 1))216 #define RED(x, bits) (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1)) 217 #define GREEN(x, bits) (((x) >> (8 + 8 - (bits))) & ((1 << (bits)) - 1)) 218 #define BLUE(x, bits) (((x) >> (8 - (bits))) & ((1 << (bits)) - 1)) 218 219 219 220 #define COL2X(col) ((col) * FONT_WIDTH) … … 227 228 #define GLYPH_POS(glyph, y, cursor) (((glyph) + (cursor) * FONT_GLYPHS) * screen.glyphbytes + (y) * screen.glyphscanline) 228 229 229 230 /** ARGB 8:8:8:8 conversion 231 * 232 */ 230 /* 231 * RGB conversion and mask functions. 232 * 233 * These functions write an RGB value to some memory in some predefined format. 234 * The naming convention corresponds to the format created by these functions. 235 * The functions use the so called network order (i.e. big endian) with respect 236 * to their names. 237 */ 238 233 239 static void rgb_0888(void *dst, uint32_t rgb) 234 240 { 235 *((uint32_t *) dst) = rgb & 0x00ffffff; 241 *((uint32_t *) dst) = host2uint32_t_be((0 << 24) | 242 (RED(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (BLUE(rgb, 8))); 243 } 244 245 static void bgr_0888(void *dst, uint32_t rgb) 246 { 247 *((uint32_t *) dst) = host2uint32_t_be((0 << 24) | 248 (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (RED(rgb, 8))); 236 249 } 237 250 238 251 static void mask_0888(void *dst, bool mask) 239 252 { 240 *((uint32_t *) dst) = (mask ? 0x00ffffff : 0); 241 } 242 243 244 /** ABGR 8:8:8:8 conversion 245 * 246 */ 247 static void bgr_0888(void *dst, uint32_t rgb) 248 { 249 *((uint32_t *) dst) 250 = (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8); 253 bgr_0888(dst, mask ? 0xffffff : 0); 251 254 } 252 255 253 256 static void rgb_8880(void *dst, uint32_t rgb) 254 257 { 255 *((uint32_t *) dst) 256 = (RED(rgb, 8) << 24) | (GREEN(rgb, 8) << 16) | BLUE(rgb, 8) << 8; 258 *((uint32_t *) dst) = host2uint32_t_be((RED(rgb, 8) << 24) | 259 (GREEN(rgb, 8) << 16) | (BLUE(rgb, 8) << 8) | 0); 260 } 261 262 static void bgr_8880(void *dst, uint32_t rgb) 263 { 264 *((uint32_t *) dst) = host2uint32_t_be((BLUE(rgb, 8) << 24) | 265 (GREEN(rgb, 8) << 16) | (RED(rgb, 8) << 8) | 0); 257 266 } 258 267 259 268 static void mask_8880(void *dst, bool mask) 260 269 { 261 *((uint32_t *) dst) = (mask ? 0xffffff00 : 0); 262 } 263 264 /** RGB 8:8:8 conversion 265 * 266 */ 270 bgr_8880(dst, mask ? 0xffffff : 0); 271 } 272 267 273 static void rgb_888(void *dst, uint32_t rgb) 274 { 275 ((uint8_t *) dst)[0] = RED(rgb, 8); 276 ((uint8_t *) dst)[1] = GREEN(rgb, 8); 277 ((uint8_t *) dst)[2] = BLUE(rgb, 8); 278 } 279 280 static void bgr_888(void *dst, uint32_t rgb) 268 281 { 269 282 ((uint8_t *) dst)[0] = BLUE(rgb, 8); … … 274 287 static void mask_888(void *dst, bool mask) 275 288 { 276 if (mask) { 277 ((uint8_t *) dst)[0] = 0xff; 278 ((uint8_t *) dst)[1] = 0xff; 279 ((uint8_t *) dst)[2] = 0xff; 280 } else { 281 ((uint8_t *) dst)[0] = 0; 282 ((uint8_t *) dst)[1] = 0; 283 ((uint8_t *) dst)[2] = 0; 284 } 285 } 286 287 288 /** BGR 8:8:8 conversion 289 * 290 */ 291 static void bgr_888(void *dst, uint32_t rgb) 292 { 293 ((uint8_t *) dst)[0] = RED(rgb, 8); 294 ((uint8_t *) dst)[1] = GREEN(rgb, 8); 295 ((uint8_t *) dst)[2] = BLUE(rgb, 8); 296 } 297 298 299 /** RGB 5:5:5 conversion 300 * 301 */ 302 static void rgb_555(void *dst, uint32_t rgb) 303 { 304 *((uint16_t *) dst) 305 = (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5); 289 bgr_888(dst, mask ? 0xffffff : 0); 290 } 291 292 static void bgr_555(void *dst, uint32_t rgb) 293 { 294 uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 5) << 5)) & 0xff; 295 uint8_t lo = (GREEN(rgb, 5) >> 3) | (RED(rgb, 5) << 2); 296 *((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo); 306 297 } 307 298 308 299 static void mask_555(void *dst, bool mask) 309 300 { 310 *((uint16_t *) dst) = (mask ? 0x7fff : 0); 311 } 312 313 314 /** RGB 5:6:5 conversion 315 * 316 */ 317 static void rgb_565(void *dst, uint32_t rgb) 318 { 319 *((uint16_t *) dst) 320 = (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5); 301 bgr_555(dst, mask ? 0xffffff : 0); 302 } 303 304 static void bgr_565(void *dst, uint32_t rgb) 305 { 306 uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 6) << 5)) & 0xff; 307 uint8_t lo = (GREEN(rgb, 6) >> 3) | (RED(rgb, 5) << 3); 308 *((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo); 321 309 } 322 310 323 311 static void mask_565(void *dst, bool mask) 324 312 { 325 *((uint16_t *) dst) = (mask ? 0xffff : 0); 326 } 327 328 329 /** RGB 3:2:3 330 * 331 */ 332 static void rgb_323(void *dst, uint32_t rgb) 313 bgr_565(dst, mask ? 0xffffff : 0); 314 } 315 316 static void bgr_323(void *dst, uint32_t rgb) 333 317 { 334 318 *((uint8_t *) dst) … … 338 322 static void mask_323(void *dst, bool mask) 339 323 { 340 *((uint8_t *) dst) = (mask ? 0xff :0);324 bgr_323(dst, mask ? 0x0 : ~0x0); 341 325 } 342 326 … … 632 616 unsigned int scan, unsigned int visual) 633 617 { 634 635 636 618 switch (visual) { 637 619 case VISUAL_INDIRECT_8: 638 screen.rgb_conv = rgb_323;620 screen.rgb_conv = bgr_323; 639 621 screen.mask_conv = mask_323; 640 622 screen.pixelbytes = 1; 641 623 break; 642 case VISUAL_ RGB_5_5_5:643 screen.rgb_conv = rgb_555;624 case VISUAL_BGR_5_5_5: 625 screen.rgb_conv = bgr_555; 644 626 screen.mask_conv = mask_555; 645 627 screen.pixelbytes = 2; 646 628 break; 647 case VISUAL_ RGB_5_6_5:648 screen.rgb_conv = rgb_565;629 case VISUAL_BGR_5_6_5: 630 screen.rgb_conv = bgr_565; 649 631 screen.mask_conv = mask_565; 650 632 screen.pixelbytes = 2; … … 673 655 screen.rgb_conv = bgr_0888; 674 656 screen.mask_conv = mask_0888; 657 screen.pixelbytes = 4; 658 break; 659 case VISUAL_BGR_8_8_8_0: 660 screen.rgb_conv = bgr_8880; 661 screen.mask_conv = mask_8880; 675 662 screen.pixelbytes = 4; 676 663 break;
Note:
See TracChangeset
for help on using the changeset viewer.