Changeset dc033a1 in mainline for uspace/srv/fb/fb.c


Ignore:
Timestamp:
2009-03-22T17:45:15Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
Children:
3fe00ee
Parents:
0a5116db
Message:

Get rid of FB_WRITE. We can use FB_DRAW_TEXT_DATA if we extend it just a little bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fb/fb.c

    r0a5116db rdc033a1  
    867867}
    868868
    869 
    870 /** Draw text data to viewport
     869/** Draw text data to viewport.
    871870 *
    872871 * @param vport Viewport id
    873  * @param data  Text data fitting exactly into viewport
    874  *
    875  */
    876 static void draw_text_data(viewport_t *vport, keyfield_t *data)
    877 {
    878         unsigned int i;
     872 * @param data  Text data.
     873 * @param x     Leftmost column of the area.
     874 * @param y     Topmost row of the area.
     875 * @param w     Number of rows.
     876 * @param h     Number of columns.
     877 */
     878static void draw_text_data(viewport_t *vport, keyfield_t *data, unsigned int x,
     879    unsigned int y, unsigned int w, unsigned int h)
     880{
     881        unsigned int i, j;
    879882        bb_cell_t *bbp;
    880883        attrs_t *a;
    881884        attr_rgb_t rgb;
    882        
    883         for (i = 0; i < vport->cols * vport->rows; i++) {
    884                 unsigned int col = i % vport->cols;
    885                 unsigned int row = i / vport->cols;
    886                
    887                 bbp = &vport->backbuf[BB_POS(vport, col, row)];
    888                 uint8_t glyph = bbp->glyph;
    889 
    890                 a = &data[i].attrs;
    891                 rgb_from_attr(&rgb, a);
    892 
    893                 bbp->glyph = data[i].character;
    894                 bbp->fg_color = rgb.fg_color;
    895                 bbp->bg_color = rgb.bg_color;
    896 
    897                 draw_vp_glyph(vport, false, col, row);
     885
     886        for (j = 0; j < h; j++) {
     887                for (i = 0; i < w; i++) {
     888                        unsigned int col = x + i;
     889                        unsigned int row = y + j;
     890
     891                        bbp = &vport->backbuf[BB_POS(vport, col, row)];
     892                        uint8_t glyph = bbp->glyph;
     893
     894                        a = &data[j * w + i].attrs;
     895                        rgb_from_attr(&rgb, a);
     896
     897                        bbp->glyph = data[j * w + i].character;
     898                        bbp->fg_color = rgb.fg_color;
     899                        bbp->bg_color = rgb.bg_color;
     900
     901                        draw_vp_glyph(vport, false, col, row);
     902                }
    898903        }
    899904        cursor_show(vport);
     
    9991004        unsigned int x;
    10001005        unsigned int y;
     1006        unsigned int w;
     1007        unsigned int h;
    10011008       
    10021009        switch (IPC_GET_METHOD(*call)) {
     
    10591066                break;
    10601067        case FB_DRAW_TEXT_DATA:
     1068                x = IPC_GET_ARG1(*call);
     1069                y = IPC_GET_ARG2(*call);
     1070                w = IPC_GET_ARG3(*call);
     1071                h = IPC_GET_ARG4(*call);
    10611072                if (!interbuffer) {
    10621073                        retval = EINVAL;
    10631074                        break;
    10641075                }
    1065                 if (intersize < vport->cols * vport->rows * sizeof(*interbuffer)) {
     1076                if (x + w > vport->cols || y + h > vport->rows) {
    10661077                        retval = EINVAL;
    10671078                        break;
    10681079                }
    1069                 draw_text_data(vport, interbuffer);
     1080                if (intersize < w * h * sizeof(*interbuffer)) {
     1081                        retval = EINVAL;
     1082                        break;
     1083                }
     1084                draw_text_data(vport, interbuffer, x, y, w, h);
    10701085                break;
    10711086        default:
     
    14721487        return rgb_from_idx(&vport->attr, fg_color, bg_color, flags);
    14731488}
    1474 
    1475 #define FB_WRITE_BUF_SIZE 256
    1476 static char fb_write_buf[FB_WRITE_BUF_SIZE];
    1477 
    1478 static void fb_write(viewport_t *vport, ipc_callid_t rid, ipc_call_t *request)
    1479 {
    1480         int row, col;
    1481         ipc_callid_t callid;
    1482         size_t len;
    1483         size_t i;
    1484 
    1485         row = IPC_GET_ARG1(*request);
    1486         col = IPC_GET_ARG2(*request);
    1487 
    1488         if ((col >= vport->cols) || (row >= vport->rows)) {
    1489                 ipc_answer_0(callid, EINVAL);
    1490                 ipc_answer_0(rid, EINVAL);
    1491                 return;
    1492         }
    1493 
    1494         if (!ipc_data_write_receive(&callid, &len)) {
    1495                 ipc_answer_0(callid, EINVAL);
    1496                 ipc_answer_0(rid, EINVAL);
    1497                 return;
    1498         }
    1499 
    1500         if (len > FB_WRITE_BUF_SIZE)
    1501                 len = FB_WRITE_BUF_SIZE;
    1502         if (len >= vport->cols - col)
    1503                 len = vport->cols - col;
    1504 
    1505         (void) ipc_data_write_finalize(callid, fb_write_buf, len);
    1506 
    1507         for (i = 0; i < len; i++) {
    1508                 draw_char(vport, fb_write_buf[i], col++, row);
    1509         }
    1510 
    1511         ipc_answer_1(rid, EOK, len);
    1512 }
    1513 
    15141489
    15151490/** Function for handling connections to FB
     
    15871562                        /* Message already answered */
    15881563                        continue;
    1589                 case FB_WRITE:
    1590                         fb_write(vport, callid, &call);
    1591                        
    1592                         /* Message already answered */
    1593                         continue;
    15941564                case FB_CLEAR:
    15951565                        vport_clear(vport);
Note: See TracChangeset for help on using the changeset viewer.