Changeset dc033a1 in mainline for uspace/srv/fb
- Timestamp:
- 2009-03-22T17:45:15Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3fe00ee
- Parents:
- 0a5116db
- Location:
- uspace/srv/fb
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fb/ega.c
r0a5116db rdc033a1 79 79 static unsigned int scr_width; 80 80 static unsigned int scr_height; 81 static char*scr_addr;81 static uint8_t *scr_addr; 82 82 83 83 static unsigned int style; … … 152 152 } 153 153 154 static void draw_text_data(keyfield_t *data) 155 { 156 int i; 157 158 for (i = 0; i < scr_width * scr_height; i++) { 159 scr_addr[i * 2] = data[i].character; 160 scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs); 154 /** Draw text data to viewport. 155 * 156 * @param vport Viewport id 157 * @param data Text data. 158 * @param x Leftmost column of the area. 159 * @param y Topmost row of the area. 160 * @param w Number of rows. 161 * @param h Number of columns. 162 */ 163 static void draw_text_data(keyfield_t *data, unsigned int x, 164 unsigned int y, unsigned int w, unsigned int h) 165 { 166 unsigned int i, j; 167 keyfield_t *field; 168 uint8_t *dp; 169 170 for (j = 0; j < h; j++) { 171 for (i = 0; i < w; i++) { 172 field = &data[j * w + i]; 173 dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))]; 174 175 dp[0] = field->character; 176 dp[1] = attr_to_ega_style(&field->attrs); 177 } 161 178 } 162 179 } … … 232 249 } 233 250 234 #define FB_WRITE_BUF_SIZE 256235 static char fb_write_buf[FB_WRITE_BUF_SIZE];236 237 static void fb_write(ipc_callid_t rid, ipc_call_t *request)238 {239 int row, col;240 ipc_callid_t callid;241 size_t len;242 size_t i;243 244 row = IPC_GET_ARG1(*request);245 col = IPC_GET_ARG2(*request);246 247 if ((col >= scr_width) || (row >= scr_height)) {248 ipc_answer_0(callid, EINVAL);249 ipc_answer_0(rid, EINVAL);250 return;251 }252 253 if (!ipc_data_write_receive(&callid, &len)) {254 ipc_answer_0(callid, EINVAL);255 ipc_answer_0(rid, EINVAL);256 return;257 }258 259 if (len > FB_WRITE_BUF_SIZE)260 len = FB_WRITE_BUF_SIZE;261 if (len >= scr_width - col)262 len = scr_width - col;263 264 (void) ipc_data_write_finalize(callid, fb_write_buf, len);265 266 for (i = 0; i < len; i++) {267 printchar(fb_write_buf[i], row, col++);268 }269 270 ipc_answer_1(rid, EOK, len);271 }272 273 251 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) 274 252 { … … 277 255 ipc_call_t call; 278 256 char c; 279 unsigned int row, col ;257 unsigned int row, col, w, h; 280 258 int bg_color, fg_color, attr; 281 259 uint32_t bg_rgb, fg_rgb; … … 310 288 break; 311 289 case FB_DRAW_TEXT_DATA: 290 col = IPC_GET_ARG1(call); 291 row = IPC_GET_ARG2(call); 292 w = IPC_GET_ARG3(call); 293 h = IPC_GET_ARG4(call); 312 294 if (!interbuf) { 313 295 retval = EINVAL; 314 296 break; 315 297 } 316 draw_text_data(interbuf); 298 if (col + w > scr_width || row + h > scr_height) { 299 retval = EINVAL; 300 break; 301 } 302 draw_text_data(interbuf, col, row, w, h); 317 303 retval = 0; 318 304 break; … … 335 321 retval = 0; 336 322 break; 337 case FB_WRITE:338 fb_write(callid, &call);339 340 /* Message already answered */341 continue;342 323 case FB_CURSOR_GOTO: 343 324 row = IPC_GET_ARG1(call); -
uspace/srv/fb/fb.c
r0a5116db rdc033a1 867 867 } 868 868 869 870 /** Draw text data to viewport 869 /** Draw text data to viewport. 871 870 * 872 871 * @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 */ 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) 880 { 881 unsigned int i, j; 879 882 bb_cell_t *bbp; 880 883 attrs_t *a; 881 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 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 } 898 903 } 899 904 cursor_show(vport); … … 999 1004 unsigned int x; 1000 1005 unsigned int y; 1006 unsigned int w; 1007 unsigned int h; 1001 1008 1002 1009 switch (IPC_GET_METHOD(*call)) { … … 1059 1066 break; 1060 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 1072 if (!interbuffer) { 1062 1073 retval = EINVAL; 1063 1074 break; 1064 1075 } 1065 if ( intersize < vport->cols * vport->rows * sizeof(*interbuffer)) {1076 if (x + w > vport->cols || y + h > vport->rows) { 1066 1077 retval = EINVAL; 1067 1078 break; 1068 1079 } 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); 1070 1085 break; 1071 1086 default: … … 1472 1487 return rgb_from_idx(&vport->attr, fg_color, bg_color, flags); 1473 1488 } 1474 1475 #define FB_WRITE_BUF_SIZE 2561476 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 1489 1515 1490 /** Function for handling connections to FB … … 1587 1562 /* Message already answered */ 1588 1563 continue; 1589 case FB_WRITE:1590 fb_write(vport, callid, &call);1591 1592 /* Message already answered */1593 continue;1594 1564 case FB_CLEAR: 1595 1565 vport_clear(vport); -
uspace/srv/fb/msim.c
r0a5116db rdc033a1 46 46 47 47 #define WIDTH 80 48 #define HEIGHT 2 548 #define HEIGHT 24 49 49 50 50 static char *virt_addr; -
uspace/srv/fb/serial_console.c
r0a5116db rdc033a1 224 224 } 225 225 226 static void draw_text_data(keyfield_t *data) 227 { 228 int i, j; 226 /** Draw text data to viewport. 227 * 228 * @param vport Viewport id 229 * @param data Text data. 230 * @param x Leftmost column of the area. 231 * @param y Topmost row of the area. 232 * @param w Number of rows. 233 * @param h Number of columns. 234 */ 235 static void draw_text_data(keyfield_t *data, unsigned int x, 236 unsigned int y, unsigned int w, unsigned int h) 237 { 238 unsigned int i, j; 239 keyfield_t *field; 229 240 attrs_t *a0, *a1; 230 241 231 serial_goto( 0, 0);242 serial_goto(y, x); 232 243 a0 = &data[0].attrs; 233 244 serial_set_attrs(a0); 234 245 235 for (i = 0; i < scr_height; i++) { 236 for (j = 0; j < scr_width; j++) { 237 a1 = &data[i * scr_width + j].attrs; 246 for (j = 0; j < h; j++) { 247 if (j > 0 && w != scr_width) 248 serial_goto(y, x); 249 250 for (i = 0; i < w; i++) { 251 unsigned int col = x + i; 252 unsigned int row = y + j; 253 254 field = &data[j * w + i]; 255 256 a1 = &field->attrs; 238 257 if (!attrs_same(*a0, *a1)) 239 258 serial_set_attrs(a1); 240 (*putc_function)( data[i * scr_width + j].character);259 (*putc_function)(field->character); 241 260 a0 = a1; 242 261 } … … 246 265 int lastcol = 0; 247 266 int lastrow = 0; 248 249 #define FB_WRITE_BUF_SIZE 256250 static char fb_write_buf[FB_WRITE_BUF_SIZE];251 252 static void fb_write(ipc_callid_t rid, ipc_call_t *request)253 {254 int row, col;255 ipc_callid_t callid;256 size_t len;257 size_t i;258 259 row = IPC_GET_ARG1(*request);260 col = IPC_GET_ARG2(*request);261 262 if ((col >= scr_width) || (row >= scr_height)) {263 ipc_answer_0(callid, EINVAL);264 ipc_answer_0(rid, EINVAL);265 return;266 }267 268 if (!ipc_data_write_receive(&callid, &len)) {269 ipc_answer_0(callid, EINVAL);270 ipc_answer_0(rid, EINVAL);271 return;272 }273 274 if (len > FB_WRITE_BUF_SIZE)275 len = FB_WRITE_BUF_SIZE;276 if (len >= scr_width - col)277 len = scr_width - col;278 279 (void) ipc_data_write_finalize(callid, fb_write_buf, len);280 281 if ((lastcol != col) || (lastrow != row))282 serial_goto(row, col);283 284 for (i = 0; i < len; i++) {285 (*putc_function)(fb_write_buf[i]);286 }287 288 lastcol = col + len;289 lastrow = row;290 291 ipc_answer_1(rid, EOK, len);292 }293 267 294 268 /** … … 304 278 305 279 char c; 306 int newcol; 307 int newrow; 280 int col, row, w, h; 308 281 int fgcolor; 309 282 int bgcolor; … … 346 319 break; 347 320 case FB_DRAW_TEXT_DATA: 321 col = IPC_GET_ARG1(call); 322 row = IPC_GET_ARG2(call); 323 w = IPC_GET_ARG3(call); 324 h = IPC_GET_ARG4(call); 348 325 if (!interbuf) { 349 326 retval = EINVAL; 350 327 break; 351 328 } 352 draw_text_data(interbuf); 329 if (col + w > scr_width || row + h > scr_height) { 330 retval = EINVAL; 331 break; 332 } 333 draw_text_data(interbuf, col, row, w, h); 334 lastrow = row + h - 1; 335 lastcol = col + w; 353 336 retval = 0; 354 337 break; 355 338 case FB_PUTCHAR: 356 339 c = IPC_GET_ARG1(call); 357 newrow = IPC_GET_ARG2(call);358 newcol = IPC_GET_ARG3(call);359 if ((lastcol != newcol) || (lastrow != newrow))360 serial_goto( newrow, newcol);361 lastcol = newcol + 1;362 lastrow = newrow;340 row = IPC_GET_ARG2(call); 341 col = IPC_GET_ARG3(call); 342 if ((lastcol != col) || (lastrow != row)) 343 serial_goto(row, col); 344 lastcol = col + 1; 345 lastrow = row; 363 346 (*putc_function)(c); 364 347 retval = 0; 365 348 break; 366 case FB_WRITE:367 fb_write(callid, &call);368 369 /* Message already answered */370 continue;371 349 case FB_CURSOR_GOTO: 372 newrow = IPC_GET_ARG1(call);373 newcol = IPC_GET_ARG2(call);374 serial_goto( newrow, newcol);375 lastrow = newrow;376 lastcol = newcol;350 row = IPC_GET_ARG1(call); 351 col = IPC_GET_ARG2(call); 352 serial_goto(row, col); 353 lastrow = row; 354 lastcol = col; 377 355 retval = 0; 378 356 break; -
uspace/srv/fb/ski.c
r0a5116db rdc033a1 48 48 49 49 #define WIDTH 80 50 #define HEIGHT 2 550 #define HEIGHT 24 51 51 52 52 /** Display character on ski debug console
Note:
See TracChangeset
for help on using the changeset viewer.
