Changeset bd02038 in mainline


Ignore:
Timestamp:
2006-06-09T08:29:25Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c891ed39
Parents:
e92aabf
Message:

Fb internal update.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • console/console.c

    re92aabf rbd02038  
    215215        connection_t *conn;
    216216        static int console_pixmap = -1;
    217         int i, j;
     217        int i, j, rc;
    218218        keyfield_t *field;
    219219        style_t *style;
     
    258258                                interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j);
    259259                /* This call can preempt, but we are already at the end */
    260                 j = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL);           
     260                rc = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL);           
    261261        };
    262262       
    263         if ((!interbuffer) || (j != 0)){
     263        if ((!interbuffer) || (j != 0)) {
    264264                set_style(&conn->screenbuffer.style);
    265265                clrscr();
  • fb/fb.c

    re92aabf rbd02038  
    213213 * @param color RGB color
    214214 */
    215 static void putpixel(int vp, unsigned int x, unsigned int y, int color)
    216 {
    217         int dx = viewports[vp].x + x;
    218         int dy = viewports[vp].y + y;
    219 
    220         if (! viewports[vp].paused)
     215static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int color)
     216{
     217        int dx = vport->x + x;
     218        int dy = vport->y + y;
     219
     220        if (! (vport->paused && vport->dbdata))
    221221                (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],color);
    222222
    223         if (viewports[vp].dbdata) {
    224                 int dline = (y + viewports[vp].dboffset) % viewports[vp].height;
    225                 int doffset = screen.pixelbytes * (dline * viewports[vp].width + x);
    226                 (*screen.rgb2scr)(&viewports[vp].dbdata[doffset],color);
     223        if (vport->dbdata) {
     224                int dline = (y + vport->dboffset) % vport->height;
     225                int doffset = screen.pixelbytes * (dline * vport->width + x);
     226                (*screen.rgb2scr)(&vport->dbdata[doffset],color);
    227227        }
    228228}
    229229
    230230/** Get pixel from viewport */
    231 static int getpixel(int vp, unsigned int x, unsigned int y)
    232 {
    233         int dx = viewports[vp].x + x;
    234         int dy = viewports[vp].y + y;
     231static int getpixel(viewport_t *vport, unsigned int x, unsigned int y)
     232{
     233        int dx = vport->x + x;
     234        int dy = vport->y + y;
    235235
    236236        return (*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]);
     
    243243}
    244244
    245 static void draw_rectangle(int vp, unsigned int sx, unsigned int sy,
     245static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
    246246                           unsigned int width, unsigned int height,
    247247                           int color)
     
    257257                putpixel_mem(tmpline, x, 0, color);
    258258
    259         if (!viewports[vp].paused) {
     259        if (!vport->paused) {
    260260                /* Recompute to screen coords */
    261                 sx += viewports[vp].x;
    262                 sy += viewports[vp].y;
     261                sx += vport->x;
     262                sy += vport->y;
    263263                /* Copy the rest */
    264264                for (y = sy;y < sy+height; y++)
     
    266266                               screen.pixelbytes * width);
    267267        }
    268         if (viewports[vp].dbdata) {
     268        if (vport->dbdata) {
    269269                for (y=sy;y < sy+height; y++) {
    270                         int rline = (y + viewports[vp].dboffset) % viewports[vp].height;
    271                         int rpos = (rline * viewports[vp].width + sx) * screen.pixelbytes;
    272                         memcpy(&viewports[vp].dbdata[rpos], tmpline, screen.pixelbytes * width);
     270                        int rline = (y + vport->dboffset) % vport->height;
     271                        int rpos = (rline * vport->width + sx) * screen.pixelbytes;
     272                        memcpy(&vport->dbdata[rpos], tmpline, screen.pixelbytes * width);
    273273                }
    274274        }
     
    277277
    278278/** Fill viewport with background color */
    279 static void clear_port(int vp)
    280 {
    281         viewport_t *vport = &viewports[vp];
    282 
    283         draw_rectangle(vp, 0, 0, vport->width, vport->height, vport->style.bg_color);
     279static void clear_port(viewport_t *vport)
     280{
     281        draw_rectangle(vport, 0, 0, vport->width, vport->height, vport->style.bg_color);
    284282}
    285283
     
    289287 * @param rows Positive number - scroll up, negative - scroll down
    290288 */
    291 static void scroll_port_nodb(int vp, int lines)
     289static void scroll_port_nodb(viewport_t *vport, int lines)
    292290{
    293291        int y;
    294292        int startline;
    295293        int endline;
    296         viewport_t *vport = &viewports[vp];
    297294
    298295        if (lines > 0) {
     
    301298                               &screen.fbaddress[POINTPOS(vport->x,y + lines)],
    302299                               screen.pixelbytes * vport->width);
    303                 draw_rectangle(vp, 0, vport->height - lines,
     300                draw_rectangle(vport, 0, vport->height - lines,
    304301                               vport->width, lines, vport->style.bg_color);
    305302        } else if (lines < 0) {
     
    309306                               &screen.fbaddress[POINTPOS(vport->x,y - lines)],
    310307                               screen.pixelbytes * vport->width);
    311                 draw_rectangle(vp, 0, 0, vport->width, lines, vport->style.bg_color);
     308                draw_rectangle(vport, 0, 0, vport->width, lines, vport->style.bg_color);
    312309        }
    313310}
    314311
    315312/** Refresh given viewport from double buffer */
    316 static void refresh_viewport_db(int vp)
     313static void refresh_viewport_db(viewport_t *vport)
    317314{
    318315        unsigned int y, srcy, srcoff, dsty, dstx;
    319316
    320         for (y = 0; y < viewports[vp].height; y++) {
    321                 srcy = (y + viewports[vp].dboffset) % viewports[vp].height;
    322                 srcoff = (viewports[vp].width * srcy) * screen.pixelbytes;
    323 
    324                 dstx = viewports[vp].x;
    325                 dsty = viewports[vp].y + y;
     317        for (y = 0; y < vport->height; y++) {
     318                srcy = (y + vport->dboffset) % vport->height;
     319                srcoff = (vport->width * srcy) * screen.pixelbytes;
     320
     321                dstx = vport->x;
     322                dsty = vport->y + y;
    326323
    327324                memcpy(&screen.fbaddress[POINTPOS(dstx,dsty)],
    328                        &viewports[vp].dbdata[srcoff],
    329                        viewports[vp].width*screen.pixelbytes);
     325                       &vport->dbdata[srcoff],
     326                       vport->width*screen.pixelbytes);
    330327        }
    331328}
    332329
    333330/** Scroll viewport that has double buffering enabled */
    334 static void scroll_port_db(int vp, int lines)
    335 {
    336         ++viewports[vp].paused;
     331static void scroll_port_db(viewport_t *vport, int lines)
     332{
     333        ++vport->paused;
    337334        if (lines > 0) {
    338                 draw_rectangle(vp, 0, 0, viewports[vp].width, lines,
    339                                viewports[vp].style.bg_color);
    340                 viewports[vp].dboffset += lines;
    341                 viewports[vp].dboffset %= viewports[vp].height;
     335                draw_rectangle(vport, 0, 0, vport->width, lines,
     336                               vport->style.bg_color);
     337                vport->dboffset += lines;
     338                vport->dboffset %= vport->height;
    342339        } else if (lines < 0) {
    343340                lines = -lines;
    344                 draw_rectangle(vp, 0, viewports[vp].height-lines,
    345                                viewports[vp].width, lines,
    346                                viewports[vp].style.bg_color);
    347 
    348                 if (viewports[vp].dboffset < lines)
    349                         viewports[vp].dboffset += viewports[vp].height;
    350                 viewports[vp].dboffset -= lines;
    351         }
    352        
    353         --viewports[vp].paused;
    354        
    355         refresh_viewport_db(vp);
    356        
     341                draw_rectangle(vport, 0, vport->height-lines,
     342                               vport->width, lines,
     343                               vport->style.bg_color);
     344
     345                if (vport->dboffset < lines)
     346                        vport->dboffset += vport->height;
     347                vport->dboffset -= lines;
     348        }
     349       
     350        --vport->paused;
     351       
     352        refresh_viewport_db(vport);
    357353}
    358354
    359355/** Scrolls viewport given number of lines */
    360 static void scroll_port(int vp, int lines)
    361 {
    362         if (viewports[vp].dbdata)
    363                 scroll_port_db(vp, lines);
     356static void scroll_port(viewport_t *vport, int lines)
     357{
     358        if (vport->dbdata)
     359                scroll_port_db(vport, lines);
    364360        else
    365                 scroll_port_nodb(vp, lines);
    366        
    367 }
    368 
    369 static void invert_pixel(int vp,unsigned int x, unsigned int y)
    370 {
    371         putpixel(vp, x, y, ~getpixel(vp, x, y));
     361                scroll_port_nodb(vport, lines);
     362       
     363}
     364
     365static void invert_pixel(viewport_t *vport, unsigned int x, unsigned int y)
     366{
     367        putpixel(vport, x, y, ~getpixel(vport, x, y));
    372368}
    373369
     
    384380 * @param transparent If false, print background color
    385381 */
    386 static void draw_glyph(int vp,__u8 glyph, unsigned int sx, unsigned int sy,
     382static void draw_glyph(viewport_t *vport,__u8 glyph, unsigned int sx, unsigned int sy,
    387383                       style_t style, int transparent)
    388384{
     
    395391                for (i = 0; i < 8; i++) {
    396392                        if (glline & (1 << (7 - i)))
    397                                 putpixel(vp, sx + i, sy + y, style.fg_color);
     393                                putpixel(vport, sx + i, sy + y, style.fg_color);
    398394                        else if (!transparent)
    399                                 putpixel(vp, sx + i, sy + y, style.bg_color);
     395                                putpixel(vport, sx + i, sy + y, style.bg_color);
    400396                }
    401397        }
     
    403399
    404400/** Invert character at given position */
    405 static void invert_char(int vp,unsigned int row, unsigned int col)
     401static void invert_char(viewport_t *vport,unsigned int row, unsigned int col)
    406402{
    407403        unsigned int x;
     
    410406        for (x = 0; x < COL_WIDTH; x++)
    411407                for (y = 0; y < FONT_SCANLINES; y++)
    412                         invert_pixel(vp, col * COL_WIDTH + x, row * FONT_SCANLINES + y);
     408                        invert_pixel(vport, col * COL_WIDTH + x, row * FONT_SCANLINES + y);
    413409}
    414410
     
    505501
    506502/** Hide cursor if it is shown */
    507 static void cursor_hide(int vp)
    508 {
    509         viewport_t *vport = &viewports[vp];
    510 
     503static void cursor_hide(viewport_t *vport)
     504{
    511505        if (vport->cursor_active && vport->cursor_shown) {
    512                 invert_char(vp, vport->cur_row, vport->cur_col);
     506                invert_char(vport, vport->cur_row, vport->cur_col);
    513507                vport->cursor_shown = 0;
    514508        }
     
    516510
    517511/** Show cursor if cursor showing is enabled */
    518 static void cursor_print(int vp)
    519 {
    520         viewport_t *vport = &viewports[vp];
    521 
     512static void cursor_print(viewport_t *vport)
     513{
    522514        /* Do not check for cursor_shown */
    523515        if (vport->cursor_active) {
    524                 invert_char(vp, vport->cur_row, vport->cur_col);
     516                invert_char(vport, vport->cur_row, vport->cur_col);
    525517                vport->cursor_shown = 1;
    526518        }
     
    528520
    529521/** Invert cursor, if it is enabled */
    530 static void cursor_blink(int vp)
    531 {
    532         viewport_t *vport = &viewports[vp];
    533 
     522static void cursor_blink(viewport_t *vport)
     523{
    534524        if (vport->cursor_shown)
    535                 cursor_hide(vp);
     525                cursor_hide(vport);
    536526        else
    537                 cursor_print(vp);
     527                cursor_print(vport);
    538528}
    539529
     
    546536 * @param transparent If false, print background color with character
    547537 */
    548 static void draw_char(int vp, char c, unsigned int row, unsigned int col, style_t style, int transparent)
    549 {
    550         viewport_t *vport = &viewports[vp];
    551 
     538static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col,
     539                      style_t style, int transparent)
     540{
    552541        /* Optimize - do not hide cursor if we are going to overwrite it */
    553542        if (vport->cursor_active && vport->cursor_shown &&
    554543            (vport->cur_col != col || vport->cur_row != row))
    555                 invert_char(vp, vport->cur_row, vport->cur_col);
    556        
    557         draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES, style, transparent);
     544                invert_char(vport, vport->cur_row, vport->cur_col);
     545       
     546        draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style, transparent);
    558547
    559548        vport->cur_col = col;
     
    567556                        vport->cur_row--;
    568557        }
    569         cursor_print(vp);
     558        cursor_print(vport);
    570559}
    571560
     
    575564 * @param data Text data fitting exactly into viewport
    576565 */
    577 static void draw_text_data(int vp, keyfield_t *data)
    578 {
    579         viewport_t *vport = &viewports[vp];
     566static void draw_text_data(viewport_t *vport, keyfield_t *data)
     567{
    580568        int i;
    581569        char c;
    582570        int col,row;
    583571
    584         clear_port(vp);
     572        clear_port(vport);
    585573        for (i=0; i < vport->cols * vport->rows; i++) {
    586574                if (data[i].character == ' ' && style_same(data[i].style,vport->style))
     
    588576                col = i % vport->cols;
    589577                row = i / vport->cols;
    590                 draw_glyph(vp, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES,
     578                draw_glyph(vport, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES,
    591579                           data[i].style, style_same(data[i].style,vport->style));
    592580        }
    593         cursor_print(vp);
     581        cursor_print(vport);
    594582}
    595583
     
    633621
    634622        ppm_draw(shm, size, 0, 0, pmap->width, pmap->height,
    635                  putpixel_pixmap, pm);
     623                 (putpixel_cb_t)putpixel_pixmap, (void *)pm);
    636624
    637625        return pm;
     
    726714               
    727715                ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call),
    728                          vport->width - x, vport->height - y, putpixel, vp);
     716                         vport->width - x, vport->height - y, (putpixel_cb_t)putpixel, vport);
    729717                break;
    730718        case FB_DRAW_TEXT_DATA:
     
    737725                        break;
    738726                }
    739                 draw_text_data(vp, interbuffer);
     727                draw_text_data(vport, interbuffer);
    740728                break;
    741729        default:
     
    996984
    997985                if (!callid) {
    998                         cursor_blink(vp);
     986                        cursor_blink(vport);
    999987                        anims_tick();
    1000988                        continue;
     
    10261014                        ipc_answer_fast(callid,0,0,0);
    10271015
    1028                         draw_char(vp, c, row, col, vport->style, IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
     1016                        draw_char(vport, c, row, col, vport->style, IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
    10291017                        continue; /* msg already answered */
    10301018                case FB_CLEAR:
    1031                         clear_port(vp);
    1032                         cursor_print(vp);
     1019                        clear_port(vport);
     1020                        cursor_print(vport);
    10331021                        retval = 0;
    10341022                        break;
     
    10411029                        }
    10421030                        retval = 0;
    1043                         cursor_hide(vp);
     1031                        cursor_hide(vport);
    10441032                        vport->cur_col = col;
    10451033                        vport->cur_row = row;
    1046                         cursor_print(vp);
     1034                        cursor_print(vport);
    10471035                        break;
    10481036                case FB_CURSOR_VISIBILITY:
    1049                         cursor_hide(vp);
     1037                        cursor_hide(vport);
    10501038                        vport->cursor_active = IPC_GET_ARG1(call);
    1051                         cursor_print(vp);
     1039                        cursor_print(vport);
    10521040                        retval = 0;
    10531041                        break;
     
    10611049                                break;
    10621050                        }
    1063                         cursor_hide(vp);
    1064                         scroll_port(vp, i*FONT_SCANLINES);
    1065                         cursor_print(vp);
     1051                        cursor_hide(vport);
     1052                        scroll_port(vport, i*FONT_SCANLINES);
     1053                        cursor_print(vport);
    10661054                        retval = 0;
    10671055                        break;
     
    11001088                                break;
    11011089                        }
    1102                         cursor_hide(vp);
     1090                        cursor_hide(vport);
    11031091                        vp = i;
    11041092                        vport = &viewports[vp];
    1105                         cursor_print(vp);
     1093                        cursor_print(vport);
    11061094                        retval = 0;
    11071095                        break;
  • fb/fb.h

    re92aabf rbd02038  
    3737#define _FB_H_
    3838
     39typedef void (* putpixel_cb_t)(void *,unsigned int, unsigned int, int);
     40
    3941int fb_init(void);
    4042
  • fb/ppm.c

    re92aabf rbd02038  
    8585             unsigned int sy,
    8686             unsigned int maxwidth, unsigned int maxheight,
    87              void (*putpixel)(int,unsigned int, unsigned int, int),int vp)
     87             putpixel_cb_t putpixel,void *vport)
    8888{
    8989        unsigned int width, height;
     
    122122                color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[2]*coef;
    123123               
    124                 (*putpixel)(vp, sx+(i % width), sy+(i / width), color);
     124                (*putpixel)(vport, sx+(i % width), sy+(i / width), color);
    125125                data += 3;
    126126        }
  • fb/ppm.h

    re92aabf rbd02038  
    3030#define _PPM_H_
    3131
     32#include "fb.h"
     33
    3234int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx,
    3335             unsigned int sy,
    3436             unsigned int maxwidth, unsigned int maxheight,
    35              void (*putpixel)(int,unsigned int, unsigned int, int),int vp);
     37             putpixel_cb_t fnc,void *);
    3638int ppm_get_data(unsigned char *data, size_t dtsz, int *width, int *height);
    3739
Note: See TracChangeset for help on using the changeset viewer.