Skip to content

Commit

Permalink
[boilerplate] Add svg-1.2 target.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Chris Wilson committed Sep 26, 2008
1 parent 86e5767 commit 0c030d3
Show file tree
Hide file tree
Showing 74 changed files with 128 additions and 40 deletions.
30 changes: 21 additions & 9 deletions boilerplate/cairo-boilerplate-svg-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
48 changes: 44 additions & 4 deletions boilerplate/cairo-boilerplate-svg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 19 additions & 5 deletions boilerplate/cairo-boilerplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
66 changes: 44 additions & 22 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ REFERENCE_IMAGES = \
bitmap-font-rgb24-ref.png \
caps-joins-alpha-quartz-ref.png \
caps-joins-alpha-ref.png \
caps-joins-alpha-svg-ref.png \
caps-joins-alpha-svg12-ref.png \
caps-joins-alpha-svg11-ref.png \
caps-joins-ref.png \
caps-joins-ps-ref.png \
caps-sub-paths-ref.png \
Expand Down Expand Up @@ -442,24 +443,28 @@ REFERENCE_IMAGES = \
font-matrix-translation-ps-argb32-ref.png \
font-matrix-translation-ps-rgb24-ref.png \
font-matrix-translation-ref.png \
font-matrix-translation-svg-ref.png \
font-matrix-translation-svg12-ref.png \
font-matrix-translation-svg11-ref.png \
font-matrix-translation-quartz-ref.png \
ft-text-antialias-none-ps-argb32-ref.png \
ft-text-antialias-none-ref.png \
ft-show-glyphs-positioning-ref.png \
ft-show-glyphs-positioning-pdf-ref.png \
ft-show-glyphs-positioning-ps-ref.png \
ft-show-glyphs-positioning-svg-ref.png \
ft-show-glyphs-positioning-svg12-ref.png \
ft-show-glyphs-positioning-svg11-ref.png \
ft-show-glyphs-table-ref.png \
ft-show-glyphs-table-ps-ref.png \
ft-text-vertical-layout-type1-pdf-ref.png \
ft-text-vertical-layout-type1-ps-ref.png \
ft-text-vertical-layout-type1-ref.png \
ft-text-vertical-layout-type1-svg-ref.png \
ft-text-vertical-layout-type1-svg12-ref.png \
ft-text-vertical-layout-type1-svg11-ref.png \
ft-text-vertical-layout-type3-pdf-ref.png \
ft-text-vertical-layout-type3-ps-ref.png \
ft-text-vertical-layout-type3-ref.png \
ft-text-vertical-layout-type3-svg-ref.png \
ft-text-vertical-layout-type3-svg12-ref.png \
ft-text-vertical-layout-type3-svg11-ref.png \
get-group-target-ref.png \
glitz-surface-source-ref.png \
glyph-cache-pressure-ref.png \
Expand Down Expand Up @@ -503,7 +508,8 @@ REFERENCE_IMAGES = \
linear-gradient-ps-ref.png \
linear-gradient-quartz-ref.png \
linear-gradient-ref.png \
linear-gradient-svg-ref.png \
linear-gradient-svg12-ref.png \
linear-gradient-svg11-ref.png \
line-width-ref.png \
line-width-scale-ps-ref.png \
line-width-scale-quartz-ref.png \
Expand Down Expand Up @@ -533,7 +539,8 @@ REFERENCE_IMAGES = \
mask-transformed-image-ref.png \
mask-transformed-similar-ref.png \
mask-transformed-similar-pdf-ref.png \
mask-transformed-similar-svg-ref.png \
mask-transformed-similar-svg12-ref.png \
mask-transformed-similar-svg11-ref.png \
meta-surface-pattern-ref.png \
meta-surface-pattern-rgb24-ref.png \
meta-surface-pattern-pdf-ref.png \
Expand Down Expand Up @@ -593,9 +600,11 @@ REFERENCE_IMAGES = \
paint-repeat-ref.png \
paint-source-alpha-pdf-argb32-ref.png \
paint-source-alpha-ref.png \
paint-source-alpha-svg-ref.png \
paint-source-alpha-svg12-ref.png \
paint-source-alpha-svg11-ref.png \
paint-with-alpha-ref.png \
paint-with-alpha-svg-ref.png \
paint-with-alpha-svg12-ref.png \
paint-with-alpha-svg11-ref.png \
paint-source-alpha-pdf-ref.png \
paint-with-alpha-pdf-ref.png \
pattern-getters-ref.png \
Expand All @@ -611,7 +620,8 @@ REFERENCE_IMAGES = \
radial-gradient-ref.png \
radial-gradient-pdf-ref.png \
radial-gradient-quartz-ref.png \
radial-gradient-svg-ref.png \
radial-gradient-svg12-ref.png \
radial-gradient-svg11-ref.png \
random-intersections-ref.png \
random-intersections-ps-ref.png \
random-intersections-quartz-ref.png \
Expand All @@ -634,7 +644,8 @@ REFERENCE_IMAGES = \
rotate-image-surface-paint-pdf-argb32-ref.png \
rotate-image-surface-paint-quartz-ref.png \
rotate-image-surface-paint-ref.png \
rotate-image-surface-paint-svg-ref.png \
rotate-image-surface-paint-svg12-ref.png \
rotate-image-surface-paint-svg11-ref.png \
scale-down-source-surface-paint-ref.png \
scale-source-surface-paint-pdf-argb32-ref.png \
scale-source-surface-paint-ref.png \
Expand Down Expand Up @@ -665,24 +676,29 @@ REFERENCE_IMAGES = \
smask-ref.png \
smask-pdf-ref.png \
smask-ps-ref.png \
smask-svg-ref.png \
smask-svg12-ref.png \
smask-svg11-ref.png \
smask-fill-ref.png \
smask-fill-pdf-ref.png \
smask-fill-svg-ref.png \
smask-fill-svg12-ref.png \
smask-fill-svg11-ref.png \
smask-image-mask-ref.png \
smask-image-mask-pdf-ref.png \
smask-mask-ref.png \
smask-mask-pdf-ref.png \
smask-mask-svg-ref.png \
smask-mask-svg12-ref.png \
smask-mask-svg11-ref.png \
smask-paint-ref.png \
smask-paint-pdf-ref.png \
smask-paint-svg-ref.png \
smask-paint-svg12-ref.png \
smask-paint-svg11-ref.png \
smask-stroke-ref.png \
smask-stroke-pdf-ref.png \
smask-text-ref.png \
smask-text-pdf-ref.png \
smask-text-ps-ref.png \
smask-text-svg-ref.png \
smask-text-svg12-ref.png \
smask-text-svg11-ref.png \
stroke-image-ref.png \
stroke-image-pdf-ref.png \
stroke-image-ps-ref.png \
Expand All @@ -693,7 +709,8 @@ REFERENCE_IMAGES = \
source-clip-scale-ps-argb32-ref.png \
source-clip-scale-ps-rgb24-ref.png \
source-clip-scale-ref.png \
source-clip-scale-svg-ref.png \
source-clip-scale-svg12-ref.png \
source-clip-scale-svg11-ref.png \
source-clip-scale-pdf-ref.png \
source-surface-scale-paint-ref.png \
source-surface-scale-paint-rgb24-ref.png \
Expand All @@ -709,7 +726,8 @@ REFERENCE_IMAGES = \
surface-pattern-scale-up-pdf-argb32-ref.png \
surface-pattern-scale-up-ps-argb32-ref.png \
surface-pattern-scale-up-ref.png \
surface-pattern-svg-ref.png \
surface-pattern-svg12-ref.png \
surface-pattern-svg11-ref.png \
svg-surface-source-ref.png \
text-antialias-gray-ref.png \
text-antialias-gray-quartz-ref.png \
Expand All @@ -732,7 +750,8 @@ REFERENCE_IMAGES = \
text-rotate-ref.png \
text-rotate-pdf-ref.png \
text-rotate-ps-ref.png \
text-rotate-svg-ref.png \
text-rotate-svg12-ref.png \
text-rotate-svg11-ref.png \
text-rotate-quartz-ref.png \
text-transform-ref.png \
text-transform-pdf-ref.png \
Expand All @@ -754,14 +773,17 @@ REFERENCE_IMAGES = \
unbounded-operator-rgb24-ref.png \
user-font-ref.png \
user-font-ps-ref.png \
user-font-svg-ref.png \
user-font-svg12-ref.png \
user-font-svg11-ref.png \
user-font-proxy-ref.png \
user-font-proxy-pdf-ref.png \
user-font-proxy-ps-ref.png \
user-font-proxy-svg-ref.png \
user-font-proxy-svg12-ref.png \
user-font-proxy-svg11-ref.png \
user-font-rescale-ref.png \
user-font-rescale-ps-ref.png \
user-font-rescale-svg-ref.png \
user-font-rescale-svg12-ref.png \
user-font-rescale-svg11-ref.png \
unbounded-operator-quartz-ref.png \
unbounded-operator-quartz-rgb24-ref.png \
xlib-expose-event-ref.png \
Expand Down
File renamed without changes
Binary file added test/caps-joins-alpha-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/font-matrix-translation-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/ft-show-glyphs-positioning-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/ft-text-vertical-layout-type1-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/ft-text-vertical-layout-type3-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/linear-gradient-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/mask-alpha-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added test/mask-surface-ctm-svg11-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/mask-surface-ctm-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added test/mask-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/mask-svg12-rgb24-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/mask-transformed-similar-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/meta-surface-pattern-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/meta-surface-pattern-svg12-rgb24-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/paint-source-alpha-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/paint-with-alpha-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/push-group-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/radial-gradient-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/rotate-image-surface-paint-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/scale-source-surface-paint-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/scale-source-surface-paint-svg12-rgb24-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/set-source-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/smask-fill-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/smask-mask-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/smask-paint-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/smask-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/smask-text-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/source-clip-scale-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/surface-pattern-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added test/text-pattern-svg12-argb32-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/text-pattern-svg12-rgb24-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/text-rotate-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/user-font-proxy-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/user-font-rescale-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added test/user-font-svg12-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0c030d3

Please sign in to comment.