Rev 4153 | Rev 4581 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4153 | Rev 4263 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | #include "pointer_mask.xbm" |
66 | #include "pointer_mask.xbm" |
67 | 67 | ||
68 | #define DEFAULT_BGCOLOR 0xf0f0f0 |
68 | #define DEFAULT_BGCOLOR 0xf0f0f0 |
69 | #define DEFAULT_FGCOLOR 0x000000 |
69 | #define DEFAULT_FGCOLOR 0x000000 |
70 | 70 | ||
- | 71 | #define GLYPH_UNAVAIL '?' |
|
- | 72 | ||
71 | #define MAX_ANIM_LEN 8 |
73 | #define MAX_ANIM_LEN 8 |
72 | #define MAX_ANIMATIONS 4 |
74 | #define MAX_ANIMATIONS 4 |
73 | #define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */ |
75 | #define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */ |
74 | #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ |
76 | #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ |
75 | 77 | ||
76 | /** Function to render a pixel from a RGB value. */ |
78 | /** Function to render a pixel from a RGB value. */ |
77 | typedef void (*rgb_conv_t)(void *, uint32_t); |
79 | typedef void (*rgb_conv_t)(void *, uint32_t); |
78 | 80 | ||
79 | /** Function to draw a glyph. */ |
81 | /** Function to draw a glyph. */ |
80 | typedef void (*dg_t)(unsigned int x, unsigned int y, bool cursor, |
82 | typedef void (*dg_t)(unsigned int x, unsigned int y, bool cursor, |
81 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
83 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color); |
82 | 84 | ||
83 | struct { |
85 | struct { |
84 | uint8_t *fb_addr; |
86 | uint8_t *fb_addr; |
85 | 87 | ||
86 | unsigned int xres; |
88 | unsigned int xres; |
Line 89... | Line 91... | ||
89 | unsigned int scanline; |
91 | unsigned int scanline; |
90 | unsigned int glyphscanline; |
92 | unsigned int glyphscanline; |
91 | 93 | ||
92 | unsigned int pixelbytes; |
94 | unsigned int pixelbytes; |
93 | unsigned int glyphbytes; |
95 | unsigned int glyphbytes; |
- | 96 | ||
- | 97 | /** Pre-rendered mask for rendering glyphs. Specific for the visual. */ |
|
- | 98 | uint8_t *glyphs; |
|
94 | 99 | ||
95 | rgb_conv_t rgb_conv; |
100 | rgb_conv_t rgb_conv; |
96 | } screen; |
101 | } screen; |
97 | 102 | ||
98 | /** Backbuffer character cell. */ |
103 | /** Backbuffer character cell. */ |
99 | typedef struct { |
104 | typedef struct { |
100 | uint8_t glyph; |
105 | uint32_t glyph; |
101 | uint32_t fg_color; |
106 | uint32_t fg_color; |
102 | uint32_t bg_color; |
107 | uint32_t bg_color; |
103 | } bb_cell_t; |
108 | } bb_cell_t; |
104 | 109 | ||
105 | typedef struct { |
110 | typedef struct { |
Line 118... | Line 123... | ||
118 | */ |
123 | */ |
119 | 124 | ||
120 | /** Current attributes. */ |
125 | /** Current attributes. */ |
121 | attr_rgb_t attr; |
126 | attr_rgb_t attr; |
122 | 127 | ||
123 | /** Pre-rendered mask for rendering glyphs. Different viewports |
- | |
124 | * might use different drawing functions depending on whether their |
- | |
125 | * scanlines are aligned on a word boundary.*/ |
- | |
126 | uint8_t *glyphs; |
- | |
127 | - | ||
128 | uint8_t *bgpixel; |
128 | uint8_t *bgpixel; |
129 | 129 | ||
- | 130 | /** |
|
130 | /** Glyph drawing function for this viewport. */ |
131 | * Glyph drawing function for this viewport. Different viewports |
- | 132 | * might use different drawing functions depending on whether their |
|
- | 133 | * scanlines are aligned on a word boundary. |
|
- | 134 | */ |
|
131 | dg_t dglyph; |
135 | dg_t dglyph; |
132 | 136 | ||
133 | /* Auto-cursor position */ |
137 | /* Auto-cursor position */ |
134 | bool cursor_active; |
138 | bool cursor_active; |
135 | unsigned int cur_col; |
139 | unsigned int cur_col; |
Line 192... | Line 196... | ||
192 | 196 | ||
193 | static int fb_set_color(viewport_t *vport, ipcarg_t fg_color, |
197 | static int fb_set_color(viewport_t *vport, ipcarg_t fg_color, |
194 | ipcarg_t bg_color, ipcarg_t attr); |
198 | ipcarg_t bg_color, ipcarg_t attr); |
195 | 199 | ||
196 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
200 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
197 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
201 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color); |
198 | static void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
202 | static void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
199 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
203 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color); |
200 | 204 | ||
201 | static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col, |
205 | static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col, |
202 | unsigned int row); |
206 | unsigned int row); |
203 | 207 | ||
204 | 208 | ||
Line 384... | Line 388... | ||
384 | */ |
388 | */ |
385 | static void vport_scroll(viewport_t *vport, int lines) |
389 | static void vport_scroll(viewport_t *vport, int lines) |
386 | { |
390 | { |
387 | unsigned int row, col; |
391 | unsigned int row, col; |
388 | unsigned int x, y; |
392 | unsigned int x, y; |
389 | uint8_t glyph; |
393 | uint32_t glyph; |
390 | uint32_t fg_color; |
394 | uint32_t fg_color; |
391 | uint32_t bg_color; |
395 | uint32_t bg_color; |
392 | bb_cell_t *bbp, *xbp; |
396 | bb_cell_t *bbp, *xbp; |
393 | 397 | ||
394 | /* |
398 | /* |
Line 417... | Line 421... | ||
417 | glyph = 0; |
421 | glyph = 0; |
418 | fg_color = vport->attr.fg_color; |
422 | fg_color = vport->attr.fg_color; |
419 | bg_color = vport->attr.bg_color; |
423 | bg_color = vport->attr.bg_color; |
420 | } |
424 | } |
421 | 425 | ||
422 | (*vport->dglyph)(x, y, false, vport->glyphs, glyph, |
426 | (*vport->dglyph)(x, y, false, screen.glyphs, glyph, |
423 | fg_color, bg_color); |
427 | fg_color, bg_color); |
424 | x += FONT_WIDTH; |
428 | x += FONT_WIDTH; |
425 | } |
429 | } |
426 | y += FONT_SCANLINES; |
430 | y += FONT_SCANLINES; |
427 | } |
431 | } |
Line 445... | Line 449... | ||
445 | 449 | ||
446 | /** Render glyphs |
450 | /** Render glyphs |
447 | * |
451 | * |
448 | * Convert glyphs from device independent font |
452 | * Convert glyphs from device independent font |
449 | * description to current visual representation. |
453 | * description to current visual representation. |
450 | * |
- | |
451 | * @param vport Viewport |
- | |
452 | * |
- | |
453 | */ |
454 | */ |
454 | static void render_glyphs(viewport_t* vport) |
455 | static void render_glyphs(void) |
455 | { |
456 | { |
456 | unsigned int glyph; |
457 | unsigned int glyph; |
457 | 458 | ||
458 | for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { |
459 | for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { |
459 | unsigned int y; |
460 | unsigned int y; |
460 | 461 | ||
461 | for (y = 0; y < FONT_SCANLINES; y++) { |
462 | for (y = 0; y < FONT_SCANLINES; y++) { |
462 | unsigned int x; |
463 | unsigned int x; |
463 | 464 | ||
464 | for (x = 0; x < FONT_WIDTH; x++) { |
465 | for (x = 0; x < FONT_WIDTH; x++) { |
465 | screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
466 | screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
466 | (fb_font[glyph * FONT_SCANLINES + y] & (1 << (7 - x))) |
467 | (fb_font[glyph][y] & (1 << (7 - x))) |
467 | ? 0xffffff : 0x000000); |
468 | ? 0xffffff : 0x000000); |
468 | 469 | ||
469 | screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
470 | screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
470 | (fb_font[glyph * FONT_SCANLINES + y] & (1 << (7 - x))) |
471 | (fb_font[glyph][y] & (1 << (7 - x))) |
471 | ? 0x000000 : 0xffffff); |
472 | ? 0x000000 : 0xffffff); |
472 | } |
473 | } |
473 | } |
474 | } |
474 | } |
475 | } |
475 | - | ||
476 | screen.rgb_conv(vport->bgpixel, vport->attr.bg_color); |
- | |
477 | } |
476 | } |
478 | 477 | ||
479 | 478 | ||
480 | /** Create new viewport |
479 | /** Create new viewport |
481 | * |
480 | * |
Line 500... | Line 499... | ||
500 | return ELIMIT; |
499 | return ELIMIT; |
501 | 500 | ||
502 | unsigned int cols = width / FONT_WIDTH; |
501 | unsigned int cols = width / FONT_WIDTH; |
503 | unsigned int rows = height / FONT_SCANLINES; |
502 | unsigned int rows = height / FONT_SCANLINES; |
504 | unsigned int bbsize = cols * rows * sizeof(bb_cell_t); |
503 | unsigned int bbsize = cols * rows * sizeof(bb_cell_t); |
505 | unsigned int glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
- | |
506 | unsigned int word_size = sizeof(unsigned long); |
504 | unsigned int word_size = sizeof(unsigned long); |
507 | 505 | ||
508 | bb_cell_t *backbuf = (bb_cell_t *) malloc(bbsize); |
506 | bb_cell_t *backbuf = (bb_cell_t *) malloc(bbsize); |
509 | if (!backbuf) |
507 | if (!backbuf) |
510 | return ENOMEM; |
508 | return ENOMEM; |
511 | 509 | ||
512 | uint8_t *glyphs = (uint8_t *) malloc(glyphsize); |
- | |
513 | if (!glyphs) { |
- | |
514 | free(backbuf); |
- | |
515 | return ENOMEM; |
- | |
516 | } |
- | |
517 | - | ||
518 | uint8_t *bgpixel = (uint8_t *) malloc(screen.pixelbytes); |
510 | uint8_t *bgpixel = (uint8_t *) malloc(screen.pixelbytes); |
519 | if (!bgpixel) { |
511 | if (!bgpixel) { |
520 | free(glyphs); |
- | |
521 | free(backbuf); |
512 | free(backbuf); |
522 | return ENOMEM; |
513 | return ENOMEM; |
523 | } |
514 | } |
524 | 515 | ||
525 | backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR); |
516 | backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR); |
526 | memset(glyphs, 0, glyphsize); |
- | |
527 | memset(bgpixel, 0, screen.pixelbytes); |
517 | memset(bgpixel, 0, screen.pixelbytes); |
528 | 518 | ||
529 | viewports[i].x = x; |
519 | viewports[i].x = x; |
530 | viewports[i].y = y; |
520 | viewports[i].y = y; |
531 | viewports[i].width = width; |
521 | viewports[i].width = width; |
Line 535... | Line 525... | ||
535 | viewports[i].rows = rows; |
525 | viewports[i].rows = rows; |
536 | 526 | ||
537 | viewports[i].attr.bg_color = DEFAULT_BGCOLOR; |
527 | viewports[i].attr.bg_color = DEFAULT_BGCOLOR; |
538 | viewports[i].attr.fg_color = DEFAULT_FGCOLOR; |
528 | viewports[i].attr.fg_color = DEFAULT_FGCOLOR; |
539 | 529 | ||
540 | viewports[i].glyphs = glyphs; |
- | |
541 | viewports[i].bgpixel = bgpixel; |
530 | viewports[i].bgpixel = bgpixel; |
542 | 531 | ||
543 | /* |
532 | /* |
544 | * Conditions necessary to select aligned version: |
533 | * Conditions necessary to select aligned version: |
545 | * |
534 | * |
Line 565... | Line 554... | ||
565 | viewports[i].bbsize = bbsize; |
554 | viewports[i].bbsize = bbsize; |
566 | viewports[i].backbuf = backbuf; |
555 | viewports[i].backbuf = backbuf; |
567 | 556 | ||
568 | viewports[i].initialized = true; |
557 | viewports[i].initialized = true; |
569 | 558 | ||
570 | render_glyphs(&viewports[i]); |
559 | screen.rgb_conv(viewports[i].bgpixel, viewports[i].attr.bg_color); |
571 | 560 | ||
572 | return i; |
561 | return i; |
573 | } |
562 | } |
574 | 563 | ||
575 | 564 | ||
Line 583... | Line 572... | ||
583 | * |
572 | * |
584 | */ |
573 | */ |
585 | static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
574 | static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
586 | unsigned int scan, unsigned int visual) |
575 | unsigned int scan, unsigned int visual) |
587 | { |
576 | { |
- | 577 | unsigned int glyphsize; |
|
- | 578 | uint8_t *glyphs; |
|
588 | switch (visual) { |
579 | switch (visual) { |
589 | case VISUAL_INDIRECT_8: |
580 | case VISUAL_INDIRECT_8: |
590 | screen.rgb_conv = rgb_323; |
581 | screen.rgb_conv = rgb_323; |
591 | screen.pixelbytes = 1; |
582 | screen.pixelbytes = 1; |
592 | break; |
583 | break; |
Line 627... | Line 618... | ||
627 | screen.yres = yres; |
618 | screen.yres = yres; |
628 | screen.scanline = scan; |
619 | screen.scanline = scan; |
629 | 620 | ||
630 | screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
621 | screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
631 | screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
622 | screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
- | 623 | ||
- | 624 | glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
|
- | 625 | glyphs = (uint8_t *) malloc(glyphsize); |
|
- | 626 | if (!glyphs) |
|
- | 627 | return false; |
|
- | 628 | ||
- | 629 | memset(glyphs, 0, glyphsize); |
|
- | 630 | screen.glyphs = glyphs; |
|
- | 631 | ||
- | 632 | render_glyphs(); |
|
632 | 633 | ||
633 | /* Create first viewport */ |
634 | /* Create first viewport */ |
634 | vport_create(0, 0, xres, yres); |
635 | vport_create(0, 0, xres, yres); |
635 | 636 | ||
636 | return true; |
637 | return true; |
Line 657... | Line 658... | ||
657 | * @param glyph Code of the glyph to draw. |
658 | * @param glyph Code of the glyph to draw. |
658 | * @param fg_color Foreground color. |
659 | * @param fg_color Foreground color. |
659 | * @param bg_color Backgroudn color. |
660 | * @param bg_color Backgroudn color. |
660 | */ |
661 | */ |
661 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
662 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
662 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color) |
663 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
663 | { |
664 | { |
664 | unsigned int i, yd; |
665 | unsigned int i, yd; |
665 | unsigned long fg_buf, bg_buf; |
666 | unsigned long fg_buf, bg_buf; |
666 | unsigned long *maskp, *dp; |
667 | unsigned long *maskp, *dp; |
667 | unsigned long mask; |
668 | unsigned long mask; |
Line 676... | Line 677... | ||
676 | fg_color); |
677 | fg_color); |
677 | screen.rgb_conv(&((uint8_t *)&bg_buf)[i * screen.pixelbytes], |
678 | screen.rgb_conv(&((uint8_t *)&bg_buf)[i * screen.pixelbytes], |
678 | bg_color); |
679 | bg_color); |
679 | } |
680 | } |
680 | 681 | ||
681 | - | ||
682 | /* Pointer to the current position in the mask. */ |
682 | /* Pointer to the current position in the mask. */ |
683 | maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)]; |
683 | maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)]; |
684 | 684 | ||
685 | /* Pointer to the current position on the screen. */ |
685 | /* Pointer to the current position on the screen. */ |
686 | dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)]; |
686 | dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)]; |
Line 718... | Line 718... | ||
718 | * @param glyph Code of the glyph to draw. |
718 | * @param glyph Code of the glyph to draw. |
719 | * @param fg_color Foreground color. |
719 | * @param fg_color Foreground color. |
720 | * @param bg_color Backgroudn color. |
720 | * @param bg_color Backgroudn color. |
721 | */ |
721 | */ |
722 | void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
722 | void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
723 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color) |
723 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
724 | { |
724 | { |
725 | unsigned int i, j, yd; |
725 | unsigned int i, j, yd; |
726 | uint8_t fg_buf[4], bg_buf[4]; |
726 | uint8_t fg_buf[4], bg_buf[4]; |
727 | uint8_t *dp, *sp; |
727 | uint8_t *dp, *sp; |
728 | unsigned int d_add; |
728 | unsigned int d_add; |
Line 743... | Line 743... | ||
743 | /* Offset to add when moving to another screen scanline. */ |
743 | /* Offset to add when moving to another screen scanline. */ |
744 | d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
744 | d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
745 | 745 | ||
746 | for (yd = 0; yd < FONT_SCANLINES; yd++) { |
746 | for (yd = 0; yd < FONT_SCANLINES; yd++) { |
747 | /* Byte containing bits of the glyph scanline. */ |
747 | /* Byte containing bits of the glyph scanline. */ |
748 | b = fb_font[glyph * FONT_SCANLINES + yd]; |
748 | b = fb_font[glyph][yd]; |
749 | 749 | ||
750 | for (i = 0; i < FONT_WIDTH; i++) { |
750 | for (i = 0; i < FONT_WIDTH; i++) { |
751 | /* Choose color based on the current bit. */ |
751 | /* Choose color based on the current bit. */ |
752 | sp = (b & 0x80) ? fg_buf : bg_buf; |
752 | sp = (b & 0x80) ? fg_buf : bg_buf; |
753 | 753 | ||
Line 777... | Line 777... | ||
777 | unsigned int row) |
777 | unsigned int row) |
778 | { |
778 | { |
779 | unsigned int x = vport->x + COL2X(col); |
779 | unsigned int x = vport->x + COL2X(col); |
780 | unsigned int y = vport->y + ROW2Y(row); |
780 | unsigned int y = vport->y + ROW2Y(row); |
781 | 781 | ||
782 | uint8_t glyph; |
782 | uint32_t glyph; |
783 | uint32_t fg_color; |
783 | uint32_t fg_color; |
784 | uint32_t bg_color; |
784 | uint32_t bg_color; |
785 | 785 | ||
786 | glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
786 | glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
787 | fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
787 | fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
788 | bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
788 | bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
789 | 789 | ||
790 | (*vport->dglyph)(x, y, cursor, vport->glyphs, glyph, |
790 | (*vport->dglyph)(x, y, cursor, screen.glyphs, glyph, |
791 | fg_color, bg_color); |
791 | fg_color, bg_color); |
792 | } |
792 | } |
793 | 793 | ||
794 | /** Hide cursor if it is shown |
794 | /** Hide cursor if it is shown |
795 | * |
795 | * |
Line 834... | Line 834... | ||
834 | * @param c Character to draw |
834 | * @param c Character to draw |
835 | * @param col Screen position relative to viewport |
835 | * @param col Screen position relative to viewport |
836 | * @param row Screen position relative to viewport |
836 | * @param row Screen position relative to viewport |
837 | * |
837 | * |
838 | */ |
838 | */ |
839 | static void draw_char(viewport_t *vport, uint8_t c, unsigned int col, unsigned int row) |
839 | static void draw_char(viewport_t *vport, wchar_t c, unsigned int col, unsigned int row) |
840 | { |
840 | { |
841 | bb_cell_t *bbp; |
841 | bb_cell_t *bbp; |
842 | 842 | ||
843 | /* Do not hide cursor if we are going to overwrite it */ |
843 | /* Do not hide cursor if we are going to overwrite it */ |
844 | if ((vport->cursor_active) && (vport->cursor_shown) && |
844 | if ((vport->cursor_active) && (vport->cursor_shown) && |
845 | ((vport->cur_col != col) || (vport->cur_row != row))) |
845 | ((vport->cur_col != col) || (vport->cur_row != row))) |
846 | cursor_hide(vport); |
846 | cursor_hide(vport); |
847 | 847 | ||
848 | bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
848 | bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
849 | bbp->glyph = c; |
849 | bbp->glyph = fb_font_glyph(c); |
850 | bbp->fg_color = vport->attr.fg_color; |
850 | bbp->fg_color = vport->attr.fg_color; |
851 | bbp->bg_color = vport->attr.bg_color; |
851 | bbp->bg_color = vport->attr.bg_color; |
852 | 852 | ||
853 | draw_vp_glyph(vport, false, col, row); |
853 | draw_vp_glyph(vport, false, col, row); |
854 | 854 | ||
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 | ||
- | 893 | a = &data[j * w + i].attrs; |
|
- | 894 | rgb_from_attr(&rgb, a); |
|
- | 895 | ||
893 | bbp->glyph = data[i].character; |
896 | bbp->glyph = fb_font_glyph(data[j * w + i].character); |
894 | bbp->fg_color = rgb.fg_color; |
897 | bbp->fg_color = rgb.fg_color; |
895 | bbp->bg_color = rgb.bg_color; |
898 | bbp->bg_color = rgb.bg_color; |
896 | 899 | ||
897 | draw_vp_glyph(vport, false, col, row); |
900 | draw_vp_glyph(vport, false, col, row); |
- | 901 | } |
|
898 | } |
902 | } |
899 | cursor_show(vport); |
903 | cursor_show(vport); |
900 | } |
904 | } |
901 | 905 | ||
902 | 906 | ||
Line 996... | Line 1000... | ||
996 | bool handled = true; |
1000 | bool handled = true; |
997 | int retval = EOK; |
1001 | int retval = EOK; |
998 | viewport_t *vport = &viewports[vp]; |
1002 | viewport_t *vport = &viewports[vp]; |
999 | unsigned int x; |
1003 | unsigned int x; |
1000 | unsigned int y; |
1004 | unsigned int y; |
- | 1005 | unsigned int w; |
|
- | 1006 | unsigned int h; |
|
1001 | 1007 | ||
1002 | switch (IPC_GET_METHOD(*call)) { |
1008 | switch (IPC_GET_METHOD(*call)) { |
1003 | case IPC_M_SHARE_OUT: |
1009 | case IPC_M_SHARE_OUT: |
1004 | /* We accept one area for data interchange */ |
1010 | /* We accept one area for data interchange */ |
1005 | if (IPC_GET_ARG1(*call) == shm_id) { |
1011 | if (IPC_GET_ARG1(*call) == shm_id) { |
Line 1056... | Line 1062... | ||
1056 | 1062 | ||
1057 | ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), |
1063 | ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), |
1058 | IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport); |
1064 | IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport); |
1059 | break; |
1065 | break; |
1060 | case FB_DRAW_TEXT_DATA: |
1066 | case FB_DRAW_TEXT_DATA: |
- | 1067 | x = IPC_GET_ARG1(*call); |
|
- | 1068 | y = IPC_GET_ARG2(*call); |
|
- | 1069 | w = IPC_GET_ARG3(*call); |
|
- | 1070 | h = IPC_GET_ARG4(*call); |
|
1061 | if (!interbuffer) { |
1071 | if (!interbuffer) { |
1062 | retval = EINVAL; |
1072 | retval = EINVAL; |
1063 | break; |
1073 | break; |
1064 | } |
1074 | } |
- | 1075 | if (x + w > vport->cols || y + h > vport->rows) { |
|
- | 1076 | retval = EINVAL; |
|
- | 1077 | break; |
|
- | 1078 | } |
|
1065 | if (intersize < vport->cols * vport->rows * sizeof(*interbuffer)) { |
1079 | if (intersize < w * h * sizeof(*interbuffer)) { |
1066 | retval = EINVAL; |
1080 | retval = EINVAL; |
1067 | break; |
1081 | break; |
1068 | } |
1082 | } |
1069 | draw_text_data(vport, interbuffer); |
1083 | draw_text_data(vport, interbuffer, x, y, w, h); |
1070 | break; |
1084 | break; |
1071 | default: |
1085 | default: |
1072 | handled = false; |
1086 | handled = false; |
1073 | } |
1087 | } |
1074 | 1088 | ||
Line 1493... | Line 1507... | ||
1493 | ipc_callid_t callid; |
1507 | ipc_callid_t callid; |
1494 | ipc_call_t call; |
1508 | ipc_call_t call; |
1495 | int retval; |
1509 | int retval; |
1496 | unsigned int i; |
1510 | unsigned int i; |
1497 | int scroll; |
1511 | int scroll; |
1498 | uint8_t glyph; |
1512 | wchar_t ch; |
1499 | unsigned int row, col; |
1513 | unsigned int row, col; |
1500 | 1514 | ||
1501 | if ((vport->cursor_active) || (anims_enabled)) |
1515 | if ((vport->cursor_active) || (anims_enabled)) |
1502 | callid = async_get_call_timeout(&call, 250000); |
1516 | callid = async_get_call_timeout(&call, 250000); |
1503 | else |
1517 | else |
Line 1530... | Line 1544... | ||
1530 | 1544 | ||
1531 | /* Exit thread */ |
1545 | /* Exit thread */ |
1532 | return; |
1546 | return; |
1533 | 1547 | ||
1534 | case FB_PUTCHAR: |
1548 | case FB_PUTCHAR: |
1535 | glyph = IPC_GET_ARG1(call); |
1549 | ch = IPC_GET_ARG1(call); |
1536 | row = IPC_GET_ARG2(call); |
1550 | row = IPC_GET_ARG2(call); |
1537 | col = IPC_GET_ARG3(call); |
1551 | col = IPC_GET_ARG3(call); |
1538 | 1552 | ||
1539 | if ((col >= vport->cols) || (row >= vport->rows)) { |
1553 | if ((col >= vport->cols) || (row >= vport->rows)) { |
1540 | retval = EINVAL; |
1554 | retval = EINVAL; |
1541 | break; |
1555 | break; |
1542 | } |
1556 | } |
1543 | ipc_answer_0(callid, EOK); |
1557 | ipc_answer_0(callid, EOK); |
1544 | 1558 | ||
1545 | draw_char(vport, glyph, col, row); |
1559 | draw_char(vport, ch, col, row); |
1546 | 1560 | ||
1547 | /* Message already answered */ |
1561 | /* Message already answered */ |
1548 | continue; |
1562 | continue; |
1549 | case FB_CLEAR: |
1563 | case FB_CLEAR: |
1550 | vport_clear(vport); |
1564 | vport_clear(vport); |
Line 1617... | Line 1631... | ||
1617 | if (!viewports[i].initialized) { |
1631 | if (!viewports[i].initialized) { |
1618 | retval = EADDRNOTAVAIL; |
1632 | retval = EADDRNOTAVAIL; |
1619 | break; |
1633 | break; |
1620 | } |
1634 | } |
1621 | viewports[i].initialized = false; |
1635 | viewports[i].initialized = false; |
1622 | if (viewports[i].glyphs) |
- | |
1623 | free(viewports[i].glyphs); |
- | |
1624 | if (viewports[i].bgpixel) |
1636 | if (viewports[i].bgpixel) |
1625 | free(viewports[i].bgpixel); |
1637 | free(viewports[i].bgpixel); |
1626 | if (viewports[i].backbuf) |
1638 | if (viewports[i].backbuf) |
1627 | free(viewports[i].backbuf); |
1639 | free(viewports[i].backbuf); |
1628 | retval = EOK; |
1640 | retval = EOK; |