Index: uspace/app/gfxdemo/gfxdemo.c
===================================================================
--- uspace/app/gfxdemo/gfxdemo.c	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ uspace/app/gfxdemo/gfxdemo.c	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -34,8 +34,8 @@
 
 #include <canvas.h>
+#include <congfx/console.h>
 #include <draw/surface.h>
 #include <fibril.h>
-#include <gfx/backend/canvas.h>
-#include <gfx/backend/console.h>
+#include <guigfx/canvas.h>
 #include <gfx/color.h>
 #include <gfx/render.h>
@@ -161,6 +161,4 @@
 	}
 
-//	sig_connect(&canvas->keyboard_event, NULL, wnd_keyboard_event);
-
 	window_resize(window, 0, 0, vw + 10, vh + 30, WINDOW_PLACEMENT_ANY);
 	window_exec(window);
Index: uspace/app/gfxdemo/meson.build
===================================================================
--- uspace/app/gfxdemo/meson.build	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ uspace/app/gfxdemo/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -27,5 +27,5 @@
 #
 
-deps = [ 'gfx' ]
+deps = [ 'gfx', 'guigfx', 'congfx' ]
 src = files(
 	'gfxdemo.c',
Index: uspace/lib/congfx/doc/doxygroups.h
===================================================================
--- uspace/lib/congfx/doc/doxygroups.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/congfx/doc/doxygroups.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,3 @@
+/** @addtogroup libcongfx libcongfx
+ * @ingroup libs
+ */
Index: uspace/lib/congfx/include/congfx/console.h
===================================================================
--- uspace/lib/congfx/include/congfx/console.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/congfx/include/congfx/console.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2019 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 libcongfx
+ * @{
+ */
+/**
+ * @file GFX console backend
+ */
+
+#ifndef _CONGFX_CONSOLE_H
+#define _CONGFX_CONSOLE_H
+
+#include <io/console.h>
+#include <stdio.h>
+#include <types/congfx/console.h>
+#include <types/gfx/context.h>
+#include <types/gfx/ops/context.h>
+
+extern gfx_context_ops_t console_gc_ops;
+
+extern errno_t console_gc_create(console_ctrl_t *, FILE *, console_gc_t **);
+extern errno_t console_gc_delete(console_gc_t *);
+extern gfx_context_t *console_gc_get_ctx(console_gc_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/congfx/include/types/congfx/console.h
===================================================================
--- uspace/lib/congfx/include/types/congfx/console.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/congfx/include/types/congfx/console.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 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 libcongfx
+ * @{
+ */
+/**
+ * @file GFX console backend
+ */
+
+#ifndef _CONGFX_TYPES_CONSOLE_H
+#define _CONGFX_TYPES_CONSOLE_H
+
+struct console_gc;
+typedef struct console_gc console_gc_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/congfx/meson.build
===================================================================
--- uspace/lib/congfx/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/congfx/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2015 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.
+#
+
+deps = [ 'gfx' ]
+src = files(
+	'src/console.c',
+)
Index: uspace/lib/congfx/private/console.h
===================================================================
--- uspace/lib/congfx/private/console.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/congfx/private/console.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2019 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 libcongfx
+ * @{
+ */
+/**
+ * @file GFX console backend structure
+ *
+ */
+
+#ifndef _CONGFX_PRIVATE_CONSOLE_H
+#define _CONGFX_PRIVATE_CONSOLE_H
+
+#include <gfx/context.h>
+#include <io/console.h>
+#include <stdio.h>
+
+/** Actual structure of graphics context.
+ *
+ * This is private to libcongfx. It is not visible to clients nor backends.
+ */
+struct console_gc {
+	/** Base graphic context */
+	gfx_context_t *gc;
+	/** Console control structure */
+	console_ctrl_t *con;
+	/** File for printing characters */
+	FILE *fout;
+};
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/congfx/src/console.c
===================================================================
--- uspace/lib/congfx/src/console.c	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/congfx/src/console.c	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2019 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 libcongfx
+ * @{
+ */
+/**
+ * @file GFX console backend
+ *
+ * This implements a graphics context over a classic console interface.
+ * This is just for experimentation purposes. In the end we want the
+ * console to actually directly suport GFX interface.
+ */
+
+#include <congfx/console.h>
+#include <gfx/context.h>
+#include <gfx/render.h>
+#include <io/pixel.h>
+#include <stdlib.h>
+#include "../private/console.h"
+#include "../private/color.h"
+
+static errno_t console_gc_set_color(void *, gfx_color_t *);
+static errno_t console_gc_fill_rect(void *, gfx_rect_t *);
+
+gfx_context_ops_t console_gc_ops = {
+	.set_color = console_gc_set_color,
+	.fill_rect = console_gc_fill_rect
+};
+
+/** Set color on console GC.
+ *
+ * Set drawing color on console GC.
+ *
+ * @param arg Console GC
+ * @param color Color
+ *
+ * @return EOK on success or an error code
+ */
+static errno_t console_gc_set_color(void *arg, gfx_color_t *color)
+{
+	console_gc_t *cgc = (console_gc_t *) arg;
+	pixel_t clr;
+
+	clr = PIXEL(0, color->r >> 8, color->g >> 8, color->b >> 8);
+
+	console_set_rgb_color(cgc->con, clr, clr);
+	return EOK;
+}
+
+/** Fill rectangle on console GC.
+ *
+ * @param arg Console GC
+ * @param rect Rectangle
+ *
+ * @return EOK on success or an error code
+ */
+static errno_t console_gc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	console_gc_t *cgc = (console_gc_t *) arg;
+	int rv;
+	int x, y;
+
+	// XXX We should handle p0.x > p1.x and p0.y > p1.y
+
+	for (y = rect->p0.y; y < rect->p1.y; y++) {
+		console_set_pos(cgc->con, rect->p0.x, y);
+
+		for (x = rect->p0.x; x < rect->p1.x; x++) {
+			rv = fputc('X', cgc->fout);
+			if (rv < 0)
+				return EIO;
+		}
+
+		console_flush(cgc->con);
+	}
+
+	return EOK;
+}
+
+/** Create console GC.
+ *
+ * Create graphics context for rendering into a console.
+ *
+ * @param con Console object
+ * @param fout File to which characters are written (console)
+ * @param rgc Place to store pointer to new GC.
+ *
+ * @return EOK on success or an error code
+ */
+errno_t console_gc_create(console_ctrl_t *con, FILE *fout,
+    console_gc_t **rgc)
+{
+	console_gc_t *cgc = NULL;
+	gfx_context_t *gc = NULL;
+	errno_t rc;
+
+	cgc = calloc(1, sizeof(console_gc_t));
+	if (cgc == NULL) {
+		rc = ENOMEM;
+		goto error;
+	}
+
+	rc = gfx_context_new(&console_gc_ops, cgc, &gc);
+	if (rc != EOK)
+		goto error;
+
+	cgc->gc = gc;
+	cgc->con = con;
+	cgc->fout = fout;
+	*rgc = cgc;
+	return EOK;
+error:
+	if (cgc != NULL)
+		free(cgc);
+	gfx_context_delete(gc);
+	return rc;
+}
+
+/** Delete console GC.
+ *
+ * @param cgc Console GC
+ */
+errno_t console_gc_delete(console_gc_t *cgc)
+{
+	errno_t rc;
+
+	rc = gfx_context_delete(cgc->gc);
+	if (rc != EOK)
+		return rc;
+
+	free(cgc);
+	return EOK;
+}
+
+/** Get generic graphic context from console GC.
+ *
+ * @param cgc Console GC
+ * @return Graphic context
+ */
+gfx_context_t *console_gc_get_ctx(console_gc_t *cgc)
+{
+	return cgc->gc;
+}
+
+/** @}
+ */
Index: pace/lib/gfx/include/gfx/backend/canvas.h
===================================================================
--- uspace/lib/gfx/include/gfx/backend/canvas.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX canvas backend
- */
-
-#ifndef _GFX_BACKEND_CANVAS_H
-#define _GFX_BACKEND_CANVAS_H
-
-#include <canvas.h>
-#include <types/gfx/backend/canvas.h>
-#include <types/gfx/context.h>
-#include <types/gfx/ops/context.h>
-
-extern gfx_context_ops_t canvas_gc_ops;
-
-extern errno_t canvas_gc_create(canvas_t *, surface_t *, canvas_gc_t **);
-extern errno_t canvas_gc_delete(canvas_gc_t *);
-extern gfx_context_t *canvas_gc_get_ctx(canvas_gc_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gfx/include/gfx/backend/console.h
===================================================================
--- uspace/lib/gfx/include/gfx/backend/console.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX console backend
- */
-
-#ifndef _GFX_BACKEND_CONSOLE_H
-#define _GFX_BACKEND_CONSOLE_H
-
-#include <io/console.h>
-#include <stdio.h>
-#include <types/gfx/backend/console.h>
-#include <types/gfx/context.h>
-#include <types/gfx/ops/context.h>
-
-extern gfx_context_ops_t console_gc_ops;
-
-extern errno_t console_gc_create(console_ctrl_t *, FILE *, console_gc_t **);
-extern errno_t console_gc_delete(console_gc_t *);
-extern gfx_context_t *console_gc_get_ctx(console_gc_t *);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/gfx/include/gfx/color.h
===================================================================
--- uspace/lib/gfx/include/gfx/color.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ uspace/lib/gfx/include/gfx/color.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -44,4 +44,6 @@
     uint16_t, gfx_color_t **);
 extern void gfx_color_delete(gfx_color_t *);
+extern void gfx_color_get_rgb_i16(gfx_color_t *, uint16_t *, uint16_t *,
+    uint16_t *);
 
 #endif
Index: pace/lib/gfx/include/types/gfx/backend/canvas.h
===================================================================
--- uspace/lib/gfx/include/types/gfx/backend/canvas.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX canvas backend
- */
-
-#ifndef _GFX_TYPES_BACKEND_CANVAS_H
-#define _GFX_TYPES_BACKEND_CANVAS_H
-
-struct canvas_gc;
-typedef struct canvas_gc canvas_gc_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/gfx/include/types/gfx/backend/console.h
===================================================================
--- uspace/lib/gfx/include/types/gfx/backend/console.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX console backend
- */
-
-#ifndef _GFX_TYPES_BACKEND_CONSOLE_H
-#define _GFX_TYPES_BACKEND_CONSOLE_H
-
-struct console_gc;
-typedef struct console_gc console_gc_t;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/gfx/meson.build
===================================================================
--- uspace/lib/gfx/meson.build	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ uspace/lib/gfx/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -27,8 +27,5 @@
 #
 
-deps = [ 'gui' ]
 src = files(
-	'src/backend/canvas.c',
-	'src/backend/console.c',
 	'src/color.c',
 	'src/context.c',
Index: pace/lib/gfx/private/backend/canvas.h
===================================================================
--- uspace/lib/gfx/private/backend/canvas.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,63 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX canvas backend structure
- *
- */
-
-#ifndef _GFX_PRIVATE_BACKEND_CANVAS_H
-#define _GFX_PRIVATE_BACKEND_CANVAS_H
-
-#include <canvas.h>
-#include <draw/surface.h>
-#include <io/pixel.h>
-#include "../context.h"
-
-/** Actual structure of graphics context.
- *
- * This is private to libgfx. It is not visible to clients nor backends.
- */
-struct canvas_gc {
-	/** Base graphic context */
-	gfx_context_t *gc;
-	/** Canvas */
-	canvas_t *canvas;
-	/** Surface */
-	surface_t *surface;
-	/** Current drawing color */
-	pixel_t color;
-};
-
-#endif
-
-/** @}
- */
Index: pace/lib/gfx/private/backend/console.h
===================================================================
--- uspace/lib/gfx/private/backend/console.h	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX console backend structure
- *
- */
-
-#ifndef _GFX_PRIVATE_BACKEND_CONSOLE_H
-#define _GFX_PRIVATE_BACKEND_CONSOLE_H
-
-#include <io/console.h>
-#include <stdio.h>
-#include "../context.h"
-
-/** Actual structure of graphics context.
- *
- * This is private to libgfx. It is not visible to clients nor backends.
- */
-struct console_gc {
-	/** Base graphic context */
-	gfx_context_t *gc;
-	/** Console control structure */
-	console_ctrl_t *con;
-	/** File for printing characters */
-	FILE *fout;
-};
-
-#endif
-
-/** @}
- */
Index: pace/lib/gfx/src/backend/canvas.c
===================================================================
--- uspace/lib/gfx/src/backend/canvas.c	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,163 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX canvas backend
- *
- * This implements a graphics context over a libgui canvas.
- * This is just for experimentation purposes and its kind of backwards.
- */
-
-#include <gfx/backend/canvas.h>
-#include <gfx/context.h>
-#include <gfx/render.h>
-#include <io/pixel.h>
-#include <stdlib.h>
-#include "../../private/backend/canvas.h"
-#include "../../private/color.h"
-
-static errno_t canvas_gc_set_color(void *, gfx_color_t *);
-static errno_t canvas_gc_fill_rect(void *, gfx_rect_t *);
-
-gfx_context_ops_t canvas_gc_ops = {
-	.set_color = canvas_gc_set_color,
-	.fill_rect = canvas_gc_fill_rect
-};
-
-/** Set color on canvas GC.
- *
- * Set drawing color on canvas GC.
- *
- * @param arg Canvas GC
- * @param color Color
- *
- * @return EOK on success or an error code
- */
-static errno_t canvas_gc_set_color(void *arg, gfx_color_t *color)
-{
-	canvas_gc_t *cgc = (canvas_gc_t *) arg;
-
-	cgc->color = PIXEL(0, color->r >> 8, color->g >> 8, color->b >> 8);
-	return EOK;
-}
-
-/** Fill rectangle on canvas GC.
- *
- * @param arg Canvas GC
- * @param rect Rectangle
- *
- * @return EOK on success or an error code
- */
-static errno_t canvas_gc_fill_rect(void *arg, gfx_rect_t *rect)
-{
-	canvas_gc_t *cgc = (canvas_gc_t *) arg;
-	int x, y;
-
-	// XXX We should handle p0.x > p1.x and p0.y > p1.y
-
-	for (y = rect->p0.y; y < rect->p1.y; y++) {
-		for (x = rect->p0.x; x < rect->p1.x; x++) {
-			surface_put_pixel(cgc->surface, x, y, cgc->color);
-		}
-	}
-
-	update_canvas(cgc->canvas, cgc->surface);
-
-	return EOK;
-}
-
-/** Create canvas GC.
- *
- * Create graphics context for rendering into a canvas.
- *
- * @param con Canvas object
- * @param fout File to which characters are written (canvas)
- * @param rgc Place to store pointer to new GC.
- *
- * @return EOK on success or an error code
- */
-errno_t canvas_gc_create(canvas_t *canvas, surface_t *surface,
-    canvas_gc_t **rgc)
-{
-	canvas_gc_t *cgc = NULL;
-	gfx_context_t *gc = NULL;
-	errno_t rc;
-
-	cgc = calloc(1, sizeof(canvas_gc_t));
-	if (cgc == NULL) {
-		rc = ENOMEM;
-		goto error;
-	}
-
-	rc = gfx_context_new(&canvas_gc_ops, cgc, &gc);
-	if (rc != EOK)
-		goto error;
-
-	cgc->gc = gc;
-	cgc->canvas = canvas;
-	cgc->surface = surface;
-	*rgc = cgc;
-	return EOK;
-error:
-	if (cgc != NULL)
-		free(cgc);
-	gfx_context_delete(gc);
-	return rc;
-}
-
-/** Delete canvas GC.
- *
- * @param cgc Canvas GC
- */
-errno_t canvas_gc_delete(canvas_gc_t *cgc)
-{
-	errno_t rc;
-
-	rc = gfx_context_delete(cgc->gc);
-	if (rc != EOK)
-		return rc;
-
-	free(cgc);
-	return EOK;
-}
-
-/** Get generic graphic context from canvas GC.
- *
- * @param cgc Canvas GC
- * @return Graphic context
- */
-gfx_context_t *canvas_gc_get_ctx(canvas_gc_t *cgc)
-{
-	return cgc->gc;
-}
-
-/** @}
- */
Index: pace/lib/gfx/src/backend/console.c
===================================================================
--- uspace/lib/gfx/src/backend/console.c	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ 	(revision )
@@ -1,172 +1,0 @@
-/*
- * Copyright (c) 2019 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 libgfx
- * @{
- */
-/**
- * @file GFX console backend
- *
- * This implements a graphics context over a classic console interface.
- * This is just for experimentation purposes. In the end we want the
- * console to actually directly suport GFX interface.
- */
-
-#include <gfx/backend/console.h>
-#include <gfx/context.h>
-#include <gfx/render.h>
-#include <io/pixel.h>
-#include <stdlib.h>
-#include "../../private/backend/console.h"
-#include "../../private/color.h"
-
-static errno_t console_gc_set_color(void *, gfx_color_t *);
-static errno_t console_gc_fill_rect(void *, gfx_rect_t *);
-
-gfx_context_ops_t console_gc_ops = {
-	.set_color = console_gc_set_color,
-	.fill_rect = console_gc_fill_rect
-};
-
-/** Set color on console GC.
- *
- * Set drawing color on console GC.
- *
- * @param arg Console GC
- * @param color Color
- *
- * @return EOK on success or an error code
- */
-static errno_t console_gc_set_color(void *arg, gfx_color_t *color)
-{
-	console_gc_t *cgc = (console_gc_t *) arg;
-	pixel_t clr;
-
-	clr = PIXEL(0, color->r >> 8, color->g >> 8, color->b >> 8);
-
-	console_set_rgb_color(cgc->con, clr, clr);
-	return EOK;
-}
-
-/** Fill rectangle on console GC.
- *
- * @param arg Console GC
- * @param rect Rectangle
- *
- * @return EOK on success or an error code
- */
-static errno_t console_gc_fill_rect(void *arg, gfx_rect_t *rect)
-{
-	console_gc_t *cgc = (console_gc_t *) arg;
-	int rv;
-	int x, y;
-
-	// XXX We should handle p0.x > p1.x and p0.y > p1.y
-
-	for (y = rect->p0.y; y < rect->p1.y; y++) {
-		console_set_pos(cgc->con, rect->p0.x, y);
-
-		for (x = rect->p0.x; x < rect->p1.x; x++) {
-			rv = fputc('X', cgc->fout);
-			if (rv < 0)
-				return EIO;
-		}
-
-		console_flush(cgc->con);
-	}
-
-	return EOK;
-}
-
-/** Create console GC.
- *
- * Create graphics context for rendering into a console.
- *
- * @param con Console object
- * @param fout File to which characters are written (console)
- * @param rgc Place to store pointer to new GC.
- *
- * @return EOK on success or an error code
- */
-errno_t console_gc_create(console_ctrl_t *con, FILE *fout,
-    console_gc_t **rgc)
-{
-	console_gc_t *cgc = NULL;
-	gfx_context_t *gc = NULL;
-	errno_t rc;
-
-	cgc = calloc(1, sizeof(console_gc_t));
-	if (cgc == NULL) {
-		rc = ENOMEM;
-		goto error;
-	}
-
-	rc = gfx_context_new(&console_gc_ops, cgc, &gc);
-	if (rc != EOK)
-		goto error;
-
-	cgc->gc = gc;
-	cgc->con = con;
-	cgc->fout = fout;
-	*rgc = cgc;
-	return EOK;
-error:
-	if (cgc != NULL)
-		free(cgc);
-	gfx_context_delete(gc);
-	return rc;
-}
-
-/** Delete console GC.
- *
- * @param cgc Console GC
- */
-errno_t console_gc_delete(console_gc_t *cgc)
-{
-	errno_t rc;
-
-	rc = gfx_context_delete(cgc->gc);
-	if (rc != EOK)
-		return rc;
-
-	free(cgc);
-	return EOK;
-}
-
-/** Get generic graphic context from console GC.
- *
- * @param cgc Console GC
- * @return Graphic context
- */
-gfx_context_t *console_gc_get_ctx(console_gc_t *cgc)
-{
-	return cgc->gc;
-}
-
-/** @}
- */
Index: uspace/lib/gfx/src/color.c
===================================================================
--- uspace/lib/gfx/src/color.c	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ uspace/lib/gfx/src/color.c	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -78,4 +78,19 @@
 }
 
+/** Convert color to 16-bit RGB coordinates.
+ *
+ * @param color Color
+ * @param r Place to store red coordinate
+ * @param g Place to store green coordinate
+ * @param b Place to store blue coordinate
+ */
+void gfx_color_get_rgb_i16(gfx_color_t *color, uint16_t *r, uint16_t *g,
+    uint16_t *b)
+{
+	*r = color->r;
+	*g = color->g;
+	*b = color->b;
+}
+
 /** @}
  */
Index: uspace/lib/guigfx/doc/doxygroups.h
===================================================================
--- uspace/lib/guigfx/doc/doxygroups.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/guigfx/doc/doxygroups.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,3 @@
+/** @addtogroup libguigfx libguigfx
+ * @ingroup libs
+ */
Index: uspace/lib/guigfx/include/guigfx/canvas.h
===================================================================
--- uspace/lib/guigfx/include/guigfx/canvas.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/guigfx/include/guigfx/canvas.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2019 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 libguigfx
+ * @{
+ */
+/**
+ * @file GFX canvas backend
+ */
+
+#ifndef _GUIGFX_CANVAS_H
+#define _GUIGFX_CANVAS_H
+
+#include <canvas.h>
+#include <types/gfx/context.h>
+#include <types/gfx/ops/context.h>
+#include <types/guigfx/canvas.h>
+
+extern gfx_context_ops_t canvas_gc_ops;
+
+extern errno_t canvas_gc_create(canvas_t *, surface_t *, canvas_gc_t **);
+extern errno_t canvas_gc_delete(canvas_gc_t *);
+extern gfx_context_t *canvas_gc_get_ctx(canvas_gc_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/guigfx/include/types/guigfx/canvas.h
===================================================================
--- uspace/lib/guigfx/include/types/guigfx/canvas.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/guigfx/include/types/guigfx/canvas.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 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 libguigfx
+ * @{
+ */
+/**
+ * @file GFX canvas backend
+ */
+
+#ifndef _GUIGFX_TYPES_CANVAS_H
+#define _GUIGFX_TYPES_CANVAS_H
+
+struct canvas_gc;
+typedef struct canvas_gc canvas_gc_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/guigfx/meson.build
===================================================================
--- uspace/lib/guigfx/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/guigfx/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2019 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.
+#
+
+deps = [ 'gui', 'gfx' ]
+src = files(
+	'src/canvas.c'
+)
Index: uspace/lib/guigfx/private/canvas.h
===================================================================
--- uspace/lib/guigfx/private/canvas.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/guigfx/private/canvas.h	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019 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 libguigfx
+ * @{
+ */
+/**
+ * @file GFX canvas backend structure
+ *
+ */
+
+#ifndef _GUIGFX_PRIVATE_CANVAS_H
+#define _GUIGFX_PRIVATE_CANVAS_H
+
+#include <canvas.h>
+#include <draw/surface.h>
+#include <gfx/context.h>
+#include <io/pixel.h>
+
+/** Actual structure of graphics context.
+ *
+ * This is private to libguigfx. It is not visible to clients nor backends.
+ */
+struct canvas_gc {
+	/** Base graphic context */
+	gfx_context_t *gc;
+	/** Canvas */
+	canvas_t *canvas;
+	/** Surface */
+	surface_t *surface;
+	/** Current drawing color */
+	pixel_t color;
+};
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/guigfx/src/canvas.c
===================================================================
--- uspace/lib/guigfx/src/canvas.c	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
+++ uspace/lib/guigfx/src/canvas.c	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2019 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 libguigfx
+ * @{
+ */
+/**
+ * @file GFX canvas backend
+ *
+ * This implements a graphics context over a libgui canvas.
+ * This is just for experimentation purposes and its kind of backwards.
+ */
+
+#include <gfx/color.h>
+#include <gfx/context.h>
+#include <gfx/render.h>
+#include <guigfx/canvas.h>
+#include <io/pixel.h>
+#include <stdlib.h>
+#include "../private/canvas.h"
+//#include "../../private/color.h"
+
+static errno_t canvas_gc_set_color(void *, gfx_color_t *);
+static errno_t canvas_gc_fill_rect(void *, gfx_rect_t *);
+
+gfx_context_ops_t canvas_gc_ops = {
+	.set_color = canvas_gc_set_color,
+	.fill_rect = canvas_gc_fill_rect
+};
+
+/** Set color on canvas GC.
+ *
+ * Set drawing color on canvas GC.
+ *
+ * @param arg Canvas GC
+ * @param color Color
+ *
+ * @return EOK on success or an error code
+ */
+static errno_t canvas_gc_set_color(void *arg, gfx_color_t *color)
+{
+	canvas_gc_t *cgc = (canvas_gc_t *) arg;
+	uint16_t r, g, b;
+
+	gfx_color_get_rgb_i16(color, &r, &g, &b);
+	cgc->color = PIXEL(0, r >> 8, g >> 8, b >> 8);
+	return EOK;
+}
+
+/** Fill rectangle on canvas GC.
+ *
+ * @param arg Canvas GC
+ * @param rect Rectangle
+ *
+ * @return EOK on success or an error code
+ */
+static errno_t canvas_gc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	canvas_gc_t *cgc = (canvas_gc_t *) arg;
+	int x, y;
+
+	// XXX We should handle p0.x > p1.x and p0.y > p1.y
+
+	for (y = rect->p0.y; y < rect->p1.y; y++) {
+		for (x = rect->p0.x; x < rect->p1.x; x++) {
+			surface_put_pixel(cgc->surface, x, y, cgc->color);
+		}
+	}
+
+	update_canvas(cgc->canvas, cgc->surface);
+
+	return EOK;
+}
+
+/** Create canvas GC.
+ *
+ * Create graphics context for rendering into a canvas.
+ *
+ * @param con Canvas object
+ * @param fout File to which characters are written (canvas)
+ * @param rgc Place to store pointer to new GC.
+ *
+ * @return EOK on success or an error code
+ */
+errno_t canvas_gc_create(canvas_t *canvas, surface_t *surface,
+    canvas_gc_t **rgc)
+{
+	canvas_gc_t *cgc = NULL;
+	gfx_context_t *gc = NULL;
+	errno_t rc;
+
+	cgc = calloc(1, sizeof(canvas_gc_t));
+	if (cgc == NULL) {
+		rc = ENOMEM;
+		goto error;
+	}
+
+	rc = gfx_context_new(&canvas_gc_ops, cgc, &gc);
+	if (rc != EOK)
+		goto error;
+
+	cgc->gc = gc;
+	cgc->canvas = canvas;
+	cgc->surface = surface;
+	*rgc = cgc;
+	return EOK;
+error:
+	if (cgc != NULL)
+		free(cgc);
+	gfx_context_delete(gc);
+	return rc;
+}
+
+/** Delete canvas GC.
+ *
+ * @param cgc Canvas GC
+ */
+errno_t canvas_gc_delete(canvas_gc_t *cgc)
+{
+	errno_t rc;
+
+	rc = gfx_context_delete(cgc->gc);
+	if (rc != EOK)
+		return rc;
+
+	free(cgc);
+	return EOK;
+}
+
+/** Get generic graphic context from canvas GC.
+ *
+ * @param cgc Canvas GC
+ * @return Graphic context
+ */
+gfx_context_t *canvas_gc_get_ctx(canvas_gc_t *cgc)
+{
+	return cgc->gc;
+}
+
+/** @}
+ */
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision 00e8290f885b3dc03a5c5a191983eb336d1e852c)
+++ uspace/lib/meson.build	(revision a3f63ac154a8851b99a2cdc01fb73050f4b9ca43)
@@ -52,4 +52,5 @@
 	'fmtutil',
 	'fs',
+	'gfx',
 	'graph',
 	'http',
@@ -82,5 +83,6 @@
 	'virtio',
 
-	'gfx',
+	'congfx',
+	'guigfx',
 	'ieee80211',
 ]
