Index: uspace/app/gfxdemo/gfxdemo.c
===================================================================
--- uspace/app/gfxdemo/gfxdemo.c	(revision 0008c0f308db358a5d1b9584126efc6a22a065f1)
+++ uspace/app/gfxdemo/gfxdemo.c	(revision 587b4cb24eec8f9acd895b16804e0b8dfd437506)
@@ -48,4 +48,41 @@
 #include <window.h>
 
+/** Clear screen.
+ *
+ * @param gc Graphic context
+ * @param w Screen width
+ * @param h Screen height
+ */
+static errno_t clear_scr(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
+{
+	gfx_color_t *color = NULL;
+	gfx_rect_t rect;
+	errno_t rc;
+
+	rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_set_color(gc, color);
+	if (rc != EOK)
+		goto error;
+
+	rect.p0.x = 0;
+	rect.p0.y = 0;
+	rect.p1.x = w;
+	rect.p1.y = h;
+
+	rc = gfx_fill_rect(gc, &rect);
+	if (rc != EOK)
+		goto error;
+
+	gfx_color_delete(color);
+	return EOK;
+error:
+	if (color != NULL)
+		gfx_color_delete(color);
+	return rc;
+}
+
 /** Run rectangle demo on a graphic context.
  *
@@ -60,4 +97,8 @@
 	int i, j;
 	errno_t rc;
+
+	rc = clear_scr(gc, w, h);
+	if (rc != EOK)
+		return rc;
 
 	for (j = 0; j < 10; j++) {
@@ -90,29 +131,17 @@
 }
 
-/** Run bitmap demo on a graphic context.
- *
- * @param gc Graphic context
- * @param w Width
- * @param h Height
- */
-static errno_t demo_bitmap(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
-{
-	gfx_bitmap_t *bitmap;
-	gfx_bitmap_params_t params;
+/** Fill bitmap with tartan pattern.
+ *
+ * @param bitmap Bitmap
+ * @param w Bitmap width
+ * @param h Bitmap height
+ * @return EOK on success or an error code
+ */
+static errno_t bitmap_tartan(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
+{
+	int i, j;
+	pixelmap_t pixelmap;
 	gfx_bitmap_alloc_t alloc;
-	int i, j;
-	gfx_coord2_t offs;
-	gfx_rect_t srect;
-	errno_t rc;
-	pixelmap_t pixelmap;
-
-	params.rect.p0.x = 0;
-	params.rect.p0.y = 0;
-	params.rect.p1.x = w;
-	params.rect.p1.y = h;
-
-	rc = gfx_bitmap_create(gc, &params, NULL, &bitmap);
-	if (rc != EOK)
-		return rc;
+	errno_t rc;
 
 	rc = gfx_bitmap_get_alloc(bitmap, &alloc);
@@ -120,5 +149,5 @@
 		return rc;
 
-	/* Fill bitmap with something. In absence of anything else, use pixelmap */
+	/* In absence of anything else, use pixelmap */
 	pixelmap.width = w;
 	pixelmap.height = h;
@@ -133,4 +162,74 @@
 	}
 
+	return EOK;
+}
+
+/** Fill bitmap with moire pattern.
+ *
+ * @param bitmap Bitmap
+ * @param w Bitmap width
+ * @param h Bitmap height
+ * @return EOK on success or an error code
+ */
+static errno_t bitmap_moire(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
+{
+	int i, j;
+	int k;
+	pixelmap_t pixelmap;
+	gfx_bitmap_alloc_t alloc;
+	errno_t rc;
+
+	rc = gfx_bitmap_get_alloc(bitmap, &alloc);
+	if (rc != EOK)
+		return rc;
+
+	/* In absence of anything else, use pixelmap */
+	pixelmap.width = w;
+	pixelmap.height = h;
+	pixelmap.data = alloc.pixels;
+
+	for (i = 0; i < w; i++) {
+		for (j = 0; j < h; j++) {
+			k = i * i + j * j;
+			pixelmap_put_pixel(&pixelmap, i, j,
+			    PIXEL(255, k, k, k));
+		}
+	}
+
+	return EOK;
+}
+
+/** Run bitmap demo on a graphic context.
+ *
+ * @param gc Graphic context
+ * @param w Width
+ * @param h Height
+ */
+static errno_t demo_bitmap(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
+{
+	gfx_bitmap_t *bitmap;
+	gfx_bitmap_params_t params;
+	int i, j;
+	gfx_coord2_t offs;
+	gfx_rect_t srect;
+	errno_t rc;
+
+	rc = clear_scr(gc, w, h);
+	if (rc != EOK)
+		return rc;
+
+	params.rect.p0.x = 0;
+	params.rect.p0.y = 0;
+	params.rect.p1.x = w;
+	params.rect.p1.y = h;
+
+	rc = gfx_bitmap_create(gc, &params, NULL, &bitmap);
+	if (rc != EOK)
+		return rc;
+
+	rc = bitmap_tartan(bitmap, w, h);
+	if (rc != EOK)
+		goto error;
+
 	for (j = 0; j < 10; j++) {
 		for (i = 0; i < 5; i++) {
@@ -139,6 +238,4 @@
 			srect.p1.x = srect.p0.x + rand() % (w - srect.p0.x);
 			srect.p1.y = srect.p0.y + rand() % (h - srect.p0.y);
-			offs.x = rand() % (w - srect.p1.x);
-			offs.y = rand() % (h - srect.p1.y);
 			offs.x = 0;
 			offs.y = 0;
@@ -147,5 +244,5 @@
 			if (rc != EOK)
 				goto error;
-			fibril_usleep(500 * 1000);
+			fibril_usleep(250 * 1000);
 		}
 	}
@@ -159,5 +256,5 @@
 }
 
-/** Run demo loop on a graphic context.
+/** Run second bitmap demo on a graphic context.
  *
  * @param gc Graphic context
@@ -165,4 +262,56 @@
  * @param h Height
  */
+static errno_t demo_bitmap2(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
+{
+	gfx_bitmap_t *bitmap;
+	gfx_bitmap_params_t params;
+	int i, j;
+	gfx_coord2_t offs;
+	errno_t rc;
+
+	rc = clear_scr(gc, w, h);
+	if (rc != EOK)
+		return rc;
+
+	params.rect.p0.x = 0;
+	params.rect.p0.y = 0;
+	params.rect.p1.x = 40;
+	params.rect.p1.y = 20;
+
+	rc = gfx_bitmap_create(gc, &params, NULL, &bitmap);
+	if (rc != EOK)
+		return rc;
+
+	rc = bitmap_moire(bitmap, 40, 20);
+	if (rc != EOK)
+		goto error;
+
+	for (j = 0; j < 10; j++) {
+		for (i = 0; i < 10; i++) {
+			offs.x = rand() % (w - 40);
+			offs.y = rand() % (h - 20);
+
+			rc = gfx_bitmap_render(bitmap, NULL, &offs);
+			if (rc != EOK)
+				goto error;
+		}
+
+		fibril_usleep(500 * 1000);
+	}
+
+	gfx_bitmap_destroy(bitmap);
+
+	return EOK;
+error:
+	gfx_bitmap_destroy(bitmap);
+	return rc;
+}
+
+/** Run demo loop on a graphic context.
+ *
+ * @param gc Graphic context
+ * @param w Width
+ * @param h Height
+ */
 static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
 {
@@ -175,4 +324,8 @@
 
 		rc = demo_bitmap(gc, w, h);
+		if (rc != EOK)
+			return rc;
+
+		rc = demo_bitmap2(gc, w, h);
 		if (rc != EOK)
 			return rc;
