[gnome-photos/wip/rishi/buffer-decoder: 17/17] tests: use cairo and simplify



commit cf4e061b282b320049e611abbe7c14273b4aff65
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Dec 23 09:48:22 2018 +0100

    tests: use cairo and simplify

 tests/unit/photos-test-gegl-buffer.c | 155 ++++++++++++++++++++++++-----------
 1 file changed, 108 insertions(+), 47 deletions(-)
---
diff --git a/tests/unit/photos-test-gegl-buffer.c b/tests/unit/photos-test-gegl-buffer.c
index f30e1911..7841dede 100644
--- a/tests/unit/photos-test-gegl-buffer.c
+++ b/tests/unit/photos-test-gegl-buffer.c
@@ -99,7 +99,6 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
   GeglColor *checkerboard_color2 = NULL; /* TODO: use g_autoptr */
   GeglNode *buffer_sink;
   GeglNode *checkerboard;
-  GeglNode *convert_format;
   GeglNode *crop;
   GeglNode *tail;
   g_autoptr (GeglNode) graph = NULL;
@@ -296,7 +295,20 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         "C268.601,307.601 274.601,292.801 273.001,288.801 "
         "C273.001,288.801 278.201,289.601 278.601,294.001 "
         "C278.601,294.001 282.601,270.801 277.801,264.801 "
-        "C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 
290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 
243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 
214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 
209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 
164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 
156.001C307.401 156.001 307.001 154.401 303.801 150.401 "
+        "C277.801,264.801 282.201,264.001 283.401,267.601 "
+        "L283.401,260.401 "
+        "C283.401,260.401 290.601,261.201 290.601,258.801 "
+        "C290.601,258.801 295.001,254.801 297.001,259.601 "
+        "C297.001,259.601 284.601,224.401 303.001,243.601 "
+        "C303.001,243.601 310.201,254.401 306.601,235.601 "
+        "C303.001,216.801 299.001,215.201 303.801,214.801 "
+        "C303.801,214.801 304.601,211.201 302.601,209.601 "
+        "C300.601,208.001 303.801,209.601 303.801,209.601 "
+        "C303.801,209.601 308.601,213.601 303.401,191.601 "
+        "C303.401,191.601 309.801,193.201 297.801,164.001 "
+        "C297.801,164.001 300.601,161.601 296.601,153.201 "
+        "C296.601,153.201 304.601,157.601 307.401,156.001 "
+        "C307.401,156.001 307.001,154.401 303.801,150.401 "
         "C303.801,150.401 282.201,95.6 302.601,117.601 "
         "C302.601,117.601 314.451,131.151 308.051,108.351 "
         "C308.051,108.351 298.94,84.341 299.717,80.045 "
@@ -307,8 +319,33 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1
       },
       {
-        "M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 
75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 
301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 
-53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 
-119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 
-139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 
-129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 
-103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 
-51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 
-42 -69.4 -39.2C-69.4 -39.2 -77 -2
 5.2 -75.
 8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 
-6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 
-97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4 "
-        "C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 
102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245 "
+        "M299.717,80.245 "
+        "C300.345,80.426 302.551,81.55 303.801,83.2 "
+        "C303.801,83.2 310.601,94 305.401,75.6 "
+        "C305.401,75.6 296.201,46.8 305.001,58 "
+        "C305.001,58 311.001,65.2 307.801,51.6 "
+        "C303.936,35.173 301.401,28.8 301.401,28.8 "
+        "C301.401,28.8 313.001,33.6 286.201,-6 "
+        "L295.001,-2.4 "
+        "C295.001,-2.4 275.401,-42 253.801,-47.2 "
+        "L245.801,-53.2 "
+        "C245.801,-53.2 284.201,-91.2 271.401,-128 "
+        "C271.401,-128 264.601,-133.2 255.001,-124 "
+        "C255.001,-124 248.601,-119.2 242.601,-120.8 "
+        "C242.601,-120.8 211.801,-119.6 209.801,-119.6 "
+        "C207.801,-119.6 173.001,-156.8 107.401,-139.2 "
+        "C107.401,-139.2 102.201,-137.2 97.801,-138.4 "
+        "C97.801,-138.4 79.4,-154.4 30.6,-131.6 "
+        "C30.6,-131.6 20.6,-129.6 19,-129.6 "
+        "C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 
-102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 
-52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 
-39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 
-11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 
-99.8 25.6 -97.8 30.8 "
+        "C-97.8,30.8 -97.4,35.6 -100.2,37.2 "
+        "C-100.2,37.2 -103.8,36.8 -95.4,48.8 "
+        "C-95.4,48.8 -94.6,50 -97.8,52.4 "
+        "C-97.8,52.4 -115,56 -117.4,72.4 "
+        "C-117.4,72.4 -131,87.2 -131,92.4 "
+        "C-131,94.705 -130.729,97.852 -130.03,102.465 "
+        "C-130.03,102.465 -130.6,110.801 -103,111.601 "
+        "C-75.4,112.401 299.717,80.245 299.717,80.245 "
         "z",
         "#cc7226",
         "#000000",
@@ -598,13 +635,13 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       },
       {
         "M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 
245.201 12.6 245.201",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
       {
         "M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 
238.001 47.6 233.801 52.6 230.801",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
@@ -618,14 +655,14 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       {
         "M47,244.801 "
         "C47,244.801 50.6,242.401 53,243.601",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
       {
         "M53.5,228.401 "
         "C53.5,228.401 56.4,223.501 61.2,222.701",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
@@ -785,7 +822,9 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1.0
       },
       {
-        "M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6 "
+        "M55.4,19.6 "
+        "C55.4,19.6 51,16.4 51,18.6 "
+        "C51,18.6 54.6,23 55.4,19.6 "
         "z",
         "#ffffff",
         "#00000000",
@@ -1047,7 +1086,9 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       },
       {
         "M22.2,63.4 "
-        "C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4",
+        "C22.2,63.4 6.8,52.4 5.8,51 "
+        "C5.8,51 -1.2,40 -14.2,39.6 "
+        "C-14.2,39.6 -35.6,40.4 -52.8,48.4",
         "#000000",
         "#4c0000",
         2.0
@@ -1895,7 +1936,10 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1.0
       },
       {
-        "M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 
287 "
+        "M270.5,287 "
+        "C270.5,287 258.5,277 256,273.5 "
+        "C256,273.5 269.5,292 269.5,299 "
+        "C269.5,299 272,291.5 270.5,287 "
         "z",
         "#cccccc",
         "#00000000",
@@ -1934,28 +1978,28 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       {
         "M-89.25,169 "
         "L-67.25,173.75",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       },
       {
         "M-39,331 "
         "C-39,331 -39.5,327.5 -48.5,338",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       },
       {
         "M-33.5,336 "
         "C-33.5,336 -31.5,329.5 -38,334",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       },
       {
         "M20.5,344.5 "
         "C20.5,344.5 22,333.5 10.5,346.5",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       }
@@ -1990,16 +2034,16 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
                                       "operation", "gegl:checkerboard",
                                       "color1", checkerboard_color1,
                                       "color2", checkerboard_color2,
-                                      "x", 5,
-                                      "y", 5,
+                                      "x", 25,
+                                      "y", 25,
                                       NULL);
 
   crop = gegl_node_new_child (graph,
                               "operation", "gegl:crop",
-                              "height", 640.0,
-                              "width", 640.0,
-                              "x", -180.0,
-                              "y", -180.0,
+                              "height", 600.0,
+                              "width", 600.0,
+                              "x", -200.0,
+                              "y", -200.0,
                               NULL);
 
   gegl_node_link (checkerboard, crop);
@@ -2007,41 +2051,58 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
 
   for (i = 0; i < G_N_ELEMENTS (paths); i++)
     {
-      GeglColor *fill = NULL; /* TODO: use g_autoptr */
-      GeglColor *stroke = NULL; /* TODO: use g_autoptr */
-      GeglNode *over;
-      GeglNode *path;
       GeglPath *d = NULL; /* TODO: use g_autoptr */
 
-      over = gegl_node_new_child (graph, "operation", "svg:src-over", NULL);
-
       d = gegl_path_new_from_string (paths[i].d);
-      fill = gegl_color_new (paths[i].fill);
-      stroke = gegl_color_new (paths[i].stroke);
-      path = gegl_node_new_child (graph,
-                                  "operation", "gegl:path",
-                                  "d", d,
-                                  "fill", fill,
-                                  "stroke", stroke,
-                                  "stroke-hardness", 1.0,
-                                  "stroke-width", paths[i].stroke_width,
-                                  NULL);
-
-      gegl_node_connect_to (path, "output", over, "aux");
-      gegl_node_link (tail, over);
-      tail = over;
+
+      if (paths[i].fill != NULL)
+        {
+          GeglColor *color = NULL; /* TODO: use g_autoptr */
+          GeglNode *fill_path;
+
+          color = gegl_color_new (paths[i].fill);
+          fill_path = gegl_node_new_child (graph,
+                                           "operation", "gegl:fill-path",
+                                           "d", d,
+                                           "color", color,
+                                           NULL);
+
+          gegl_node_link (tail, fill_path);
+          tail = fill_path;
+
+          g_object_unref (color);
+        }
+
+      if (paths[i].stroke != NULL)
+        {
+          GeglColor *color = NULL; /* TODO: use g_autoptr */
+          GeglNode *vector_stroke;
+
+          color = gegl_color_new (paths[i].stroke);
+          vector_stroke = gegl_node_new_child (graph,
+                                               "operation", "gegl:vector-stroke",
+                                               "d", d,
+                                               "color", color,
+                                               "width", paths[i].stroke_width,
+                                               NULL);
+
+          gegl_node_link (tail, vector_stroke);
+          tail = vector_stroke;
+
+          g_object_unref (color);
+        }
 
       g_object_unref (d);
-      g_object_unref (fill);
-      g_object_unref (stroke);
     }
 
   format = babl_format ("R'G'B'A u8");
-  convert_format = gegl_node_new_child (graph, "operation", "gegl:convert-format", "format", format, NULL);
-
-  buffer_sink = gegl_node_new_child (graph, "operation", "gegl:buffer-sink", "buffer", &buffer, NULL);
+  buffer_sink = gegl_node_new_child (graph,
+                                     "operation", "gegl:buffer-sink",
+                                     "buffer", &buffer,
+                                     "format", format,
+                                     NULL);
 
-  gegl_node_link_many (tail, convert_format, buffer_sink, NULL);
+  gegl_node_link (tail, buffer_sink);
   gegl_node_process (buffer_sink);
 
   fixture->buffer = g_object_ref (buffer);


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