font: draw backgrounds
authorDavid Herrmann <dh.herrmann@googlemail.com>
Wed, 30 May 2012 16:48:59 +0000 (18:48 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Wed, 30 May 2012 16:48:59 +0000 (18:48 +0200)
The pango backend now correctly draws colored or uncolored backgrounds.
This is needed to support drawing cursors.

We currently do not optimize this for performance. In fact, this reduces
performance a lot and we could avoid drawing backgrounds if we cleared the
background to the same color before. However, this also means we currently
could move drawing the background into the console backend again. The
transparency feature is awful, anyway and I don't see any reason
supporting it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/font_pango.c

index 3a7616b..aebda27 100644 (file)
@@ -689,6 +689,7 @@ int font_screen_draw_start(struct font_screen *screen)
 
        cairo_set_operator(screen->cr, CAIRO_OPERATOR_OVER);
        cairo_set_source_rgb(screen->cr, 1, 1, 1);
+       cairo_set_line_width(screen->cr, 1.0);
 
        if (screen->absolute)
                cairo_scale(screen->cr, screen->scale_x, screen->scale_y);
@@ -718,6 +719,19 @@ int font_screen_draw_char(struct font_screen *screen, kmscon_symbol_t ch,
        }
 
        if (attr->inverse)
+               cairo_set_source_rgb(screen->cr, attr->fr, attr->fg, attr->fb);
+       else
+               cairo_set_source_rgb(screen->cr, attr->br, attr->bg, attr->bb);
+
+       cairo_move_to(screen->cr, cellx * screen->advance_x,
+                     celly * screen->advance_y);
+       cairo_rel_line_to(screen->cr, screen->advance_x, 0);
+       cairo_rel_line_to(screen->cr, 0, screen->advance_y);
+       cairo_rel_line_to(screen->cr, -screen->advance_x, 0);
+       cairo_close_path(screen->cr);
+       cairo_fill(screen->cr);
+
+       if (attr->inverse)
                cairo_set_source_rgb(screen->cr, attr->br, attr->bg, attr->bb);
        else
                cairo_set_source_rgb(screen->cr, attr->fr, attr->fg, attr->fb);