Index: uspace/app/terminal/terminal.c
===================================================================
--- uspace/app/terminal/terminal.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/app/terminal/terminal.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -835,4 +835,5 @@
 
 	term->gc = ui_window_get_gc(term->window);
+	term->ui_res = ui_window_get_res(term->window);
 
 	ui_window_set_cb(term->window, &terminal_window_cb, (void *) term);
Index: uspace/app/terminal/terminal.h
===================================================================
--- uspace/app/terminal/terminal.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/app/terminal/terminal.h	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -57,4 +57,5 @@
 	ui_t *ui;
 	ui_window_t *window;
+	ui_resource_t *ui_res;
 	gfx_context_t *gc;
 
Index: uspace/app/uidemo/uidemo.c
===================================================================
--- uspace/app/uidemo/uidemo.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/app/uidemo/uidemo.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -99,4 +99,5 @@
 	ui_demo_t demo;
 	gfx_rect_t rect;
+	ui_resource_t *ui_res;
 	errno_t rc;
 
@@ -126,4 +127,6 @@
 	demo.window = window;
 
+	ui_res = ui_window_get_res(window);
+
 	rc = ui_fixed_create(&demo.fixed);
 	if (rc != EOK) {
@@ -132,5 +135,5 @@
 	}
 
-	rc = ui_label_create(ui, "Hello there!", &demo.label);
+	rc = ui_label_create(ui_res, "Hello there!", &demo.label);
 	if (rc != EOK) {
 		printf("Error creating label.\n");
@@ -151,5 +154,5 @@
 	}
 
-	rc = ui_pbutton_create(ui, "Confirm", &demo.pb1);
+	rc = ui_pbutton_create(ui_res, "Confirm", &demo.pb1);
 	if (rc != EOK) {
 		printf("Error creating button.\n");
@@ -173,5 +176,5 @@
 	}
 
-	rc = ui_pbutton_create(ui, "Cancel", &demo.pb2);
+	rc = ui_pbutton_create(ui_res, "Cancel", &demo.pb2);
 	if (rc != EOK) {
 		printf("Error creating button.\n");
Index: uspace/lib/ui/include/ui/label.h
===================================================================
--- uspace/lib/ui/include/ui/label.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/include/ui/label.h	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -42,7 +42,7 @@
 #include <types/ui/control.h>
 #include <types/ui/label.h>
-#include <types/ui/ui.h>
+#include <types/ui/resource.h>
 
-extern errno_t ui_label_create(ui_t *, const char *,
+extern errno_t ui_label_create(ui_resource_t *, const char *,
     ui_label_t **);
 extern void ui_label_destroy(ui_label_t *);
Index: uspace/lib/ui/include/ui/pbutton.h
===================================================================
--- uspace/lib/ui/include/ui/pbutton.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/include/ui/pbutton.h	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -43,8 +43,8 @@
 #include <types/ui/event.h>
 #include <types/ui/pbutton.h>
-#include <types/ui/ui.h>
+#include <types/ui/resource.h>
 #include <stdbool.h>
 
-extern errno_t ui_pbutton_create(ui_t *, const char *,
+extern errno_t ui_pbutton_create(ui_resource_t *, const char *,
     ui_pbutton_t **);
 extern void ui_pbutton_destroy(ui_pbutton_t *);
Index: uspace/lib/ui/include/ui/wdecor.h
===================================================================
--- uspace/lib/ui/include/ui/wdecor.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/include/ui/wdecor.h	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -41,8 +41,8 @@
 #include <io/pos_event.h>
 #include <stdbool.h>
-#include <types/ui/ui.h>
+#include <types/ui/resource.h>
 #include <types/ui/wdecor.h>
 
-extern errno_t ui_wdecor_create(ui_t *, const char *,
+extern errno_t ui_wdecor_create(ui_resource_t *, const char *,
     ui_wdecor_t **);
 extern void ui_wdecor_destroy(ui_wdecor_t *);
Index: uspace/lib/ui/include/ui/window.h
===================================================================
--- uspace/lib/ui/include/ui/window.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/include/ui/window.h	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -53,4 +53,5 @@
 extern void ui_window_add(ui_window_t *, ui_control_t *);
 extern void ui_window_remove(ui_window_t *, ui_control_t *);
+extern ui_resource_t *ui_window_get_res(ui_window_t *);
 extern gfx_context_t *ui_window_get_gc(ui_window_t *);
 extern void ui_window_get_app_rect(ui_window_t *, gfx_rect_t *);
Index: uspace/lib/ui/private/ui.h
===================================================================
--- uspace/lib/ui/private/ui.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/private/ui.h	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -48,6 +48,4 @@
 	/** Display */
 	display_t *display;
-	/** UI resource */
-	struct ui_resource *resource;
 	/** Output owned by UI, clean up when destroying UI */
 	bool myoutput;
Index: uspace/lib/ui/src/label.c
===================================================================
--- uspace/lib/ui/src/label.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/src/label.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -45,5 +45,4 @@
 #include "../private/label.h"
 #include "../private/resource.h"
-#include "../private/ui.h"
 
 static void ui_label_ctl_destroy(void *);
@@ -65,5 +64,5 @@
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ui_label_create(ui_t *ui, const char *text,
+errno_t ui_label_create(ui_resource_t *resource, const char *text,
     ui_label_t **rlabel)
 {
@@ -88,5 +87,5 @@
 	}
 
-	label->res = ui->resource;
+	label->res = resource;
 	label->halign = gfx_halign_left;
 	*rlabel = label;
Index: uspace/lib/ui/src/pbutton.c
===================================================================
--- uspace/lib/ui/src/pbutton.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/src/pbutton.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -47,5 +47,4 @@
 #include "../private/pbutton.h"
 #include "../private/resource.h"
-#include "../private/ui.h"
 
 /** Caption movement when button is pressed down */
@@ -73,5 +72,5 @@
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ui_pbutton_create(ui_t *ui, const char *caption,
+errno_t ui_pbutton_create(ui_resource_t *resource, const char *caption,
     ui_pbutton_t **rpbutton)
 {
@@ -97,5 +96,5 @@
 	}
 
-	pbutton->res = ui->resource;
+	pbutton->res = resource;
 	*rpbutton = pbutton;
 	return EOK;
Index: uspace/lib/ui/src/wdecor.c
===================================================================
--- uspace/lib/ui/src/wdecor.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/src/wdecor.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -46,5 +46,4 @@
 #include <ui/wdecor.h>
 #include "../private/resource.h"
-#include "../private/ui.h"
 #include "../private/wdecor.h"
 
@@ -62,5 +61,5 @@
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ui_wdecor_create(ui_t *ui, const char *caption,
+errno_t ui_wdecor_create(ui_resource_t *resource, const char *caption,
     ui_wdecor_t **rwdecor)
 {
@@ -78,5 +77,5 @@
 	}
 
-	rc = ui_pbutton_create(ui, "X", &wdecor->btn_close);
+	rc = ui_pbutton_create(resource, "X", &wdecor->btn_close);
 	if (rc != EOK) {
 		free(wdecor->caption);
@@ -88,5 +87,5 @@
 	    (void *)wdecor);
 
-	wdecor->res = ui->resource;
+	wdecor->res = resource;
 	wdecor->active = true;
 	*rwdecor = wdecor;
Index: uspace/lib/ui/src/window.c
===================================================================
--- uspace/lib/ui/src/window.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/src/window.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -135,7 +135,5 @@
 		goto error;
 
-	ui->resource = res;
-
-	rc = ui_wdecor_create(ui, params->caption, &wdecor);
+	rc = ui_wdecor_create(res, params->caption, &wdecor);
 	if (rc != EOK)
 		goto error;
@@ -225,12 +223,9 @@
 }
 
-/** Get window GC.
- *
- * Return the grapic context of the window. It is relative to the upper-left
- * corner of the window.
- *
- * @param window Window
- * @return Graphic context
- */
+ui_resource_t *ui_window_get_res(ui_window_t *window)
+{
+	return window->res;
+}
+
 gfx_context_t *ui_window_get_gc(ui_window_t *window)
 {
@@ -238,12 +233,4 @@
 }
 
-/** Get window application rectangle.
- *
- * Return the window's application rectangle. This is a rectangle covering
- * everything apart from the window frame and title bar.
- *
- * @param window Window
- * @param rect Place to store application rectangle
- */
 void ui_window_get_app_rect(ui_window_t *window, gfx_rect_t *rect)
 {
@@ -254,9 +241,4 @@
 }
 
-/** Paint window.
- *
- * @param window Window
- * @return EOK on success or an error code
- */
 errno_t ui_window_paint(ui_window_t *window)
 {
Index: uspace/lib/ui/test/label.c
===================================================================
--- uspace/lib/ui/test/label.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/test/label.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -34,5 +34,5 @@
 #include <ui/control.h>
 #include <ui/label.h>
-#include <ui/ui.h>
+#include <ui/resource.h>
 #include "../private/label.h"
 
@@ -40,4 +40,38 @@
 
 PCUT_TEST_SUITE(label);
+
+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 {
+	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;
 
 typedef struct {
@@ -149,11 +183,18 @@
 {
 	errno_t rc;
-	ui_t *ui;
-	ui_label_t *label;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_label_create(ui, "Hello", &label);
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
+	ui_label_t *label;
+
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_label_create(resource, "Hello", &label);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -162,5 +203,84 @@
 
 	ui_label_destroy(label);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+static errno_t testgc_set_color(void *arg, gfx_color_t *color)
+{
+	(void) arg;
+	(void) color;
+	return EOK;
+}
+
+static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	(void) arg;
+	(void) rect;
+	return EOK;
+}
+
+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 = (params->rect.p1.x - params->rect.p0.x) *
+		    sizeof(uint32_t);
+		tbm->alloc.off0 = 0;
+		tbm->alloc.pixels = calloc(sizeof(uint32_t),
+		    (params->rect.p1.x - params->rect.p0.x) *
+		    (params->rect.p1.y - params->rect.p0.y));
+		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;
 }
 
Index: uspace/lib/ui/test/pbutton.c
===================================================================
--- uspace/lib/ui/test/pbutton.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/test/pbutton.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -34,5 +34,5 @@
 #include <ui/control.h>
 #include <ui/pbutton.h>
-#include <ui/ui.h>
+#include <ui/resource.h>
 #include "../private/pbutton.h"
 
@@ -40,4 +40,21 @@
 
 PCUT_TEST_SUITE(pbutton);
+
+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
+};
 
 static void test_pbutton_clicked(ui_pbutton_t *, void *);
@@ -49,4 +66,21 @@
 static ui_pbutton_cb_t dummy_pbutton_cb = {
 };
+
+typedef struct {
+	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;
 
 typedef struct {
@@ -135,11 +169,18 @@
 {
 	errno_t rc;
-	ui_t *ui;
-	ui_pbutton_t *pbutton;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_pbutton_create(ui, "Hello", &pbutton);
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
+	ui_pbutton_t *pbutton;
+
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_pbutton_create(resource, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -148,5 +189,8 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 }
 
@@ -181,12 +225,19 @@
 {
 	errno_t rc;
-	ui_t *ui;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
 	ui_pbutton_t *pbutton;
 	test_cb_resp_t resp;
 
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_pbutton_create(ui, "Hello", &pbutton);
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_pbutton_create(resource, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -208,5 +259,8 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 }
 
@@ -215,12 +269,19 @@
 {
 	errno_t rc;
-	ui_t *ui;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
 	ui_pbutton_t *pbutton;
 	test_cb_resp_t resp;
 
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_pbutton_create(ui, "Hello", &pbutton);
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_pbutton_create(resource, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -247,5 +308,8 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 }
 
@@ -254,12 +318,19 @@
 {
 	errno_t rc;
-	ui_t *ui;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
 	ui_pbutton_t *pbutton;
 	test_cb_resp_t resp;
 
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_pbutton_create(ui, "Hello", &pbutton);
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_pbutton_create(resource, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -291,5 +362,8 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 }
 
@@ -298,5 +372,7 @@
 {
 	errno_t rc;
-	ui_t *ui;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
 	ui_pbutton_t *pbutton;
 	ui_evclaim_t claim;
@@ -304,8 +380,13 @@
 	gfx_rect_t rect;
 
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_pbutton_create(ui, "Hello", &pbutton);
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_pbutton_create(resource, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -343,5 +424,8 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 }
 
@@ -350,13 +434,20 @@
 {
 	errno_t rc;
-	ui_t *ui;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
 	ui_pbutton_t *pbutton;
 	pos_event_t event;
 	gfx_rect_t rect;
 
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_pbutton_create(ui, "Hello", &pbutton);
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_pbutton_create(resource, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -391,5 +482,84 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+static errno_t testgc_set_color(void *arg, gfx_color_t *color)
+{
+	(void) arg;
+	(void) color;
+	return EOK;
+}
+
+static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	(void) arg;
+	(void) rect;
+	return EOK;
+}
+
+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 = (params->rect.p1.x - params->rect.p0.x) *
+		    sizeof(uint32_t);
+		tbm->alloc.off0 = 0;
+		tbm->alloc.pixels = calloc(sizeof(uint32_t),
+		    (params->rect.p1.x - params->rect.p0.x) *
+		    (params->rect.p1.y - params->rect.p0.y));
+		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;
 }
 
Index: uspace/lib/ui/test/wdecor.c
===================================================================
--- uspace/lib/ui/test/wdecor.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/test/wdecor.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -33,5 +33,5 @@
 #include <stdbool.h>
 #include <ui/pbutton.h>
-#include <ui/ui.h>
+#include <ui/resource.h>
 #include <ui/wdecor.h>
 #include "../private/wdecor.h"
@@ -40,4 +40,21 @@
 
 PCUT_TEST_SUITE(wdecor);
+
+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
+};
 
 static void test_wdecor_close(ui_wdecor_t *, void *);
@@ -51,4 +68,21 @@
 static ui_wdecor_cb_t dummy_wdecor_cb = {
 };
+
+typedef struct {
+	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;
 
 typedef struct {
@@ -125,11 +159,18 @@
 {
 	errno_t rc;
-	ui_t *ui;
-	ui_wdecor_t *wdecor;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = ui_wdecor_create(ui, "Hello", &wdecor);
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
+	ui_wdecor_t *wdecor;
+
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_wdecor_create(resource, "Hello", &wdecor);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -138,5 +179,8 @@
 
 	ui_wdecor_destroy(wdecor);
-	ui_destroy(ui);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 }
 
@@ -327,4 +371,80 @@
 }
 
+static errno_t testgc_set_color(void *arg, gfx_color_t *color)
+{
+	(void) arg;
+	(void) color;
+	return EOK;
+}
+
+static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	(void) arg;
+	(void) rect;
+	return EOK;
+}
+
+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 = (params->rect.p1.x - params->rect.p0.x) *
+		    sizeof(uint32_t);
+		tbm->alloc.off0 = 0;
+		tbm->alloc.pixels = calloc(sizeof(uint32_t),
+		    (params->rect.p1.x - params->rect.p0.x) *
+		    (params->rect.p1.y - params->rect.p0.y));
+		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;
+}
+
 static void test_wdecor_close(ui_wdecor_t *wdecor, void *arg)
 {
Index: uspace/lib/ui/test/window.c
===================================================================
--- uspace/lib/ui/test/window.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
+++ uspace/lib/ui/test/window.c	(revision 3583ffba079f2204a6f171e8f3c934940ddb3679)
@@ -35,4 +35,5 @@
 #include <stdbool.h>
 #include <ui/control.h>
+#include <ui/resource.h>
 #include <ui/ui.h>
 #include <ui/window.h>
@@ -173,11 +174,12 @@
 }
 
-/** ui_window_get_gc/rect() return valid objects */
-PCUT_TEST(gc_rect)
-{
-	errno_t rc;
-	ui_t *ui = NULL;
-	ui_wnd_params_t params;
-	ui_window_t *window = NULL;
+/** ui_window_get_res/gc/rect() return valid objects */
+PCUT_TEST(get_res_gc_rect)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	ui_resource_t *res;
 	gfx_context_t *gc;
 	gfx_rect_t rect;
@@ -192,4 +194,7 @@
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 	PCUT_ASSERT_NOT_NULL(window);
+
+	res = ui_window_get_res(window);
+	PCUT_ASSERT_NOT_NULL(res);
 
 	gc = ui_window_get_gc(window);
