SVG: Add documentation for public API. Fix test filenames and add testing of CAIRO_CONTENT_COLOR

This commit is contained in:
Emmanuel Pacaud 2006-04-14 22:53:58 +02:00
parent f919ba858f
commit e952e0aff8
2 changed files with 52 additions and 1 deletions

View file

@ -137,6 +137,24 @@ _cairo_svg_surface_create_for_stream_internal (cairo_output_stream_t *stream,
return surface;
}
/**
* cairo_svg_surface_create_for_stream:
* @write: a #cairo_write_func_t to accept the output data
* @closure: the closure argument for @write
* @width_in_points: width of the surface, in points (1 point == 1/72.0 inch)
* @height_in_points: height of the surface, in points (1 point == 1/72.0 inch)
*
* Creates a SVG surface of the specified size in points to be written
* incrementally to the stream represented by @write and @closure.
*
* Return value: a pointer to the newly created surface. The caller
* owns the surface and should call cairo_surface_destroy when done
* with it.
*
* This function always returns a valid pointer, but it will return a
* pointer to a "nil" surface if an error such as out of memory
* occurs. You can use cairo_surface_status() to check for this.
*/
cairo_surface_t *
cairo_svg_surface_create_for_stream (cairo_write_func_t write,
void *closure,
@ -156,6 +174,23 @@ cairo_svg_surface_create_for_stream (cairo_write_func_t write,
return _cairo_svg_surface_create_for_stream_internal (stream, width, height);
}
/**
* cairo_svg_surface_create:
* @filename: a filename for the SVG output (must be writable)
* @width_in_points: width of the surface, in points (1 point == 1/72.0 inch)
* @height_in_points: height of the surface, in points (1 point == 1/72.0 inch)
*
* Creates a SVG surface of the specified size in points to be written
* to @filename.
*
* Return value: a pointer to the newly created surface. The caller
* owns the surface and should call cairo_surface_destroy when done
* with it.
*
* This function always returns a valid pointer, but it will return a
* pointer to a "nil" surface if an error such as out of memory
* occurs. You can use cairo_surface_status() to check for this.
**/
cairo_surface_t *
cairo_svg_surface_create (const char *filename,
double width,
@ -174,6 +209,18 @@ cairo_svg_surface_create (const char *filename,
return _cairo_svg_surface_create_for_stream_internal (stream, width, height);
}
/**
* cairo_svg_surface_set_dpi:
* @surface: a svg cairo_surface_t
* @x_dpi: horizontal dpi
* @y_dpi: vertical dpi
*
* Set the horizontal and vertical resolution for image fallbacks.
* When the svg backend needs to fall back to image overlays, it will
* use this resolution. These DPI values are not used for any other
* purpose, (in particular, they do not have any bearing on the size
* passed to cairo_svg_surface_create() nor on the CTM).
**/
void
cairo_svg_surface_set_dpi (cairo_surface_t *surface,
double x_dpi,

View file

@ -1321,7 +1321,9 @@ create_svg_surface (cairo_test_t *test,
ptc->width = width;
ptc->height = height;
xasprintf (&ptc->filename, "%s-%s%s", test->name, "svg-argb32-out", ".svg");
xasprintf (&ptc->filename, "%s-svg-%s-out.svg",
test->name, _cairo_test_content_name (content));
surface = cairo_svg_surface_create (ptc->filename, width, height);
if (cairo_surface_status (surface)) {
free (ptc->filename);
@ -1591,6 +1593,8 @@ 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 },
#endif