[cairo-commit] 2 commits - test/cairo-test.c test/cairo-test.h test/raster-source.c test/record1414x.c test/record2x.c test/record90.c test/record.c test/recordflip.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 18 19:34:51 UTC 2020


 test/cairo-test.c    |    8 ++++++++
 test/cairo-test.h    |    3 +++
 test/raster-source.c |   15 ++++++++++++++-
 test/record.c        |    2 +-
 test/record1414x.c   |    2 +-
 test/record2x.c      |    2 +-
 test/record90.c      |    2 +-
 test/recordflip.c    |    2 +-
 8 files changed, 30 insertions(+), 6 deletions(-)

New commits:
commit 1676935768b888b3e4038b6dddb4f6362c137345
Author: Mathieu Duponchelle <mathieu at centricular.com>
Date:   Tue May 29 17:56:16 2018 +0200

    raster-source: fix when builddir != srcdir
    
    When the build dir is different from the source dir,
    "png.png" is not a valid path. As we can't dispose of
    an allocated filename, we add an atexit handler.

diff --git a/test/raster-source.c b/test/raster-source.c
index 5a7646e8a..ee2a570c3 100644
--- a/test/raster-source.c
+++ b/test/raster-source.c
@@ -34,6 +34,8 @@
 #define WIDTH 200
 #define HEIGHT 80
 
+static char *png_filename = NULL;
+
 /* Lazy way of determining PNG dimensions... */
 static void
 png_dimensions (const char *filename,
@@ -84,15 +86,26 @@ release (cairo_pattern_t *pattern, void *closure, cairo_surface_t *image)
     cairo_surface_destroy (image);
 }
 
+static void
+free_filename(void)
+{
+    free (png_filename);
+}
+
 static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
-    const char *png_filename = "png.png";
     cairo_pattern_t *png, *red;
     cairo_content_t content;
     int png_width, png_height;
     int i, j;
 
+    if (png_filename == NULL) {
+      const cairo_test_context_t *ctx = cairo_test_get_context (cr);
+      xasprintf (&png_filename, "%s/png.png", ctx->srcdir);
+      atexit (free_filename);
+    }
+
     png_dimensions (png_filename, &content, &png_width, &png_height);
 
     png = cairo_pattern_create_raster_source ((void*)png_filename,
commit 4645ecf3f89de9e25fc83d7c0fdb89188de7a2a3
Author: Mathieu Duponchelle <mathieu at centricular.com>
Date:   Tue May 29 17:54:02 2018 +0200

    record tests: fix when builddir != srcdir
    
    When builddir != srcdir, cairo_test_create_pattern_from_png
    needs a non-NULL ctx to work with.

diff --git a/test/cairo-test.c b/test/cairo-test.c
index dbfbf7e34..bab952603 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1662,6 +1662,14 @@ cairo_test_get_context (cairo_t *cr)
     return cairo_get_user_data (cr, &_cairo_test_context_key);
 }
 
+cairo_t *
+cairo_test_create (cairo_surface_t *surface, cairo_test_context_t *ctx)
+{
+  cairo_t *cr = cairo_create(surface);
+  cairo_set_user_data(cr, &_cairo_test_context_key, ctx, NULL);
+  return cr;
+}
+
 cairo_surface_t *
 cairo_test_create_surface_from_png (const cairo_test_context_t *ctx,
 	                            const char *filename)
diff --git a/test/cairo-test.h b/test/cairo-test.h
index 7e9605f61..767c1ddf5 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -317,6 +317,9 @@ cairo_test_get_reference_image (cairo_test_context_t *ctx,
 cairo_bool_t
 cairo_test_mkdir (const char *path);
 
+cairo_t *
+cairo_test_create (cairo_surface_t *surface, cairo_test_context_t *ctx);
+
 CAIRO_END_DECLS
 
 #endif
diff --git a/test/record.c b/test/record.c
index 774c13316..bc5e1f72e 100644
--- a/test/record.c
+++ b/test/record.c
@@ -346,7 +346,7 @@ record_create (cairo_t *target)
     cairo_t *cr;
 
     surface = cairo_recording_surface_create (cairo_surface_get_content (cairo_get_target (target)), NULL);
-    cr = cairo_create (surface);
+    cr = cairo_test_create (surface, cairo_test_get_context (target));
     cairo_surface_destroy (surface);
 
     return cr;
diff --git a/test/record1414x.c b/test/record1414x.c
index 029e5a4d6..c38857c1f 100644
--- a/test/record1414x.c
+++ b/test/record1414x.c
@@ -339,7 +339,7 @@ record_create (cairo_t *target)
     cairo_t *cr;
 
     surface = cairo_recording_surface_create (cairo_surface_get_content (cairo_get_target (target)), NULL);
-    cr = cairo_create (surface);
+    cr = cairo_test_create (surface, cairo_test_get_context (target));
     cairo_surface_destroy (surface);
 
     return cr;
diff --git a/test/record2x.c b/test/record2x.c
index 7fe037732..caca0e603 100644
--- a/test/record2x.c
+++ b/test/record2x.c
@@ -335,7 +335,7 @@ record_create (cairo_t *target)
     cairo_t *cr;
 
     surface = cairo_recording_surface_create (cairo_surface_get_content (cairo_get_target (target)), NULL);
-    cr = cairo_create (surface);
+    cr = cairo_test_create (surface, cairo_test_get_context (target));
     cairo_surface_destroy (surface);
 
     return cr;
diff --git a/test/record90.c b/test/record90.c
index 95ba3b1b1..aeec5af81 100644
--- a/test/record90.c
+++ b/test/record90.c
@@ -335,7 +335,7 @@ record_create (cairo_t *target)
     cairo_t *cr;
 
     surface = cairo_recording_surface_create (cairo_surface_get_content (cairo_get_target (target)), NULL);
-    cr = cairo_create (surface);
+    cr = cairo_test_create (surface, cairo_test_get_context (target));
     cairo_surface_destroy (surface);
 
     return cr;
diff --git a/test/recordflip.c b/test/recordflip.c
index e923c8a2a..495fe9dd6 100644
--- a/test/recordflip.c
+++ b/test/recordflip.c
@@ -333,7 +333,7 @@ record_create (cairo_t *target)
     cairo_t *cr;
 
     surface = cairo_recording_surface_create (cairo_surface_get_content (cairo_get_target (target)), NULL);
-    cr = cairo_create (surface);
+    cr = cairo_test_create (surface, cairo_test_get_context (target));
     cairo_surface_destroy (surface);
 
     return cr;


More information about the cairo-commit mailing list