Changeset 303


Ignore:
Timestamp:
Jan 2, 2004, 4:34:16 PM (19 years ago)
Author:
Sam Hocevar
Message:
  • src/graphics.c: + Split the drawing of foreground and background colours in the X11

driver. Nice performance improvement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/graphics.c

    r300 r303  
    872872        unsigned int x, y, len;
    873873
    874         /* FIXME: This is very, very slow. There are several things that can
    875          * be done in order to speed up things:
    876          *  - cache characters once rendered
    877          *  - pre-render all characters
    878          *  - use our own rendering routine (screen depth dependent) */
     874        /* First draw the background colours. Splitting the process in two
     875         * loops like this is actually slightly faster. */
    879876        for(y = 0; y < _caca_height; y++)
    880877        {
     
    884881
    885882                len = 1;
    886                 while(x + len < _caca_width && attr[len] == attr[0])
     883                while(x + len < _caca_width
     884                       && (attr[len] >> 4) == (attr[0] >> 4))
    887885                    len++;
    888886
     
    891889                               x * x11_font_width, y * x11_font_height,
    892890                               len * x11_font_width, x11_font_height);
     891            }
     892        }
     893
     894        /* Then print the foreground characters */
     895        for(y = 0; y < _caca_height; y++)
     896        {
     897            for(x = 0; x < _caca_width; x += len)
     898            {
     899                unsigned char *attr = x11_attr + x + y * _caca_width;
     900
     901                len = 1;
     902
     903                /* Skip spaces */
     904                if(x11_char[x + y * _caca_width] == ' ')
     905                    continue;
     906
     907                while(x + len < _caca_width
     908                       && (attr[len] & 0xf) == (attr[0] & 0xf))
     909                    len++;
    893910
    894911                XSetForeground(x11_dpy, x11_gc, x11_colors[attr[0] & 0xf]);
Note: See TracChangeset for help on using the changeset viewer.