Changeset 67b05ff in mainline for uspace/srv/hid/console/gcons.c
- Timestamp:
- 2011-08-10T18:34:23Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c6f08726
- Parents:
- 62e29ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/gcons.c
r62e29ae r67b05ff 41 41 #include <align.h> 42 42 #include <bool.h> 43 #include <imgmap.h> 43 44 44 45 #include "console.h" 45 46 #include "gcons.h" 47 #include "images.h" 46 48 47 49 #define CONSOLE_TOP 66 … … 57 59 #define COLOR_FOREGROUND 0x202020 58 60 #define COLOR_BACKGROUND 0xffffff 59 60 extern char _binary_gfx_helenos_ppm_start[0];61 extern int _binary_gfx_helenos_ppm_size;62 extern char _binary_gfx_nameic_ppm_start[0];63 extern int _binary_gfx_nameic_ppm_size;64 61 65 62 extern char _binary_gfx_anim_1_ppm_start[0]; … … 84 81 static sysarg_t xres; 85 82 static sysarg_t yres; 83 84 static imgmap_t *helenos_img; 85 static imgmap_t *nameic_img; 86 86 87 87 enum butstate { … … 358 358 } 359 359 360 /** Draw a PPM pixmap to framebuffer 361 * 362 * @param logo Pointer to PPM data 363 * @param size Size of PPM data 364 * @param x Coordinate of upper left corner 365 * @param y Coordinate of upper left corner 366 * 367 */ 368 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y) 360 /** Draw an image map to framebuffer 361 * 362 * @param img Image map 363 * @param x Coordinate of upper left corner 364 * @param y Coordinate of upper left corner 365 * 366 */ 367 static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y) 368 { 369 if (img == NULL) 370 return; 371 372 /* Create area */ 373 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 374 MAP_ANONYMOUS, 0, 0); 375 if (shm == MAP_FAILED) 376 return; 377 378 memcpy(shm, img, img->size); 379 380 /* Send area */ 381 int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm); 382 if (rc) 383 goto exit; 384 385 rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ); 386 if (rc) 387 goto drop; 388 389 /* Draw logo */ 390 async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y); 391 392 drop: 393 /* Drop area */ 394 async_obsolete_msg_0(fbphone, FB_DROP_SHM); 395 396 exit: 397 /* Remove area */ 398 munmap(shm, img->size); 399 } 400 401 /** Redraws console graphics */ 402 void gcons_redraw_console(void) 403 { 404 if (!use_gcons) 405 return; 406 407 vp_switch(0); 408 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 409 clear(); 410 draw_imgmap(helenos_img, xres - 66, 2); 411 draw_imgmap(nameic_img, 5, 17); 412 413 unsigned int i; 414 for (i = 0; i < CONSOLE_COUNT; i++) 415 redraw_state(i); 416 417 vp_switch(console_vp); 418 } 419 420 /** Creates a pixmap on framebuffer 421 * 422 * @param data PPM data 423 * @param size PPM data size 424 * 425 * @return Pixmap identification 426 * 427 */ 428 static int make_pixmap(char *data, size_t size) 369 429 { 370 430 /* Create area */ … … 372 432 MAP_ANONYMOUS, 0, 0); 373 433 if (shm == MAP_FAILED) 374 return; 375 376 memcpy(shm, logo, size); 434 return -1; 435 436 memcpy(shm, data, size); 437 438 int pxid = -1; 377 439 378 440 /* Send area */ … … 385 447 goto drop; 386 448 387 /* Draw logo */388 async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y);389 390 drop:391 /* Drop area */392 async_obsolete_msg_0(fbphone, FB_DROP_SHM);393 394 exit:395 /* Remove area */396 munmap(shm, size);397 }398 399 /** Redraws console graphics */400 void gcons_redraw_console(void)401 {402 if (!use_gcons)403 return;404 405 vp_switch(0);406 set_rgb_color(COLOR_MAIN, COLOR_MAIN);407 clear();408 draw_pixmap(_binary_gfx_helenos_ppm_start,409 (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2);410 draw_pixmap(_binary_gfx_nameic_ppm_start,411 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);412 413 unsigned int i;414 for (i = 0; i < CONSOLE_COUNT; i++)415 redraw_state(i);416 417 vp_switch(console_vp);418 }419 420 /** Creates a pixmap on framebuffer421 *422 * @param data PPM data423 * @param size PPM data size424 *425 * @return Pixmap identification426 *427 */428 static int make_pixmap(char *data, size_t size)429 {430 /* Create area */431 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |432 MAP_ANONYMOUS, 0, 0);433 if (shm == MAP_FAILED)434 return -1;435 436 memcpy(shm, data, size);437 438 int pxid = -1;439 440 /* Send area */441 int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);442 if (rc)443 goto exit;444 445 rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);446 if (rc)447 goto drop;448 449 449 /* Obtain pixmap */ 450 450 rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP); … … 504 504 if ((xres < 800) || (yres < 600)) 505 505 return; 506 507 /* Create image maps */ 508 helenos_img = imgmap_decode_tga((void *) helenos_tga); 509 nameic_img = imgmap_decode_tga((void *) nameic_tga); 506 510 507 511 /* Create console viewport */
Note:
See TracChangeset
for help on using the changeset viewer.