[cairo-commit] src/cairo-analysis-surface.c src/cairo-directfb-surface.c src/cairo-glitz-surface.c src/cairo-gstate.c src/cairoint.h src/cairo-meta-surface.c src/cairo-paginated-surface.c src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-quartz-surface.c src/cairo-scaled-font.c src/cairo-surface.c src/cairo-surface-fallback.c src/cairo-surface-fallback-private.h src/cairo-svg-surface.c src/cairo-win32-font.c src/cairo-win32-surface.c src/cairo-xcb-surface.c src/cairo-xlib-surface.c src/test-meta-surface.c src/test-paginated-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Aug 31 08:38:55 PDT 2007


 src/cairo-analysis-surface.c         |    2 -
 src/cairo-directfb-surface.c         |    2 -
 src/cairo-glitz-surface.c            |    2 -
 src/cairo-gstate.c                   |   43 ++++++++++++++++++++++++++---------
 src/cairo-meta-surface.c             |    2 -
 src/cairo-paginated-surface.c        |    2 -
 src/cairo-pdf-surface.c              |    2 -
 src/cairo-ps-surface.c               |    2 -
 src/cairo-quartz-surface.c           |    2 -
 src/cairo-scaled-font.c              |    2 -
 src/cairo-surface-fallback-private.h |    2 -
 src/cairo-surface-fallback.c         |    4 +--
 src/cairo-surface.c                  |    4 +--
 src/cairo-svg-surface.c              |    2 -
 src/cairo-win32-font.c               |    2 -
 src/cairo-win32-surface.c            |    2 -
 src/cairo-xcb-surface.c              |   20 ++++++++--------
 src/cairo-xlib-surface.c             |    4 +--
 src/cairoint.h                       |   12 ++++-----
 src/test-meta-surface.c              |    2 -
 src/test-paginated-surface.c         |    2 -
 21 files changed, 69 insertions(+), 48 deletions(-)

New commits:
diff-tree 919bea6dbb32746f11781cd3a94eb44f5c4a32e6 (from 62377cbac17779fd51ec108e9704be8d3eed4935)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Aug 31 11:24:06 2007 +0100

    [cairo-gstate] Avoid copying untransformed glyphs.
    
    Skip the memory duplication of the incoming glyphs if we do not need
    to transform them into the backend coordinate system.
    
    As a consequence we need to constify the glyphs passed to the backend
    functions.

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index afbd30f..e49af66 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -393,7 +393,7 @@ static cairo_int_status_t
 _cairo_analysis_surface_show_glyphs (void		  *abstract_surface,
 				     cairo_operator_t	   op,
 				     cairo_pattern_t	  *source,
-				     cairo_glyph_t	  *glyphs,
+				     const cairo_glyph_t  *glyphs,
 				     int		   num_glyphs,
 				     cairo_scaled_font_t  *scaled_font)
 {
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index 409f79d..198c198 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1451,7 +1451,7 @@ static cairo_int_status_t
 _cairo_directfb_surface_show_glyphs ( void                 *abstract_dst,
                                      cairo_operator_t      op,
                                      cairo_pattern_t      *pattern,
-                                     cairo_glyph_t	  *glyphs,
+                                     const cairo_glyph_t  *glyphs,
                                      int                   num_glyphs,
                                      cairo_scaled_font_t  *scaled_font)
 {
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 8f497a9..c61ec4d 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -2086,7 +2086,7 @@ _cairo_glitz_surface_old_show_glyphs (ca
 				      int		   dst_y,
 				      unsigned int	   width,
 				      unsigned int	   height,
-				      cairo_glyph_t       *glyphs,
+				      const cairo_glyph_t *glyphs,
 				      int		   num_glyphs)
 {
     cairo_glitz_surface_attributes_t	attributes;
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index cda40b1..e0d3065 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -58,6 +58,9 @@ _cairo_gstate_transform_glyphs_to_backen
                                            int                  num_glyphs,
                                            cairo_glyph_t       *transformed_glyphs);
 
+static cairo_bool_t
+_cairo_gstate_transform_glyphs_to_backend_required (cairo_gstate_t *gstate);
+
 cairo_status_t
 _cairo_gstate_init (cairo_gstate_t  *gstate,
 		    cairo_surface_t *target)
@@ -1567,16 +1570,19 @@ _cairo_gstate_show_glyphs (cairo_gstate_
     if (status)
 	return status;
 
-    if (num_glyphs <= STACK_GLYPHS_LEN) {
-	transformed_glyphs = stack_transformed_glyphs;
-    } else {
-	transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
-	if (transformed_glyphs == NULL)
-	    return CAIRO_STATUS_NO_MEMORY;
-    }
-
-    _cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
-                                               transformed_glyphs);
+    if (_cairo_gstate_transform_glyphs_to_backend_required (gstate)) {
+	if (num_glyphs <= STACK_GLYPHS_LEN) {
+	    transformed_glyphs = stack_transformed_glyphs;
+	} else {
+	    transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
+	    if (transformed_glyphs == NULL)
+		return CAIRO_STATUS_NO_MEMORY;
+	}
+
+	_cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
+						   transformed_glyphs);
+    } else
+	transformed_glyphs = (cairo_glyph_t *) glyphs;
 
     status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
     if (status)
@@ -1592,7 +1598,8 @@ _cairo_gstate_show_glyphs (cairo_gstate_
     _cairo_pattern_fini (&source_pattern.base);
 
 CLEANUP_GLYPHS:
-    if (transformed_glyphs != stack_transformed_glyphs)
+    if (transformed_glyphs != stack_transformed_glyphs &&
+	    transformed_glyphs != glyphs)
       free (transformed_glyphs);
 
     return status;
@@ -1648,6 +1655,20 @@ _cairo_gstate_get_antialias (cairo_gstat
     return gstate->antialias;
 }
 
+static cairo_bool_t
+_cairo_gstate_transform_glyphs_to_backend_required (cairo_gstate_t *gstate)
+{
+    cairo_matrix_t *ctm = &gstate->ctm;
+    cairo_matrix_t *device_transform = &gstate->target->device_transform;
+
+    if (_cairo_matrix_is_identity (ctm) &&
+        _cairo_matrix_is_identity (device_transform) &&
+	gstate->font_matrix.x0 == 0 && gstate->font_matrix.y0 == 0)
+	return FALSE;
+
+    return TRUE;
+}
+
 /**
  * _cairo_gstate_transform_glyphs_to_backend:
  * @gstate: a #cairo_gstate_t
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index d8f5064..bc5434c 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -426,7 +426,7 @@ static cairo_int_status_t
 _cairo_meta_surface_show_glyphs (void			*abstract_surface,
 				 cairo_operator_t	 op,
 				 cairo_pattern_t	*source,
-				 cairo_glyph_t		*glyphs,
+				 const cairo_glyph_t	*glyphs,
 				 int			 num_glyphs,
 				 cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 85f00fa..e8bdc2a 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -530,7 +530,7 @@ static cairo_int_status_t
 _cairo_paginated_surface_show_glyphs (void			*abstract_surface,
 				      cairo_operator_t		 op,
 				      cairo_pattern_t		*source,
-				      cairo_glyph_t		*glyphs,
+				      const cairo_glyph_t	*glyphs,
 				      int			 num_glyphs,
 				      cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 2677605..aa65dad 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -3880,7 +3880,7 @@ static cairo_int_status_t
 _cairo_pdf_surface_show_glyphs (void			*abstract_surface,
 				cairo_operator_t	 op,
 				cairo_pattern_t		*source,
-				cairo_glyph_t		*glyphs,
+				const cairo_glyph_t	*glyphs,
 				int			 num_glyphs,
 				cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 211ecd1..53e55dc 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2230,7 +2230,7 @@ static cairo_int_status_t
 _cairo_ps_surface_show_glyphs (void		     *abstract_surface,
 			       cairo_operator_t	      op,
 			       cairo_pattern_t	     *source,
-			       cairo_glyph_t         *glyphs,
+			       const cairo_glyph_t   *glyphs,
 			       int		      num_glyphs,
 			       cairo_scaled_font_t   *scaled_font)
 {
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 540bdca..d87d31e 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1315,7 +1315,7 @@ static cairo_int_status_t
 _cairo_quartz_surface_show_glyphs (void *abstract_surface,
 				    cairo_operator_t op,
 				    cairo_pattern_t *source,
-				    cairo_glyph_t *glyphs,
+				    const cairo_glyph_t *glyphs,
 				    int num_glyphs,
 				    cairo_scaled_font_t *scaled_font)
 {
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index cb3af9f..387a1b9 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -1140,7 +1140,7 @@ _cairo_scaled_font_show_glyphs (cairo_sc
 				int			dest_y,
 				unsigned int		width,
 				unsigned int		height,
-				cairo_glyph_t	       *glyphs,
+				const cairo_glyph_t    *glyphs,
 				int                     num_glyphs)
 {
     cairo_status_t status;
diff --git a/src/cairo-surface-fallback-private.h b/src/cairo-surface-fallback-private.h
index 82c5625..00ad49e 100644
--- a/src/cairo-surface-fallback-private.h
+++ b/src/cairo-surface-fallback-private.h
@@ -75,7 +75,7 @@ cairo_private cairo_status_t
 _cairo_surface_fallback_show_glyphs (cairo_surface_t		*surface,
 				     cairo_operator_t		 op,
 				     cairo_pattern_t		*source,
-				     cairo_glyph_t		*glyphs,
+				     const cairo_glyph_t	*glyphs,
 				     int			 num_glyphs,
 				     cairo_scaled_font_t	*scaled_font);
 
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index ab19d2c..ced4dc5 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -915,7 +915,7 @@ _cairo_surface_fallback_fill (cairo_surf
 
 typedef struct {
     cairo_scaled_font_t *font;
-    cairo_glyph_t *glyphs;
+    const cairo_glyph_t *glyphs;
     int num_glyphs;
 } cairo_show_glyphs_info_t;
 
@@ -984,7 +984,7 @@ cairo_status_t
 _cairo_surface_fallback_show_glyphs (cairo_surface_t		*surface,
 				     cairo_operator_t		 op,
 				     cairo_pattern_t		*source,
-				     cairo_glyph_t		*glyphs,
+				     const cairo_glyph_t	*glyphs,
 				     int			 num_glyphs,
 				     cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index b44b853..8e39b5e 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1901,7 +1901,7 @@ cairo_status_t
 _cairo_surface_show_glyphs (cairo_surface_t	*surface,
 			    cairo_operator_t	 op,
 			    cairo_pattern_t	*source,
-			    cairo_glyph_t	*glyphs,
+			    const cairo_glyph_t	*glyphs,
 			    int			 num_glyphs,
 			    cairo_scaled_font_t	*scaled_font)
 {
@@ -1986,7 +1986,7 @@ _cairo_surface_old_show_glyphs (cairo_sc
 				int			 dest_y,
 				unsigned int		 width,
 				unsigned int		 height,
-				cairo_glyph_t		*glyphs,
+				const cairo_glyph_t	*glyphs,
 				int			 num_glyphs)
 {
     cairo_status_t status;
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index eafec32..60fea96 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1954,7 +1954,7 @@ static cairo_int_status_t
 _cairo_svg_surface_show_glyphs (void			*abstract_surface,
 				cairo_operator_t	 op,
 				cairo_pattern_t		*pattern,
-				cairo_glyph_t		*glyphs,
+				const cairo_glyph_t	*glyphs,
 				int			 num_glyphs,
 				cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 484ca17..d9e82c0 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -1170,7 +1170,7 @@ _cairo_win32_scaled_font_show_glyphs (vo
 				      int			dest_y,
 				      unsigned int		width,
 				      unsigned int		height,
-				      cairo_glyph_t	       *glyphs,
+				      const cairo_glyph_t      *glyphs,
 				      int                 	num_glyphs)
 {
     cairo_win32_scaled_font_t *scaled_font = abstract_font;
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 1358670..e82a528 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -1497,7 +1497,7 @@ static cairo_int_status_t
 _cairo_win32_surface_show_glyphs (void			*surface,
 				  cairo_operator_t	 op,
 				  cairo_pattern_t	*source,
-				  cairo_glyph_t		*glyphs,
+				  const cairo_glyph_t   *glyphs,
 				  int			 num_glyphs,
 				  cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index bcdadae..46ee162 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1620,11 +1620,11 @@ _cairo_xcb_surface_scaled_glyph_fini (ca
 
 static cairo_int_status_t
 _cairo_xcb_surface_show_glyphs (void                *abstract_dst,
-				 cairo_operator_t     op,
-				 cairo_pattern_t     *src_pattern,
-				 cairo_glyph_t       *glyphs,
-				 int		      num_glyphs,
-				 cairo_scaled_font_t *scaled_font);
+				cairo_operator_t     op,
+				cairo_pattern_t     *src_pattern,
+				const cairo_glyph_t *glyphs,
+				int		     num_glyphs,
+				cairo_scaled_font_t *scaled_font);
 
 static cairo_bool_t
 _cairo_xcb_surface_is_similar (void *surface_a,
@@ -2307,11 +2307,11 @@ typedef cairo_status_t (*cairo_xcb_surfa
 
 static cairo_int_status_t
 _cairo_xcb_surface_show_glyphs (void                *abstract_dst,
-				 cairo_operator_t     op,
-				 cairo_pattern_t     *src_pattern,
-				 cairo_glyph_t       *glyphs,
-				 int		      num_glyphs,
-				 cairo_scaled_font_t *scaled_font)
+				cairo_operator_t     op,
+				cairo_pattern_t     *src_pattern,
+				const cairo_glyph_t *glyphs,
+				int		     num_glyphs,
+				cairo_scaled_font_t *scaled_font)
 {
     cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
     cairo_xcb_surface_t *dst = abstract_dst;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index c95ec16..6021622 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -68,7 +68,7 @@ static cairo_int_status_t
 _cairo_xlib_surface_show_glyphs (void                *abstract_dst,
 				 cairo_operator_t     op,
 				 cairo_pattern_t     *src_pattern,
-				 cairo_glyph_t       *glyphs,
+				 const cairo_glyph_t *glyphs,
 				 int		      num_glyphs,
 				 cairo_scaled_font_t *scaled_font);
 
@@ -2984,7 +2984,7 @@ static cairo_int_status_t
 _cairo_xlib_surface_show_glyphs (void                *abstract_dst,
 				 cairo_operator_t     op,
 				 cairo_pattern_t     *src_pattern,
-				 cairo_glyph_t       *glyphs,
+				 const cairo_glyph_t *glyphs,
 				 int		      num_glyphs,
 				 cairo_scaled_font_t *scaled_font)
 {
diff --git a/src/cairoint.h b/src/cairoint.h
index 58f2ea3..dcdcb9a 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -570,7 +570,7 @@ struct _cairo_scaled_font_backend {
 			 int			 dest_y,
 			 unsigned int		 width,
 			 unsigned int		 height,
-			 cairo_glyph_t		*glyphs,
+			 const cairo_glyph_t	*glyphs,
 			 int			 num_glyphs);
 
     cairo_warn cairo_int_status_t
@@ -798,7 +798,7 @@ struct _cairo_surface_backend {
 				 int				 dest_y,
 				 unsigned int			 width,
 				 unsigned int			 height,
-				 cairo_glyph_t			*glyphs,
+				 const cairo_glyph_t		*glyphs,
 				 int				 num_glyphs);
 
     void
@@ -860,7 +860,7 @@ struct _cairo_surface_backend {
     (*show_glyphs)		(void			*surface,
 				 cairo_operator_t	 op,
 				 cairo_pattern_t	*source,
-				 cairo_glyph_t		*glyphs,
+				 const cairo_glyph_t	*glyphs,
 				 int			 num_glyphs,
 				 cairo_scaled_font_t	*scaled_font);
 
@@ -1638,7 +1638,7 @@ _cairo_scaled_font_show_glyphs (cairo_sc
 				int		     dest_y,
 				unsigned int	     width,
 				unsigned int	     height,
-				cairo_glyph_t	    *glyphs,
+				const cairo_glyph_t *glyphs,
 				int		     num_glyphs);
 
 cairo_private cairo_status_t
@@ -1810,7 +1810,7 @@ cairo_private cairo_status_t
 _cairo_surface_show_glyphs (cairo_surface_t	*surface,
 			    cairo_operator_t	 op,
 			    cairo_pattern_t	*source,
-			    cairo_glyph_t	*glyphs,
+			    const cairo_glyph_t	*glyphs,
 			    int			 num_glyphs,
 			    cairo_scaled_font_t	*scaled_font);
 
@@ -1917,7 +1917,7 @@ _cairo_surface_old_show_glyphs (cairo_sc
 				int			 dest_y,
 				unsigned int		 width,
 				unsigned int		 height,
-				cairo_glyph_t		*glyphs,
+				const cairo_glyph_t	*glyphs,
 				int			 num_glyphs);
 
 cairo_private cairo_status_t
diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c
index 3992b4c..41eb7c4 100644
--- a/src/test-meta-surface.c
+++ b/src/test-meta-surface.c
@@ -251,7 +251,7 @@ static cairo_int_status_t
 _test_meta_surface_show_glyphs (void			*abstract_surface,
 				cairo_operator_t	 op,
 				cairo_pattern_t		*source,
-				cairo_glyph_t		*glyphs,
+				const cairo_glyph_t	*glyphs,
 				int			 num_glyphs,
 				cairo_scaled_font_t	*scaled_font)
 {
diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c
index 1e08c2d..9f8040f 100644
--- a/src/test-paginated-surface.c
+++ b/src/test-paginated-surface.c
@@ -228,7 +228,7 @@ static cairo_int_status_t
 _test_paginated_surface_show_glyphs (void			*abstract_surface,
 				     cairo_operator_t		 op,
 				     cairo_pattern_t		*source,
-				     cairo_glyph_t		*glyphs,
+				     const cairo_glyph_t	*glyphs,
 				     int			 num_glyphs,
 				     cairo_scaled_font_t	*scaled_font)
 {


More information about the cairo-commit mailing list