Changeset 88c3151 in mainline for fb/fb.c


Ignore:
Timestamp:
2006-06-01T15:27:38Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3993b3d
Parents:
a2ae4f4
Message:

Added most of required functionality to framebuffer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fb/fb.c

    ra2ae4f4 r88c3151  
    7878        int bgcolor, fgcolor;
    7979        /* Auto-cursor position */
    80         int cursor_active, cur_x, cur_y;
     80        int cursor_active, cur_col, cur_row;
    8181} viewport_t;
    8282
     
    197197        }       
    198198}
    199 
    200 /** Optimized scroll for windows that cover whole lines */
    201 //static void scroll_optim(int vp, int rows)
    202 //{
    203         /* TODO */
    204 //}
    205199
    206200/** Scroll port up/down
     
    323317                return ELIMIT;
    324318
    325         viewports[i].initialized = 1;
     319        if (width ==0 || height == 0 ||
     320            x+width > screen.xres || y+height > screen.yres)
     321                return EINVAL;
     322        if (width < FONT_SCANLINES || height < COL_WIDTH)
     323                return EINVAL;
     324
    326325        viewports[i].x = x;
    327326        viewports[i].y = y;
     
    335334        viewports[i].fgcolor = DEFAULT_FGCOLOR;
    336335       
     336        viewports[i].initialized = 1;
     337
    337338        return i;
    338339}
     
    415416}
    416417
     418static void draw_char(int vp, char c, unsigned int col, unsigned int row)
     419{
     420        viewport_t *vport = &viewports[vp];
     421
     422        if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row))
     423                invert_char(vp, vport->cur_col,vport->cur_row);
     424       
     425        draw_glyph(vp, c, col, row);
     426       
     427        if (vport->cursor_active) {
     428                vport->cur_col++;
     429                if (vport->cur_col>= vport->cols) {
     430                        vport->cur_col = 0;
     431                        vport->cur_row++;
     432                        if (vport->cur_row >= vport->rows)
     433                                vport->cur_row--;
     434                }
     435                invert_char(vp, vport->cur_col,vport->cur_row);
     436        }
     437}
     438
    417439void client_connection(ipc_callid_t iid, ipc_call_t *icall)
    418440{
     
    423445        unsigned int row,col;
    424446        char c;
     447
    425448        int vp = 0;
     449        viewport_t *vport = &viewports[0];
    426450
    427451        if (client_connected) {
     
    429453                return;
    430454        }
     455        client_connected = 1;
    431456        ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
    432457
     
    438463                        /* cleanup other viewports */
    439464                        for (i=1; i < MAX_VIEWPORTS; i++)
    440                                 viewports[i].initialized = 0;
     465                                vport->initialized = 0;
    441466                        ipc_answer_fast(callid,0,0,0);
    442467                        return; /* Exit thread */
     
    445470                        row = IPC_GET_ARG2(call);
    446471                        col = IPC_GET_ARG3(call);
    447                         if (row >= viewports[vp].rows || col >= viewports[vp].cols) {
     472                        if (row >= vport->rows || col >= vport->cols) {
    448473                                retval = EINVAL;
    449474                                break;
    450475                        }
    451476                        ipc_answer_fast(callid,0,0,0);
    452                         draw_glyph(vp,c, row, col);
     477
     478                        draw_char(vp, c, row, col);
    453479                        continue; /* msg already answered */
    454480                case FB_CLEAR:
    455481                        clear_port(vp);
     482                        if (vport->cursor_active)
     483                                invert_char(vp, vport->cur_col,vport->cur_row);
    456484                        retval = 0;
    457485                        break;
    458 /*              case FB_CURSOR_GOTO: */
    459 /*                      retval = 0; */
    460 /*                      break; */
    461 /*              case FB_CURSOR_VISIBILITY: */
    462 /*                      retval = 0; */
    463 /*                      break; */
     486                case FB_CURSOR_GOTO:
     487                        row = IPC_GET_ARG1(call);
     488                        col = IPC_GET_ARG2(call);
     489                        if (row >= vport->rows || col >= vport->cols) {
     490                                retval = EINVAL;
     491                                break;
     492                        }
     493                        retval = 0;
     494                        if (viewports[vp].cursor_active) {
     495                                invert_char(vp, vport->cur_col,vport->cur_row);
     496                                invert_char(vp, col, row);
     497                        }
     498                        vport->cur_col = col;
     499                        vport->cur_row = row;
     500                        break;
     501                case FB_CURSOR_VISIBILITY:
     502                        i = IPC_GET_ARG1(call);
     503                        retval = 0;
     504                        if ((i && vport->cursor_active) || (!i && !vport->cursor_active))
     505                                break;
     506
     507                        vport->cursor_active = i;
     508                        invert_char(vp, vport->cur_col,vport->cur_row);
     509                        break;
    464510                case FB_GET_CSIZE:
    465                         ipc_answer_fast(callid, 0, viewports[vp].rows, viewports[vp].cols);
     511                        ipc_answer_fast(callid, 0, vport->rows, vport->cols);
     512                        continue;
     513                case FB_SCROLL:
     514                        i = IPC_GET_ARG1(call);
     515                        if (i > vport->rows || i < (- (int)vport->rows)) {
     516                                retval = EINVAL;
     517                                break;
     518                        }
     519                        if (vport->cursor_active)
     520                                invert_char(vp, vport->cur_col,vport->cur_row);
     521                        scroll_port(vp, i);
     522                        if (vport->cursor_active)
     523                                invert_char(vp, vport->cur_col,vport->cur_row);
     524                        retval = 0;
     525                        break;
     526                case FB_VIEWPORT_SWITCH:
     527                        i = IPC_GET_ARG1(call);
     528                        if (i < 0 || i >= MAX_VIEWPORTS) {
     529                                retval = EINVAL;
     530                                break;
     531                        }
     532                        if (! viewports[i].initialized ) {
     533                                retval = EADDRNOTAVAIL;
     534                                break;
     535                        }
     536                        vp = i;
     537                        vport = &viewports[vp];
     538                        retval = 0;
     539                        break;
     540                case FB_VIEWPORT_CREATE:
     541                        retval = viewport_create(IPC_GET_ARG1(call) >> 16,
     542                                                 IPC_GET_ARG1(call) & 0xffff,
     543                                                 IPC_GET_ARG2(call) >> 16,
     544                                                 IPC_GET_ARG2(call) & 0xffff);
     545                        break;
     546                case FB_VIEWPORT_DELETE:
     547                        i = IPC_GET_ARG1(call);
     548                        if (i < 0 || i >= MAX_VIEWPORTS) {
     549                                retval = EINVAL;
     550                                break;
     551                        }
     552                        if (! viewports[i].initialized ) {
     553                                retval = EADDRNOTAVAIL;
     554                                break;
     555                        }
     556                        viewports[i].initialized = 0;
     557                        retval = 0;
     558                        break;
     559                case FB_SET_STYLE:
     560                        vport->fgcolor = IPC_GET_ARG1(call);
     561                        vport->bgcolor = IPC_GET_ARG2(call);
     562                        retval = 0;
     563                        break;
     564                case FB_GET_RESOLUTION:
     565                        ipc_answer_fast(callid, 0, screen.xres,screen.yres);
    466566                        continue;
    467567                default:
    468568                        retval = ENOENT;
    469569                }
    470                 retval = ENOENT;
    471570                ipc_answer_fast(callid,retval,0,0);
    472571        }
Note: See TracChangeset for help on using the changeset viewer.