Index: uspace/srv/fb/fb.c
===================================================================
--- uspace/srv/fb/fb.c	(revision bcb47faa948e9d78c8e7af6ae1a678b21fe43c59)
+++ uspace/srv/fb/fb.c	(revision 2d320816b2f2fe3ea0819c573ee3e5a20663b17a)
@@ -140,4 +140,8 @@
 static bool client_connected = false;  /**< Allow only 1 connection */
 
+static void draw_glyph(viewport_t *vport, bool cursor, unsigned int col,
+    unsigned int row);
+
+
 #define RED(x, bits)                 ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))
 #define GREEN(x, bits)               ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
@@ -220,6 +224,22 @@
 }
 
-
-/** Redraw viewport
+/** Draw a filled rectangle. */
+static void draw_filled_rect(unsigned int x0, unsigned int y0, unsigned int x1,
+    unsigned int y1, uint32_t color)
+{
+	unsigned int x, y;
+	uint8_t cbuf[4];
+
+	screen.rgb_conv(cbuf, color);
+
+	for (y = y0; y < y1; y++) {
+		for (x = x0; x < x1; x++) {
+			memcpy(&screen.fb_addr[FB_POS(x, y)], cbuf,
+			    screen.pixelbytes);
+		}
+	}
+}
+
+/** Redraw viewport.
  *
  * @param vport Viewport to redraw
@@ -228,41 +248,24 @@
 static void vport_redraw(viewport_t *vport)
 {
-	unsigned int row;
-	
+	unsigned int row, col;
+
 	for (row = 0; row < vport->rows; row++) {
-		unsigned int y = vport->y + ROW2Y(row);
-		unsigned int yd;
-		
-		for (yd = 0; yd < FONT_SCANLINES; yd++) {
-			unsigned int x;
-			unsigned int col;
-			
-			for (col = 0, x = vport->x; col < vport->cols; col++, x += FONT_WIDTH)
-				memcpy(&screen.fb_addr[FB_POS(x, y + yd)],
-			    &vport->glyphs[GLYPH_POS(vport->backbuf[BB_POS(vport, col, row)], yd, false)],
-			    screen.glyphscanline);
-		}
-	}
-	
+		for (col = 0; col < vport->cols; col++) {
+			draw_glyph(vport, false, col, row);
+		}
+	}
+
 	if (COL2X(vport->cols) < vport->width) {
-		unsigned int y;
-		
-		for (y = 0; y < vport->height; y++) {
-			unsigned int x;
-			
-			for (x = COL2X(vport->cols); x < vport->width; x++)
-				memcpy(&screen.fb_addr[FB_POS(x, y)], vport->bgpixel, screen.pixelbytes);
-		}
-	}
-	
+		draw_filled_rect(
+		    vport->x + COL2X(vport->cols), vport->y,
+		    vport->x + vport->width, vport->y + vport->height,
+		    vport->style.bg_color);
+	}
+
 	if (ROW2Y(vport->rows) < vport->height) {
-		unsigned int y;
-		
-		for (y = ROW2Y(vport->rows); y < vport->height; y++) {
-			unsigned int x;
-			
-			for (x = 0; x < vport->width; x++)
-				memcpy(&screen.fb_addr[FB_POS(x, y)], vport->bgpixel, screen.pixelbytes);
-		}
+		draw_filled_rect(
+		    vport->x, vport->y + ROW2Y(vport->rows),
+		    vport->x + vport->width, vport->y + vport->height,
+		    vport->style.bg_color);
 	}
 }
@@ -280,5 +283,4 @@
 }
 
-
 /** Scroll viewport by given number of lines
  *
@@ -289,40 +291,23 @@
 static void vport_scroll(viewport_t *vport, int lines)
 {
-	unsigned int row;
-	
+	unsigned int row, col;
+
+	if (lines > 0) {
+		memcpy(vport->backbuf, vport->backbuf + vport->cols * lines,
+		    vport->cols * (vport->rows - lines));
+		memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)],
+		    0, vport->cols * lines);
+	} else {
+		memcpy(vport->backbuf - vport->cols * lines, vport->backbuf,
+		    vport->cols * (vport->rows + lines));
+		memset(vport->backbuf, 0, - vport->cols * lines);
+	}
+
 	for (row = 0; row < vport->rows; row++) {
-		unsigned int y = vport->y + ROW2Y(row);
-		unsigned int yd;
-		
-		for (yd = 0; yd < FONT_SCANLINES; yd++) {
-			unsigned int x;
-			unsigned int col;
-			
-			for (col = 0, x = vport->x; col < vport->cols; col++, x += FONT_WIDTH) {
-				uint8_t glyph;
-				
-				if ((row + lines >= 0) && (row + lines < vport->rows)) {
-					if (vport->backbuf[BB_POS(vport, col, row)] == vport->backbuf[BB_POS(vport, col, row + lines)])
-						continue;
-					
-					glyph = vport->backbuf[BB_POS(vport, col, row + lines)];
-				} else
-					glyph = 0;
-				
-				memcpy(&screen.fb_addr[FB_POS(x, y + yd)],
-				    &vport->glyphs[GLYPH_POS(glyph, yd, false)], screen.glyphscanline);
-			}
-		}
-	}
-	
-	if (lines > 0) {
-		memcpy(vport->backbuf, vport->backbuf + vport->cols * lines, vport->cols * (vport->rows - lines));
-		memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], 0, vport->cols * lines);
-	} else {
-		memcpy(vport->backbuf - vport->cols * lines, vport->backbuf, vport->cols * (vport->rows + lines));
-		memset(vport->backbuf, 0, - vport->cols * lines);
-	}
-}
-
+		for (col = 0; col < vport->cols; col++) {
+			draw_glyph(vport, false, col, row);
+		}
+	}
+}
 
 /** Render glyphs
@@ -931,5 +916,5 @@
 		return;
 	
-	/* Save image under the cursor */
+	/* Save image under the pointer. */
 	if (pointer_vport == -1) {
 		pointer_vport = vport_create(pointer_x, pointer_y, pointer_width, pointer_height);
@@ -946,5 +931,5 @@
 		copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);
 	
-	/* Draw cursor */
+	/* Draw mouse pointer. */
 	for (i = 0; i < pointer_height; i++)
 		for (j = 0; j < pointer_width; j++) {
@@ -967,5 +952,5 @@
 static void mouse_hide(void)
 {
-	/* Restore image under the cursor */
+	/* Restore image under the pointer. */
 	if (pointer_shown) {
 		draw_pixmap(pointer_vport, pointer_pixmap);
