Index: uspace/lib/gfx/src/bitmap.c
===================================================================
--- uspace/lib/gfx/src/bitmap.c	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/lib/gfx/src/bitmap.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -77,6 +77,8 @@
 
 	rc = gc->ops->bitmap_create(gc->arg, params, alloc, &bm_priv);
-	if (rc != EOK)
+	if (rc != EOK) {
+		free(bitmap);
 		return rc;
+	}
 
 	bitmap->gc = gc;
Index: uspace/lib/memgfx/src/memgc.c
===================================================================
--- uspace/lib/memgfx/src/memgc.c	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/lib/memgfx/src/memgc.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -70,5 +70,5 @@
  * Set drawing color on memory GC.
  *
- * @param arg Canvas GC
+ * @param arg Memory GC
  * @param color Color
  *
@@ -87,5 +87,5 @@
 /** Fill rectangle on memory GC.
  *
- * @param arg Canvas GC
+ * @param arg Memory GC
  * @param rect Rectangle
  *
@@ -166,5 +166,5 @@
 /** Delete memory GC.
  *
- * @param mgc Canvas GC
+ * @param mgc Memory GC
  */
 errno_t mem_gc_delete(mem_gc_t *mgc)
@@ -195,5 +195,5 @@
 /** Get generic graphic context from memory GC.
  *
- * @param mgc Canvas GC
+ * @param mgc Memory GC
  * @return Graphic context
  */
@@ -210,5 +210,5 @@
 /** Create bitmap in memory GC.
  *
- * @param arg Canvas GC
+ * @param arg Memory GC
  * @param params Bitmap params
  * @param alloc Bitmap allocation info or @c NULL
Index: uspace/srv/hid/display/clonegc.c
===================================================================
--- uspace/srv/hid/display/clonegc.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
+++ uspace/srv/hid/display/clonegc.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -0,0 +1,534 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup display
+ * @{
+ */
+/**
+ * @file Cloning graphics context
+ *
+ * This implements a graphics context that duplicates rendering to a number
+ * of GCs.
+ */
+
+#include <assert.h>
+#include <gfx/color.h>
+#include <gfx/context.h>
+#include <gfx/render.h>
+#include <stdlib.h>
+#include "clonegc.h"
+
+static errno_t ds_clonegc_set_color(void *, gfx_color_t *);
+static errno_t ds_clonegc_fill_rect(void *, gfx_rect_t *);
+static errno_t ds_clonegc_bitmap_create(void *, gfx_bitmap_params_t *,
+    gfx_bitmap_alloc_t *, void **);
+static errno_t ds_clonegc_bitmap_destroy(void *);
+static errno_t ds_clonegc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
+static errno_t ds_clonegc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
+
+static ds_clonegc_output_t *ds_clonegc_first_output(ds_clonegc_t *);
+static ds_clonegc_output_t *ds_clonegc_next_output(ds_clonegc_output_t *);
+static ds_clonegc_bitmap_t *ds_clonegc_first_bitmap(ds_clonegc_t *);
+static ds_clonegc_bitmap_t *ds_clonegc_next_bitmap(ds_clonegc_bitmap_t *);
+static ds_clonegc_outbitmap_t *ds_clonegc_bitmap_first_obm(ds_clonegc_bitmap_t *);
+static ds_clonegc_outbitmap_t *ds_clonegc_bitmap_next_obm(ds_clonegc_outbitmap_t *);
+static errno_t ds_clonegc_outbitmap_create(ds_clonegc_output_t *,
+    ds_clonegc_bitmap_t *, gfx_bitmap_t *);
+static errno_t ds_clonegc_outbitmap_destroy(ds_clonegc_outbitmap_t *);
+static errno_t ds_clonegc_bitmap_add_output(ds_clonegc_bitmap_t *,
+    ds_clonegc_output_t *);
+
+gfx_context_ops_t ds_clonegc_ops = {
+	.set_color = ds_clonegc_set_color,
+	.fill_rect = ds_clonegc_fill_rect,
+	.bitmap_create = ds_clonegc_bitmap_create,
+	.bitmap_destroy = ds_clonegc_bitmap_destroy,
+	.bitmap_render = ds_clonegc_bitmap_render,
+	.bitmap_get_alloc = ds_clonegc_bitmap_get_alloc
+};
+
+/** Set color on clone GC.
+ *
+ * Set drawing color on memory GC.
+ *
+ * @param arg Clone GC
+ * @param color Color
+ *
+ * @return EOK on success or an error code
+ */
+static errno_t ds_clonegc_set_color(void *arg, gfx_color_t *color)
+{
+	ds_clonegc_t *cgc = (ds_clonegc_t *)arg;
+	ds_clonegc_output_t *output;
+	errno_t rc;
+
+	output = ds_clonegc_first_output(cgc);
+	while (output != NULL) {
+		rc = gfx_set_color(output->gc, color);
+		if (rc != EOK)
+			return rc;
+
+		output = ds_clonegc_next_output(output);
+	}
+
+	return EOK;
+}
+
+/** Fill rectangle on clone GC.
+ *
+ * @param arg Clone GC
+ * @param rect Rectangle
+ *
+ * @return EOK on success or an error code
+ */
+static errno_t ds_clonegc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	ds_clonegc_t *cgc = (ds_clonegc_t *)arg;
+	ds_clonegc_output_t *output;
+	errno_t rc;
+
+	output = ds_clonegc_first_output(cgc);
+	while (output != NULL) {
+		rc = gfx_fill_rect(output->gc, rect);
+		if (rc != EOK)
+			return rc;
+
+		output = ds_clonegc_next_output(output);
+	}
+
+	return EOK;
+}
+
+/** Create cloning GC.
+ *
+ * Create graphics context for copying rendering into several GCs.
+ *
+ * @param outgc Primary output GC
+ * @param rgc Place to store pointer to new clone GC
+ *
+ * @return EOK on success or an error code
+ */
+errno_t ds_clonegc_create(gfx_context_t *outgc, ds_clonegc_t **rgc)
+{
+	ds_clonegc_t *cgc = NULL;
+	gfx_context_t *gc = NULL;
+	errno_t rc;
+
+	cgc = calloc(1, sizeof(ds_clonegc_t));
+	if (cgc == NULL) {
+		rc = ENOMEM;
+		goto error;
+	}
+
+	rc = gfx_context_new(&ds_clonegc_ops, cgc, &gc);
+	if (rc != EOK)
+		goto error;
+
+	cgc->gc = gc;
+	list_initialize(&cgc->outputs);
+	list_initialize(&cgc->bitmaps);
+
+	if (outgc != NULL) {
+		rc = ds_clonegc_add_output(cgc, outgc);
+		if (rc != EOK)
+			goto error;
+	}
+
+	*rgc = cgc;
+	return EOK;
+error:
+	if (cgc != NULL)
+		free(cgc);
+	if (gc != NULL)
+		gfx_context_delete(gc);
+	return rc;
+}
+
+/** Delete cloning GC.
+ *
+ * @param cgc Cloning GC
+ */
+errno_t ds_clonegc_delete(ds_clonegc_t *cgc)
+{
+	errno_t rc;
+
+	rc = gfx_context_delete(cgc->gc);
+	if (rc != EOK)
+		return rc;
+
+	free(cgc);
+	return EOK;
+}
+
+/** Add new output to cloning GC.
+ *
+ * @param cgc Cloning GC
+ * @param outgc New output GC
+ * @return EOK on success, ENOMEM if out of memory
+ */
+errno_t ds_clonegc_add_output(ds_clonegc_t *cgc, gfx_context_t *outgc)
+{
+	ds_clonegc_output_t *output;
+	ds_clonegc_bitmap_t *cbm;
+	errno_t rc;
+
+	output = calloc(1, sizeof(ds_clonegc_output_t));
+	if (output == NULL)
+		return ENOMEM;
+
+	output->clonegc = cgc;
+	list_append(&output->loutputs, &cgc->outputs);
+	output->gc = outgc;
+	list_initialize(&output->obitmaps);
+
+	/* Extend each existing bitmap to the new output */
+	cbm = ds_clonegc_first_bitmap(cgc);
+	while (cbm != NULL) {
+		rc = ds_clonegc_bitmap_add_output(cbm, output);
+		if (rc != EOK)
+			goto error;
+
+		cbm = ds_clonegc_next_bitmap(cbm);
+	}
+
+	return EOK;
+error:
+	list_remove(&output->loutputs);
+	free(output);
+	return rc;
+}
+
+/** Get generic graphic context from clone GC.
+ *
+ * @param cgc Clone GC
+ * @return Graphic context
+ */
+gfx_context_t *ds_clonegc_get_ctx(ds_clonegc_t *cgc)
+{
+	return cgc->gc;
+}
+
+/** Create bitmap in clone GC.
+ *
+ * @param arg Clone GC
+ * @param params Bitmap params
+ * @param alloc Bitmap allocation info or @c NULL
+ * @param rbm Place to store pointer to new bitmap
+ * @return EOK on success or an error code
+ */
+errno_t ds_clonegc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
+    gfx_bitmap_alloc_t *alloc, void **rbm)
+{
+	ds_clonegc_t *cgc = (ds_clonegc_t *)arg;
+	ds_clonegc_bitmap_t *cbm = NULL;
+	ds_clonegc_output_t *output;
+	gfx_bitmap_t *bitmap;
+	errno_t rc;
+
+	cbm = calloc(1, sizeof(ds_clonegc_bitmap_t));
+	if (cbm == NULL)
+		return ENOMEM;
+
+	list_initialize(&cbm->obitmaps);
+	cbm->clonegc = cgc;
+	cbm->params = *params;
+
+	output = ds_clonegc_first_output(cgc);
+	assert(output != NULL);
+
+	/* Create the first output bitmap */
+
+	rc = gfx_bitmap_create(output->gc, params, alloc, &bitmap);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_bitmap_get_alloc(bitmap, &cbm->alloc);
+	if (rc != EOK)
+		goto error;
+
+	rc = ds_clonegc_outbitmap_create(output, cbm, bitmap);
+	if (rc != EOK)
+		goto error;
+
+	bitmap = NULL;
+
+	/* Create all other output bitmaps as copies */
+	output = ds_clonegc_next_output(output);
+	while (output != NULL) {
+		rc = ds_clonegc_bitmap_add_output(cbm, output);
+		if (rc != EOK)
+			goto error;
+
+		output = ds_clonegc_next_output(output);
+	}
+
+	list_append(&cbm->lbitmaps, &cgc->bitmaps);
+	*rbm = (void *)cbm;
+	return EOK;
+error:
+	if (bitmap != NULL)
+		gfx_bitmap_destroy(bitmap);
+	if (cbm != NULL)
+		ds_clonegc_bitmap_destroy(cbm);
+	return rc;
+}
+
+/** Destroy bitmap in memory GC.
+ *
+ * @param bm Bitmap
+ * @return EOK on success or an error code
+ */
+static errno_t ds_clonegc_bitmap_destroy(void *bm)
+{
+	ds_clonegc_bitmap_t *cbm = (ds_clonegc_bitmap_t *)bm;
+	ds_clonegc_outbitmap_t *outbm;
+	errno_t rc;
+
+	outbm = ds_clonegc_bitmap_first_obm(cbm);
+	while (outbm != NULL) {
+		rc = ds_clonegc_outbitmap_destroy(outbm);
+		if (rc != EOK)
+			return rc;
+
+		outbm = ds_clonegc_bitmap_first_obm(cbm);
+	}
+
+	list_remove(&cbm->lbitmaps);
+	free(cbm);
+	return EOK;
+}
+
+/** Render bitmap in memory GC.
+ *
+ * @param bm Bitmap
+ * @param srect0 Source rectangle or @c NULL
+ * @param offs0 Offset or @c NULL
+ * @return EOK on success or an error code
+ */
+static errno_t ds_clonegc_bitmap_render(void *bm, gfx_rect_t *srect0,
+    gfx_coord2_t *offs0)
+{
+	ds_clonegc_bitmap_t *cbm = (ds_clonegc_bitmap_t *)bm;
+	ds_clonegc_outbitmap_t *outbm;
+	errno_t rc;
+
+	outbm = ds_clonegc_bitmap_first_obm(cbm);
+	while (outbm != NULL) {
+		rc = gfx_bitmap_render(outbm->obitmap, srect0, offs0);
+		if (rc != EOK)
+			return rc;
+
+		outbm = ds_clonegc_bitmap_next_obm(outbm);
+	}
+
+	return EOK;
+}
+
+/** Get allocation info for bitmap in memory GC.
+ *
+ * @param bm Bitmap
+ * @param alloc Place to store allocation info
+ * @return EOK on success or an error code
+ */
+static errno_t ds_clonegc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
+{
+	ds_clonegc_bitmap_t *cbm = (ds_clonegc_bitmap_t *)bm;
+
+	*alloc = cbm->alloc;
+	return EOK;
+}
+
+/** Get first clone GC output.
+ *
+ * @param cgc Clone GC
+ * @return First output or @c NULL if there are none
+ */
+static ds_clonegc_output_t *ds_clonegc_first_output(ds_clonegc_t *cgc)
+{
+	link_t *link;
+
+	link = list_first(&cgc->outputs);
+	if (link == NULL)
+		return NULL;
+
+	return list_get_instance(link, ds_clonegc_output_t, loutputs);
+}
+
+/** Get next clone GC output.
+ *
+ * @param cur Current output
+ * @return Next output or @c NULL if @a cur is the last
+ */
+static ds_clonegc_output_t *ds_clonegc_next_output(ds_clonegc_output_t *cur)
+{
+	link_t *link;
+
+	link = list_next(&cur->loutputs, &cur->clonegc->outputs);
+	if (link == NULL)
+		return NULL;
+
+	return list_get_instance(link, ds_clonegc_output_t, loutputs);
+}
+
+/** Get first clone GC bitmap.
+ *
+ * @param cgc Clone GC
+ * @return First bitmap or @c NULL if there are none
+ */
+static ds_clonegc_bitmap_t *ds_clonegc_first_bitmap(ds_clonegc_t *cgc)
+{
+	link_t *link;
+
+	link = list_first(&cgc->bitmaps);
+	if (link == NULL)
+		return NULL;
+
+	return list_get_instance(link, ds_clonegc_bitmap_t, lbitmaps);
+}
+
+/** Get next clone GC bitmap.
+ *
+ * @param cur Current bitmap
+ * @return Next bitmap or @c NULL if @a cur is the last
+ */
+static ds_clonegc_bitmap_t *ds_clonegc_next_bitmap(ds_clonegc_bitmap_t *cur)
+{
+	link_t *link;
+
+	link = list_next(&cur->lbitmaps, &cur->clonegc->bitmaps);
+	if (link == NULL)
+		return NULL;
+
+	return list_get_instance(link, ds_clonegc_bitmap_t, lbitmaps);
+}
+
+/** Get first output bitmap of a clone GC bitmap.
+ *
+ * @param cbm Clone GC bitmap
+ * @return First output bitmap or @c NULL if there are none
+ */
+static ds_clonegc_outbitmap_t *ds_clonegc_bitmap_first_obm(ds_clonegc_bitmap_t *cbm)
+{
+	link_t *link;
+
+	link = list_first(&cbm->obitmaps);
+	if (link == NULL)
+		return NULL;
+
+	return list_get_instance(link, ds_clonegc_outbitmap_t, lbbitmaps);
+}
+
+/** Get next output bitmap of a clone GC bitmap.
+ *
+ * @param cur Current output bitmap
+ * @return Next output bitmap or @c NULL if @a cur is the last
+ */
+static ds_clonegc_outbitmap_t *ds_clonegc_bitmap_next_obm(ds_clonegc_outbitmap_t *cur)
+{
+	link_t *link;
+
+	link = list_next(&cur->lbbitmaps, &cur->bitmap->obitmaps);
+	if (link == NULL)
+		return NULL;
+
+	return list_get_instance(link, ds_clonegc_outbitmap_t, lbbitmaps);
+}
+
+/** Create clone GC output bitmap.
+ *
+ * Create a new entry in the output x bitmap matrix.
+ *
+ * @param output Clone GC output
+ * @param cbm Clone GC bitmap
+ * @param obitmap Output bitmap
+ */
+static errno_t ds_clonegc_outbitmap_create(ds_clonegc_output_t *output,
+    ds_clonegc_bitmap_t *cbm, gfx_bitmap_t *obitmap)
+{
+	ds_clonegc_outbitmap_t *outbm;
+
+	outbm = calloc(1, sizeof(ds_clonegc_outbitmap_t));
+	if (outbm == NULL)
+		return ENOMEM;
+
+	outbm->output = output;
+	outbm->bitmap = cbm;
+	list_append(&outbm->lobitmaps, &output->obitmaps);
+	list_append(&outbm->lbbitmaps, &cbm->obitmaps);
+	outbm->obitmap = obitmap;
+
+	return EOK;
+}
+
+/** Destroy clone GC output bitmap.
+ *
+ * @param outbm Output bitmap
+ * @return EOK on success or an error code
+ */
+static errno_t ds_clonegc_outbitmap_destroy(ds_clonegc_outbitmap_t *outbm)
+{
+	errno_t rc;
+
+	rc = gfx_bitmap_destroy(outbm->obitmap);
+	if (rc != EOK)
+		return rc;
+
+	list_remove(&outbm->lobitmaps);
+	list_remove(&outbm->lbbitmaps);
+	free(outbm);
+	return EOK;
+}
+
+/** Extend clone GC bitmap to new output.
+ *
+ * @param cbm Clone GC bitmap
+ * @param output Clone GC output
+ */
+static errno_t ds_clonegc_bitmap_add_output(ds_clonegc_bitmap_t *cbm,
+    ds_clonegc_output_t *output)
+{
+	gfx_bitmap_t *obitmap = NULL;
+	errno_t rc;
+
+	rc = gfx_bitmap_create(output->gc, &cbm->params, &cbm->alloc, &obitmap);
+	if (rc != EOK)
+		goto error;
+
+	rc = ds_clonegc_outbitmap_create(output, cbm, obitmap);
+	if (rc != EOK)
+		goto error;
+
+	return EOK;
+error:
+	if (obitmap != NULL)
+		gfx_bitmap_destroy(obitmap);
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/srv/hid/display/clonegc.h
===================================================================
--- uspace/srv/hid/display/clonegc.h	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
+++ uspace/srv/hid/display/clonegc.h	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup display
+ * @{
+ */
+/**
+ * @file Cloning grapics context
+ */
+
+#ifndef CLONEGC_H
+#define CLONEGC_H
+
+#include <errno.h>
+#include <gfx/bitmap.h>
+#include "types/display/clonegc.h"
+
+extern gfx_context_ops_t ds_clonegc_ops;
+
+extern errno_t ds_clonegc_create(gfx_context_t *, ds_clonegc_t **);
+extern errno_t ds_clonegc_delete(ds_clonegc_t *);
+extern errno_t ds_clonegc_add_output(ds_clonegc_t *, gfx_context_t *);
+extern gfx_context_t *ds_clonegc_get_ctx(ds_clonegc_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/hid/display/ddev.c
===================================================================
--- uspace/srv/hid/display/ddev.c	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/srv/hid/display/ddev.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -141,5 +141,5 @@
 	}
 
-	rc = ds_display_paint_bg(display, NULL);
+	rc = ds_display_paint(display, NULL);
 	if (rc != EOK)
 		return rc;
Index: uspace/srv/hid/display/display.c
===================================================================
--- uspace/srv/hid/display/display.c	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/srv/hid/display/display.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -42,4 +42,5 @@
 #include <stdlib.h>
 #include "client.h"
+#include "clonegc.h"
 #include "cursimg.h"
 #include "cursor.h"
@@ -505,6 +506,21 @@
 		disp->rect = ddev->info.rect;
 
+		/* Create cloning GC */
+		rc = ds_clonegc_create(ddev->gc, &disp->fbgc);
+		if (rc != EOK) {
+			// XXX Remove output
+			return ENOMEM;
+		}
+
 		/* Allocate backbuffer */
 		rc = ds_display_alloc_backbuf(disp);
+		if (rc != EOK) {
+			// XXX Remove output
+			// XXX Delete clone GC
+			goto error;
+		}
+	} else {
+		/* Add new output device to cloning GC */
+		rc = ds_clonegc_add_output(disp->fbgc, ddev->gc);
 		if (rc != EOK)
 			goto error;
@@ -596,15 +612,9 @@
 static gfx_context_t *ds_display_get_unbuf_gc(ds_display_t *display)
 {
-	ds_ddev_t *ddev;
-
-	/*
-	 * XXX To properly support multiple display devices, create
-	 * a cloning GC that copies rendering operation to each output.
-	 */
-	ddev = ds_display_first_ddev(display);
-	if (ddev == NULL)
-		return NULL;
-
-	return ddev->gc;
+	/* In case of unit tests */
+	if (display->fbgc == NULL)
+		return NULL;
+
+	return ds_clonegc_get_ctx(display->fbgc);
 }
 
Index: uspace/srv/hid/display/meson.build
===================================================================
--- uspace/srv/hid/display/meson.build	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/srv/hid/display/meson.build	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -31,4 +31,5 @@
 src = files(
 	'client.c',
+	'clonegc.c',
 	'cursor.c',
 	'cursimg.c',
@@ -45,4 +46,5 @@
 test_src = files(
 	'client.c',
+	'clonegc.c',
 	'cursimg.c',
 	'cursor.c',
@@ -52,4 +54,5 @@
 	'window.c',
 	'test/client.c',
+	'test/clonegc.c',
 	'test/cursor.c',
 	'test/display.c',
Index: uspace/srv/hid/display/test/clonegc.c
===================================================================
--- uspace/srv/hid/display/test/clonegc.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
+++ uspace/srv/hid/display/test/clonegc.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -0,0 +1,709 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <gfx/color.h>
+#include <gfx/render.h>
+#include <pcut/pcut.h>
+#include <stdio.h>
+
+#include "../clonegc.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(clonegc);
+
+static errno_t testgc_set_color(void *, gfx_color_t *);
+static errno_t testgc_fill_rect(void *, gfx_rect_t *);
+static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
+    gfx_bitmap_alloc_t *, void **);
+static errno_t testgc_bitmap_destroy(void *);
+static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
+static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
+
+static gfx_context_ops_t ops = {
+	.set_color = testgc_set_color,
+	.fill_rect = testgc_fill_rect,
+	.bitmap_create = testgc_bitmap_create,
+	.bitmap_destroy = testgc_bitmap_destroy,
+	.bitmap_render = testgc_bitmap_render,
+	.bitmap_get_alloc = testgc_bitmap_get_alloc
+};
+
+typedef struct {
+	/** Error code to return */
+	errno_t rc;
+
+	bool set_color_called;
+	gfx_color_t *set_color_color;
+
+	bool fill_rect_called;
+	gfx_rect_t *fill_rect_rect;
+
+	bool bm_created;
+	bool bm_destroyed;
+	gfx_bitmap_params_t bm_params;
+	void *bm_pixels;
+	gfx_rect_t bm_srect;
+	gfx_coord2_t bm_offs;
+	bool bm_rendered;
+	bool bm_got_alloc;
+} test_gc_t;
+
+typedef struct {
+	test_gc_t *tgc;
+	gfx_bitmap_alloc_t alloc;
+	bool myalloc;
+} testgc_bitmap_t;
+
+enum {
+	alloc_pitch = 42,
+	alloc_off0 = 33
+};
+
+/** Test creating and deleting clone GC */
+PCUT_TEST(create_delete)
+{
+	ds_clonegc_t *cgc;
+	errno_t rc;
+
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Test set color operation with two output GCs */
+PCUT_TEST(set_color)
+{
+	ds_clonegc_t *cgc;
+	gfx_context_t *gc;
+	test_gc_t tgc1;
+	gfx_context_t *gc1;
+	test_gc_t tgc2;
+	gfx_context_t *gc2;
+	gfx_color_t *color;
+	errno_t rc;
+
+	/* Create clone GC */
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = ds_clonegc_get_ctx(cgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	/* Add two output GCs */
+
+	rc = gfx_context_new(&ops, &tgc1, &gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = gfx_context_new(&ops, &tgc2, &gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = gfx_color_new_rgb_i16(0xaaaa, 0xbbbb, 0xcccc, &color);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Set color returning error */
+
+	tgc1.set_color_called = false;
+	tgc2.set_color_called = false;
+	tgc1.rc = EINVAL;
+	tgc2.rc = EINVAL;
+
+	rc = gfx_set_color(gc, color);
+	PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.set_color_called);
+	PCUT_ASSERT_EQUALS(color, tgc1.set_color_color);
+	PCUT_ASSERT_FALSE(tgc2.set_color_called);
+
+	/* Set color returning success for all outputs */
+	tgc1.set_color_called = false;
+	tgc2.set_color_called = false;
+	tgc1.rc = EOK;
+	tgc2.rc = EOK;
+
+	rc = gfx_set_color(gc, color);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.set_color_called);
+	PCUT_ASSERT_EQUALS(color, tgc1.set_color_color);
+	PCUT_ASSERT_TRUE(tgc2.set_color_called);
+	PCUT_ASSERT_EQUALS(color, tgc2.set_color_color);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gfx_color_delete(color);
+}
+
+/** Fill rectangle operation with two output GCs */
+PCUT_TEST(fill_rect)
+{
+	ds_clonegc_t *cgc;
+	gfx_context_t *gc;
+	test_gc_t tgc1;
+	gfx_context_t *gc1;
+	test_gc_t tgc2;
+	gfx_context_t *gc2;
+	gfx_rect_t rect;
+	errno_t rc;
+
+	/* Create clone GC */
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = ds_clonegc_get_ctx(cgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	/* Add two output GCs */
+
+	rc = gfx_context_new(&ops, &tgc1, &gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = gfx_context_new(&ops, &tgc2, &gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rect.p0.x = 1;
+	rect.p0.y = 2;
+	rect.p1.x = 3;
+	rect.p1.y = 4;
+
+	/* Fill rectangle returning error */
+
+	tgc1.fill_rect_called = false;
+	tgc2.fill_rect_called = false;
+	tgc1.rc = EINVAL;
+	tgc2.rc = EINVAL;
+
+	rc = gfx_fill_rect(gc, &rect);
+	PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.fill_rect_called);
+	PCUT_ASSERT_EQUALS(&rect, tgc1.fill_rect_rect);
+	PCUT_ASSERT_FALSE(tgc2.fill_rect_called);
+
+	/* Fill rectangle returning success for all outputs */
+	tgc1.fill_rect_called = false;
+	tgc2.fill_rect_called = false;
+	tgc1.rc = EOK;
+	tgc2.rc = EOK;
+
+	rc = gfx_fill_rect(gc, &rect);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.fill_rect_called);
+	PCUT_ASSERT_EQUALS(&rect, tgc1.fill_rect_rect);
+	PCUT_ASSERT_TRUE(tgc2.fill_rect_called);
+	PCUT_ASSERT_EQUALS(&rect, tgc2.fill_rect_rect);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Operations on regular bitmap with two output GCs, callee allocation */
+PCUT_TEST(bitmap_twogc_callee_alloc)
+{
+	ds_clonegc_t *cgc;
+	gfx_context_t *gc;
+	test_gc_t tgc1;
+	gfx_context_t *gc1;
+	test_gc_t tgc2;
+	gfx_context_t *gc2;
+	gfx_bitmap_params_t params;
+	gfx_bitmap_t *bitmap;
+	gfx_bitmap_alloc_t alloc;
+	gfx_rect_t rect;
+	gfx_coord2_t off;
+	errno_t rc;
+
+	/* Create clone GC */
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = ds_clonegc_get_ctx(cgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	/* Add two output GCs */
+
+	rc = gfx_context_new(&ops, &tgc1, &gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = gfx_context_new(&ops, &tgc2, &gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Create bitmap with NULL allocation */
+	tgc1.bm_created = false;
+	tgc2.bm_created = false;
+	gfx_bitmap_params_init(&params);
+	params.rect.p0.x = 1;
+	params.rect.p0.y = 2;
+	params.rect.p1.x = 3;
+	params.rect.p1.y = 4;
+
+	rc = gfx_bitmap_create(gc, &params, NULL, &bitmap);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.bm_created);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.x, tgc1.bm_params.rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.y, tgc1.bm_params.rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.x, tgc1.bm_params.rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.y, tgc1.bm_params.rect.p1.y);
+
+	PCUT_ASSERT_TRUE(tgc2.bm_created);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.x, tgc2.bm_params.rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.y, tgc2.bm_params.rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.x, tgc2.bm_params.rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.y, tgc2.bm_params.rect.p1.y);
+
+	/* Get allocation */
+
+	rc = gfx_bitmap_get_alloc(bitmap, &alloc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_INT_EQUALS(alloc_pitch, alloc.pitch);
+	PCUT_ASSERT_EQUALS(tgc1.bm_pixels, alloc.pixels);
+	PCUT_ASSERT_EQUALS(tgc2.bm_pixels, alloc.pixels);
+
+	/* Render bitmap */
+	tgc1.bm_rendered = false;
+	tgc1.bm_rendered = false;
+	rect.p0.x = 10;
+	rect.p0.y = 20;
+	rect.p1.x = 30;
+	rect.p1.y = 40;
+	off.x = 50;
+	off.y = 60;
+	rc = gfx_bitmap_render(bitmap, &rect, &off);
+	PCUT_ASSERT_TRUE(tgc1.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc1.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc1.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc1.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc1.bm_srect.p1.y);
+	PCUT_ASSERT_TRUE(tgc2.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc2.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc2.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc2.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc2.bm_srect.p1.y);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Operations on regular bitmap with two output GCs, caller allocation */
+PCUT_TEST(bitmap_twogc_caller_alloc)
+{
+	ds_clonegc_t *cgc;
+	gfx_context_t *gc;
+	test_gc_t tgc1;
+	gfx_context_t *gc1;
+	test_gc_t tgc2;
+	gfx_context_t *gc2;
+	gfx_bitmap_params_t params;
+	gfx_bitmap_t *bitmap;
+	gfx_bitmap_alloc_t alloc;
+	gfx_bitmap_alloc_t galloc;
+	void *pixels;
+	gfx_rect_t rect;
+	gfx_coord2_t off;
+	errno_t rc;
+
+	/* Create clone GC */
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = ds_clonegc_get_ctx(cgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	/* Add two output GCs */
+	rc = gfx_context_new(&ops, &tgc1, &gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = gfx_context_new(&ops, &tgc2, &gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Create bitmap with caller allocation */
+	tgc1.bm_created = false;
+	tgc2.bm_created = false;
+	gfx_bitmap_params_init(&params);
+	params.rect.p0.x = 1;
+	params.rect.p0.y = 2;
+	params.rect.p1.x = 3;
+	params.rect.p1.y = 4;
+
+	pixels = calloc(2 * 2, sizeof(uint32_t));
+	PCUT_ASSERT_NOT_NULL(pixels);
+
+	alloc.pitch = 8;
+	alloc.off0 = 0;
+	alloc.pixels = pixels;
+
+	rc = gfx_bitmap_create(gc, &params, &alloc, &bitmap);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.bm_created);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.x, tgc1.bm_params.rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.y, tgc1.bm_params.rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.x, tgc1.bm_params.rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.y, tgc1.bm_params.rect.p1.y);
+
+	PCUT_ASSERT_TRUE(tgc2.bm_created);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.x, tgc2.bm_params.rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.y, tgc2.bm_params.rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.x, tgc2.bm_params.rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.y, tgc2.bm_params.rect.p1.y);
+
+	/* Get allocation */
+	rc = gfx_bitmap_get_alloc(bitmap, &galloc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_INT_EQUALS(alloc.pitch, galloc.pitch);
+	PCUT_ASSERT_INT_EQUALS(alloc.off0, galloc.off0);
+	PCUT_ASSERT_EQUALS(alloc.pixels, galloc.pixels);
+	PCUT_ASSERT_EQUALS(tgc1.bm_pixels, galloc.pixels);
+	PCUT_ASSERT_EQUALS(tgc2.bm_pixels, galloc.pixels);
+
+	/* Render bitmap */
+	tgc1.bm_rendered = false;
+	tgc1.bm_rendered = false;
+	rect.p0.x = 10;
+	rect.p0.y = 20;
+	rect.p1.x = 30;
+	rect.p1.y = 40;
+	off.x = 50;
+	off.y = 60;
+	rc = gfx_bitmap_render(bitmap, &rect, &off);
+	PCUT_ASSERT_TRUE(tgc1.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc1.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc1.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc1.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc1.bm_srect.p1.y);
+	PCUT_ASSERT_TRUE(tgc2.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc2.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc2.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc2.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc2.bm_srect.p1.y);
+
+	free(pixels);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Create bitmap, then add second GC, callee allocation */
+PCUT_TEST(bitmap_addgc_callee_alloc)
+{
+	ds_clonegc_t *cgc;
+	gfx_context_t *gc;
+	test_gc_t tgc1;
+	gfx_context_t *gc1;
+	test_gc_t tgc2;
+	gfx_context_t *gc2;
+	gfx_bitmap_params_t params;
+	gfx_bitmap_t *bitmap;
+	gfx_bitmap_alloc_t alloc;
+	gfx_rect_t rect;
+	gfx_coord2_t off;
+	errno_t rc;
+
+	/* Create clone GC */
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = ds_clonegc_get_ctx(cgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	/* Add one output GC */
+	rc = gfx_context_new(&ops, &tgc1, &gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Create bitmap with NULL allocation */
+	tgc1.bm_created = false;
+	tgc2.bm_created = false;
+	gfx_bitmap_params_init(&params);
+	params.rect.p0.x = 1;
+	params.rect.p0.y = 2;
+	params.rect.p1.x = 3;
+	params.rect.p1.y = 4;
+
+	rc = gfx_bitmap_create(gc, &params, NULL, &bitmap);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.bm_created);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.x, tgc1.bm_params.rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.y, tgc1.bm_params.rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.x, tgc1.bm_params.rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.y, tgc1.bm_params.rect.p1.y);
+
+	PCUT_ASSERT_FALSE(tgc2.bm_created);
+
+	/* Get allocation */
+	rc = gfx_bitmap_get_alloc(bitmap, &alloc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_INT_EQUALS(alloc_pitch, alloc.pitch);
+	PCUT_ASSERT_EQUALS(tgc1.bm_pixels, alloc.pixels);
+
+	/* Add second output GC */
+	rc = gfx_context_new(&ops, &tgc2, &gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Render bitmap */
+	tgc1.bm_rendered = false;
+	tgc1.bm_rendered = false;
+	rect.p0.x = 10;
+	rect.p0.y = 20;
+	rect.p1.x = 30;
+	rect.p1.y = 40;
+	off.x = 50;
+	off.y = 60;
+	rc = gfx_bitmap_render(bitmap, &rect, &off);
+	PCUT_ASSERT_TRUE(tgc1.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc1.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc1.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc1.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc1.bm_srect.p1.y);
+	PCUT_ASSERT_TRUE(tgc2.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc2.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc2.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc2.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc2.bm_srect.p1.y);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Create bitmap, then add second GC, caller allocation */
+PCUT_TEST(bitmap_addgc_caller_alloc)
+{
+	ds_clonegc_t *cgc;
+	gfx_context_t *gc;
+	test_gc_t tgc1;
+	gfx_context_t *gc1;
+	test_gc_t tgc2;
+	gfx_context_t *gc2;
+	gfx_bitmap_params_t params;
+	gfx_bitmap_t *bitmap;
+	gfx_bitmap_alloc_t alloc;
+	gfx_bitmap_alloc_t galloc;
+	void *pixels;
+	gfx_rect_t rect;
+	gfx_coord2_t off;
+	errno_t rc;
+
+	/* Create clone GC */
+	rc = ds_clonegc_create(NULL, &cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = ds_clonegc_get_ctx(cgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	/* Add one output GC */
+	rc = gfx_context_new(&ops, &tgc1, &gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Create bitmap with caller allocation */
+	tgc1.bm_created = false;
+	tgc2.bm_created = false;
+	gfx_bitmap_params_init(&params);
+	params.rect.p0.x = 1;
+	params.rect.p0.y = 2;
+	params.rect.p1.x = 3;
+	params.rect.p1.y = 4;
+
+	pixels = calloc(2 * 2, sizeof(uint32_t));
+	PCUT_ASSERT_NOT_NULL(pixels);
+
+	alloc.pitch = 8;
+	alloc.off0 = 0;
+	alloc.pixels = pixels;
+
+	rc = gfx_bitmap_create(gc, &params, &alloc, &bitmap);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc1.bm_created);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.x, tgc1.bm_params.rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p0.y, tgc1.bm_params.rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.x, tgc1.bm_params.rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(params.rect.p1.y, tgc1.bm_params.rect.p1.y);
+
+	PCUT_ASSERT_FALSE(tgc2.bm_created);
+
+	/* Get allocation */
+	rc = gfx_bitmap_get_alloc(bitmap, &galloc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_INT_EQUALS(alloc.pitch, galloc.pitch);
+	PCUT_ASSERT_INT_EQUALS(alloc.off0, galloc.off0);
+	PCUT_ASSERT_EQUALS(alloc.pixels, galloc.pixels);
+	PCUT_ASSERT_EQUALS(tgc1.bm_pixels, galloc.pixels);
+
+	/* Add second output GC */
+	rc = gfx_context_new(&ops, &tgc2, &gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_clonegc_add_output(cgc, gc2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	/* Render bitmap */
+	tgc1.bm_rendered = false;
+	tgc1.bm_rendered = false;
+	rect.p0.x = 10;
+	rect.p0.y = 20;
+	rect.p1.x = 30;
+	rect.p1.y = 40;
+	off.x = 50;
+	off.y = 60;
+	rc = gfx_bitmap_render(bitmap, &rect, &off);
+	PCUT_ASSERT_TRUE(tgc1.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc1.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc1.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc1.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc1.bm_srect.p1.y);
+	PCUT_ASSERT_TRUE(tgc2.bm_rendered);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc2.bm_srect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc2.bm_srect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc2.bm_srect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc2.bm_srect.p1.y);
+
+	free(pixels);
+
+	rc = ds_clonegc_delete(cgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+static errno_t testgc_set_color(void *arg, gfx_color_t *color)
+{
+	test_gc_t *tgc = (test_gc_t *) arg;
+
+	tgc->set_color_called = true;
+	tgc->set_color_color = color;
+
+	return tgc->rc;
+}
+
+static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	test_gc_t *tgc = (test_gc_t *) arg;
+
+	tgc->fill_rect_called = true;
+	tgc->fill_rect_rect = rect;
+
+	return tgc->rc;
+}
+
+static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
+    gfx_bitmap_alloc_t *alloc, void **rbm)
+{
+	test_gc_t *tgc = (test_gc_t *) arg;
+	testgc_bitmap_t *tbm;
+
+	tbm = calloc(1, sizeof(testgc_bitmap_t));
+	if (tbm == NULL)
+		return ENOMEM;
+
+	if (alloc == NULL) {
+		tbm->alloc.pitch = alloc_pitch;
+		tbm->alloc.off0 = alloc_off0;
+		tbm->alloc.pixels = calloc(1, 420);
+		tbm->myalloc = true;
+		if (tbm->alloc.pixels == NULL) {
+			free(tbm);
+			return ENOMEM;
+		}
+	} else {
+		tbm->alloc = *alloc;
+	}
+
+	tbm->tgc = tgc;
+	tgc->bm_created = true;
+	tgc->bm_params = *params;
+	tgc->bm_pixels = tbm->alloc.pixels;
+	*rbm = (void *)tbm;
+	return EOK;
+}
+
+static errno_t testgc_bitmap_destroy(void *bm)
+{
+	testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
+	if (tbm->myalloc)
+		free(tbm->alloc.pixels);
+	tbm->tgc->bm_destroyed = true;
+	free(tbm);
+	return EOK;
+}
+
+static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
+    gfx_coord2_t *offs)
+{
+	testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
+	tbm->tgc->bm_rendered = true;
+	tbm->tgc->bm_srect = *srect;
+	tbm->tgc->bm_offs = *offs;
+	return EOK;
+}
+
+static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
+{
+	testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
+	*alloc = tbm->alloc;
+	tbm->tgc->bm_got_alloc = true;
+	return EOK;
+}
+
+PCUT_EXPORT(clonegc);
Index: uspace/srv/hid/display/test/main.c
===================================================================
--- uspace/srv/hid/display/test/main.c	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/srv/hid/display/test/main.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -32,4 +32,5 @@
 
 PCUT_IMPORT(client);
+PCUT_IMPORT(clonegc);
 PCUT_IMPORT(cursor);
 PCUT_IMPORT(display);
Index: uspace/srv/hid/display/types/display/clonegc.h
===================================================================
--- uspace/srv/hid/display/types/display/clonegc.h	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
+++ uspace/srv/hid/display/types/display/clonegc.h	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup display
+ * @{
+ */
+/**
+ * @file Cloning graphic context
+ */
+
+#ifndef TYPES_DISPLAY_CLONEGC_H
+#define TYPES_DISPLAY_CLONEGC_H
+
+#include <adt/list.h>
+#include <gfx/context.h>
+
+/** Cloning graphic context.
+ *
+ * A graphic context that clones rendering to a number of GCs. We need
+ * to clone every bitmap to every GC so we end up with a matrix-like
+ * structure (made of linked lists).
+ *
+ * ds_clonegc_output_t x ds_clonegc_bitmap_t -> ds_clonegc_outbitmap_t.
+ */
+typedef struct {
+	/** Graphic context */
+	gfx_context_t *gc;
+	/** Output GCs (of ds_clonegc_output_t) */
+	list_t outputs;
+	/** Bitmaps (of ds_clonegc_bitmap_t) */
+	list_t bitmaps;
+} ds_clonegc_t;
+
+/** Clone GC output */
+typedef struct {
+	/** Containing clone GC */
+	ds_clonegc_t *clonegc;
+	/** Link to @c clonegc->outputs */
+	link_t loutputs;
+	/** Output GC */
+	gfx_context_t *gc;
+	/** Output bitmaps (of ds_clonegc_outbitmap_t) */
+	list_t obitmaps;
+} ds_clonegc_output_t;
+
+/** Bitmap in cloning GC.
+ *
+ * Has a list of output bitmaps for all outputs.
+ */
+typedef struct {
+	/** Containing clone GC */
+	ds_clonegc_t *clonegc;
+	/** Bitmap parameters */
+	gfx_bitmap_params_t params;
+	/** Bitmap allocation */
+	gfx_bitmap_alloc_t alloc;
+	/** Link to @c clonegc->bitmaps */
+	link_t lbitmaps;
+	/** Output bitmaps (of ds_clonegc_outbitmap_t) */
+	list_t obitmaps;
+} ds_clonegc_bitmap_t;
+
+/** Output bitmap in cloning GC.
+ *
+ * It is contained in two linked lists. The list of all output bitmaps for
+ * a particular output and the list of all output bitmaps for a particular
+ * bitmap.
+ */
+typedef struct {
+	/** Containing output */
+	ds_clonegc_output_t *output;
+	/** Containing bitmap */
+	ds_clonegc_bitmap_t *bitmap;
+	/** Link to @c output->obitmaps */
+	link_t lobitmaps;
+	/** Linkt ot @c bitmap->obitmaps */
+	link_t lbbitmaps;
+	/** Output-specific bitmap */
+	gfx_bitmap_t *obitmap;
+} ds_clonegc_outbitmap_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/hid/display/types/display/display.h
===================================================================
--- uspace/srv/hid/display/types/display/display.h	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/srv/hid/display/types/display/display.h	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -45,4 +45,5 @@
 #include <types/display/cursor.h>
 #include "cursor.h"
+#include "clonegc.h"
 #include "window.h"
 
@@ -100,4 +101,7 @@
 	mem_gc_t *bbgc;
 
+	/** Frontbuffer (clone) GC */
+	ds_clonegc_t *fbgc;
+
 	/** Backbuffer dirty rectangle */
 	gfx_rect_t dirty_rect;
Index: uspace/srv/hid/rfb/main.c
===================================================================
--- uspace/srv/hid/rfb/main.c	(revision 66a408f7126c478b69911641d731a269d8ef6266)
+++ uspace/srv/hid/rfb/main.c	(revision 5271e4ce7c269901a92de4f2e7b3ed4926eec5f2)
@@ -110,5 +110,5 @@
 	rfb->damage_rect.y = new_rect.p0.y;
 	rfb->damage_rect.width = new_rect.p1.x - new_rect.p0.x;
-	rfb->damage_rect.height = new_rect.p1.y - new_rect.p1.y;
+	rfb->damage_rect.height = new_rect.p1.y - new_rect.p0.y;
 }
 
