Rev 4164 | Rev 4211 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4164 | Rev 4167 | ||
|---|---|---|---|
| Line 864... | Line 864... | ||
| 864 | } |
864 | } |
| 865 | 865 | ||
| 866 | cursor_show(vport); |
866 | cursor_show(vport); |
| 867 | } |
867 | } |
| 868 | 868 | ||
| 869 | - | ||
| 870 | /** Draw text data to viewport |
869 | /** Draw text data to viewport. |
| 871 | * |
870 | * |
| 872 | * @param vport Viewport id |
871 | * @param vport Viewport id |
| 873 | * @param data Text data fitting exactly into viewport |
872 | * @param data Text data. |
| - | 873 | * @param x Leftmost column of the area. |
|
| - | 874 | * @param y Topmost row of the area. |
|
| 874 | * |
875 | * @param w Number of rows. |
| - | 876 | * @param h Number of columns. |
|
| 875 | */ |
877 | */ |
| 876 | static void draw_text_data(viewport_t *vport, keyfield_t *data) |
878 | static void draw_text_data(viewport_t *vport, keyfield_t *data, unsigned int x, |
| - | 879 | unsigned int y, unsigned int w, unsigned int h) |
|
| 877 | { |
880 | { |
| 878 | unsigned int i; |
881 | unsigned int i, j; |
| 879 | bb_cell_t *bbp; |
882 | bb_cell_t *bbp; |
| 880 | attrs_t *a; |
883 | attrs_t *a; |
| 881 | attr_rgb_t rgb; |
884 | 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 | 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 | ||
| 893 | bbp->glyph = data[i].character; |
897 | bbp->glyph = data[j * w + i].character; |
| 894 | bbp->fg_color = rgb.fg_color; |
898 | bbp->fg_color = rgb.fg_color; |
| 895 | bbp->bg_color = rgb.bg_color; |
899 | bbp->bg_color = rgb.bg_color; |
| 896 | 900 | ||
| 897 | draw_vp_glyph(vport, false, col, row); |
901 | draw_vp_glyph(vport, false, col, row); |
| - | 902 | } |
|
| 898 | } |
903 | } |
| 899 | cursor_show(vport); |
904 | cursor_show(vport); |
| 900 | } |
905 | } |
| 901 | 906 | ||
| 902 | 907 | ||
| Line 996... | Line 1001... | ||
| 996 | bool handled = true; |
1001 | bool handled = true; |
| 997 | int retval = EOK; |
1002 | int retval = EOK; |
| 998 | viewport_t *vport = &viewports[vp]; |
1003 | viewport_t *vport = &viewports[vp]; |
| 999 | unsigned int x; |
1004 | unsigned int x; |
| 1000 | unsigned int y; |
1005 | unsigned int y; |
| - | 1006 | unsigned int w; |
|
| - | 1007 | unsigned int h; |
|
| 1001 | 1008 | ||
| 1002 | switch (IPC_GET_METHOD(*call)) { |
1009 | switch (IPC_GET_METHOD(*call)) { |
| 1003 | case IPC_M_SHARE_OUT: |
1010 | case IPC_M_SHARE_OUT: |
| 1004 | /* We accept one area for data interchange */ |
1011 | /* We accept one area for data interchange */ |
| 1005 | if (IPC_GET_ARG1(*call) == shm_id) { |
1012 | if (IPC_GET_ARG1(*call) == shm_id) { |
| Line 1056... | Line 1063... | ||
| 1056 | 1063 | ||
| 1057 | ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), |
1064 | ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), |
| 1058 | IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport); |
1065 | IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport); |
| 1059 | break; |
1066 | break; |
| 1060 | case FB_DRAW_TEXT_DATA: |
1067 | 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); |
|
| 1061 | if (!interbuffer) { |
1072 | if (!interbuffer) { |
| 1062 | retval = EINVAL; |
1073 | retval = EINVAL; |
| 1063 | break; |
1074 | break; |
| 1064 | } |
1075 | } |
| - | 1076 | if (x + w > vport->cols || y + h > vport->rows) { |
|
| - | 1077 | retval = EINVAL; |
|
| - | 1078 | break; |
|
| - | 1079 | } |
|
| 1065 | if (intersize < vport->cols * vport->rows * sizeof(*interbuffer)) { |
1080 | if (intersize < w * h * sizeof(*interbuffer)) { |
| 1066 | retval = EINVAL; |
1081 | retval = EINVAL; |
| 1067 | break; |
1082 | break; |
| 1068 | } |
1083 | } |
| 1069 | draw_text_data(vport, interbuffer); |
1084 | draw_text_data(vport, interbuffer, x, y, w, h); |
| 1070 | break; |
1085 | break; |
| 1071 | default: |
1086 | default: |
| 1072 | handled = false; |
1087 | handled = false; |
| 1073 | } |
1088 | } |
| 1074 | 1089 | ||
| Line 1470... | Line 1485... | ||
| 1470 | ipcarg_t bg_color, ipcarg_t flags) |
1485 | ipcarg_t bg_color, ipcarg_t flags) |
| 1471 | { |
1486 | { |
| 1472 | return rgb_from_idx(&vport->attr, fg_color, bg_color, flags); |
1487 | return rgb_from_idx(&vport->attr, fg_color, bg_color, flags); |
| 1473 | } |
1488 | } |
| 1474 | 1489 | ||
| 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 | - | ||
| 1514 | - | ||
| 1515 | /** Function for handling connections to FB |
1490 | /** Function for handling connections to FB |
| 1516 | * |
1491 | * |
| 1517 | */ |
1492 | */ |
| 1518 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
1493 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
| 1519 | { |
1494 | { |
| Line 1584... | Line 1559... | ||
| 1584 | 1559 | ||
| 1585 | draw_char(vport, glyph, col, row); |
1560 | draw_char(vport, glyph, col, row); |
| 1586 | 1561 | ||
| 1587 | /* Message already answered */ |
1562 | /* Message already answered */ |
| 1588 | continue; |
1563 | continue; |
| 1589 | case FB_WRITE: |
- | |
| 1590 | fb_write(vport, callid, &call); |
- | |
| 1591 | - | ||
| 1592 | /* Message already answered */ |
- | |
| 1593 | continue; |
- | |
| 1594 | case FB_CLEAR: |
1564 | case FB_CLEAR: |
| 1595 | vport_clear(vport); |
1565 | vport_clear(vport); |
| 1596 | cursor_show(vport); |
1566 | cursor_show(vport); |
| 1597 | retval = EOK; |
1567 | retval = EOK; |
| 1598 | break; |
1568 | break; |