Changes in uspace/srv/hid/console/gcons.c [c6f08726:e3a46c2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/gcons.c
rc6f08726 re3a46c2 41 41 #include <align.h> 42 42 #include <bool.h> 43 #include <imgmap.h>44 43 45 44 #include "console.h" 46 45 #include "gcons.h" 47 #include "images.h"48 46 49 47 #define CONSOLE_TOP 66 … … 60 58 #define COLOR_BACKGROUND 0xffffff 61 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 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 62 83 static bool use_gcons = false; 63 84 static sysarg_t xres; 64 85 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;78 86 79 87 enum butstate { … … 93 101 static int fbphone; 94 102 95 /** List of imagemaps identifying these icons */96 static int ic_ imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};103 /** List of pixmaps identifying these icons */ 104 static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; 97 105 static int animation = -1; 98 106 … … 141 149 enum butstate state = console_state[index]; 142 150 143 if (ic_ imgmaps[state] != -1)144 async_obsolete_msg_2(fbphone, FB_VP_DRAW_ IMGMAP, cstatus_vp[index],145 ic_ imgmaps[state]);151 if (ic_pixmaps[state] != -1) 152 async_obsolete_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index], 153 ic_pixmaps[state]); 146 154 147 155 if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL) … … 350 358 } 351 359 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 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) 369 { 364 370 /* Create area */ 365 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |371 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 366 372 MAP_ANONYMOUS, 0, 0); 367 373 if (shm == MAP_FAILED) 368 374 return; 369 375 370 memcpy(shm, img, img->size);376 memcpy(shm, logo, size); 371 377 372 378 /* Send area */ … … 380 386 381 387 /* Draw logo */ 382 async_obsolete_msg_2(fbphone, FB_DRAW_ IMGMAP, x, y);388 async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y); 383 389 384 390 drop: … … 388 394 exit: 389 395 /* Remove area */ 390 munmap(shm, img->size);396 munmap(shm, size); 391 397 } 392 398 … … 400 406 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 401 407 clear(); 402 draw_imgmap(helenos_img, xres - 66, 2); 403 draw_imgmap(nameic_img, 5, 17); 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); 404 412 405 413 unsigned int i; … … 410 418 } 411 419 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 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) 429 { 424 430 /* Create area */ 425 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,426 MAP_ SHARED | MAP_ANONYMOUS, 0, 0);431 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 432 MAP_ANONYMOUS, 0, 0); 427 433 if (shm == MAP_FAILED) 428 434 return -1; 429 435 430 memcpy(shm, img, img->size);431 432 int id = -1;436 memcpy(shm, data, size); 437 438 int pxid = -1; 433 439 434 440 /* Send area */ … … 441 447 goto drop; 442 448 443 /* Obtain image map identifier*/444 rc = async_obsolete_req_0_0(fbphone, FB_SHM2 IMGMAP);449 /* Obtain pixmap */ 450 rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP); 445 451 if (rc < 0) 446 452 goto drop; 447 453 448 id = rc;454 pxid = rc; 449 455 450 456 drop: … … 454 460 exit: 455 461 /* Remove area */ 456 munmap(shm, img->size);457 458 return id;462 munmap(shm, size); 463 464 return pxid; 459 465 } 460 466 … … 466 472 return; 467 473 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); 474 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 475 (size_t) &_binary_gfx_anim_1_ppm_size); 476 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 477 478 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 479 (size_t) &_binary_gfx_anim_2_ppm_size); 480 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 481 482 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 483 (size_t) &_binary_gfx_anim_3_ppm_size); 484 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 485 486 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 487 (size_t) &_binary_gfx_anim_4_ppm_size); 488 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 479 489 480 490 async_obsolete_msg_1(fbphone, FB_ANIM_START, an); … … 494 504 if ((xres < 800) || (yres < 600)) 495 505 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);520 506 521 507 /* Create console viewport */ … … 545 531 546 532 /* Initialize icons */ 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]; 533 ic_pixmaps[CONS_SELECTED] = 534 make_pixmap(_binary_gfx_cons_selected_ppm_start, 535 (size_t) &_binary_gfx_cons_selected_ppm_size); 536 ic_pixmaps[CONS_IDLE] = 537 make_pixmap(_binary_gfx_cons_idle_ppm_start, 538 (size_t) &_binary_gfx_cons_idle_ppm_size); 539 ic_pixmaps[CONS_HAS_DATA] = 540 make_pixmap(_binary_gfx_cons_has_data_ppm_start, 541 (size_t) &_binary_gfx_cons_has_data_ppm_size); 542 ic_pixmaps[CONS_DISCONNECTED] = 543 make_pixmap(_binary_gfx_cons_idle_ppm_start, 544 (size_t) &_binary_gfx_cons_idle_ppm_size); 545 ic_pixmaps[CONS_KERNEL] = 546 make_pixmap(_binary_gfx_cons_kernel_ppm_start, 547 (size_t) &_binary_gfx_cons_kernel_ppm_size); 548 ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; 553 549 554 550 make_anim();
Note:
See TracChangeset
for help on using the changeset viewer.