[gtk+] Create tests for cairo node



commit 74a677a79d54ea9904c79a1d597e5106777d2cef
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Oct 6 23:56:54 2017 +0530

    Create tests for cairo node
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788534

 tests/rendernode-create-tests.c |   47 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/tests/rendernode-create-tests.c b/tests/rendernode-create-tests.c
index 0f8d760..2621c26 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 },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]