Changeset ee24574 in mainline for uspace/srv/hid/console/gcons.c


Ignore:
Timestamp:
2011-08-18T08:00:42Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a92cf94f
Parents:
0f963cb (diff), c53a705 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/gcons.c

    r0f963cb ree24574  
    4141#include <align.h>
    4242#include <bool.h>
     43#include <imgmap.h>
    4344
    4445#include "console.h"
    4546#include "gcons.h"
     47#include "images.h"
    4648
    4749#define CONSOLE_TOP     66
     
    5860#define COLOR_BACKGROUND  0xffffff
    5961
    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 
    8362static bool use_gcons = false;
    8463static sysarg_t xres;
    8564static sysarg_t yres;
     65
     66static imgmap_t *helenos_img;
     67static imgmap_t *nameic_img;
     68
     69static imgmap_t *anim_1_img;
     70static imgmap_t *anim_2_img;
     71static imgmap_t *anim_3_img;
     72static imgmap_t *anim_4_img;
     73
     74static imgmap_t *cons_has_data_img;
     75static imgmap_t *cons_idle_img;
     76static imgmap_t *cons_kernel_img;
     77static imgmap_t *cons_selected_img;
    8678
    8779enum butstate {
     
    10193static int fbphone;
    10294
    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 */
     96static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
    10597static int animation = -1;
    10698
     
    149141        enum butstate state = console_state[index];
    150142       
    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]);
    154146       
    155147        if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL)
     
    358350}
    359351
    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 {
     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 */
     359static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y)
     360{
     361        if (img == NULL)
     362                return;
     363       
    370364        /* Create area */
    371         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     365        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    372366            MAP_ANONYMOUS, 0, 0);
    373367        if (shm == MAP_FAILED)
    374368                return;
    375369       
    376         memcpy(shm, logo, size);
     370        memcpy(shm, img, img->size);
    377371       
    378372        /* Send area */
     
    386380       
    387381        /* Draw logo */
    388         async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y);
     382        async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y);
    389383       
    390384drop:
     
    394388exit:
    395389        /* Remove area */
    396         munmap(shm, size);
     390        munmap(shm, img->size);
    397391}
    398392
     
    406400        set_rgb_color(COLOR_MAIN, COLOR_MAIN);
    407401        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);
     402        draw_imgmap(helenos_img, xres - 66, 2);
     403        draw_imgmap(nameic_img, 5, 17);
    412404       
    413405        unsigned int i;
     
    418410}
    419411
    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 {
     412/** Create an image map on framebuffer
     413 *
     414 * @param img Image map.
     415 *
     416 * @return Image map identification
     417 *
     418 */
     419static int make_imgmap(imgmap_t *img)
     420{
     421        if (img == NULL)
     422                return -1;
     423       
    430424        /* Create area */
    431         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    432             MAP_ANONYMOUS, 0, 0);
     425        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,
     426            MAP_SHARED | MAP_ANONYMOUS, 0, 0);
    433427        if (shm == MAP_FAILED)
    434428                return -1;
    435429       
    436         memcpy(shm, data, size);
    437        
    438         int pxid = -1;
     430        memcpy(shm, img, img->size);
     431       
     432        int id = -1;
    439433       
    440434        /* Send area */
     
    447441                goto drop;
    448442       
    449         /* Obtain pixmap */
    450         rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP);
     443        /* Obtain image map identifier */
     444        rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP);
    451445        if (rc < 0)
    452446                goto drop;
    453447       
    454         pxid = rc;
     448        id = rc;
    455449       
    456450drop:
     
    460454exit:
    461455        /* Remove area */
    462         munmap(shm, size);
    463        
    464         return pxid;
     456        munmap(shm, img->size);
     457       
     458        return id;
    465459}
    466460
     
    472466                return;
    473467       
    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);
     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);
    489479       
    490480        async_obsolete_msg_1(fbphone, FB_ANIM_START, an);
     
    504494        if ((xres < 800) || (yres < 600))
    505495                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);
    506520       
    507521        /* Create console viewport */
     
    531545       
    532546        /* Initialize icons */
    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];
     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];
    549553       
    550554        make_anim();
Note: See TracChangeset for help on using the changeset viewer.