[cairo-commit] cairo/test .cvsignore, 1.62, 1.63 Makefile.am, 1.105, 1.106 cairo-test.c, 1.69, 1.70 svg2png.c, NONE, 1.1

Emmanuel Pacaud commit at pdx.freedesktop.org
Mon Dec 19 13:59:37 PST 2005


Committed by: emmanuel

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv27212/test

Modified Files:
	.cvsignore Makefile.am cairo-test.c 
Added Files:
	svg2png.c 
Log Message:
2005-12-19  Emmanuel Pacaud <emmanuel.pacaud at free.fr>

	* configure.in: CAIRO_CAN_TEST_SVG_SURFACE depends on librsvg.
	* src/cairo-svg-surface.c: cairo_svg_surface_t owns a xml node, for
	support of svg_surface_composite.
	(_cairo_svg_surface_create_for_document): init xml_node. All surfaces
	except first one are stored in defs node.
	(emit_composite_image_pattern): returns pattern size, and don't call
	emit_transform if is_pattern == TRUE.
	(emit_composite_svg_pattern): do something.
	(emit_composite_pattern): returns pattern size.
	(_cairo_svg_surface_composite): xml_node is stored in
	cairo_svg_surface_t now.
	(emit_surface_pattern): emit surface pattern width here.
	Fix property names.
	(_cairo_svg_path_close_path): don't close path if no current point.
	(_cairo_svg_surface_fill_rectangles): new.
	(_cairo_svg_surface_fill): emit fill rule. xml_node is in surface now.
	(_cairo_svg_surface_composite_trapezoids): xml_node is in surface now.
	(_cairo_svg_surface_stroke): ditto.
	(_cairo_svg_surface_intersect_clip_path): ditto. Emit fill rule.
	* test/.cvsignore: ignore svg2png.
	* test/Makefile.am: build svg2png utility.
	* test/cairo-test.c (create_svg_surface): new.
	(svg_surface_write_to_png): new.
	(cleanup_svg): new.
	(cairo_test_expecting): test SVG backend if CAIRO_HAS_SVG_SURFACE &&
	CAIRO_CAN_TEST_SVG_SURFACE.
	* test/svg2png.c: new.



Index: .cvsignore
===================================================================
RCS file: /cvs/cairo/cairo/test/.cvsignore,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- .cvsignore	19 Dec 2005 01:20:06 -0000	1.62
+++ .cvsignore	19 Dec 2005 21:59:35 -0000	1.63
@@ -45,6 +45,7 @@
 pdf-clip.pdf
 pdf-surface
 pdf-surface.pdf
+svg2png
 svg-clip
 svg-clip.svg
 svg-surface

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- Makefile.am	19 Dec 2005 01:20:07 -0000	1.105
+++ Makefile.am	19 Dec 2005 21:59:35 -0000	1.106
@@ -273,7 +273,6 @@
 LDADDS += $(GLITZ_WGL_LIBS)
 endif
 
-
 if HAVE_PTHREAD
 LDADDS += -lpthread
 endif
@@ -359,8 +358,15 @@
 pdf2png_LDADD = $(LDADDS) $(POPPLER_LIBS)
 endif
 
+if CAIRO_CAN_TEST_SVG_SURFACE
+noinst_PROGRAMS += svg2png
+svg2png_CFLAGS = $(LIBRSVG_CFLAGS)
+svg2png_LDADD = $(LIBRSVG_LIBS)
+endif
+
 CLEANFILES =					\
 	*.ps					\
+	*.svg					\
 	*-out.png				\
 	*-diff.png				\
 	*.log					\

Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- cairo-test.c	19 Dec 2005 01:20:07 -0000	1.69
+++ cairo-test.c	19 Dec 2005 21:59:35 -0000	1.70
@@ -1127,6 +1127,71 @@
 }
 #endif /* CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE */
 
+#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
+#include "cairo-svg.h"
+
+cairo_user_data_key_t	svg_closure_key;
+
+typedef struct _svg_target_closure
+{
+    char    *filename;
+    int	    width, height;
+} svg_target_closure_t;
+
+static cairo_surface_t *
+create_svg_surface (cairo_test_t *test, cairo_format_t format,
+		    void **closure)
+{
+    int width = test->width;
+    int height = test->height;
+    svg_target_closure_t *ptc;
+    cairo_surface_t *surface;
+
+    /* This is the only format supported by the PS surface backend. */
+    assert (format == CAIRO_FORMAT_RGB24);
+
+    *closure = ptc = xmalloc (sizeof (svg_target_closure_t));
+
+    ptc->width = width;
+    ptc->height = height;
+    
+    xasprintf (&ptc->filename, "%s-%s%s", test->name, "svg-rgb24-out", ".svg");
+    surface = cairo_svg_surface_create (ptc->filename, width, height);
+    if (cairo_surface_status (surface)) {
+	free (ptc->filename);
+	free (ptc);
+	return NULL;
+    }
+    cairo_surface_set_user_data (surface, &svg_closure_key, ptc, NULL);
+    return surface;
+}
+
+static cairo_status_t
+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);
+
+    sprintf (command, "./svg2png %s %s",
+	     ptc->filename, filename);
+
+    if (system (command) != 0)
+	return CAIRO_STATUS_WRITE_ERROR;
+    
+    return CAIRO_STATUS_WRITE_ERROR;
+}
+
+static void
+cleanup_svg (void *closure)
+{
+    svg_target_closure_t *ptc = closure;
+    free (ptc->filename);
+    free (ptc);
+}
+#endif /* CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE */
+
 static cairo_test_status_t
 cairo_test_for_target (cairo_test_t *test,
 		       cairo_test_draw_function_t draw,
@@ -1307,6 +1372,10 @@
 	    { "pdf", CAIRO_FORMAT_RGB24, 
 		create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf },
 #endif
+#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
+	    { "svg", CAIRO_FORMAT_RGB24,
+		    create_svg_surface, svg_surface_write_to_png, cleanup_svg },
+#endif
 #if CAIRO_HAS_BEOS_SURFACE
 	    { "beos", CAIRO_FORMAT_RGB24,
 		create_beos_surface, cairo_surface_write_to_png, cleanup_beos},

--- NEW FILE: svg2png.c ---
(This appears to be a binary file; contents omitted.)



More information about the cairo-commit mailing list