Changes in uspace/srv/hid/console/gcons.c [79ae36dd:c6f08726] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/gcons.c
r79ae36dd rc6f08726 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 … … 58 60 #define COLOR_BACKGROUND 0xffffff 59 61 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 65 extern char _binary_gfx_anim_1_ppm_start[0];66 extern int _binary_gfx_anim_1_ppm_size;67 extern char _binary_gfx_anim_2_ppm_start[0];68 extern int _binary_gfx_anim_2_ppm_size;69 extern char _binary_gfx_anim_3_ppm_start[0];70 extern int _binary_gfx_anim_3_ppm_size;71 extern char _binary_gfx_anim_4_ppm_start[0];72 extern int _binary_gfx_anim_4_ppm_size;73 74 extern char _binary_gfx_cons_selected_ppm_start[0];75 extern int _binary_gfx_cons_selected_ppm_size;76 extern char _binary_gfx_cons_idle_ppm_start[0];77 extern int _binary_gfx_cons_idle_ppm_size;78 extern char _binary_gfx_cons_has_data_ppm_start[0];79 extern int _binary_gfx_cons_has_data_ppm_size;80 extern char _binary_gfx_cons_kernel_ppm_start[0];81 extern int _binary_gfx_cons_kernel_ppm_size;82 83 62 static bool use_gcons = false; 84 63 static sysarg_t xres; 85 64 static sysarg_t yres; 65 66 static imgmap_t *helenos_img; 67 static imgmap_t *nameic_img; 68 69 static imgmap_t *anim_1_img; 70 static imgmap_t *anim_2_img; 71 static imgmap_t *anim_3_img; 72 static imgmap_t *anim_4_img; 73 74 static imgmap_t *cons_has_data_img; 75 static imgmap_t *cons_idle_img; 76 static imgmap_t *cons_kernel_img; 77 static imgmap_t *cons_selected_img; 86 78 87 79 enum butstate { … … 101 93 static int fbphone; 102 94 103 /** List of pixmaps identifying these icons */104 static int ic_ pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};95 /** List of image maps identifying these icons */ 96 static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; 105 97 static int animation = -1; 106 98 … … 149 141 enum butstate state = console_state[index]; 150 142 151 if (ic_ pixmaps[state] != -1)152 async_obsolete_msg_2(fbphone, FB_VP_DRAW_ PIXMAP, cstatus_vp[index],153 ic_ pixmaps[state]);143 if (ic_imgmaps[state] != -1) 144 async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index], 145 ic_imgmaps[state]); 154 146 155 147 if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL) … … 168 160 void gcons_change_console(size_t index) 169 161 { 170 if (!use_gcons) 171 return; 162 if (!use_gcons) { 163 active_console = index; 164 return; 165 } 172 166 173 167 if (active_console == KERNEL_CONSOLE) { … … 356 350 } 357 351 358 /** Draw a PPM pixmap to framebuffer 359 * 360 * @param logo Pointer to PPM data 361 * @param size Size of PPM data 362 * @param x Coordinate of upper left corner 363 * @param y Coordinate of upper left corner 364 * 365 */ 366 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y) 367 { 352 /** Draw an image map to framebuffer 353 * 354 * @param img Image map 355 * @param x Coordinate of upper left corner 356 * @param y Coordinate of upper left corner 357 * 358 */ 359 static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y) 360 { 361 if (img == NULL) 362 return; 363 368 364 /* Create area */ 369 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |365 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 370 366 MAP_ANONYMOUS, 0, 0); 371 367 if (shm == MAP_FAILED) 372 368 return; 373 369 374 memcpy(shm, logo,size);370 memcpy(shm, img, img->size); 375 371 376 372 /* Send area */ … … 384 380 385 381 /* Draw logo */ 386 async_obsolete_msg_2(fbphone, FB_DRAW_ PPM, x, y);382 async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y); 387 383 388 384 drop: … … 392 388 exit: 393 389 /* Remove area */ 394 munmap(shm, size);390 munmap(shm, img->size); 395 391 } 396 392 … … 404 400 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 405 401 clear(); 406 draw_pixmap(_binary_gfx_helenos_ppm_start, 407 (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); 408 draw_pixmap(_binary_gfx_nameic_ppm_start, 409 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 402 draw_imgmap(helenos_img, xres - 66, 2); 403 draw_imgmap(nameic_img, 5, 17); 410 404 411 405 unsigned int i; … … 416 410 } 417 411 418 /** Creates a pixmap on framebuffer 419 * 420 * @param data PPM data 421 * @param size PPM data size 422 * 423 * @return Pixmap identification 424 * 425 */ 426 static int make_pixmap(char *data, size_t size) 427 { 412 /** Create an image map on framebuffer 413 * 414 * @param img Image map. 415 * 416 * @return Image map identification 417 * 418 */ 419 static int make_imgmap(imgmap_t *img) 420 { 421 if (img == NULL) 422 return -1; 423 428 424 /* Create area */ 429 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |430 MAP_ ANONYMOUS, 0, 0);425 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, 426 MAP_SHARED | MAP_ANONYMOUS, 0, 0); 431 427 if (shm == MAP_FAILED) 432 428 return -1; 433 429 434 memcpy(shm, data,size);435 436 int pxid = -1;430 memcpy(shm, img, img->size); 431 432 int id = -1; 437 433 438 434 /* Send area */ … … 445 441 goto drop; 446 442 447 /* Obtain pixmap*/448 rc = async_obsolete_req_0_0(fbphone, FB_SHM2 PIXMAP);443 /* Obtain image map identifier */ 444 rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP); 449 445 if (rc < 0) 450 446 goto drop; 451 447 452 pxid = rc;448 id = rc; 453 449 454 450 drop: … … 458 454 exit: 459 455 /* Remove area */ 460 munmap(shm, size);461 462 return pxid;456 munmap(shm, img->size); 457 458 return id; 463 459 } 464 460 … … 470 466 return; 471 467 472 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 473 (size_t) &_binary_gfx_anim_1_ppm_size); 474 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 475 476 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 477 (size_t) &_binary_gfx_anim_2_ppm_size); 478 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 479 480 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 481 (size_t) &_binary_gfx_anim_3_ppm_size); 482 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 483 484 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 485 (size_t) &_binary_gfx_anim_4_ppm_size); 486 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 468 int pm = make_imgmap(anim_1_img); 469 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 470 471 pm = make_imgmap(anim_2_img); 472 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 473 474 pm = make_imgmap(anim_3_img); 475 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 476 477 pm = make_imgmap(anim_4_img); 478 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 487 479 488 480 async_obsolete_msg_1(fbphone, FB_ANIM_START, an); … … 502 494 if ((xres < 800) || (yres < 600)) 503 495 return; 496 497 /* Create image maps */ 498 helenos_img = imgmap_decode_tga((void *) helenos_tga, 499 helenos_tga_size); 500 nameic_img = imgmap_decode_tga((void *) nameic_tga, 501 nameic_tga_size); 502 503 anim_1_img = imgmap_decode_tga((void *) anim_1_tga, 504 anim_1_tga_size); 505 anim_2_img = imgmap_decode_tga((void *) anim_2_tga, 506 anim_2_tga_size); 507 anim_3_img = imgmap_decode_tga((void *) anim_3_tga, 508 anim_3_tga_size); 509 anim_4_img = imgmap_decode_tga((void *) anim_4_tga, 510 anim_4_tga_size); 511 512 cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga, 513 cons_has_data_tga_size); 514 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga, 515 cons_idle_tga_size); 516 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga, 517 cons_kernel_tga_size); 518 cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga, 519 cons_selected_tga_size); 504 520 505 521 /* Create console viewport */ … … 529 545 530 546 /* Initialize icons */ 531 ic_pixmaps[CONS_SELECTED] = 532 make_pixmap(_binary_gfx_cons_selected_ppm_start, 533 (size_t) &_binary_gfx_cons_selected_ppm_size); 534 ic_pixmaps[CONS_IDLE] = 535 make_pixmap(_binary_gfx_cons_idle_ppm_start, 536 (size_t) &_binary_gfx_cons_idle_ppm_size); 537 ic_pixmaps[CONS_HAS_DATA] = 538 make_pixmap(_binary_gfx_cons_has_data_ppm_start, 539 (size_t) &_binary_gfx_cons_has_data_ppm_size); 540 ic_pixmaps[CONS_DISCONNECTED] = 541 make_pixmap(_binary_gfx_cons_idle_ppm_start, 542 (size_t) &_binary_gfx_cons_idle_ppm_size); 543 ic_pixmaps[CONS_KERNEL] = 544 make_pixmap(_binary_gfx_cons_kernel_ppm_start, 545 (size_t) &_binary_gfx_cons_kernel_ppm_size); 546 ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; 547 ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img); 548 ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img); 549 ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img); 550 ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img); 551 ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img); 552 ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED]; 547 553 548 554 make_anim();
Note:
See TracChangeset
for help on using the changeset viewer.