Index: src/cairo-svg-surface.c =================================================================== RCS file: /cvs/cairo/cairo/src/cairo-svg-surface.c,v retrieving revision 1.1 diff -u -p -u -r1.1 cairo-svg-surface.c --- src/cairo-svg-surface.c 8 Dec 2005 21:09:27 -0000 1.1 +++ src/cairo-svg-surface.c 10 Dec 2005 20:43:03 -0000 @@ -67,6 +67,7 @@ struct cairo_svg_document { xmlDocPtr xml_doc; xmlNodePtr xml_node_defs; xmlNodePtr xml_node; + xmlNodePtr xml_node_pageset; unsigned int linear_pattern_id; unsigned int radial_pattern_id; @@ -193,7 +194,7 @@ _cairo_svg_surface_create_for_document ( static cairo_surface_t * _cairo_svg_surface_create_similar (void *abstract_src, - cairo_format_t format, + cairo_content_t content, int width, int height) { @@ -979,6 +980,41 @@ _cairo_svg_surface_composite_trapezoids return CAIRO_STATUS_SUCCESS; } +static cairo_status_t +_cairo_svg_document_add_page (cairo_svg_document_t *document, + cairo_svg_surface_t *surface) +{ + assert (!document->finished); + + xmlAddChild (document->xml_node_pageset, document->xml_node); + document->xml_node = xmlNewNode (NULL, CC2XML ("page")); + + return CAIRO_STATUS_SUCCESS; +} + +static cairo_int_status_t +_cairo_svg_surface_copy_page (void *abstract_surface) +{ + cairo_svg_surface_t *surface = abstract_surface; + cairo_svg_document_t *document = surface->document; + + return _cairo_svg_document_add_page (document, surface); +} + +static cairo_int_status_t +_cairo_svg_surface_show_page (void *abstract_surface) +{ + cairo_svg_surface_t *surface = abstract_surface; + cairo_svg_document_t *document = surface->document; + cairo_int_status_t status; + + status = _cairo_svg_document_add_page (document, surface); + if (status) + return status; + + return CAIRO_STATUS_SUCCESS; +} + static cairo_int_status_t _cairo_svg_surface_get_extents (void *abstract_surface, cairo_rectangle_t *rectangle) @@ -1222,8 +1258,8 @@ static const cairo_surface_backend_t cai _cairo_svg_surface_composite, NULL, /* fill_rectangle */ _cairo_svg_surface_composite_trapezoids, - NULL, /* copy_page */ - NULL, /* show_page */ + _cairo_svg_surface_copy_page, + _cairo_svg_surface_show_page, NULL, /* set_clip_region */ _cairo_svg_surface_intersect_clip_path, _cairo_svg_surface_get_extents, @@ -1275,13 +1311,17 @@ _cairo_svg_document_create (cairo_output xmlDocSetRootElement (doc, node); document->xml_doc = doc; - document->xml_node = node; document->xml_node_defs = xmlNewChild (node, NULL, CC2XML ("defs"), NULL); + document->xml_node_pageset = xmlNewChild (node, NULL, CC2XML ("pageSet"), NULL); + document->xml_node = xmlNewNode (NULL, CC2XML ("page")); _cairo_dtostr (buffer, sizeof buffer, width); xmlSetProp (node, CC2XML ("width"), CC2XML (buffer)); _cairo_dtostr (buffer, sizeof buffer, height); xmlSetProp (node, CC2XML ("height"), CC2XML (buffer)); + xmlSetProp (node, CC2XML ("xmlns"), CC2XML ("http://www.w3.org/2000/svg")); + xmlSetProp (node, CC2XML ("version"), CC2XML ("1.2")); + xmlSetProp (node, CC2XML ("streamable"), CC2XML ("true")); return document; } @@ -1321,6 +1361,8 @@ _cairo_svg_document_finish (cairo_svg_do xmlFree(xml_buffer); xmlFreeDoc (document->xml_doc); + xmlFreeNode (document->xml_node); + status = _cairo_output_stream_get_status (output); _cairo_output_stream_destroy (output);