Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 4527fb5 in mainline


Ignore:
Timestamp:
2009-04-04T21:13:26Z (12 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master
Children:
f2b8cdc
Parents:
67ebf21
Message:

The pre-rendered glyphs are not viewport-specific. This was taking too much time and memory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fb/fb.c

    r67ebf21 r4527fb5  
    9494        unsigned int pixelbytes;
    9595        unsigned int glyphbytes;
     96
     97        /** Pre-rendered mask for rendering glyphs. Specific for the visual. */
     98        uint8_t *glyphs;
    9699       
    97100        rgb_conv_t rgb_conv;
     
    123126        attr_rgb_t attr;
    124127
    125         /** Pre-rendered mask for rendering glyphs. Different viewports
     128        uint8_t *bgpixel;
     129
     130        /**
     131         * Glyph drawing function for this viewport.  Different viewports
    126132         * might use different drawing functions depending on whether their
    127          * scanlines are aligned on a word boundary.*/
    128         uint8_t *glyphs;
    129 
    130         uint8_t *bgpixel;
    131 
    132         /** Glyph drawing function for this viewport. */
     133         * scanlines are aligned on a word boundary.
     134         */
    133135        dg_t dglyph;
    134136       
     
    422424                        }
    423425
    424                         (*vport->dglyph)(x, y, false, vport->glyphs, glyph,
     426                        (*vport->dglyph)(x, y, false, screen.glyphs, glyph,
    425427                            fg_color, bg_color);
    426428                        x += FONT_WIDTH;
     
    450452 * Convert glyphs from device independent font
    451453 * description to current visual representation.
    452  *
    453  * @param vport Viewport
    454  *
    455  */
    456 static void render_glyphs(viewport_t* vport)
     454 */
     455static void render_glyphs(void)
    457456{
    458457        unsigned int glyph;
    459        
     458
    460459        for (glyph = 0; glyph < FONT_GLYPHS; glyph++) {
    461460                unsigned int y;
    462                
     461
    463462                for (y = 0; y < FONT_SCANLINES; y++) {
    464463                        unsigned int x;
    465                        
     464
    466465                        for (x = 0; x < FONT_WIDTH; x++) {
    467                                 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],
    468467                                    (fb_font[glyph][y] & (1 << (7 - x)))
    469468                                    ? 0xffffff : 0x000000);
    470                                
    471                                 screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes],
     469
     470                                screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes],
    472471                                    (fb_font[glyph][y] & (1 << (7 - x)))
    473472                                    ? 0x000000 : 0xffffff);
     
    475474                }
    476475        }
    477        
    478         screen.rgb_conv(vport->bgpixel, vport->attr.bg_color);
    479476}
    480477
     
    505502        unsigned int rows = height / FONT_SCANLINES;
    506503        unsigned int bbsize = cols * rows * sizeof(bb_cell_t);
    507         unsigned int glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes;
    508504        unsigned int word_size = sizeof(unsigned long);
    509505       
     
    512508                return ENOMEM;
    513509       
    514         uint8_t *glyphs = (uint8_t *) malloc(glyphsize);
    515         if (!glyphs) {
     510        uint8_t *bgpixel = (uint8_t *) malloc(screen.pixelbytes);
     511        if (!bgpixel) {
    516512                free(backbuf);
    517513                return ENOMEM;
    518514        }
    519        
    520         uint8_t *bgpixel = (uint8_t *) malloc(screen.pixelbytes);
    521         if (!bgpixel) {
    522                 free(glyphs);
    523                 free(backbuf);
    524                 return ENOMEM;
    525         }
    526515
    527516        backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR);
    528         memset(glyphs, 0, glyphsize);
    529517        memset(bgpixel, 0, screen.pixelbytes);
    530518       
     
    540528        viewports[i].attr.fg_color = DEFAULT_FGCOLOR;
    541529       
    542         viewports[i].glyphs = glyphs;
    543530        viewports[i].bgpixel = bgpixel;
    544531
     
    570557        viewports[i].initialized = true;
    571558       
    572         render_glyphs(&viewports[i]);
     559        screen.rgb_conv(viewports[i].bgpixel, viewports[i].attr.bg_color);
    573560       
    574561        return i;
     
    588575    unsigned int scan, unsigned int visual)
    589576{
     577        unsigned int glyphsize;
     578        uint8_t *glyphs;
    590579        switch (visual) {
    591580        case VISUAL_INDIRECT_8:
     
    632621        screen.glyphscanline = FONT_WIDTH * screen.pixelbytes;
    633622        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();
    634633       
    635634        /* Create first viewport */
     
    789788        bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color;
    790789
    791         (*vport->dglyph)(x, y, cursor, vport->glyphs, glyph,
     790        (*vport->dglyph)(x, y, cursor, screen.glyphs, glyph,
    792791            fg_color, bg_color);
    793792}
     
    16351634                        }
    16361635                        viewports[i].initialized = false;
    1637                         if (viewports[i].glyphs)
    1638                                 free(viewports[i].glyphs);
    16391636                        if (viewports[i].bgpixel)
    16401637                                free(viewports[i].bgpixel);
Note: See TracChangeset for help on using the changeset viewer.