[cairo-commit] cairo/src cairo-ps-surface.c,1.66,1.67

Carl Worth commit at pdx.freedesktop.org
Thu Jan 12 13:36:39 PST 2006


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv20396/src

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

2006-01-12  Carl Worth  <cworth at cworth.org>

        Some fixes for the fact that multi-page output was totally broken
        for cairo_ps_surface_t (at least):

        * src/cairo-ps-surface.c: (_cairo_ps_surface_emit_header),
        (_cairo_ps_surface_emit_footer),
        (_cairo_ps_surface_create_for_stream_internal),
        (_cairo_ps_surface_start_page), (_cairo_ps_surface_end_page),
        (_cairo_ps_surface_copy_page), (_cairo_ps_surface_show_page),
        (_cairo_ps_surface_composite), (_cairo_ps_surface_fill_rectangles),
        (_cairo_ps_surface_composite_trapezoids),
        (_cairo_ps_surface_old_show_glyphs), (_cairo_ps_surface_fill):
        Move the Y-axis-flipping to be on a per-page basis (as it was
        before and as it must be). Put page number back in, (still missing
        th number of pages from the header).

        * test/ps-surface.c: (draw), (main): Add multi-page output for
        better testing.


Index: cairo-ps-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ps-surface.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- cairo-ps-surface.c	12 Jan 2006 00:01:25 -0000	1.66
+++ cairo-ps-surface.c	12 Jan 2006 21:36:36 -0000	1.67
@@ -68,6 +68,9 @@
     double x_dpi;
     double y_dpi;
 
+    cairo_bool_t need_start_page; 
+    int num_pages;
+
 #if DONE_ADDING_FONTS_SUPPORT_BACK_AFTER_SWITCHING_TO_PAGINATED
     cairo_array_t fonts;
 #endif
@@ -104,12 +107,6 @@
 				 surface->width,
 				 surface->height);
 
-    _cairo_output_stream_printf (surface->stream,
-				 "gsave %f %f translate %f %f scale \n",
-				 0.0, surface->height,
-				 1.0/surface->base.device_x_scale,
-				 -1.0/surface->base.device_y_scale);
-
     /* The "/FlateDecode filter" currently used is a feature of
      * LanguageLevel 3 */
     _cairo_output_stream_printf (surface->stream,
@@ -123,9 +120,6 @@
 _cairo_ps_surface_emit_footer (cairo_ps_surface_t *surface)
 {
     _cairo_output_stream_printf (surface->stream,
-				 "grestore\n");
-
-    _cairo_output_stream_printf (surface->stream,
 				 "%%%%Trailer\n"
 				 "%%%%EOF\n");
 }
@@ -156,6 +150,9 @@
     surface->base.device_y_scale = surface->y_dpi / 72.0;
 #endif
 
+    surface->need_start_page = TRUE;
+    surface->num_pages = 0;
+
 #if DONE_ADDING_FONTS_SUPPORT_BACK_AFTER_SWITCHING_TO_PAGINATED
     _cairo_array_init (&surface->fonts, sizeof (cairo_font_subset_t *));
 #endif
@@ -274,26 +271,43 @@
     return CAIRO_STATUS_SUCCESS;
 }
 
-#if DONE_ADDING_PAGES_SUPPORT_AFTER_SWITCHING_TO_PAGINATED
-static cairo_int_status_t
+static void
 _cairo_ps_surface_start_page (cairo_ps_surface_t *surface)
 {
     _cairo_output_stream_printf (surface->stream,
 				 "%%%%Page: %d\n",
-				 page_number);
+				 ++surface->num_pages);
 
-    return CAIRO_STATUS_SUCCESS;
+
+    _cairo_output_stream_printf (surface->stream,
+				 "gsave %f %f translate %f %f scale \n",
+				 0.0, surface->height,
+				 1.0/surface->base.device_x_scale,
+				 -1.0/surface->base.device_y_scale);
+
+    surface->need_start_page = FALSE;
+}
+
+static void
+_cairo_ps_surface_end_page (cairo_ps_surface_t *surface)
+{
+    _cairo_output_stream_printf (surface->stream,
+				 "grestore\n");
+
+    _cairo_output_stream_printf (surface->stream,
+				 "%%%%EndPage\n");
+
+    surface->need_start_page = TRUE;
 }
-#endif
 
 static cairo_int_status_t
 _cairo_ps_surface_copy_page (void *abstract_surface)
 {
     cairo_ps_surface_t *surface = abstract_surface;
 
-    _cairo_output_stream_printf (surface->stream,
-				 "copypage\n"
-				 "%%%%EndPage\n");
+    _cairo_output_stream_printf (surface->stream, "copypage\n");
+
+    _cairo_ps_surface_end_page (surface);
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -303,9 +317,11 @@
 {
     cairo_ps_surface_t *surface = abstract_surface;
 
-    _cairo_output_stream_printf (surface->stream,
-				 "showpage\n"
-				 "%%%%EndPage\n");
+    _cairo_output_stream_printf (surface->stream, "showpage\n");
+
+    _cairo_ps_surface_end_page (surface);
+
+    surface->need_start_page = TRUE;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -828,6 +844,9 @@
     cairo_image_surface_t *image;
     void *image_extra;
 
+    if (surface->need_start_page)
+	_cairo_ps_surface_start_page (surface);
+
     if (mask_pattern) {
 	/* FIXME: Investigate how this can be done... we'll probably
 	 * need pixmap fallbacks for this, though. */
@@ -894,6 +913,9 @@
 
     if (!num_rects)
 	return CAIRO_STATUS_SUCCESS;
+
+    if (surface->need_start_page)
+	_cairo_ps_surface_start_page (surface);
     
     if (color_operation_needs_fallback (op, color)) {
 	int min_x = rects[0].x;
@@ -960,6 +982,9 @@
     if (pattern_operation_needs_fallback (op, pattern))
 	return _cairo_ps_surface_add_fallback_area (surface, x_dst, y_dst, width, height);
 
+    if (surface->need_start_page)
+	_cairo_ps_surface_start_page (surface);
+
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_composite_trapezoids\n");
 
@@ -1156,6 +1181,9 @@
     if (surface->fallback)
 	return CAIRO_STATUS_SUCCESS;
 
+    if (surface->need_start_page)
+	_cairo_ps_surface_start_page (surface);
+
     /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
     if (! _cairo_scaled_font_is_ft (scaled_font))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1223,6 +1251,10 @@
 					     0, 0,
 					     surface->width,
 					     surface->height);
+
+    if (surface->need_start_page)
+	_cairo_ps_surface_start_page (surface);
+
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_fill\n");
 



More information about the cairo-commit mailing list