Changeset bd02038 in mainline
- Timestamp:
- 2006-06-09T08:29:25Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c891ed39
- Parents:
- e92aabf
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
console/console.c
re92aabf rbd02038 215 215 connection_t *conn; 216 216 static int console_pixmap = -1; 217 int i, j ;217 int i, j, rc; 218 218 keyfield_t *field; 219 219 style_t *style; … … 258 258 interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j); 259 259 /* 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); 261 261 }; 262 262 263 if ((!interbuffer) || (j != 0)) {263 if ((!interbuffer) || (j != 0)) { 264 264 set_style(&conn->screenbuffer.style); 265 265 clrscr(); -
fb/fb.c
re92aabf rbd02038 213 213 * @param color RGB color 214 214 */ 215 static void putpixel( int vp, unsigned int x, unsigned int y, int color)216 { 217 int dx = v iewports[vp].x + x;218 int dy = v iewports[vp].y + y;219 220 if (! viewports[vp].paused)215 static 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)) 221 221 (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],color); 222 222 223 if (v iewports[vp].dbdata) {224 int dline = (y + v iewports[vp].dboffset) % viewports[vp].height;225 int doffset = screen.pixelbytes * (dline * v iewports[vp].width + x);226 (*screen.rgb2scr)(&v iewports[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); 227 227 } 228 228 } 229 229 230 230 /** Get pixel from viewport */ 231 static int getpixel( int vp, unsigned int x, unsigned int y)232 { 233 int dx = v iewports[vp].x + x;234 int dy = v iewports[vp].y + y;231 static int getpixel(viewport_t *vport, unsigned int x, unsigned int y) 232 { 233 int dx = vport->x + x; 234 int dy = vport->y + y; 235 235 236 236 return (*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]); … … 243 243 } 244 244 245 static void draw_rectangle( int vp, unsigned int sx, unsigned int sy,245 static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy, 246 246 unsigned int width, unsigned int height, 247 247 int color) … … 257 257 putpixel_mem(tmpline, x, 0, color); 258 258 259 if (!v iewports[vp].paused) {259 if (!vport->paused) { 260 260 /* Recompute to screen coords */ 261 sx += v iewports[vp].x;262 sy += v iewports[vp].y;261 sx += vport->x; 262 sy += vport->y; 263 263 /* Copy the rest */ 264 264 for (y = sy;y < sy+height; y++) … … 266 266 screen.pixelbytes * width); 267 267 } 268 if (v iewports[vp].dbdata) {268 if (vport->dbdata) { 269 269 for (y=sy;y < sy+height; y++) { 270 int rline = (y + v iewports[vp].dboffset) % viewports[vp].height;271 int rpos = (rline * v iewports[vp].width + sx) * screen.pixelbytes;272 memcpy(&v iewports[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); 273 273 } 274 274 } … … 277 277 278 278 /** 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); 279 static void clear_port(viewport_t *vport) 280 { 281 draw_rectangle(vport, 0, 0, vport->width, vport->height, vport->style.bg_color); 284 282 } 285 283 … … 289 287 * @param rows Positive number - scroll up, negative - scroll down 290 288 */ 291 static void scroll_port_nodb( int vp, int lines)289 static void scroll_port_nodb(viewport_t *vport, int lines) 292 290 { 293 291 int y; 294 292 int startline; 295 293 int endline; 296 viewport_t *vport = &viewports[vp];297 294 298 295 if (lines > 0) { … … 301 298 &screen.fbaddress[POINTPOS(vport->x,y + lines)], 302 299 screen.pixelbytes * vport->width); 303 draw_rectangle(vp , 0, vport->height - lines,300 draw_rectangle(vport, 0, vport->height - lines, 304 301 vport->width, lines, vport->style.bg_color); 305 302 } else if (lines < 0) { … … 309 306 &screen.fbaddress[POINTPOS(vport->x,y - lines)], 310 307 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); 312 309 } 313 310 } 314 311 315 312 /** Refresh given viewport from double buffer */ 316 static void refresh_viewport_db( int vp)313 static void refresh_viewport_db(viewport_t *vport) 317 314 { 318 315 unsigned int y, srcy, srcoff, dsty, dstx; 319 316 320 for (y = 0; y < v iewports[vp].height; y++) {321 srcy = (y + v iewports[vp].dboffset) % viewports[vp].height;322 srcoff = (v iewports[vp].width * srcy) * screen.pixelbytes;323 324 dstx = v iewports[vp].x;325 dsty = v iewports[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; 326 323 327 324 memcpy(&screen.fbaddress[POINTPOS(dstx,dsty)], 328 &v iewports[vp].dbdata[srcoff],329 v iewports[vp].width*screen.pixelbytes);325 &vport->dbdata[srcoff], 326 vport->width*screen.pixelbytes); 330 327 } 331 328 } 332 329 333 330 /** Scroll viewport that has double buffering enabled */ 334 static void scroll_port_db( int vp, int lines)335 { 336 ++v iewports[vp].paused;331 static void scroll_port_db(viewport_t *vport, int lines) 332 { 333 ++vport->paused; 337 334 if (lines > 0) { 338 draw_rectangle(vp , 0, 0, viewports[vp].width, lines,339 v iewports[vp].style.bg_color);340 v iewports[vp].dboffset += lines;341 v iewports[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; 342 339 } else if (lines < 0) { 343 340 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); 357 353 } 358 354 359 355 /** Scrolls viewport given number of lines */ 360 static void scroll_port( int vp, int lines)361 { 362 if (v iewports[vp].dbdata)363 scroll_port_db(vp , lines);356 static void scroll_port(viewport_t *vport, int lines) 357 { 358 if (vport->dbdata) 359 scroll_port_db(vport, lines); 364 360 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 365 static void invert_pixel(viewport_t *vport, unsigned int x, unsigned int y) 366 { 367 putpixel(vport, x, y, ~getpixel(vport, x, y)); 372 368 } 373 369 … … 384 380 * @param transparent If false, print background color 385 381 */ 386 static void draw_glyph( int vp,__u8 glyph, unsigned int sx, unsigned int sy,382 static void draw_glyph(viewport_t *vport,__u8 glyph, unsigned int sx, unsigned int sy, 387 383 style_t style, int transparent) 388 384 { … … 395 391 for (i = 0; i < 8; i++) { 396 392 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); 398 394 else if (!transparent) 399 putpixel(vp , sx + i, sy + y, style.bg_color);395 putpixel(vport, sx + i, sy + y, style.bg_color); 400 396 } 401 397 } … … 403 399 404 400 /** Invert character at given position */ 405 static void invert_char( int vp,unsigned int row, unsigned int col)401 static void invert_char(viewport_t *vport,unsigned int row, unsigned int col) 406 402 { 407 403 unsigned int x; … … 410 406 for (x = 0; x < COL_WIDTH; x++) 411 407 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); 413 409 } 414 410 … … 505 501 506 502 /** Hide cursor if it is shown */ 507 static void cursor_hide(int vp) 508 { 509 viewport_t *vport = &viewports[vp]; 510 503 static void cursor_hide(viewport_t *vport) 504 { 511 505 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); 513 507 vport->cursor_shown = 0; 514 508 } … … 516 510 517 511 /** Show cursor if cursor showing is enabled */ 518 static void cursor_print(int vp) 519 { 520 viewport_t *vport = &viewports[vp]; 521 512 static void cursor_print(viewport_t *vport) 513 { 522 514 /* Do not check for cursor_shown */ 523 515 if (vport->cursor_active) { 524 invert_char(vp , vport->cur_row, vport->cur_col);516 invert_char(vport, vport->cur_row, vport->cur_col); 525 517 vport->cursor_shown = 1; 526 518 } … … 528 520 529 521 /** Invert cursor, if it is enabled */ 530 static void cursor_blink(int vp) 531 { 532 viewport_t *vport = &viewports[vp]; 533 522 static void cursor_blink(viewport_t *vport) 523 { 534 524 if (vport->cursor_shown) 535 cursor_hide(vp );525 cursor_hide(vport); 536 526 else 537 cursor_print(vp );527 cursor_print(vport); 538 528 } 539 529 … … 546 536 * @param transparent If false, print background color with character 547 537 */ 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 538 static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col, 539 style_t style, int transparent) 540 { 552 541 /* Optimize - do not hide cursor if we are going to overwrite it */ 553 542 if (vport->cursor_active && vport->cursor_shown && 554 543 (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); 558 547 559 548 vport->cur_col = col; … … 567 556 vport->cur_row--; 568 557 } 569 cursor_print(vp );558 cursor_print(vport); 570 559 } 571 560 … … 575 564 * @param data Text data fitting exactly into viewport 576 565 */ 577 static void draw_text_data(int vp, keyfield_t *data) 578 { 579 viewport_t *vport = &viewports[vp]; 566 static void draw_text_data(viewport_t *vport, keyfield_t *data) 567 { 580 568 int i; 581 569 char c; 582 570 int col,row; 583 571 584 clear_port(vp );572 clear_port(vport); 585 573 for (i=0; i < vport->cols * vport->rows; i++) { 586 574 if (data[i].character == ' ' && style_same(data[i].style,vport->style)) … … 588 576 col = i % vport->cols; 589 577 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, 591 579 data[i].style, style_same(data[i].style,vport->style)); 592 580 } 593 cursor_print(vp );581 cursor_print(vport); 594 582 } 595 583 … … 633 621 634 622 ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, 635 putpixel_pixmap,pm);623 (putpixel_cb_t)putpixel_pixmap, (void *)pm); 636 624 637 625 return pm; … … 726 714 727 715 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); 729 717 break; 730 718 case FB_DRAW_TEXT_DATA: … … 737 725 break; 738 726 } 739 draw_text_data(vp , interbuffer);727 draw_text_data(vport, interbuffer); 740 728 break; 741 729 default: … … 996 984 997 985 if (!callid) { 998 cursor_blink(vp );986 cursor_blink(vport); 999 987 anims_tick(); 1000 988 continue; … … 1026 1014 ipc_answer_fast(callid,0,0,0); 1027 1015 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); 1029 1017 continue; /* msg already answered */ 1030 1018 case FB_CLEAR: 1031 clear_port(vp );1032 cursor_print(vp );1019 clear_port(vport); 1020 cursor_print(vport); 1033 1021 retval = 0; 1034 1022 break; … … 1041 1029 } 1042 1030 retval = 0; 1043 cursor_hide(vp );1031 cursor_hide(vport); 1044 1032 vport->cur_col = col; 1045 1033 vport->cur_row = row; 1046 cursor_print(vp );1034 cursor_print(vport); 1047 1035 break; 1048 1036 case FB_CURSOR_VISIBILITY: 1049 cursor_hide(vp );1037 cursor_hide(vport); 1050 1038 vport->cursor_active = IPC_GET_ARG1(call); 1051 cursor_print(vp );1039 cursor_print(vport); 1052 1040 retval = 0; 1053 1041 break; … … 1061 1049 break; 1062 1050 } 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); 1066 1054 retval = 0; 1067 1055 break; … … 1100 1088 break; 1101 1089 } 1102 cursor_hide(vp );1090 cursor_hide(vport); 1103 1091 vp = i; 1104 1092 vport = &viewports[vp]; 1105 cursor_print(vp );1093 cursor_print(vport); 1106 1094 retval = 0; 1107 1095 break; -
fb/fb.h
re92aabf rbd02038 37 37 #define _FB_H_ 38 38 39 typedef void (* putpixel_cb_t)(void *,unsigned int, unsigned int, int); 40 39 41 int fb_init(void); 40 42 -
fb/ppm.c
re92aabf rbd02038 85 85 unsigned int sy, 86 86 unsigned int maxwidth, unsigned int maxheight, 87 void (*putpixel)(int,unsigned int, unsigned int, int),int vp)87 putpixel_cb_t putpixel,void *vport) 88 88 { 89 89 unsigned int width, height; … … 122 122 color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[2]*coef; 123 123 124 (*putpixel)(vp , sx+(i % width), sy+(i / width), color);124 (*putpixel)(vport, sx+(i % width), sy+(i / width), color); 125 125 data += 3; 126 126 } -
fb/ppm.h
re92aabf rbd02038 30 30 #define _PPM_H_ 31 31 32 #include "fb.h" 33 32 34 int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx, 33 35 unsigned int sy, 34 36 unsigned int maxwidth, unsigned int maxheight, 35 void (*putpixel)(int,unsigned int, unsigned int, int),int vp);37 putpixel_cb_t fnc,void *); 36 38 int ppm_get_data(unsigned char *data, size_t dtsz, int *width, int *height); 37 39
Note:
See TracChangeset
for help on using the changeset viewer.