diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-26 16:49:57 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-26 17:26:25 +0100 |
commit | e0f214710760a0e0332207cb3009e3119867bd13 (patch) | |
tree | 80ff9fc7dea054d279248485dc6e757783a75782 /boilerplate | |
parent | 0c030d3b768718eac5d429d0c819934f32896b25 (diff) |
[boilerplate] Add a PS 2 target.
Ensure that we can generate PS2 output when required by creating a PS
level 2 target and using GhostScript for conformance testing.
Diffstat (limited to 'boilerplate')
-rw-r--r-- | boilerplate/cairo-boilerplate-ps-private.h | 29 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate-ps.c | 55 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate.c | 23 |
3 files changed, 88 insertions, 19 deletions
diff --git a/boilerplate/cairo-boilerplate-ps-private.h b/boilerplate/cairo-boilerplate-ps-private.h index 6f1bad6b..a6a19500 100644 --- a/boilerplate/cairo-boilerplate-ps-private.h +++ b/boilerplate/cairo-boilerplate-ps-private.h @@ -28,15 +28,26 @@ #define _CAIRO_BOILERPLATE_PS_PRIVATE_H_ cairo_surface_t * -_cairo_boilerplate_ps_create_surface (const char *name, - cairo_content_t content, - int width, - int height, - int max_width, - int max_height, - cairo_boilerplate_mode_t mode, - int id, - void **closure); +_cairo_boilerplate_ps2_create_surface (const char *name, + cairo_content_t content, + int width, + int height, + int max_width, + int max_height, + cairo_boilerplate_mode_t mode, + int id, + void **closure); + +cairo_surface_t * +_cairo_boilerplate_ps3_create_surface (const char *name, + cairo_content_t content, + int width, + int height, + int max_width, + int max_height, + cairo_boilerplate_mode_t mode, + int id, + void **closure); void _cairo_boilerplate_ps_cleanup (void *closure); diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c index 6df9776d..7c6ebe9c 100644 --- a/boilerplate/cairo-boilerplate-ps.c +++ b/boilerplate/cairo-boilerplate-ps.c @@ -37,14 +37,14 @@ #include <signal.h> #endif -cairo_user_data_key_t ps_closure_key; +static const cairo_user_data_key_t ps_closure_key; -typedef struct _ps_target_closure -{ +typedef struct _ps_target_closure { char *filename; int width; int height; cairo_surface_t *target; + cairo_ps_level_t level; } ps_target_closure_t; static cairo_status_t @@ -65,9 +65,10 @@ _cairo_boilerplate_ps_surface_set_creation_date (cairo_surface_t *abstract_surfa return CAIRO_STATUS_SUCCESS; } -cairo_surface_t * +static cairo_surface_t * _cairo_boilerplate_ps_create_surface (const char *name, cairo_content_t content, + cairo_ps_level_t level, int width, int height, int max_width, @@ -89,6 +90,7 @@ _cairo_boilerplate_ps_create_surface (const char *name, xasprintf (&ptc->filename, "%s-out.ps", name); xunlink (ptc->filename); + ptc->level = level; ptc->width = width; ptc->height = height; @@ -96,6 +98,7 @@ _cairo_boilerplate_ps_create_surface (const char *name, if (cairo_surface_status (surface)) goto CLEANUP_FILENAME; + cairo_ps_surface_restrict_to_level (surface, level); _cairo_boilerplate_ps_surface_set_creation_date (surface, 0); cairo_surface_set_fallback_resolution (surface, 72., 72.); @@ -125,6 +128,44 @@ _cairo_boilerplate_ps_create_surface (const char *name, return surface; } +cairo_surface_t * +_cairo_boilerplate_ps2_create_surface (const char *name, + cairo_content_t content, + int width, + int height, + int max_width, + int max_height, + cairo_boilerplate_mode_t mode, + int id, + void **closure) +{ + return _cairo_boilerplate_ps_create_surface (name, content, + CAIRO_PS_LEVEL_2, + width, height, + max_width, max_height, + mode, id, + closure); +} + +cairo_surface_t * +_cairo_boilerplate_ps3_create_surface (const char *name, + cairo_content_t content, + int width, + int height, + int max_width, + int max_height, + cairo_boilerplate_mode_t mode, + int id, + void **closure) +{ + return _cairo_boilerplate_ps_create_surface (name, content, + CAIRO_PS_LEVEL_3, + width, height, + max_width, max_height, + mode, id, + closure); +} + cairo_status_t _cairo_boilerplate_ps_finish_surface (cairo_surface_t *surface) { @@ -177,8 +218,10 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char char command[4096]; int exitstatus; - sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s", - ptc->width, ptc->height, filename, ptc->filename); + sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s %s", + ptc->width, ptc->height, filename, + ptc->level == CAIRO_PS_LEVEL_2 ? "-c 2 .setlanguagelevel -f" : "", + ptc->filename); exitstatus = system (command); #if _XOPEN_SOURCE && HAVE_SIGNAL_H if (WIFSIGNALED (exitstatus)) diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index 7c9890f3..f88d983c 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -445,16 +445,31 @@ static cairo_boilerplate_target_t targets[] = _cairo_boilerplate_xlib_synchronize}, #endif #if CAIRO_HAS_PS_SURFACE && CAIRO_CAN_TEST_PS_SURFACE - { "ps", ".ps", CAIRO_SURFACE_TYPE_PS, + { "ps2", ".ps", CAIRO_SURFACE_TYPE_PS, CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0, - _cairo_boilerplate_ps_create_surface, + _cairo_boilerplate_ps2_create_surface, _cairo_boilerplate_ps_finish_surface, _cairo_boilerplate_ps_get_image_surface, _cairo_boilerplate_ps_surface_write_to_png, _cairo_boilerplate_ps_cleanup, NULL, TRUE }, - { "ps", ".ps", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0, - _cairo_boilerplate_ps_create_surface, + { "ps2", ".ps", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0, + _cairo_boilerplate_ps2_create_surface, + _cairo_boilerplate_ps_finish_surface, + _cairo_boilerplate_ps_get_image_surface, + _cairo_boilerplate_ps_surface_write_to_png, + _cairo_boilerplate_ps_cleanup, + NULL, TRUE }, + { "ps3", ".ps", CAIRO_SURFACE_TYPE_PS, + CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0, + _cairo_boilerplate_ps3_create_surface, + _cairo_boilerplate_ps_finish_surface, + _cairo_boilerplate_ps_get_image_surface, + _cairo_boilerplate_ps_surface_write_to_png, + _cairo_boilerplate_ps_cleanup, + NULL, TRUE }, + { "ps3", ".ps", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0, + _cairo_boilerplate_ps3_create_surface, _cairo_boilerplate_ps_finish_surface, _cairo_boilerplate_ps_get_image_surface, _cairo_boilerplate_ps_surface_write_to_png, |