summaryrefslogtreecommitdiff
path: root/tests/rendernode-create-tests.c
diff options
context:
space:
mode:
authorUmang Jain <mailumangjain@gmail.com>2017-10-06 23:56:54 +0530
committerUmang Jain <mailumangjain@gmail.com>2017-10-08 18:22:34 +0530
commit74a677a79d54ea9904c79a1d597e5106777d2cef (patch)
treed34b75f96cc830376a4138d47d9fd69faea62970 /tests/rendernode-create-tests.c
parenta933c7c4bd01a8a65eaca24f20b0ecd490ea2fd4 (diff)
downloadgtk+-74a677a79d54ea9904c79a1d597e5106777d2cef.tar.gz
Create tests for cairo node
https://bugzilla.gnome.org/show_bug.cgi?id=788534
Diffstat (limited to 'tests/rendernode-create-tests.c')
-rw-r--r--tests/rendernode-create-tests.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/rendernode-create-tests.c b/tests/rendernode-create-tests.c
index 0f8d760869..2621c264f5 100644
--- a/tests/rendernode-create-tests.c
+++ b/tests/rendernode-create-tests.c
@@ -426,6 +426,52 @@ text (guint n)
}
GskRenderNode *
+cairo_node (guint n)
+{
+ GskRenderNode **nodes = g_newa (GskRenderNode *, n);
+ GskRenderNode *container;
+ cairo_surface_t *surface;
+ graphene_rect_t bounds;
+ gint offset = 0, height, width, stride;
+ guchar *buf;
+ guint i;
+
+ for (i = 0; i < n; i++)
+ {
+ bounds.size.width = g_random_int_range (20, 100);
+ bounds.origin.x = g_random_int_range (0, 1000 - bounds.size.width);
+ bounds.size.height = g_random_int_range (20, 100);
+ bounds.origin.y = g_random_int_range (0, 1000 - bounds.size.height);
+
+ height = g_random_int_range (1, 100);
+ width = g_random_int_range (1, 100);
+ stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width + offset);
+
+ buf = g_malloc (stride * height);
+
+ if (i % 3 == 0)
+ surface = NULL;
+ else
+ surface = cairo_image_surface_create_for_data (buf, CAIRO_FORMAT_ARGB32, width, height, stride);
+
+ nodes[i] = gsk_cairo_node_new_for_surface (&bounds, surface);
+
+ /* Offset in stride helps to test when image is not 'tightly packed' condition */
+ offset = offset ? 0 : 3;
+
+ cairo_surface_destroy (surface);
+ g_free (buf);
+ }
+
+ container = gsk_container_node_new (nodes, n);
+
+ for (i = 0; i < n; i++)
+ gsk_render_node_unref (nodes[i]);
+
+ return container;
+}
+
+GskRenderNode *
box_shadows (guint n)
{
GskRenderNode **nodes = g_newa (GskRenderNode *, n);
@@ -480,6 +526,7 @@ main (int argc, char **argv)
const char *name;
GskRenderNode * (* func) (guint n);
} functions[] = {
+ { "cairo.node", cairo_node },
{ "colors.node", colors },
{ "clipped-colors.node", clipped_colors },
{ "rounded-borders.node", rounded_borders },