Bladeren bron

* src/graphics.c:

+ Split the drawing of foreground and background colours in the X11
      driver. Nice performance improvement.
tags/v0.99.beta14
Sam Hocevar sam 21 jaren geleden
bovenliggende
commit
bd361462be
1 gewijzigde bestanden met toevoegingen van 23 en 6 verwijderingen
  1. +23
    -6
      src/graphics.c

+ 23
- 6
src/graphics.c Bestand weergeven

@@ -871,11 +871,8 @@ void caca_refresh(void)
{
unsigned int x, y, len;

/* FIXME: This is very, very slow. There are several things that can
* be done in order to speed up things:
* - cache characters once rendered
* - pre-render all characters
* - use our own rendering routine (screen depth dependent) */
/* First draw the background colours. Splitting the process in two
* loops like this is actually slightly faster. */
for(y = 0; y < _caca_height; y++)
{
for(x = 0; x < _caca_width; x += len)
@@ -883,13 +880,33 @@ void caca_refresh(void)
unsigned char *attr = x11_attr + x + y * _caca_width;

len = 1;
while(x + len < _caca_width && attr[len] == attr[0])
while(x + len < _caca_width
&& (attr[len] >> 4) == (attr[0] >> 4))
len++;

XSetForeground(x11_dpy, x11_gc, x11_colors[attr[0] >> 4]);
XFillRectangle(x11_dpy, x11_pixmap, x11_gc,
x * x11_font_width, y * x11_font_height,
len * x11_font_width, x11_font_height);
}
}

/* Then print the foreground characters */
for(y = 0; y < _caca_height; y++)
{
for(x = 0; x < _caca_width; x += len)
{
unsigned char *attr = x11_attr + x + y * _caca_width;

len = 1;

/* Skip spaces */
if(x11_char[x + y * _caca_width] == ' ')
continue;

while(x + len < _caca_width
&& (attr[len] & 0xf) == (attr[0] & 0xf))
len++;

XSetForeground(x11_dpy, x11_gc, x11_colors[attr[0] & 0xf]);
XDrawString(x11_dpy, x11_pixmap, x11_gc, x * x11_font_width,


Laden…
Annuleren
Opslaan