Changeset d7baee6 in mainline for uspace/fb/fb.c


Ignore:
Timestamp:
2007-01-17T13:03:08Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df4ed85
Parents:
c738d65
Message:

Rather big indentation and formatting changes.
More inteligent long line wrapping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/fb/fb.c

    rc738d65 rd7baee6  
    150150
    151151/* Conversion routines between different color representations */
    152 static void rgb_byte0888(void *dst, int rgb)
     152static void
     153rgb_byte0888(void *dst, int rgb)
    153154{
    154155        *(int *)dst = rgb;
    155156}
    156157
    157 static int byte0888_rgb(void *src)
     158static int
     159byte0888_rgb(void *src)
    158160{
    159161        return (*(int *)src) & 0xffffff;
    160162}
    161163
    162 static void bgr_byte0888(void *dst, int rgb)
     164static void
     165bgr_byte0888(void *dst, int rgb)
    163166{
    164167        *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |
     
    166169}
    167170
    168 static int byte0888_bgr(void *src)
     171static int
     172byte0888_bgr(void *src)
    169173{
    170174        int color = *(uint32_t *)(src);
    171         return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color
    172                 >> 16) & 0xff);
    173 }
    174 
    175 static void rgb_byte888(void *dst, int rgb)
     175        return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) |
     176                ((color >> 16) & 0xff);
     177}
     178
     179static void
     180rgb_byte888(void *dst, int rgb)
    176181{
    177182        uint8_t *scr = dst;
     
    187192}
    188193
    189 static int byte888_rgb(void *src)
     194static int
     195byte888_rgb(void *src)
    190196{
    191197        uint8_t *scr = src;
     
    198204
    199205/**  16-bit depth (5:5:5) */
    200 static void rgb_byte555(void *dst, int rgb)
     206static void
     207rgb_byte555(void *dst, int rgb)
    201208{
    202209        /* 5-bit, 5-bits, 5-bits */
     
    206213
    207214/** 16-bit depth (5:5:5) */
    208 static int byte555_rgb(void *src)
     215static int
     216byte555_rgb(void *src)
    209217{
    210218        int color = *(uint16_t *)(src);
    211         return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) <<
    212                 (8 + 3)) | ((color & 0x1f) << 3);
     219        return (((color >> 10) & 0x1f) << (16 + 3)) |
     220                (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
    213221}
    214222
    215223/**  16-bit depth (5:6:5) */
    216 static void rgb_byte565(void *dst, int rgb)
     224static void
     225rgb_byte565(void *dst, int rgb)
    217226{
    218227        /* 5-bit, 6-bits, 5-bits */
     
    222231
    223232/** 16-bit depth (5:6:5) */
    224 static int byte565_rgb(void *src)
     233static int
     234byte565_rgb(void *src)
    225235{
    226236        int color = *(uint16_t *)(src);
    227         return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) <<
    228                 (8 + 2)) | ((color & 0x1f) << 3);
     237        return (((color >> 11) & 0x1f) << (16 + 3)) |
     238                (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
    229239}
    230240
    231241/** Put pixel - 8-bit depth (3:2:3) */
    232 static void rgb_byte8(void *dst, int rgb)
     242static void
     243rgb_byte8(void *dst, int rgb)
    233244{
    234245        *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
     
    236247
    237248/** Return pixel color - 8-bit depth (3:2:3) */
    238 static int byte8_rgb(void *src)
     249static int
     250byte8_rgb(void *src)
    239251{
    240252        int color = *(uint8_t *)src;
    241         return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) <<
    242                 (8 + 6)) | ((color & 0x7) << 5);
     253        return (((color >> 5) & 0x7) << (16 + 5)) |
     254                (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
    243255}
    244256
     
    250262 * @param color RGB color
    251263 */
    252 static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int
    253         color)
     264static void
     265putpixel(viewport_t *vport, unsigned int x, unsigned int y, int color)
    254266{
    255267        int dx = vport->x + x;
     
    257269
    258270        if (! (vport->paused && vport->dbdata))
    259                 (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)], COLOR(color));
     271                (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],
     272                        COLOR(color));
    260273
    261274        if (vport->dbdata) {
     
    267280
    268281/** Get pixel from viewport */
    269 static int getpixel(viewport_t *vport, unsigned int x, unsigned int y)
     282static int
     283getpixel(viewport_t *vport, unsigned int x, unsigned int y)
    270284{
    271285        int dx = vport->x + x;
    272286        int dy = vport->y + y;
    273287
    274         return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
    275 }
    276 
    277 static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y, int
    278         color)
     288        return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx, dy)]));
     289}
     290
     291static inline void
     292putpixel_mem(char *mem, unsigned int x, unsigned int y, int color)
    279293{
    280294        (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
    281295}
    282296
    283 static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
     297static void
     298draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
    284299        unsigned int width, unsigned int height, int color)
    285300{
     
    316331
    317332/** Fill viewport with background color */
    318 static void clear_port(viewport_t *vport)
     333static void
     334clear_port(viewport_t *vport)
    319335{
    320336        draw_rectangle(vport, 0, 0, vport->width, vport->height,
     
    327343 * @param lines Positive number - scroll up, negative - scroll down
    328344 */
    329 static void scroll_port_nodb(viewport_t *vport, int lines)
     345static void
     346scroll_port_nodb(viewport_t *vport, int lines)
    330347{
    331348        int y;
     
    351368
    352369/** Refresh given viewport from double buffer */
    353 static void refresh_viewport_db(viewport_t *vport)
     370static void
     371refresh_viewport_db(viewport_t *vport)
    354372{
    355373        unsigned int y, srcy, srcoff, dsty, dstx;
     
    369387
    370388/** Scroll viewport that has double buffering enabled */
    371 static void scroll_port_db(viewport_t *vport, int lines)
     389static void
     390scroll_port_db(viewport_t *vport, int lines)
    372391{
    373392        ++vport->paused;
     
    394413
    395414/** Scrolls viewport given number of lines */
    396 static void scroll_port(viewport_t *vport, int lines)
     415static void
     416scroll_port(viewport_t *vport, int lines)
    397417{
    398418        if (vport->dbdata)
     
    403423}
    404424
    405 static void invert_pixel(viewport_t *vport, unsigned int x, unsigned int y)
     425static void
     426invert_pixel(viewport_t *vport, unsigned int x, unsigned int y)
    406427{
    407428        putpixel(vport, x, y, ~getpixel(vport, x, y));
     
    420441 * @param transparent If false, print background color
    421442 */
    422 static void draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
     443static void
     444draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
    423445         unsigned int sy, style_t style, int transparent)
    424446{
     
    441463
    442464/** Invert character at given position */
    443 static void invert_char(viewport_t *vport,unsigned int row, unsigned int col)
     465static void
     466invert_char(viewport_t *vport,unsigned int row, unsigned int col)
    444467{
    445468        unsigned int x;
     
    460483 * @return New viewport number
    461484 */
    462 static int viewport_create(unsigned int x, unsigned int y,unsigned int width,
     485static int
     486viewport_create(unsigned int x, unsigned int y,unsigned int width,
    463487        unsigned int height)
    464488{
    465489        int i;
    466490
    467         for (i=0; i < MAX_VIEWPORTS; i++) {
     491        for (i = 0; i < MAX_VIEWPORTS; i++) {
    468492                if (!viewports[i].initialized)
    469493                        break;
     
    491515        return i;
    492516}
    493 
    494517
    495518/** Initialize framebuffer as a chardev output device
     
    503526 *
    504527 */
    505 static bool screen_init(void *addr, unsigned int xres, unsigned int yres,
     528static bool
     529screen_init(void *addr, unsigned int xres, unsigned int yres,
    506530        unsigned int scan, unsigned int visual, bool invert_colors)
    507531{
     
    559583
    560584/** Hide cursor if it is shown */
    561 static void cursor_hide(viewport_t *vport)
     585static void
     586cursor_hide(viewport_t *vport)
    562587{
    563588        if (vport->cursor_active && vport->cursor_shown) {
     
    568593
    569594/** Show cursor if cursor showing is enabled */
    570 static void cursor_print(viewport_t *vport)
     595static void
     596cursor_print(viewport_t *vport)
    571597{
    572598        /* Do not check for cursor_shown */
     
    578604
    579605/** Invert cursor, if it is enabled */
    580 static void cursor_blink(viewport_t *vport)
     606static void
     607cursor_blink(viewport_t *vport)
    581608{
    582609        if (vport->cursor_shown)
     
    594621 * @param transparent If false, print background color with character
    595622 */
    596 static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int
    597         col, style_t style, int transparent)
     623static void
     624draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col,
     625        style_t style, int transparent)
    598626{
    599627        /* Optimize - do not hide cursor if we are going to overwrite it */
     
    623651 * @param data Text data fitting exactly into viewport
    624652 */
    625 static void draw_text_data(viewport_t *vport, keyfield_t *data)
     653static void
     654draw_text_data(viewport_t *vport, keyfield_t *data)
    626655{
    627656        int i;
     
    642671}
    643672
    644 
    645673/** Return first free pixmap */
    646 static int find_free_pixmap(void)
     674static int
     675find_free_pixmap(void)
    647676{
    648677        int i;
    649678       
    650         for (i=0;i < MAX_PIXMAPS;i++)
     679        for (i = 0;i < MAX_PIXMAPS;i++)
    651680                if (!pixmaps[i].data)
    652681                        return i;
     
    654683}
    655684
    656 static void putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color)
     685static void
     686putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color)
    657687{
    658688        pixmap_t *pmap = &pixmaps[pm];
     
    663693
    664694/** Create a new pixmap and return appropriate ID */
    665 static int shm2pixmap(unsigned char *shm, size_t size)
     695static int
     696shm2pixmap(unsigned char *shm, size_t size)
    666697{
    667698        int pm;
     
    706737 * to redefine static variables with __thread
    707738 */
    708 static int shm_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
     739static int
     740shm_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
    709741{
    710742        static keyfield_t *interbuffer = NULL;
     
    718750        int retval = 0;
    719751        viewport_t *vport = &viewports[vp];
    720         unsigned int x,y;
     752        unsigned int x, y;
    721753
    722754        switch (IPC_GET_METHOD(*call)) {
     
    775807               
    776808                ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
    777                         IPC_GET_ARG2(*call), vport->width - x, vport->height -
    778                         y, (putpixel_cb_t)putpixel, vport);
     809                        IPC_GET_ARG2(*call), vport->width - x,
     810                        vport->height - y, (putpixel_cb_t)putpixel, vport);
    779811                break;
    780812        case FB_DRAW_TEXT_DATA:
     
    799831}
    800832
    801 static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap)
     833static void
     834copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap)
    802835{
    803836        int y;
     
    815848
    816849        for (y = 0; y < height; y++) {
    817                 tmp = (vport->y + y) * screen.scanline + vport->x *
    818                         screen.pixelbytes;
     850                tmp = (vport->y + y) * screen.scanline +
     851                        vport->x * screen.pixelbytes;
    819852                memcpy(pmap->data + rowsize * y, screen.fbaddress + tmp,
    820853                        rowsize);
     
    823856
    824857/** Save viewport to pixmap */
    825 static int save_vp_to_pixmap(viewport_t *vport)
     858static int
     859save_vp_to_pixmap(viewport_t *vport)
    826860{
    827861        int pm;
     
    874908        realrowsize = realwidth * screen.pixelbytes;
    875909
    876         for (y=0; y < realheight; y++) {
    877                 tmp = (vport->y + y) * screen.scanline + vport->x *
    878                         screen.pixelbytes;
     910        for (y = 0; y < realheight; y++) {
     911                tmp = (vport->y + y) * screen.scanline +
     912                        vport->x * screen.pixelbytes;
    879913                memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize,
    880914                        realrowsize);
     
    884918
    885919/** Tick animation one step forward */
    886 static void anims_tick(void)
     920static void
     921anims_tick(void)
    887922{
    888923        int i;
     
    894929                return;
    895930
    896         for (i=0; i < MAX_ANIMATIONS; i++) {
     931        for (i = 0; i < MAX_ANIMATIONS; i++) {
    897932                if (!animations[i].animlen || !animations[i].initialized ||
    898933                        !animations[i].enabled)
     
    911946static int pointer_pixmap = -1;
    912947
    913 static void mouse_show(void)
    914 {
    915         int i,j;
     948static void
     949mouse_show(void)
     950{
     951        int i, j;
    916952        int visibility;
    917953        int color;
     
    942978                for (j = 0; j < pointer_width; j++) {
    943979                        bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8;
    944                         visibility = pointer_mask_bits[bytepos] & (1 << (j %
    945                                 8));
     980                        visibility = pointer_mask_bits[bytepos] &
     981                                (1 << (j % 8));
    946982                        if (visibility) {
    947983                                color = pointer_bits[bytepos] & (1 << (j % 8))
     
    950986                                        i < screen.yres)
    951987                                        putpixel(&viewports[0], pointer_x + j,
    952                                                  pointer_y+i, color);
     988                                                pointer_y + i, color);
    953989                        }
    954990                }
     
    956992}
    957993
    958 static void mouse_hide(void)
     994static void
     995mouse_hide(void)
    959996{
    960997        /* Restore image under the cursor */
     
    9651002}
    9661003
    967 static void mouse_move(unsigned int x, unsigned int y)
     1004static void
     1005mouse_move(unsigned int x, unsigned int y)
    9681006{
    9691007        mouse_hide();
     
    9731011}
    9741012
    975 static int anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
     1013static int
     1014anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
    9761015{
    9771016        int handled = 1;
     
    10701109
    10711110/** Handler for messages concerning pixmap handling */
    1072 static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
     1111static int
     1112pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
    10731113{
    10741114        int handled = 1;
     
    11231163 *
    11241164 */
    1125 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     1165static void
     1166fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
    11261167{
    11271168        ipc_callid_t callid;
     
    11441185        while (1) {
    11451186                if (vport->cursor_active || anims_enabled)
    1146                         callid = async_get_call_timeout(&call,250000);
     1187                        callid = async_get_call_timeout(&call, 250000);
    11471188                else
    11481189                        callid = async_get_call(&call);
     
    11791220                                break;
    11801221                        }
    1181                         ipc_answer_fast(callid,0,0,0);
     1222                        ipc_answer_fast(callid, 0, 0, 0);
    11821223
    11831224                        draw_char(vport, c, row, col, vport->style,
     
    12651306                case FB_VIEWPORT_CREATE:
    12661307                        retval = viewport_create(IPC_GET_ARG1(call) >> 16,
    1267                                 IPC_GET_ARG1(call) & 0xffff, IPC_GET_ARG2(call)
    1268                                  >> 16, IPC_GET_ARG2(call) & 0xffff);
     1308                                IPC_GET_ARG1(call) & 0xffff,
     1309                                IPC_GET_ARG2(call) >> 16,
     1310                                IPC_GET_ARG2(call) & 0xffff);
    12691311                        break;
    12701312                case FB_VIEWPORT_DELETE:
     
    13011343                        retval = ENOENT;
    13021344                }
    1303                 ipc_answer_fast(callid,retval,0,0);
     1345                ipc_answer_fast(callid,retval, 0, 0);
    13041346        }
    13051347}
    13061348
    13071349/** Initialization of framebuffer */
    1308 int fb_init(void)
     1350int
     1351fb_init(void)
    13091352{
    13101353        void *fb_ph_addr;
Note: See TracChangeset for help on using the changeset viewer.