Changeset 67b05ff in mainline


Ignore:
Timestamp:
2011-08-10T18:34:23Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c6f08726
Parents:
62e29ae
Message:

cherrypick from fb server rewrite: store images as Truevision TGA (instead of PPM) and use a library to decode them into image maps

Files:
6 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile

    r62e29ae r67b05ff  
    169169        lib/drv \
    170170        lib/packet \
     171        lib/imgmap \
    171172        lib/net \
    172173        lib/ext2 \
  • uspace/Makefile.common

    r62e29ae r67b05ff  
    106106LIBBLOCK_PREFIX = $(LIB_PREFIX)/block
    107107LIBFS_PREFIX = $(LIB_PREFIX)/fs
     108LIBIMGMAP_PREFIX = $(LIB_PREFIX)/imgmap
    108109LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
    109110
  • uspace/srv/hid/console/Makefile

    r62e29ae r67b05ff  
    2929
    3030USPACE_PREFIX = ../../..
     31LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a
     32EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX)
    3133BINARY = console
    3234
     
    3436        console.c \
    3537        keybuffer.c \
     38        images.c \
    3639        gcons.c
    3740
    38 IMAGES = \
    39         gfx/helenos.ppm \
    40         gfx/nameic.ppm \
     41IMAGES_OLD = \
    4142        gfx/cons_selected.ppm \
    4243        gfx/cons_idle.ppm \
     
    4849        gfx/anim_4.ppm
    4950
     51IMAGES = \
     52        gfx/helenos.tga \
     53        gfx/nameic.tga
     54
    5055SOURCES = \
    5156        $(GENERIC_SOURCES) \
    52         $(IMAGES)
     57        $(IMAGES_OLD)
     58
     59PRE_DEPEND = images.c images.h
     60EXTRA_CLEAN = images.c images.h
    5361
    5462include $(USPACE_PREFIX)/Makefile.common
     
    5664%.o: %.ppm
    5765        $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@
     66
     67images.c images.h: $(IMAGES)
     68        $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^
  • uspace/srv/hid/console/gcons.c

    r62e29ae r67b05ff  
    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
     
    5759#define COLOR_FOREGROUND  0x202020
    5860#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;
    6461
    6562extern char _binary_gfx_anim_1_ppm_start[0];
     
    8481static sysarg_t xres;
    8582static sysarg_t yres;
     83
     84static imgmap_t *helenos_img;
     85static imgmap_t *nameic_img;
    8686
    8787enum butstate {
     
    358358}
    359359
    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 */
     367static 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       
     392drop:
     393        /* Drop area */
     394        async_obsolete_msg_0(fbphone, FB_DROP_SHM);
     395       
     396exit:
     397        /* Remove area */
     398        munmap(shm, img->size);
     399}
     400
     401/** Redraws console graphics */
     402void 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 */
     428static int make_pixmap(char *data, size_t size)
    369429{
    370430        /* Create area */
     
    372432            MAP_ANONYMOUS, 0, 0);
    373433        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;
    377439       
    378440        /* Send area */
     
    385447                goto drop;
    386448       
    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 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 {
    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        
    449449        /* Obtain pixmap */
    450450        rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP);
     
    504504        if ((xres < 800) || (yres < 600))
    505505                return;
     506       
     507        /* Create image maps */
     508        helenos_img = imgmap_decode_tga((void *) helenos_tga);
     509        nameic_img = imgmap_decode_tga((void *) nameic_tga);
    506510       
    507511        /* Create console viewport */
  • uspace/srv/hid/fb/Makefile

    r62e29ae r67b05ff  
    8686endif
    8787
    88 EXTRA_CFLAGS += -D$(UARCH)
     88LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a
     89EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) -D$(UARCH)
    8990
    9091include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/fb/fb.c

    r62e29ae r67b05ff  
    10951095                        shm = dest;
    10961096                       
    1097                         if (shm[0] != 'P')
     1097                        if ((shm[0] != 'P') || (shm[0] != 'I'))
    10981098                                return false;
    10991099                       
  • uspace/srv/hid/fb/ppm.c

    r62e29ae r67b05ff  
    2929#include <sys/types.h>
    3030#include <errno.h>
     31#include <imgmap.h>
    3132
    3233#include "ppm.h"
     
    9495        unsigned int coef;
    9596       
     97        /*
     98         * This is temporary hack to draw
     99         * image maps within the original code base.
     100         * This will be completely rewritten in the
     101         * new framebuffer server.
     102         */
     103        if (data[0] == 'I') {
     104                imgmap_t *img = (imgmap_t *) data;
     105               
     106                if (img->visual != VISUAL_BGR_8_8_8)
     107                        return EINVAL;
     108               
     109                data = img->data;
     110               
     111                for (sysarg_t y = 0; y < img->height; y++) {
     112                        for (sysarg_t x = 0; x < img->width; x++) {
     113                                if ((x > maxwidth) || (y > maxheight)) {
     114                                        data += 3;
     115                                        continue;
     116                                }
     117                               
     118                                color = (data[2] << 16) + (data[1] << 8) + data[0];
     119                               
     120                                (*putpixel)(vport, sx + x, sy + y, color);
     121                                data += 3;
     122                        }
     123                }
     124               
     125                return 0;
     126        }
     127       
    96128        /* Read magic */
    97129        if ((data[0] != 'P') || (data[1] != '6'))
Note: See TracChangeset for help on using the changeset viewer.