diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-13 17:21:05 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-29 08:08:36 +0100 |
commit | a9d997fecd54cea7dcd71487a24dbae14d0073a8 (patch) | |
tree | 78939c70f6411d9600630d5080871dc730e152ab /boilerplate | |
parent | 28887ac272c8a36a41da4d6d58044164b94da6f3 (diff) |
[script] Introduce cairo_script_context_t
cairo_script_context_t is an encapsulation object for interfacing with the
output - multiple surfaces can share the same context, meaning that they
write to the same destination file/stream.
Diffstat (limited to 'boilerplate')
-rw-r--r-- | boilerplate/cairo-boilerplate-script.c | 5 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate.c | 26 |
2 files changed, 8 insertions, 23 deletions
diff --git a/boilerplate/cairo-boilerplate-script.c b/boilerplate/cairo-boilerplate-script.c index 24a5843a..b944a55d 100644 --- a/boilerplate/cairo-boilerplate-script.c +++ b/boilerplate/cairo-boilerplate-script.c @@ -48,6 +48,7 @@ _cairo_boilerplate_script_create_surface (const char *name, void **closure) { script_target_closure_t *ptc; + cairo_script_context_t *ctx; cairo_surface_t *surface; cairo_status_t status; @@ -59,7 +60,9 @@ _cairo_boilerplate_script_create_surface (const char *name, xasprintf (&ptc->filename, "%s.out.cs", name); xunlink (ptc->filename); - surface = cairo_script_surface_create (ptc->filename, width, height); + ctx = cairo_script_context_create (ptc->filename); + surface = cairo_script_surface_create (ctx, width, height); + cairo_script_context_destroy (ctx); status = cairo_surface_set_user_data (surface, &script_closure_key, ptc, NULL); diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index f15f7393..1abfe09e 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -151,17 +151,6 @@ _cairo_boilerplate_meta_create_surface (const char *name, extents.height = height; return cairo_meta_surface_create (content, &extents); } - -#if CAIRO_HAS_SCRIPT_SURFACE -static cairo_status_t -stdio_write (void *closure, const unsigned char *data, unsigned int len) -{ - if (fwrite (data, len, 1, closure) != 1) - return CAIRO_STATUS_WRITE_ERROR; - - return CAIRO_STATUS_SUCCESS; -} -#endif #endif const cairo_user_data_key_t cairo_boilerplate_output_basename_key; @@ -172,7 +161,6 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src, int width, int height) { - FILE *file = NULL; cairo_surface_t *surface, *image; cairo_t *cr; cairo_status_t status; @@ -195,17 +183,14 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src, test_name = cairo_surface_get_user_data (src, &cairo_boilerplate_output_basename_key); if (test_name != NULL) { + cairo_script_context_t *ctx; char *filename; xasprintf (&filename, "%s.out.trace", test_name); - file = fopen (filename, "w"); + ctx = cairo_script_context_create (filename); + surface = cairo_script_surface_create_for_target (ctx, image); + cairo_script_context_destroy (ctx); free (filename); - - if (file != NULL) { - surface = cairo_script_surface_create_for_target (image, - stdio_write, - file); - } } } #endif @@ -224,9 +209,6 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src, } cairo_destroy (cr); - if (file != NULL) - fclose (file); - return image; } |