summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-07-03 18:26:50 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-03 18:26:50 +0100
commit6003ab77e1ebefadb97338de0e7da4a76d973b1a (patch)
treee375335dac3abfdd3e75cb18a317824556de84f6 /test
parent2a9903dbbfeb3fe843f0d618d15674b37a29f3a9 (diff)
Export meta-surface
The meta-surface is a vital tool to record a trace of drawing commands in-memory. As such it is used throughout cairo. The value of such a surface is immediately obvious and should be applicable for many applications. The first such case is by cairo-test-trace which wants to record the entire graph of drawing commands that affect a surface in the event of a failure.
Diffstat (limited to 'test')
-rw-r--r--test/cairo-test-trace.c58
-rw-r--r--test/get-clip.c5
2 files changed, 25 insertions, 38 deletions
diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c
index 18e1934b5..bee0551d5 100644
--- a/test/cairo-test-trace.c
+++ b/test/cairo-test-trace.c
@@ -64,9 +64,6 @@
#include <cairo-script.h>
#endif
-/* XXX give me a real meta surface! */
-#include <test-meta-surface.h>
-
/* For basename */
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
@@ -603,9 +600,6 @@ cleanup_recorder (void *arg)
cairo_surface_finish (thread->surface);
cairo_surface_destroy (thread->surface);
- if (thread->target->cleanup)
- thread->target->cleanup (thread->closure);
-
close (thread->sk);
free (thread);
}
@@ -628,9 +622,7 @@ record (void *arg)
* 2. Runs in the same process, but separate thread.
*/
static pid_t
-spawn_recorder (const char *socket_path,
- const cairo_boilerplate_target_t *target,
- const char *trace)
+spawn_recorder (const char *socket_path, const char *trace)
{
test_runner_thread_t *thread;
pthread_t id;
@@ -653,18 +645,13 @@ spawn_recorder (const char *socket_path,
}
thread->base = NULL;
- thread->target = target;
+ thread->target = NULL;
thread->contexts = NULL;
thread->context_id = 0;
thread->trace = trace;
- thread->surface = target->create_surface (NULL,
- target->content,
- 1, 1,
- 1, 1,
- CAIRO_BOILERPLATE_MODE_TEST,
- 0,
- &thread->closure);
+ thread->surface = cairo_meta_surface_create (CAIRO_CONTENT_COLOR_ALPHA,
+ 0, 0);
if (thread->surface == NULL) {
cleanup_recorder (thread);
return -1;
@@ -853,7 +840,7 @@ static void
write_images (const char *trace, struct slave *slave, int num_slaves)
{
while (num_slaves--) {
- if (slave->image != NULL) {
+ if (slave->image != NULL && ! slave->is_meta) {
char *filename;
xasprintf (&filename, "%s-%s-fail.png",
@@ -887,7 +874,7 @@ write_trace (const char *trace, struct slave *slave)
slave->height);
free (filename);
- status = _cairo_test_meta_surface_replay (slave->image, script);
+ status = cairo_meta_surface_replay (slave->image, script);
cairo_surface_destroy (script);
#endif
}
@@ -1179,6 +1166,7 @@ target_is_measurable (const cairo_boilerplate_target_t *target)
case CAIRO_SURFACE_TYPE_SCRIPT:
case CAIRO_SURFACE_TYPE_SVG:
case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
+ case CAIRO_SURFACE_TYPE_META:
default:
return FALSE;
}
@@ -1243,8 +1231,9 @@ _test_trace (test_runner_t *test,
struct error_info *error)
{
const char *shm_path = SHM_PATH_XXX;
- const cairo_boilerplate_target_t *target, *image, *meta;
+ const cairo_boilerplate_target_t *target, *image;
struct slave *slaves, *s;
+ pid_t slave;
char socket_dir[] = "/tmp/cairo-test-trace.XXXXXX";
char *socket_path;
int sk, fd;
@@ -1280,29 +1269,22 @@ _test_trace (test_runner_t *test,
#if HAVE_PTHREAD_H
/* set-up a meta-surface to reconstruct errors */
- meta = cairo_boilerplate_get_target_by_name ("test-meta",
- CAIRO_CONTENT_COLOR_ALPHA);
- if (meta != NULL) {
- pid_t slave;
-
- slave = spawn_recorder (socket_path, meta, trace);
- if (slave < 0) {
- fprintf (stderr, "Unable to create meta surface\n");
- goto cleanup_sk;
- }
-
- s->pid = slave;
- s->is_meta = TRUE;
- s->target = meta;
- s->fd = -1;
- s->reference = NULL;
- s++;
+ slave = spawn_recorder (socket_path, trace);
+ if (slave < 0) {
+ fprintf (stderr, "Unable to create meta surface\n");
+ goto cleanup_sk;
}
+
+ s->pid = slave;
+ s->is_meta = TRUE;
+ s->target = NULL;
+ s->fd = -1;
+ s->reference = NULL;
+ s++;
#endif
/* spawn slave processes to run the trace */
for (i = 0; i < test->num_targets; i++) {
- pid_t slave;
const cairo_boilerplate_target_t *reference;
struct slave *master;
diff --git a/test/get-clip.c b/test/get-clip.c
index 1a07f0128..c7414b4ac 100644
--- a/test/get-clip.c
+++ b/test/get-clip.c
@@ -132,10 +132,15 @@ draw (cairo_t *cr, int width, int height)
uses_clip_rects = TRUE;
break;
case CAIRO_SURFACE_TYPE_QUARTZ:
+ case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
case CAIRO_SURFACE_TYPE_PDF:
case CAIRO_SURFACE_TYPE_PS:
case CAIRO_SURFACE_TYPE_SVG:
case CAIRO_SURFACE_TYPE_OS2:
+ case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
+ case CAIRO_SURFACE_TYPE_SCRIPT:
+ case CAIRO_SURFACE_TYPE_QT:
+ case CAIRO_SURFACE_TYPE_META:
default:
uses_clip_rects = FALSE;
break;