[cairo-commit] 6 commits - src/cairo-analysis-surface.c src/cairo-paginated-private.h src/cairo-paginated-surface.c src/cairo-pdf-surface.c src/cairo-pdf-surface-private.h src/cairo-ps-surface.c src/cairo-ps-surface-private.h

Adrian Johnson ajohnson at kemper.freedesktop.org
Sun Sep 16 03:59:14 PDT 2007


 src/cairo-analysis-surface.c    |   12 +++++++++-
 src/cairo-paginated-private.h   |    5 ++++
 src/cairo-paginated-surface.c   |   26 ++++++++++++++++++++--
 src/cairo-pdf-surface-private.h |    2 +
 src/cairo-pdf-surface.c         |   16 ++++++++++---
 src/cairo-ps-surface-private.h  |    2 +
 src/cairo-ps-surface.c          |   47 +++++++++++++++++-----------------------
 7 files changed, 76 insertions(+), 34 deletions(-)

New commits:
diff-tree 3f4875dbe20e1d093d70f49c32f7ddf6a6e6ef61 (from 14786385b40aa0ae83e3b077a82e3f34aba63f22)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Sep 16 20:26:33 2007 +0930

    Analysis-surface: Use pattern extents to limit show_glyphs extents

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index f738a6d..967785f 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -479,6 +479,17 @@ _cairo_analysis_surface_show_glyphs (voi
     if (status)
 	return status;
 
+    if (_cairo_operator_bounded_by_source (op)) {
+	cairo_rectangle_int_t source_extents;
+	status = _cairo_pattern_get_extents (source, &source_extents);
+	if (status)
+	    return status;
+
+	_cairo_rectangle_intersect (&extents, &source_extents);
+    }
+
+    _cairo_rectangle_intersect (&extents, &surface->current_clip);
+
     if (_cairo_operator_bounded_by_mask (op)) {
 	status = _cairo_scaled_font_glyph_device_extents (scaled_font,
 							  glyphs,
@@ -490,7 +501,6 @@ _cairo_analysis_surface_show_glyphs (voi
 	_cairo_rectangle_intersect (&extents, &glyph_extents);
     }
 
-    _cairo_rectangle_intersect (&extents, &surface->current_clip);
     status = _cairo_analysis_surface_add_operation (surface, &extents, backend_status);
 
     return status;
diff-tree 14786385b40aa0ae83e3b077a82e3f34aba63f22 (from 46cb7e69526e8b5663077e7409dc232a0f56800b)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Sep 16 19:43:28 2007 +0930

    Change paginated surface size when PS/PDF _set_size() called
    
    The finer-grained fallbacks would not work correctly if the page
    was set to a larger size.
    
    Add _cairo_paginated_surface_set_size() function that is called
    from cairo_ps_surface_set_size() and cairo_pdf_surface_set_size().

diff --git a/src/cairo-paginated-private.h b/src/cairo-paginated-private.h
index 42d100b..fdcb8fa 100644
--- a/src/cairo-paginated-private.h
+++ b/src/cairo-paginated-private.h
@@ -133,4 +133,9 @@ _cairo_paginated_surface_get_target (cai
 cairo_private cairo_bool_t
 _cairo_surface_is_paginated (cairo_surface_t *surface);
 
+cairo_private cairo_status_t
+_cairo_paginated_surface_set_size (cairo_surface_t 	*surface,
+				   int			 width,
+				   int			 height);
+
 #endif /* CAIRO_PAGINATED_H */
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index b908573..76cf5bb 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -128,6 +128,29 @@ _cairo_paginated_surface_get_target (cai
     return paginated_surface->target;
 }
 
+cairo_status_t
+_cairo_paginated_surface_set_size (cairo_surface_t 	*surface,
+				   int			 width,
+				   int			 height)
+{
+    cairo_paginated_surface_t *paginated_surface;
+
+    assert (_cairo_surface_is_paginated (surface));
+
+    paginated_surface = (cairo_paginated_surface_t *) surface;
+
+    paginated_surface->width = width;
+    paginated_surface->height = height;
+
+    cairo_surface_destroy (paginated_surface->meta);
+    paginated_surface->meta = _cairo_meta_surface_create (paginated_surface->content,
+							  width, height);
+    if (cairo_surface_status (paginated_surface->meta))
+	return cairo_surface_status (paginated_surface->meta);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
 static cairo_status_t
 _cairo_paginated_surface_finish (void *abstract_surface)
 {
diff --git a/src/cairo-pdf-surface-private.h b/src/cairo-pdf-surface-private.h
index 99b5393..0de4c0f 100644
--- a/src/cairo-pdf-surface-private.h
+++ b/src/cairo-pdf-surface-private.h
@@ -124,6 +124,8 @@ struct _cairo_pdf_surface {
     cairo_paginated_mode_t paginated_mode;
 
     cairo_bool_t force_fallbacks;
+
+    cairo_surface_t *paginated_surface;
 };
 
 #endif /* CAIRO_PDF_SURFACE_PRIVATE_H */
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 2f50c13..48b24f2 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -357,10 +357,11 @@ _cairo_pdf_surface_create_for_stream_int
     _cairo_output_stream_printf (surface->output,
 				 "%%%c%c%c%c\r\n", 181, 237, 174, 251);
 
-    return _cairo_paginated_surface_create (&surface->base,
-					    CAIRO_CONTENT_COLOR_ALPHA,
-					    width, height,
-					    &cairo_pdf_surface_paginated_backend);
+    surface->paginated_surface = _cairo_paginated_surface_create (&surface->base,
+								  CAIRO_CONTENT_COLOR_ALPHA,
+								  width, height,
+								  &cairo_pdf_surface_paginated_backend);
+    return surface->paginated_surface;
 
 fail:
     free (surface);
@@ -513,6 +514,11 @@ cairo_pdf_surface_set_size (cairo_surfac
     pdf_surface->width = width_in_points;
     pdf_surface->height = height_in_points;
     cairo_matrix_init (&pdf_surface->cairo_to_pdf, 1, 0, 0, -1, 0, height_in_points);
+    status = _cairo_paginated_surface_set_size (pdf_surface->paginated_surface,
+						width_in_points,
+						height_in_points);
+    if (status)
+	_cairo_surface_set_error (surface, status);
 }
 
 static void
diff --git a/src/cairo-ps-surface-private.h b/src/cairo-ps-surface-private.h
index 2499b99..3a23c21 100644
--- a/src/cairo-ps-surface-private.h
+++ b/src/cairo-ps-surface-private.h
@@ -75,6 +75,8 @@ typedef struct cairo_ps_surface {
     cairo_array_t dsc_page_setup_comments;
 
     cairo_array_t *dsc_comment_target;
+
+    cairo_surface_t *paginated_surface;
 } cairo_ps_surface_t;
 
 #endif /* CAIRO_PS_SURFACE_PRIVATE_H */
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 6ffbf0e..83e5bbb 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -817,10 +817,11 @@ _cairo_ps_surface_create_for_stream_inte
 
     surface->dsc_comment_target = &surface->dsc_header_comments;
 
-    return _cairo_paginated_surface_create (&surface->base,
-					    CAIRO_CONTENT_COLOR_ALPHA,
-					    width, height,
-					    &cairo_ps_surface_paginated_backend);
+    surface->paginated_surface = _cairo_paginated_surface_create (&surface->base,
+								   CAIRO_CONTENT_COLOR_ALPHA,
+								   width, height,
+								   &cairo_ps_surface_paginated_backend);
+    return surface->paginated_surface;
 
  CLEANUP_OUTPUT_STREAM:
     status = _cairo_output_stream_destroy (surface->stream);
@@ -988,6 +989,11 @@ cairo_ps_surface_set_size (cairo_surface
 
     ps_surface->width = width_in_points;
     ps_surface->height = height_in_points;
+    status = _cairo_paginated_surface_set_size (ps_surface->paginated_surface,
+						width_in_points,
+						height_in_points);
+    if (status)
+	_cairo_surface_set_error (surface, status);
 }
 
 /**
diff-tree 46cb7e69526e8b5663077e7409dc232a0f56800b (from e9d85235f9cceed92af428e0ab43503fe0850636)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Sep 16 16:32:54 2007 +0930

    PS: Remove initclip operator
    
    The DSC and EPS specifications do not allow the use of initclip.
    Instead each page is wrapped in a gsave/restore pair and a
    "grestore gsave" is emitted when the clip path is reset.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 8134bbb..6ffbf0e 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1267,7 +1267,7 @@ _cairo_ps_surface_start_page (void *abst
 				 (int) ceil (surface->height));
 
     _cairo_output_stream_printf (surface->stream,
-				 "gsave %f %f translate 1.0 -1.0 scale \n",
+				 "gsave %f %f translate 1.0 -1.0 scale gsave\n",
 				 0.0, surface->height);
 
     _cairo_output_stream_printf (surface->stream,
@@ -1285,7 +1285,7 @@ static void
 _cairo_ps_surface_end_page (cairo_ps_surface_t *surface)
 {
     _cairo_output_stream_printf (surface->stream,
-				 "grestore\n");
+				 "grestore grestore\n");
 }
 
 static cairo_int_status_t
@@ -1884,7 +1884,7 @@ _cairo_ps_surface_intersect_clip_path (v
 #endif
 
     if (path == NULL) {
-	_cairo_output_stream_printf (stream, "initclip\n");
+	_cairo_output_stream_printf (stream, "grestore gsave\n");
 	return CAIRO_STATUS_SUCCESS;
     }
 
diff-tree e9d85235f9cceed92af428e0ab43503fe0850636 (from a5cb48fcf269c16dd138c0ee31b138b1f13e623d)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Sep 16 16:21:10 2007 +0930

    PDF: Fix copy_page() bug

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index d43cdb0..2f50c13 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2279,6 +2279,8 @@ _cairo_pdf_surface_copy_page (void *abst
 {
     cairo_pdf_surface_t *surface = abstract_surface;
 
+    _cairo_pdf_surface_stop_content_stream (surface);
+
     return _cairo_pdf_surface_write_page (surface);
 }
 
diff-tree a5cb48fcf269c16dd138c0ee31b138b1f13e623d (from 03f7a51f47717af45afbc439ce2178789449ab32)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Sep 16 16:15:10 2007 +0930

    PS: Remove copy_page()
    
    The DSC specification recommends not using the copypage operator as it
    breaks page independence.

diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index e4f1762..b908573 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -377,8 +377,7 @@ _cairo_paginated_surface_copy_page (void
 
     /* XXX: It might make sense to add some suport here for calling
      * cairo_surface_copy_page on the target surface. It would be an
-     * optimization for the output, (so that PostScript could include
-     * copypage, for example), but the interaction with image
+     * optimization for the output, but the interaction with image
      * fallbacks gets tricky. For now, we just let the target see a
      * show_page and we implement the copying by simply not destroying
      * the meta-surface. */
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index b90fb38..8134bbb 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1289,18 +1289,6 @@ _cairo_ps_surface_end_page (cairo_ps_sur
 }
 
 static cairo_int_status_t
-_cairo_ps_surface_copy_page (void *abstract_surface)
-{
-    cairo_ps_surface_t *surface = abstract_surface;
-
-    _cairo_ps_surface_end_page (surface);
-
-    _cairo_output_stream_printf (surface->stream, "copypage\n");
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_int_status_t
 _cairo_ps_surface_show_page (void *abstract_surface)
 {
     cairo_ps_surface_t *surface = abstract_surface;
@@ -2387,7 +2375,7 @@ static const cairo_surface_backend_t cai
     NULL, /* composite */
     NULL, /* fill_rectangles */
     NULL, /* composite_trapezoids */
-    _cairo_ps_surface_copy_page,
+    NULL, /* cairo_ps_surface_copy_page */
     _cairo_ps_surface_show_page,
     NULL, /* set_clip_region */
     _cairo_ps_surface_intersect_clip_path,
diff-tree 03f7a51f47717af45afbc439ce2178789449ab32 (from 1274147ce3ec855488fe4e437838b1134c494413)
Author: Ken Herron <kherron+cairo at fmailbox.com>
Date:   Sun Sep 16 15:56:16 2007 +0930

    PS output optimizations (#11442)
    
    This patches cairo-ps-surface.c to use the aliases for moveto, lineto, curveto,
    and closepath. It also uses selectfont to select fonts.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 211ecd1..b90fb38 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -180,7 +180,7 @@ _cairo_ps_surface_path_move_to (void *cl
     path_info->has_sub_path = FALSE;
 
     _cairo_output_stream_printf (path_info->stream,
-				 "%f %f moveto ",
+				 "%f %f M ",
 				 _cairo_fixed_to_double (point->x),
 				 _cairo_fixed_to_double (point->y));
 
@@ -203,7 +203,7 @@ _cairo_ps_surface_path_line_to (void *cl
     path_info->has_sub_path = TRUE;
 
     _cairo_output_stream_printf (path_info->stream,
-				 "%f %f lineto ",
+				 "%f %f L ",
 				 _cairo_fixed_to_double (point->x),
 				 _cairo_fixed_to_double (point->y));
 
@@ -221,7 +221,7 @@ _cairo_ps_surface_path_curve_to (void   
     path_info->has_sub_path = TRUE;
 
     _cairo_output_stream_printf (path_info->stream,
-				 "%f %f %f %f %f %f curveto ",
+				 "%f %f %f %f %f %f C ",
 				 _cairo_fixed_to_double (b->x),
 				 _cairo_fixed_to_double (b->y),
 				 _cairo_fixed_to_double (c->x),
@@ -244,7 +244,7 @@ _cairo_ps_surface_path_close_path (void 
     }
 
     _cairo_output_stream_printf (path_info->stream,
-				 "closepath\n");
+				 "P\n");
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -2278,9 +2278,8 @@ _cairo_ps_surface_show_glyphs (void		   
     while (i < num_glyphs_unsigned) {
         if (glyph_ids[i].subset_id != current_subset_id) {
             _cairo_output_stream_printf (surface->stream,
-                                         "/CairoFont-%d-%d findfont\n"
-                                         "[ %f %f %f %f 0 0 ] makefont\n"
-                                         "setfont\n",
+                                         "/CairoFont-%d-%d "
+                                         "[ %f %f %f %f 0 0 ] selectfont\n",
                                          subset_glyph.font_id,
                                          glyph_ids[i].subset_id,
                                          scaled_font->scale.xx,


More information about the cairo-commit mailing list