diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-26 15:26:40 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-26 17:11:51 +0100 |
commit | 0c030d3b768718eac5d429d0c819934f32896b25 (patch) | |
tree | 9b60f3dda1341ba4f37d4a77125411682456d2ea /boilerplate | |
parent | 86e57671dd21078215505202ef8aa2141d10fb9c (diff) |
[boilerplate] Add svg-1.2 target.
SVG 1.2 is sufficiently different from 1.1 that it has separate code
paths within cairo-svg-surface and so justifies its own boilerplate
target.
Diffstat (limited to 'boilerplate')
-rw-r--r-- | boilerplate/cairo-boilerplate-svg-private.h | 30 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate-svg.c | 48 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate.c | 24 |
3 files changed, 84 insertions, 18 deletions
diff --git a/boilerplate/cairo-boilerplate-svg-private.h b/boilerplate/cairo-boilerplate-svg-private.h index ea429488..075bdcd1 100644 --- a/boilerplate/cairo-boilerplate-svg-private.h +++ b/boilerplate/cairo-boilerplate-svg-private.h @@ -28,15 +28,27 @@ #define _CAIRO_BOILERPLATE_SVG_PRIVATE_H_ cairo_surface_t * -_cairo_boilerplate_svg_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_svg11_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_svg12_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_status_t _cairo_boilerplate_svg_finish_surface (cairo_surface_t *surface); diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c index c3ad8d2f..227088cc 100644 --- a/boilerplate/cairo-boilerplate-svg.c +++ b/boilerplate/cairo-boilerplate-svg.c @@ -39,16 +39,16 @@ cairo_user_data_key_t svg_closure_key; -typedef struct _svg_target_closure -{ +typedef struct _svg_target_closure { char *filename; int width, height; cairo_surface_t *target; } svg_target_closure_t; -cairo_surface_t * +static cairo_surface_t * _cairo_boilerplate_svg_create_surface (const char *name, cairo_content_t content, + cairo_svg_version_t version, int width, int height, int max_width, @@ -73,6 +73,7 @@ _cairo_boilerplate_svg_create_surface (const char *name, if (cairo_surface_status (surface)) goto CLEANUP_FILENAME; + cairo_svg_surface_restrict_to_version (surface, version); cairo_surface_set_fallback_resolution (surface, 72., 72.); if (content == CAIRO_CONTENT_COLOR) { @@ -101,6 +102,45 @@ _cairo_boilerplate_svg_create_surface (const char *name, return surface; } +cairo_surface_t * +_cairo_boilerplate_svg11_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) +{ + /* current default, but be explicit in case the default changes */ + return _cairo_boilerplate_svg_create_surface (name, content, + CAIRO_SVG_VERSION_1_1, + width, height, + max_width, max_height, + mode, id, + closure); +} + +cairo_surface_t * +_cairo_boilerplate_svg12_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_svg_create_surface (name, content, + CAIRO_SVG_VERSION_1_2, + width, height, + max_width, max_height, + mode, id, + closure); +} + cairo_status_t _cairo_boilerplate_svg_finish_surface (cairo_surface_t *surface) { @@ -207,7 +247,7 @@ cairo_boilerplate_svg_surface_force_fallbacks (cairo_surface_t *abstract_surface cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface; cairo_svg_surface_t *surface; - if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PDF) + if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_SVG) return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; surface = (cairo_svg_surface_t*) paginated->target; diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index 65898e16..7c9890f3 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -479,20 +479,34 @@ static cairo_boilerplate_target_t targets[] = NULL, TRUE }, #endif #if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE - /* It seems we should be able to round-trip SVG content perfrectly + /* It seems we should be able to round-trip SVG content perfectly * through librsvg and cairo, but for some mysterious reason, some * systems get an error of 1 for some pixels on some of the text * tests. XXX: I'd still like to chase these down at some point. * For now just set the svg error tolerance to 1. */ - { "svg", ".svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1, - _cairo_boilerplate_svg_create_surface, + { "svg11", ".svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1, + _cairo_boilerplate_svg11_create_surface, _cairo_boilerplate_svg_finish_surface, _cairo_boilerplate_svg_get_image_surface, _cairo_boilerplate_svg_surface_write_to_png, _cairo_boilerplate_svg_cleanup, NULL, TRUE }, - { "svg", ".svg", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1, - _cairo_boilerplate_svg_create_surface, + { "svg11", ".svg", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1, + _cairo_boilerplate_svg11_create_surface, + _cairo_boilerplate_svg_finish_surface, + _cairo_boilerplate_svg_get_image_surface, + _cairo_boilerplate_svg_surface_write_to_png, + _cairo_boilerplate_svg_cleanup, + NULL, TRUE }, + { "svg12", ".svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1, + _cairo_boilerplate_svg12_create_surface, + _cairo_boilerplate_svg_finish_surface, + _cairo_boilerplate_svg_get_image_surface, + _cairo_boilerplate_svg_surface_write_to_png, + _cairo_boilerplate_svg_cleanup, + NULL, TRUE }, + { "svg12", ".svg", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1, + _cairo_boilerplate_svg12_create_surface, _cairo_boilerplate_svg_finish_surface, _cairo_boilerplate_svg_get_image_surface, _cairo_boilerplate_svg_surface_write_to_png, |