[cairo-commit] cairo/test pdf-surface.c, 1.8, 1.9 ps-surface.c, 1.1, 1.2

Carl Worth commit at pdx.freedesktop.org
Tue May 17 05:58:04 PDT 2005


Committed by: cworth

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

Modified Files:
	pdf-surface.c ps-surface.c 
Log Message:

        * src/cairoint.h:
        * src/cairo-output-stream.c: Remove destroy_closure from
        cairo_output_stream_t interface.

        * src/cairo-pdf.h:
        * src/cairo-pdf-surface.c: Remove destroy_closure argument from
        cairo_pdf_surface_create_for_stream. Rename width,height to
        width_in_points, height_in_points for better clarity.

        * src/cairo-ps.h:
        * src/cairo-ps-surface.c: Brush a bunch of dust off of the PS
        backend and bring it up to date with the latest API conventions
        from the PDF backend. These include: accepting a filename rather
        than a FILE in the primary constructor, providing a stream-based
        interface for more flexibility, and accepting a surface size in
        device-space units (points) rather than inches.

        * test/pdf-surface.c: (main): Make it a little more clear that the
        width and height being passed around are in units of points.

        * test/ps-surface.c: (main): Update to the latest cairo-ps.h
        changes as described above. Notice how much more sane things
        become now that the surface size is described in device-space
        units.


Index: pdf-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/test/pdf-surface.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pdf-surface.c	17 May 2005 08:05:35 -0000	1.8
+++ pdf-surface.c	17 May 2005 12:58:02 -0000	1.9
@@ -35,8 +35,8 @@
 
 #define WIDTH_IN_INCHES  3
 #define HEIGHT_IN_INCHES 3
-#define WIDTH  (WIDTH_IN_INCHES  * 72.0)
-#define HEIGHT (HEIGHT_IN_INCHES * 72.0)
+#define WIDTH_IN_POINTS  (WIDTH_IN_INCHES  * 72.0)
+#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
 
 static void
 draw (cairo_t *cr, double width, double height)
@@ -93,15 +93,16 @@
 
     printf("\n");
 
-    surface = cairo_pdf_surface_create (filename, WIDTH, HEIGHT);
+    surface = cairo_pdf_surface_create (filename,
+					WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
     if (surface == NULL) {
-	cairo_test_log ("Failed to create pdf surface for file %s\n", filename);
+	fprintf (stderr, "Failed to create pdf surface for file %s\n", filename);
 	return CAIRO_TEST_FAILURE;
     }
 
     cr = cairo_create (surface);
 
-    draw (cr, WIDTH, HEIGHT);
+    draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
 
     cairo_show_page (cr);
 

Index: ps-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/test/ps-surface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ps-surface.c	17 May 2005 08:05:35 -0000	1.1
+++ ps-surface.c	17 May 2005 12:58:02 -0000	1.2
@@ -87,21 +87,14 @@
 int
 main (void)
 {
-    FILE *file;
     cairo_t *cr;
     const char *filename = "ps-surface.ps";
     cairo_surface_t *surface;
 
     printf("\n");
 
-    file = fopen (filename, "wb");
-    if (file == NULL) {
-	fprintf (stderr, "Failed to open file %s\n", filename);
-	return CAIRO_TEST_FAILURE;
-    }
-
-    surface = cairo_ps_surface_create (file, WIDTH_IN_INCHES, HEIGHT_IN_INCHES,
-				       300, 300);
+    surface = cairo_ps_surface_create (filename,
+				       WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
     if (surface == NULL) {
 	cairo_test_log ("Failed to create pdf surface for file %s\n", filename);
 	return CAIRO_TEST_FAILURE;
@@ -109,7 +102,7 @@
 
     cr = cairo_create (surface);
 
-    draw (cr, WIDTH_IN_INCHES * 300, HEIGHT_IN_INCHES * 300);
+    draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
 
     cairo_show_page (cr);
 




More information about the cairo-commit mailing list