Changeset dcdc31d in mainline for kernel/genarch/src/fb/fb.c


Ignore:
Timestamp:
2009-03-24T14:37:39Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ccdcf6
Parents:
ac7c8d12
Message:

use Unicode font glyphs and mapping for framebuffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/fb/fb.c

    rac7c8d12 rdcdc31d  
    5454
    5555static uint8_t *fb_addr;
    56 static uint8_t *backbuf;
     56static uint16_t *backbuf;
    5757static uint8_t *glyphs;
    5858static uint8_t *bgscan;
     
    200200 *
    201201 */
    202 static void glyph_draw(uint8_t glyph, unsigned int col, unsigned int row, bool silent)
     202static void glyph_draw(uint16_t glyph, unsigned int col, unsigned int row, bool silent)
    203203{
    204204        unsigned int x = COL2X(col);
     
    243243                                for (col = 0, x = 0; col < cols; col++,
    244244                                    x += FONT_WIDTH) {
    245                                         uint8_t glyph;
     245                                        uint16_t glyph;
    246246                                       
    247247                                        if (row < rows - 1) {
     
    262262        }
    263263       
    264         memmove(backbuf, backbuf + cols, cols * (rows - 1));
    265         memsetb(&backbuf[BB_POS(0, rows - 1)], cols, 0);
     264        memmove(backbuf, &backbuf[BB_POS(0, 1)], cols * (rows - 1) * sizeof(uint16_t));
     265        memsetw(&backbuf[BB_POS(0, rows - 1)], cols, 0);
    266266}
    267267
     
    269269static void cursor_put(bool silent)
    270270{
    271         glyph_draw(CURSOR, position % cols, position / cols, silent);
     271        glyph_draw(fb_font_glyph(CURSOR), position % cols, position / cols, silent);
    272272}
    273273
     
    275275static void cursor_remove(bool silent)
    276276{
    277         glyph_draw(0, position % cols, position / cols, silent);
     277        glyph_draw(fb_font_glyph(0), position % cols, position / cols, silent);
    278278}
    279279
     
    284284 *
    285285 */
    286 static void fb_putchar(outdev_t *dev, char ch, bool silent)
     286static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent)
    287287{
    288288        spinlock_lock(&fb_lock);
     
    306306                cursor_remove(silent);
    307307                do {
    308                         glyph_draw((uint8_t) ' ', position % cols,
     308                        glyph_draw(fb_font_glyph(' '), position % cols,
    309309                            position / cols, silent);
    310310                        position++;
     
    312312                break;
    313313        default:
    314                 glyph_draw((uint8_t) ch, position % cols,
     314                glyph_draw(fb_font_glyph(ch), position % cols,
    315315                    position / cols, silent);
    316316                position++;
     
    342342{
    343343        /* Prerender glyphs */
    344         unsigned int glyph;
     344        uint16_t glyph;
    345345       
    346346        for (glyph = 0; glyph < FONT_GLYPHS; glyph++) {
     
    353353                                void *dst = &glyphs[GLYPH_POS(glyph, y) +
    354354                                    x * pixelbytes];
    355                                 uint32_t rgb = (fb_font[ROW2Y(glyph) + y] &
     355                                uint32_t rgb = (fb_font[glyph][y] &
    356356                                    (1 << (7 - x))) ? FG_COLOR : BG_COLOR;
    357357                                rgb_conv(dst, rgb);
     
    399399                        for (col = 0, x = 0; col < cols;
    400400                            col++, x += FONT_WIDTH) {
    401                                 void *d = &fb_addr[FB_POS(x, y + yd)];
    402                                 void *s = &glyphs[GLYPH_POS(backbuf[BB_POS(col,
    403                                     row)], yd)];
    404                                 memcpy(d, s, glyphscanline);
     401                                uint16_t glyph = backbuf[BB_POS(col, row)];
     402                                void *dst = &fb_addr[FB_POS(x, y + yd)];
     403                                void *src = &glyphs[GLYPH_POS(glyph, yd)];
     404                                memcpy(dst, src, glyphscanline);
    405405                        }
    406406                }
     
    495495        bgscanbytes = xres * pixelbytes;
    496496       
    497         unsigned int fbsize = scanline * yres;
    498         unsigned int bbsize = cols * rows;
    499         unsigned int glyphsize = FONT_GLYPHS * glyphbytes;
    500        
    501         backbuf = (uint8_t *) malloc(bbsize, 0);
     497        size_t fbsize = scanline * yres;
     498        size_t bbsize = cols * rows * sizeof(uint16_t);
     499        size_t glyphsize = FONT_GLYPHS * glyphbytes;
     500       
     501        backbuf = (uint16_t *) malloc(bbsize, 0);
    502502        if (!backbuf)
    503503                panic("Unable to allocate backbuffer.");
     
    511511                panic("Unable to allocate background pixel.");
    512512       
    513         memsetb(backbuf, bbsize, 0);
     513        memsetw(backbuf, cols * rows, 0);
    514514       
    515515        glyphs_render();
Note: See TracChangeset for help on using the changeset viewer.