Rev 3744 | Rev 3792 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3744 | Rev 3767 | ||
---|---|---|---|
Line 49... | Line 49... | ||
49 | #include <ipc/ipc.h> |
49 | #include <ipc/ipc.h> |
50 | #include <ipc/ns.h> |
50 | #include <ipc/ns.h> |
51 | #include <ipc/services.h> |
51 | #include <ipc/services.h> |
52 | #include <kernel/errno.h> |
52 | #include <kernel/errno.h> |
53 | #include <kernel/genarch/fb/visuals.h> |
53 | #include <kernel/genarch/fb/visuals.h> |
- | 54 | #include <console/color.h> |
|
- | 55 | #include <console/style.h> |
|
54 | #include <async.h> |
56 | #include <async.h> |
55 | #include <bool.h> |
57 | #include <bool.h> |
56 | 58 | ||
57 | #include "font-8x16.h" |
59 | #include "font-8x16.h" |
58 | #include "fb.h" |
60 | #include "fb.h" |
Line 91... | Line 93... | ||
91 | unsigned int glyphbytes; |
93 | unsigned int glyphbytes; |
92 | 94 | ||
93 | rgb_conv_t rgb_conv; |
95 | rgb_conv_t rgb_conv; |
94 | } screen; |
96 | } screen; |
95 | 97 | ||
- | 98 | /** Backbuffer character cell. */ |
|
- | 99 | typedef struct { |
|
- | 100 | uint8_t glyph; |
|
- | 101 | uint32_t fg_color; |
|
- | 102 | uint32_t bg_color; |
|
- | 103 | } bb_cell_t; |
|
- | 104 | ||
96 | typedef struct { |
105 | typedef struct { |
97 | bool initialized; |
106 | bool initialized; |
98 | unsigned int x; |
107 | unsigned int x; |
99 | unsigned int y; |
108 | unsigned int y; |
100 | unsigned int width; |
109 | unsigned int width; |
Line 106... | Line 115... | ||
106 | 115 | ||
107 | /* |
116 | /* |
108 | * Style and glyphs for text printing |
117 | * Style and glyphs for text printing |
109 | */ |
118 | */ |
110 | 119 | ||
111 | /** Current style. */ |
120 | /** Current attributes. */ |
112 | style_t style; |
121 | attr_rgb_t attr; |
113 | 122 | ||
114 | /** Pre-rendered mask for rendering glyphs. Different viewports |
123 | /** Pre-rendered mask for rendering glyphs. Different viewports |
115 | * might use different drawing functions depending on whether their |
124 | * might use different drawing functions depending on whether their |
116 | * scanlines are aligned on a word boundary.*/ |
125 | * scanlines are aligned on a word boundary.*/ |
117 | uint8_t *glyphs; |
126 | uint8_t *glyphs; |
Line 126... | Line 135... | ||
126 | unsigned int cur_col; |
135 | unsigned int cur_col; |
127 | unsigned int cur_row; |
136 | unsigned int cur_row; |
128 | bool cursor_shown; |
137 | bool cursor_shown; |
129 | 138 | ||
130 | /* Back buffer */ |
139 | /* Back buffer */ |
- | 140 | bb_cell_t *backbuf; |
|
131 | unsigned int bbsize; |
141 | unsigned int bbsize; |
132 | uint8_t *backbuf; |
- | |
133 | } viewport_t; |
142 | } viewport_t; |
134 | 143 | ||
135 | typedef struct { |
144 | typedef struct { |
136 | bool initialized; |
145 | bool initialized; |
137 | bool enabled; |
146 | bool enabled; |
Line 154... | Line 163... | ||
154 | static pixmap_t pixmaps[MAX_PIXMAPS]; |
163 | static pixmap_t pixmaps[MAX_PIXMAPS]; |
155 | static viewport_t viewports[128]; |
164 | static viewport_t viewports[128]; |
156 | 165 | ||
157 | static bool client_connected = false; /**< Allow only 1 connection */ |
166 | static bool client_connected = false; /**< Allow only 1 connection */ |
158 | 167 | ||
- | 168 | static uint32_t color_table[16] = { |
|
- | 169 | [COLOR_BLACK] = 0x000000, |
|
- | 170 | [COLOR_BLUE] = 0x0000f0, |
|
- | 171 | [COLOR_GREEN] = 0x00f000, |
|
- | 172 | [COLOR_CYAN] = 0x00f0f0, |
|
- | 173 | [COLOR_RED] = 0xf00000, |
|
- | 174 | [COLOR_MAGENTA] = 0xf000f0, |
|
- | 175 | [COLOR_YELLOW] = 0xf0f000, |
|
- | 176 | [COLOR_WHITE] = 0xf0f0f0, |
|
- | 177 | ||
- | 178 | [8 + COLOR_BLACK] = 0x000000, |
|
- | 179 | [8 + COLOR_BLUE] = 0x0000ff, |
|
- | 180 | [8 + COLOR_GREEN] = 0x00ff00, |
|
- | 181 | [8 + COLOR_CYAN] = 0x00ffff, |
|
- | 182 | [8 + COLOR_RED] = 0xff0000, |
|
- | 183 | [8 + COLOR_MAGENTA] = 0xff00ff, |
|
- | 184 | [8 + COLOR_YELLOW] = 0xffff00, |
|
- | 185 | [8 + COLOR_WHITE] = 0xffffff, |
|
- | 186 | }; |
|
- | 187 | ||
- | 188 | static int rgb_from_style(attr_rgb_t *rgb, int style); |
|
- | 189 | static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color, |
|
- | 190 | ipcarg_t bg_color, ipcarg_t flags); |
|
- | 191 | ||
- | 192 | static int fb_set_color(viewport_t *vport, ipcarg_t fg_color, |
|
- | 193 | ipcarg_t bg_color, ipcarg_t attr); |
|
- | 194 | ||
159 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
195 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
160 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
196 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
161 | static void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
197 | static void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
162 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
198 | uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color); |
163 | 199 | ||
Line 297... | Line 333... | ||
297 | 333 | ||
298 | if (COL2X(vport->cols) < vport->width) { |
334 | if (COL2X(vport->cols) < vport->width) { |
299 | draw_filled_rect( |
335 | draw_filled_rect( |
300 | vport->x + COL2X(vport->cols), vport->y, |
336 | vport->x + COL2X(vport->cols), vport->y, |
301 | vport->x + vport->width, vport->y + vport->height, |
337 | vport->x + vport->width, vport->y + vport->height, |
302 | vport->style.bg_color); |
338 | vport->attr.bg_color); |
303 | } |
339 | } |
304 | 340 | ||
305 | if (ROW2Y(vport->rows) < vport->height) { |
341 | if (ROW2Y(vport->rows) < vport->height) { |
306 | draw_filled_rect( |
342 | draw_filled_rect( |
307 | vport->x, vport->y + ROW2Y(vport->rows), |
343 | vport->x, vport->y + ROW2Y(vport->rows), |
308 | vport->x + vport->width, vport->y + vport->height, |
344 | vport->x + vport->width, vport->y + vport->height, |
309 | vport->style.bg_color); |
345 | vport->attr.bg_color); |
310 | } |
346 | } |
311 | } |
347 | } |
312 | 348 | ||
- | 349 | static void backbuf_clear(bb_cell_t *backbuf, size_t len, uint32_t fg_color, |
|
- | 350 | uint32_t bg_color) |
|
- | 351 | { |
|
- | 352 | unsigned i; |
|
- | 353 | ||
- | 354 | for (i = 0; i < len; i++) { |
|
- | 355 | backbuf[i].glyph = 0; |
|
- | 356 | backbuf[i].fg_color = fg_color; |
|
- | 357 | backbuf[i].bg_color = bg_color; |
|
- | 358 | } |
|
- | 359 | } |
|
313 | 360 | ||
314 | /** Clear viewport. |
361 | /** Clear viewport. |
315 | * |
362 | * |
316 | * @param vport Viewport to clear |
363 | * @param vport Viewport to clear |
317 | * |
364 | * |
318 | */ |
365 | */ |
319 | static void vport_clear(viewport_t *vport) |
366 | static void vport_clear(viewport_t *vport) |
320 | { |
367 | { |
321 | memset(vport->backbuf, 0, vport->bbsize); |
368 | backbuf_clear(vport->backbuf, vport->cols * vport->rows, |
- | 369 | vport->attr.fg_color, vport->attr.bg_color); |
|
322 | vport_redraw(vport); |
370 | vport_redraw(vport); |
323 | } |
371 | } |
324 | 372 | ||
325 | /** Scroll viewport by the specified number of lines. |
373 | /** Scroll viewport by the specified number of lines. |
326 | * |
374 | * |
Line 331... | Line 379... | ||
331 | static void vport_scroll(viewport_t *vport, int lines) |
379 | static void vport_scroll(viewport_t *vport, int lines) |
332 | { |
380 | { |
333 | unsigned int row, col; |
381 | unsigned int row, col; |
334 | unsigned int x, y; |
382 | unsigned int x, y; |
335 | uint8_t glyph; |
383 | uint8_t glyph; |
- | 384 | uint32_t fg_color; |
|
- | 385 | uint32_t bg_color; |
|
- | 386 | bb_cell_t *bbp, *xbp; |
|
336 | 387 | ||
337 | /* |
388 | /* |
338 | * Redraw. |
389 | * Redraw. |
339 | */ |
390 | */ |
340 | 391 | ||
341 | y = vport->y; |
392 | y = vport->y; |
342 | for (row = 0; row < vport->rows; row++) { |
393 | for (row = 0; row < vport->rows; row++) { |
343 | x = vport->x; |
394 | x = vport->x; |
344 | for (col = 0; col < vport->cols; col++) { |
395 | for (col = 0; col < vport->cols; col++) { |
345 | if ((row + lines >= 0) && (row + lines < vport->rows)) { |
396 | if ((row + lines >= 0) && (row + lines < vport->rows)) { |
346 | glyph = vport->backbuf[BB_POS(vport, col, row + lines)]; |
397 | xbp = &vport->backbuf[BB_POS(vport, col, row + lines)]; |
- | 398 | bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
|
347 | 399 | ||
- | 400 | glyph = xbp->glyph; |
|
- | 401 | fg_color = xbp->fg_color; |
|
- | 402 | bg_color = xbp->bg_color; |
|
- | 403 | ||
- | 404 | if (bbp->glyph == glyph && |
|
- | 405 | bbp->fg_color == xbp->fg_color && |
|
348 | if (vport->backbuf[BB_POS(vport, col, row)] == glyph) { |
406 | bbp->bg_color == xbp->bg_color) { |
349 | x += FONT_WIDTH; |
407 | x += FONT_WIDTH; |
350 | continue; |
408 | continue; |
351 | } |
409 | } |
352 | } else { |
410 | } else { |
353 | glyph = 0; |
411 | glyph = 0; |
- | 412 | fg_color = vport->attr.fg_color; |
|
- | 413 | bg_color = vport->attr.bg_color; |
|
354 | } |
414 | } |
355 | 415 | ||
356 | (*vport->dglyph)(x, y, false, vport->glyphs, glyph, |
416 | (*vport->dglyph)(x, y, false, vport->glyphs, glyph, |
357 | vport->style.fg_color, vport->style.bg_color); |
417 | fg_color, bg_color); |
358 | x += FONT_WIDTH; |
418 | x += FONT_WIDTH; |
359 | } |
419 | } |
360 | y += FONT_SCANLINES; |
420 | y += FONT_SCANLINES; |
361 | } |
421 | } |
362 | 422 | ||
Line 364... | Line 424... | ||
364 | * Scroll backbuffer. |
424 | * Scroll backbuffer. |
365 | */ |
425 | */ |
366 | 426 | ||
367 | if (lines > 0) { |
427 | if (lines > 0) { |
368 | memmove(vport->backbuf, vport->backbuf + vport->cols * lines, |
428 | memmove(vport->backbuf, vport->backbuf + vport->cols * lines, |
369 | vport->cols * (vport->rows - lines)); |
429 | vport->cols * (vport->rows - lines) * sizeof(bb_cell_t)); |
370 | memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], |
430 | backbuf_clear(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], |
371 | 0, vport->cols * lines); |
431 | vport->cols * lines, vport->attr.fg_color, vport->attr.bg_color); |
372 | } else { |
432 | } else { |
373 | memmove(vport->backbuf - vport->cols * lines, vport->backbuf, |
433 | memmove(vport->backbuf - vport->cols * lines, vport->backbuf, |
374 | vport->cols * (vport->rows + lines)); |
434 | vport->cols * (vport->rows + lines) * sizeof(bb_cell_t)); |
375 | memset(vport->backbuf, 0, - vport->cols * lines); |
435 | backbuf_clear(vport->backbuf, - vport->cols * lines, |
- | 436 | vport->attr.fg_color, vport->attr.bg_color); |
|
376 | } |
437 | } |
377 | } |
438 | } |
378 | 439 | ||
379 | /** Render glyphs |
440 | /** Render glyphs |
380 | * |
441 | * |
Line 404... | Line 465... | ||
404 | ? 0x000000 : 0xffffff); |
465 | ? 0x000000 : 0xffffff); |
405 | } |
466 | } |
406 | } |
467 | } |
407 | } |
468 | } |
408 | 469 | ||
409 | screen.rgb_conv(vport->bgpixel, vport->style.bg_color); |
470 | screen.rgb_conv(vport->bgpixel, vport->attr.bg_color); |
410 | } |
471 | } |
411 | 472 | ||
412 | 473 | ||
413 | /** Create new viewport |
474 | /** Create new viewport |
414 | * |
475 | * |
Line 432... | Line 493... | ||
432 | if (i == MAX_VIEWPORTS) |
493 | if (i == MAX_VIEWPORTS) |
433 | return ELIMIT; |
494 | return ELIMIT; |
434 | 495 | ||
435 | unsigned int cols = width / FONT_WIDTH; |
496 | unsigned int cols = width / FONT_WIDTH; |
436 | unsigned int rows = height / FONT_SCANLINES; |
497 | unsigned int rows = height / FONT_SCANLINES; |
437 | unsigned int bbsize = cols * rows; |
498 | unsigned int bbsize = cols * rows * sizeof(bb_cell_t); |
438 | unsigned int glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
499 | unsigned int glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
439 | unsigned int word_size = sizeof(unsigned long); |
500 | unsigned int word_size = sizeof(unsigned long); |
440 | 501 | ||
441 | uint8_t *backbuf = (uint8_t *) malloc(bbsize); |
502 | bb_cell_t *backbuf = (bb_cell_t *) malloc(bbsize); |
442 | if (!backbuf) |
503 | if (!backbuf) |
443 | return ENOMEM; |
504 | return ENOMEM; |
444 | 505 | ||
445 | uint8_t *glyphs = (uint8_t *) malloc(glyphsize); |
506 | uint8_t *glyphs = (uint8_t *) malloc(glyphsize); |
446 | if (!glyphs) { |
507 | if (!glyphs) { |
Line 452... | Line 513... | ||
452 | if (!bgpixel) { |
513 | if (!bgpixel) { |
453 | free(glyphs); |
514 | free(glyphs); |
454 | free(backbuf); |
515 | free(backbuf); |
455 | return ENOMEM; |
516 | return ENOMEM; |
456 | } |
517 | } |
457 | 518 | ||
458 | memset(backbuf, 0, bbsize); |
519 | backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR); |
459 | memset(glyphs, 0, glyphsize); |
520 | memset(glyphs, 0, glyphsize); |
460 | memset(bgpixel, 0, screen.pixelbytes); |
521 | memset(bgpixel, 0, screen.pixelbytes); |
461 | 522 | ||
462 | viewports[i].x = x; |
523 | viewports[i].x = x; |
463 | viewports[i].y = y; |
524 | viewports[i].y = y; |
Line 465... | Line 526... | ||
465 | viewports[i].height = height; |
526 | viewports[i].height = height; |
466 | 527 | ||
467 | viewports[i].cols = cols; |
528 | viewports[i].cols = cols; |
468 | viewports[i].rows = rows; |
529 | viewports[i].rows = rows; |
469 | 530 | ||
470 | viewports[i].style.bg_color = DEFAULT_BGCOLOR; |
531 | viewports[i].attr.bg_color = DEFAULT_BGCOLOR; |
471 | viewports[i].style.fg_color = DEFAULT_FGCOLOR; |
532 | viewports[i].attr.fg_color = DEFAULT_FGCOLOR; |
472 | 533 | ||
473 | viewports[i].glyphs = glyphs; |
534 | viewports[i].glyphs = glyphs; |
474 | viewports[i].bgpixel = bgpixel; |
535 | viewports[i].bgpixel = bgpixel; |
475 | 536 | ||
476 | /* |
537 | /* |
Line 705... | Line 766... | ||
705 | static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col, |
766 | static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col, |
706 | unsigned int row) |
767 | unsigned int row) |
707 | { |
768 | { |
708 | unsigned int x = vport->x + COL2X(col); |
769 | unsigned int x = vport->x + COL2X(col); |
709 | unsigned int y = vport->y + ROW2Y(row); |
770 | unsigned int y = vport->y + ROW2Y(row); |
- | 771 | ||
710 | uint8_t glyph; |
772 | uint8_t glyph; |
- | 773 | uint32_t fg_color; |
|
- | 774 | uint32_t bg_color; |
|
711 | 775 | ||
712 | glyph = vport->backbuf[BB_POS(vport, col, row)]; |
776 | glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
- | 777 | fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
|
- | 778 | bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
|
713 | 779 | ||
714 | (*vport->dglyph)(x, y, cursor, vport->glyphs, glyph, |
780 | (*vport->dglyph)(x, y, cursor, vport->glyphs, glyph, |
715 | vport->style.fg_color, vport->style.bg_color); |
781 | fg_color, bg_color); |
716 | } |
782 | } |
717 | 783 | ||
718 | /** Hide cursor if it is shown |
784 | /** Hide cursor if it is shown |
719 | * |
785 | * |
720 | */ |
786 | */ |
Line 760... | Line 826... | ||
760 | * @param row Screen position relative to viewport |
826 | * @param row Screen position relative to viewport |
761 | * |
827 | * |
762 | */ |
828 | */ |
763 | static void draw_char(viewport_t *vport, uint8_t c, unsigned int col, unsigned int row) |
829 | static void draw_char(viewport_t *vport, uint8_t c, unsigned int col, unsigned int row) |
764 | { |
830 | { |
- | 831 | bb_cell_t *bbp; |
|
- | 832 | ||
765 | /* Do not hide cursor if we are going to overwrite it */ |
833 | /* Do not hide cursor if we are going to overwrite it */ |
766 | if ((vport->cursor_active) && (vport->cursor_shown) && |
834 | if ((vport->cursor_active) && (vport->cursor_shown) && |
767 | ((vport->cur_col != col) || (vport->cur_row != row))) |
835 | ((vport->cur_col != col) || (vport->cur_row != row))) |
768 | cursor_hide(vport); |
836 | cursor_hide(vport); |
769 | 837 | ||
770 | vport->backbuf[BB_POS(vport, col, row)] = c; |
838 | bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
- | 839 | bbp->glyph = c; |
|
- | 840 | bbp->fg_color = vport->attr.fg_color; |
|
- | 841 | bbp->bg_color = vport->attr.bg_color; |
|
- | 842 | ||
771 | draw_vp_glyph(vport, false, col, row); |
843 | draw_vp_glyph(vport, false, col, row); |
772 | 844 | ||
773 | vport->cur_col = col; |
845 | vport->cur_col = col; |
774 | vport->cur_row = row; |
846 | vport->cur_row = row; |
775 | 847 | ||
Line 792... | Line 864... | ||
792 | * |
864 | * |
793 | */ |
865 | */ |
794 | static void draw_text_data(viewport_t *vport, keyfield_t *data) |
866 | static void draw_text_data(viewport_t *vport, keyfield_t *data) |
795 | { |
867 | { |
796 | unsigned int i; |
868 | unsigned int i; |
- | 869 | bb_cell_t *bbp; |
|
- | 870 | attrs_t *a; |
|
- | 871 | attr_rgb_t rgb; |
|
797 | 872 | ||
798 | for (i = 0; i < vport->cols * vport->rows; i++) { |
873 | for (i = 0; i < vport->cols * vport->rows; i++) { |
799 | unsigned int col = i % vport->cols; |
874 | unsigned int col = i % vport->cols; |
800 | unsigned int row = i / vport->cols; |
875 | unsigned int row = i / vport->cols; |
801 | 876 | ||
802 | uint8_t glyph = vport->backbuf[BB_POS(vport, col, row)]; |
877 | bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
803 | - | ||
804 | // TODO: use data[i].style |
878 | uint8_t glyph = bbp->glyph; |
805 | 879 | ||
806 | if (glyph != data[i].character) { |
880 | if (glyph != data[i].character) { |
807 | vport->backbuf[BB_POS(vport, col, row)] = data[i].character; |
881 | bbp->glyph = data[i].character; |
- | 882 | a = &data[i].attrs; |
|
- | 883 | ||
- | 884 | switch (a->t) { |
|
- | 885 | case at_style: |
|
- | 886 | rgb_from_style(&rgb, a->a.s.style); |
|
- | 887 | break; |
|
- | 888 | case at_idx: |
|
- | 889 | rgb_from_idx(&rgb, a->a.i.fg_color, |
|
- | 890 | a->a.i.bg_color, a->a.i.flags); |
|
- | 891 | break; |
|
- | 892 | case at_rgb: |
|
- | 893 | rgb = a->a.r; |
|
- | 894 | break; |
|
- | 895 | } |
|
- | 896 | ||
- | 897 | bbp->fg_color = rgb.fg_color; |
|
- | 898 | bbp->bg_color = rgb.bg_color; |
|
- | 899 | ||
808 | draw_vp_glyph(vport, false, col, row); |
900 | draw_vp_glyph(vport, false, col, row); |
809 | } |
901 | } |
810 | } |
902 | } |
811 | cursor_show(vport); |
903 | cursor_show(vport); |
812 | } |
904 | } |
Line 1320... | Line 1412... | ||
1320 | ipc_answer_0(callid, retval); |
1412 | ipc_answer_0(callid, retval); |
1321 | return handled; |
1413 | return handled; |
1322 | 1414 | ||
1323 | } |
1415 | } |
1324 | 1416 | ||
- | 1417 | static int rgb_from_style(attr_rgb_t *rgb, int style) |
|
- | 1418 | { |
|
- | 1419 | switch (style) { |
|
- | 1420 | case STYLE_NORMAL: |
|
- | 1421 | rgb->fg_color = color_table[COLOR_BLACK]; |
|
- | 1422 | rgb->bg_color = color_table[COLOR_WHITE]; |
|
- | 1423 | break; |
|
- | 1424 | case STYLE_EMPHASIS: |
|
- | 1425 | rgb->fg_color = color_table[COLOR_RED]; |
|
- | 1426 | rgb->bg_color = color_table[COLOR_WHITE]; |
|
- | 1427 | break; |
|
- | 1428 | default: |
|
- | 1429 | return EINVAL; |
|
- | 1430 | } |
|
- | 1431 | ||
- | 1432 | return EOK; |
|
- | 1433 | } |
|
- | 1434 | ||
- | 1435 | static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color, |
|
- | 1436 | ipcarg_t bg_color, ipcarg_t flags) |
|
- | 1437 | { |
|
- | 1438 | fg_color = (fg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0); |
|
- | 1439 | bg_color = (bg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0); |
|
- | 1440 | ||
- | 1441 | rgb->fg_color = color_table[fg_color]; |
|
- | 1442 | rgb->bg_color = color_table[bg_color]; |
|
- | 1443 | ||
- | 1444 | return EOK; |
|
- | 1445 | } |
|
- | 1446 | ||
- | 1447 | static int fb_set_style(viewport_t *vport, ipcarg_t style) |
|
- | 1448 | { |
|
- | 1449 | return rgb_from_style(&vport->attr, (int) style); |
|
- | 1450 | } |
|
- | 1451 | ||
- | 1452 | static int fb_set_color(viewport_t *vport, ipcarg_t fg_color, |
|
- | 1453 | ipcarg_t bg_color, ipcarg_t flags) |
|
- | 1454 | { |
|
- | 1455 | return rgb_from_idx(&vport->attr, fg_color, bg_color, flags); |
|
- | 1456 | } |
|
- | 1457 | ||
1325 | /** Function for handling connections to FB |
1458 | /** Function for handling connections to FB |
1326 | * |
1459 | * |
1327 | */ |
1460 | */ |
1328 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
1461 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
1329 | { |
1462 | { |
Line 1476... | Line 1609... | ||
1476 | if (viewports[i].backbuf) |
1609 | if (viewports[i].backbuf) |
1477 | free(viewports[i].backbuf); |
1610 | free(viewports[i].backbuf); |
1478 | retval = EOK; |
1611 | retval = EOK; |
1479 | break; |
1612 | break; |
1480 | case FB_SET_STYLE: |
1613 | case FB_SET_STYLE: |
- | 1614 | retval = fb_set_style(vport, IPC_GET_ARG1(call)); |
|
- | 1615 | break; |
|
- | 1616 | case FB_SET_COLOR: |
|
- | 1617 | retval = fb_set_color(vport, IPC_GET_ARG1(call), |
|
- | 1618 | IPC_GET_ARG2(call), IPC_GET_ARG3(call)); |
|
- | 1619 | break; |
|
- | 1620 | case FB_SET_RGB_COLOR: |
|
1481 | vport->style.fg_color = IPC_GET_ARG1(call); |
1621 | vport->attr.fg_color = IPC_GET_ARG1(call); |
1482 | vport->style.bg_color = IPC_GET_ARG2(call); |
1622 | vport->attr.bg_color = IPC_GET_ARG2(call); |
1483 | retval = EOK; |
1623 | retval = EOK; |
1484 | break; |
1624 | break; |
1485 | case FB_GET_RESOLUTION: |
1625 | case FB_GET_RESOLUTION: |
1486 | ipc_answer_2(callid, EOK, screen.xres, screen.yres); |
1626 | ipc_answer_2(callid, EOK, screen.xres, screen.yres); |
1487 | continue; |
1627 | continue; |