diff --git a/doc/public/tmpl/cairo-beos.sgml b/doc/public/tmpl/cairo-beos.sgml index b3ea139dc..707d7e1ae 100644 --- a/doc/public/tmpl/cairo-beos.sgml +++ b/doc/public/tmpl/cairo-beos.sgml @@ -14,3 +14,6 @@ BeOS surface support + + + diff --git a/doc/public/tmpl/cairo-font-options.sgml b/doc/public/tmpl/cairo-font-options.sgml index f80064241..e87b5506c 100644 --- a/doc/public/tmpl/cairo-font-options.sgml +++ b/doc/public/tmpl/cairo-font-options.sgml @@ -14,6 +14,9 @@ How a font should be rendered + + + diff --git a/doc/public/tmpl/cairo-font.sgml b/doc/public/tmpl/cairo-font.sgml index fff13cd89..b65281e21 100644 --- a/doc/public/tmpl/cairo-font.sgml +++ b/doc/public/tmpl/cairo-font.sgml @@ -14,6 +14,9 @@ Base class for fonts + + + diff --git a/doc/public/tmpl/cairo-ft.sgml b/doc/public/tmpl/cairo-ft.sgml index d5ee69c6e..275f7af2f 100644 --- a/doc/public/tmpl/cairo-ft.sgml +++ b/doc/public/tmpl/cairo-ft.sgml @@ -14,3 +14,6 @@ Font support for FreeType + + + diff --git a/doc/public/tmpl/cairo-glitz.sgml b/doc/public/tmpl/cairo-glitz.sgml index 0d204dedf..437c71e08 100644 --- a/doc/public/tmpl/cairo-glitz.sgml +++ b/doc/public/tmpl/cairo-glitz.sgml @@ -14,3 +14,6 @@ OpenGL accelerated rendering using the Glitz library + + + diff --git a/doc/public/tmpl/cairo-image.sgml b/doc/public/tmpl/cairo-image.sgml index 761627ead..8e8dc86e1 100644 --- a/doc/public/tmpl/cairo-image.sgml +++ b/doc/public/tmpl/cairo-image.sgml @@ -17,6 +17,9 @@ Rendering to memory buffers + + + diff --git a/doc/public/tmpl/cairo-matrix.sgml b/doc/public/tmpl/cairo-matrix.sgml index 19b3abc5f..3effbd239 100644 --- a/doc/public/tmpl/cairo-matrix.sgml +++ b/doc/public/tmpl/cairo-matrix.sgml @@ -29,6 +29,9 @@ Generic matrix operations + + + diff --git a/doc/public/tmpl/cairo-paths.sgml b/doc/public/tmpl/cairo-paths.sgml index b06bc0e9d..01bf12d67 100644 --- a/doc/public/tmpl/cairo-paths.sgml +++ b/doc/public/tmpl/cairo-paths.sgml @@ -14,6 +14,9 @@ Creating paths and manipulating path data + + + diff --git a/doc/public/tmpl/cairo-pattern.sgml b/doc/public/tmpl/cairo-pattern.sgml index 831985863..f7f29b147 100644 --- a/doc/public/tmpl/cairo-pattern.sgml +++ b/doc/public/tmpl/cairo-pattern.sgml @@ -14,6 +14,9 @@ Gradients and filtered sources + + + diff --git a/doc/public/tmpl/cairo-pdf.sgml b/doc/public/tmpl/cairo-pdf.sgml index efef4a671..4f7dbd71d 100644 --- a/doc/public/tmpl/cairo-pdf.sgml +++ b/doc/public/tmpl/cairo-pdf.sgml @@ -14,3 +14,6 @@ Rendering PDF documents + + + diff --git a/doc/public/tmpl/cairo-png.sgml b/doc/public/tmpl/cairo-png.sgml index d2d6d383d..cba1516e7 100644 --- a/doc/public/tmpl/cairo-png.sgml +++ b/doc/public/tmpl/cairo-png.sgml @@ -14,6 +14,9 @@ Reading and writing PNG images + + + diff --git a/doc/public/tmpl/cairo-ps.sgml b/doc/public/tmpl/cairo-ps.sgml index 087f464fd..a3d5765a6 100644 --- a/doc/public/tmpl/cairo-ps.sgml +++ b/doc/public/tmpl/cairo-ps.sgml @@ -14,3 +14,6 @@ Rendering PostScript documents + + + diff --git a/doc/public/tmpl/cairo-quartz.sgml b/doc/public/tmpl/cairo-quartz.sgml index 226dabe07..02a69d919 100644 --- a/doc/public/tmpl/cairo-quartz.sgml +++ b/doc/public/tmpl/cairo-quartz.sgml @@ -14,3 +14,6 @@ Rendering to Quartz surfaces + + + diff --git a/doc/public/tmpl/cairo-scaled-font.sgml b/doc/public/tmpl/cairo-scaled-font.sgml index 9202aded4..06564548f 100644 --- a/doc/public/tmpl/cairo-scaled-font.sgml +++ b/doc/public/tmpl/cairo-scaled-font.sgml @@ -14,6 +14,9 @@ Caching metrics for a particular font size + + + diff --git a/doc/public/tmpl/cairo-status.sgml b/doc/public/tmpl/cairo-status.sgml index 1a9d86f9f..de5f35fea 100644 --- a/doc/public/tmpl/cairo-status.sgml +++ b/doc/public/tmpl/cairo-status.sgml @@ -14,6 +14,9 @@ Decoding cairo's status + + + diff --git a/doc/public/tmpl/cairo-surface.sgml b/doc/public/tmpl/cairo-surface.sgml index bbd829d83..69d63d276 100644 --- a/doc/public/tmpl/cairo-surface.sgml +++ b/doc/public/tmpl/cairo-surface.sgml @@ -14,6 +14,9 @@ Base class for surfaces + + + diff --git a/doc/public/tmpl/cairo-text.sgml b/doc/public/tmpl/cairo-text.sgml index 8514789c6..56678b167 100644 --- a/doc/public/tmpl/cairo-text.sgml +++ b/doc/public/tmpl/cairo-text.sgml @@ -14,6 +14,9 @@ Rendering text and sets of glyphs + + + diff --git a/doc/public/tmpl/cairo-transforms.sgml b/doc/public/tmpl/cairo-transforms.sgml index 14351e215..65199c8b4 100644 --- a/doc/public/tmpl/cairo-transforms.sgml +++ b/doc/public/tmpl/cairo-transforms.sgml @@ -14,3 +14,6 @@ Manipulating the current transformation matrix + + + diff --git a/doc/public/tmpl/cairo-types.sgml b/doc/public/tmpl/cairo-types.sgml index 66a309864..9e6f6b599 100644 --- a/doc/public/tmpl/cairo-types.sgml +++ b/doc/public/tmpl/cairo-types.sgml @@ -14,6 +14,9 @@ Generic data types used in the cairo API + + + diff --git a/doc/public/tmpl/cairo-version.sgml b/doc/public/tmpl/cairo-version.sgml index 329a2f43b..42eb58eb7 100644 --- a/doc/public/tmpl/cairo-version.sgml +++ b/doc/public/tmpl/cairo-version.sgml @@ -114,6 +114,9 @@ if (cairo_version() >= %CAIRO_VERSION_ENCODE(1, 0, 0)) + + + diff --git a/doc/public/tmpl/cairo-win32-fonts.sgml b/doc/public/tmpl/cairo-win32-fonts.sgml index d686ace2e..3652ccbdc 100644 --- a/doc/public/tmpl/cairo-win32-fonts.sgml +++ b/doc/public/tmpl/cairo-win32-fonts.sgml @@ -14,3 +14,6 @@ Font support for Microsoft Windows + + + diff --git a/doc/public/tmpl/cairo-win32.sgml b/doc/public/tmpl/cairo-win32.sgml index 6cc1cd864..b486ba833 100644 --- a/doc/public/tmpl/cairo-win32.sgml +++ b/doc/public/tmpl/cairo-win32.sgml @@ -14,3 +14,6 @@ Microsoft Windows surface support + + + diff --git a/doc/public/tmpl/cairo-xcb-xrender.sgml b/doc/public/tmpl/cairo-xcb-xrender.sgml index 635fa3ccc..fc243236d 100644 --- a/doc/public/tmpl/cairo-xcb-xrender.sgml +++ b/doc/public/tmpl/cairo-xcb-xrender.sgml @@ -14,3 +14,6 @@ X Window System rendering using the XCB library + + + diff --git a/doc/public/tmpl/cairo-xcb.sgml b/doc/public/tmpl/cairo-xcb.sgml index 635fa3ccc..fc243236d 100644 --- a/doc/public/tmpl/cairo-xcb.sgml +++ b/doc/public/tmpl/cairo-xcb.sgml @@ -14,3 +14,6 @@ X Window System rendering using the XCB library + + + diff --git a/doc/public/tmpl/cairo-xlib-xrender.sgml b/doc/public/tmpl/cairo-xlib-xrender.sgml index df970a2f2..c99d78407 100644 --- a/doc/public/tmpl/cairo-xlib-xrender.sgml +++ b/doc/public/tmpl/cairo-xlib-xrender.sgml @@ -14,3 +14,6 @@ XLib/Xrender Backend + + + diff --git a/doc/public/tmpl/cairo-xlib.sgml b/doc/public/tmpl/cairo-xlib.sgml index 7480fad1a..f931a50f8 100644 --- a/doc/public/tmpl/cairo-xlib.sgml +++ b/doc/public/tmpl/cairo-xlib.sgml @@ -14,3 +14,6 @@ X Window System rendering using XLib + + + diff --git a/doc/public/tmpl/cairo.sgml b/doc/public/tmpl/cairo.sgml index 32fd94f40..04480e715 100644 --- a/doc/public/tmpl/cairo.sgml +++ b/doc/public/tmpl/cairo.sgml @@ -24,6 +24,9 @@ The cairo drawing context + + + diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c index accbe0043..eb01214ae 100644 --- a/src/cairo-svg-surface.c +++ b/src/cairo-svg-surface.c @@ -80,6 +80,8 @@ struct cairo_svg_document { struct cairo_svg_surface { cairo_surface_t base; + cairo_content_t content; + unsigned int id; double width; @@ -112,8 +114,9 @@ _cairo_svg_document_reference (cairo_svg_document_t *document); static cairo_surface_t * _cairo_svg_surface_create_for_document (cairo_svg_document_t *document, - double width, - double height); + cairo_content_t content, + double width, + double height); static const cairo_surface_backend_t cairo_svg_surface_backend; @@ -129,7 +132,8 @@ _cairo_svg_surface_create_for_stream_internal (cairo_output_stream_t *stream, if (document == NULL) return NULL; - surface = _cairo_svg_surface_create_for_document (document, width, height); + surface = _cairo_svg_surface_create_for_document (document, CAIRO_CONTENT_COLOR_ALPHA, + width, height); document->owner = surface; _cairo_svg_document_destroy (document); @@ -234,11 +238,12 @@ cairo_svg_surface_set_dpi (cairo_surface_t *surface, static cairo_surface_t * _cairo_svg_surface_create_for_document (cairo_svg_document_t *document, - double width, - double height) + cairo_content_t content, + double width, + double height) { cairo_svg_surface_t *surface; - xmlNodePtr clip, clip_rect; + xmlNodePtr clip, rect; int clip_id; char buffer[CAIRO_SVG_DTOSTR_BUFFER_LEN]; @@ -262,11 +267,11 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t *document, clip = xmlNewChild (document->xml_node_defs, NULL, CC2XML ("clipPath"), NULL); snprintf (buffer, sizeof buffer, "clip%d", clip_id); xmlSetProp (clip, CC2XML ("id"), C2XML (buffer)); - clip_rect = xmlNewChild (clip, NULL, CC2XML ("rect"), NULL); + rect = xmlNewChild (clip, NULL, CC2XML ("rect"), NULL); _cairo_dtostr (buffer, sizeof buffer, width); - xmlSetProp (clip_rect, CC2XML ("width"), C2XML (buffer)); + xmlSetProp (rect, CC2XML ("width"), C2XML (buffer)); _cairo_dtostr (buffer, sizeof buffer, height); - xmlSetProp (clip_rect, CC2XML ("height"), C2XML (buffer)); + xmlSetProp (rect, CC2XML ("height"), C2XML (buffer)); surface->xml_node = xmlNewNode (NULL, CC2XML ("g")); surface->xml_root_node = surface->xml_node; @@ -276,9 +281,19 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t *document, snprintf (buffer, sizeof buffer, "url(#clip%d)", clip_id); xmlSetProp (surface->xml_node, CC2XML ("clip-path"), C2XML (buffer)); + if (content == CAIRO_CONTENT_COLOR) { + rect = xmlNewChild (surface->xml_node, NULL, CC2XML ("rect"), NULL); + _cairo_dtostr (buffer, sizeof buffer, width); + xmlSetProp (rect, CC2XML ("width"), C2XML (buffer)); + _cairo_dtostr (buffer, sizeof buffer, height); + xmlSetProp (rect, CC2XML ("height"), C2XML (buffer)); + xmlSetProp (rect, CC2XML ("style"), CC2XML ("opacity:1; stroke:none; fill:rgb(0,0,0);")); + } + surface->modified = TRUE; surface->previous_id = surface->id; - + surface->content = content; + return &surface->base; } @@ -290,8 +305,12 @@ _cairo_svg_surface_create_similar (void *abstract_src, { cairo_svg_surface_t *template = abstract_src; + if (content != CAIRO_CONTENT_COLOR_ALPHA && + content != CAIRO_CONTENT_COLOR) + return (cairo_surface_t *) &_cairo_surface_nil; + return _cairo_svg_surface_create_for_document (template->document, - width, height); + content, width, height); } static cairo_status_t @@ -524,7 +543,8 @@ emit_composite_svg_pattern (xmlNodePtr node, xmlAddChild (document->xml_node_defs, xmlCopyNode (surface->xml_root_node, 1)); child = xmlNewChild (node, NULL, CC2XML("use"), NULL); - snprintf (buffer, sizeof buffer, "#surface%d", surface->previous_id); + snprintf (buffer, sizeof buffer, "#surface%d", + surface->modified ? surface->id : surface->previous_id); xmlSetProp (child, CC2XML ("xlink:href"), C2XML (buffer)); if (!is_pattern) { @@ -1061,9 +1081,28 @@ _cairo_svg_surface_paint (void *abstract_surface, if (surface->clip_level == 0 && (op == CAIRO_OPERATOR_CLEAR || op == CAIRO_OPERATOR_SOURCE)) { - xmlFreeNode (surface->xml_root_node->children); - if (op == CAIRO_OPERATOR_CLEAR) - return CAIRO_STATUS_SUCCESS; + xmlNodePtr child = surface->xml_root_node->children; + + while (child != NULL) { + xmlUnlinkNode (child); + xmlFreeNode (child); + child = surface->xml_root_node->children; + } + + if (op == CAIRO_OPERATOR_CLEAR) { + if (surface->content == CAIRO_CONTENT_COLOR) { + xmlNodePtr rect; + char buffer[CAIRO_SVG_DTOSTR_BUFFER_LEN]; + + rect = xmlNewChild (surface->xml_node, NULL, CC2XML ("rect"), NULL); + _cairo_dtostr (buffer, sizeof buffer, surface->width); + xmlSetProp (rect, CC2XML ("width"), C2XML (buffer)); + _cairo_dtostr (buffer, sizeof buffer, surface->height); + xmlSetProp (rect, CC2XML ("height"), C2XML (buffer)); + xmlSetProp (rect, CC2XML ("style"), CC2XML ("opacity:1; stroke:none; fill:rgb(0,0,0);")); + } + return CAIRO_STATUS_SUCCESS; + } } emit_paint (surface->xml_node, surface, op, source); diff --git a/test/cairo-test.c b/test/cairo-test.c index 59b55f7ba..9105a1b36 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -1304,6 +1304,7 @@ typedef struct _svg_target_closure { char *filename; int width, height; + cairo_surface_t *target; } svg_target_closure_t; static cairo_surface_t * @@ -1330,7 +1331,19 @@ create_svg_surface (cairo_test_t *test, free (ptc); return NULL; } + cairo_svg_surface_set_dpi (surface, 72., 72.); + + if (content == CAIRO_CONTENT_COLOR) { + ptc->target = surface; + surface = cairo_surface_create_similar (ptc->target, + CAIRO_CONTENT_COLOR, + width, height); + } else { + ptc->target = NULL; + } + cairo_surface_set_user_data (surface, &svg_closure_key, ptc, NULL); + return surface; } @@ -1340,15 +1353,26 @@ svg_surface_write_to_png (cairo_surface_t *surface, const char *filename) svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key); char command[4096]; - cairo_surface_finish (surface); + if (ptc->target) { + cairo_t *cr; + cr = cairo_create (ptc->target); + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint (cr); + cairo_show_page (cr); + cairo_destroy (cr); + cairo_surface_finish (surface); + surface = ptc->target; + } + + cairo_surface_finish (surface); sprintf (command, "./svg2png %s %s", ptc->filename, filename); if (system (command) != 0) return CAIRO_STATUS_WRITE_ERROR; - return CAIRO_STATUS_WRITE_ERROR; + return CAIRO_STATUS_SUCCESS; } static void @@ -1593,10 +1617,14 @@ cairo_test_expecting (cairo_test_t *test, cairo_test_draw_function_t draw, create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf }, #endif #if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE - { "svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR, - create_svg_surface, svg_surface_write_to_png, cleanup_svg }, { "svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, create_svg_surface, svg_surface_write_to_png, cleanup_svg }, + + /* A SVG surface is COLOR_APLHA by default, and currently a create + * similar with content != COLOR_ALPHA will return a nil surface. + * So don't test COLOR for now. */ + { "svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR, + create_svg_surface, svg_surface_write_to_png, cleanup_svg }, #endif #if CAIRO_HAS_BEOS_SURFACE { "beos", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR,