[cairo-commit] Branch 'surface-internals' - 2 commits - src/cairoint.h src/cairo-scaled-font.c src/cairo-surface.c src/cairo-surface-fallback.c src/cairo-surface-fallback-private.h

Carl Worth cworth at kemper.freedesktop.org
Mon Mar 6 13:08:32 PST 2006


 src/cairo-scaled-font.c              |    6 ++--
 src/cairo-surface-fallback-private.h |   28 ++++++++++----------
 src/cairo-surface-fallback.c         |   48 +++++++++++++++++++----------------
 src/cairo-surface.c                  |   33 ++++++++++++++----------
 src/cairoint.h                       |   46 ++++++++++++++++++---------------
 5 files changed, 90 insertions(+), 71 deletions(-)

New commits:
diff-tree af2cf45e8f2db7198eb28c24cfa7a463a68d5c56 (from f27cfb7142262b3f9fcb45d959476e8cd361f573)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Mar 6 12:53:54 2006 -0800

    Sprinkle const attributes down from _cairo_surface_fill_rectangles.
    
    This is needed since we will now be using const patterns such as
    CAIRO_PATTERN_TRANSPARENT with these functions. The const-correctness
    stops at the surface backend interface so that we can modify the
    backends in a separate commit. That's nice to do, since it requires
    some care, (not all backends are compiled so it's easy to miss some).
    This also lets me be more lazy for now.

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 3395f25..93ca208 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -839,7 +839,7 @@ _cairo_scaled_font_glyph_device_extents 
 cairo_status_t
 _cairo_scaled_font_show_glyphs (cairo_scaled_font_t    *scaled_font,
 				cairo_operator_t        op,
-				cairo_pattern_t        *pattern,
+				const cairo_pattern_t  *pattern,
 				cairo_surface_t        *surface,
 				int                     source_x,
 				int                     source_y,
@@ -862,9 +862,11 @@ _cairo_scaled_font_show_glyphs (cairo_sc
     if (scaled_font->status)
 	return scaled_font->status;
 
+    /* XXX: Cast away const, since I'm too lazy to push the
+     * const-correctness down into the backend interface. */
     if (scaled_font->backend->show_glyphs != NULL) {
 	status = scaled_font->backend->show_glyphs (scaled_font,
-						    op, pattern, 
+						    op, (cairo_pattern_t *) pattern,
 						    surface,
 						    source_x, source_y,
 						    dest_x, dest_y,
diff --git a/src/cairo-surface-fallback-private.h b/src/cairo-surface-fallback-private.h
index 8bd158a..ad15a9b 100644
--- a/src/cairo-surface-fallback-private.h
+++ b/src/cairo-surface-fallback-private.h
@@ -64,7 +64,7 @@ _cairo_surface_fallback_stroke (cairo_su
 cairo_private cairo_status_t
 _cairo_surface_fallback_fill (cairo_surface_t		*surface,
 			      cairo_operator_t		 op,
-			      cairo_pattern_t		*source,
+			      const cairo_pattern_t	*source,
 			      cairo_path_fixed_t	*path,
 			      cairo_fill_rule_t		 fill_rule,
 			      double		 	 tolerance,
@@ -82,18 +82,18 @@ cairo_private cairo_surface_t *
 _cairo_surface_fallback_snapshot (cairo_surface_t *surface);
 
 cairo_private cairo_status_t
-_cairo_surface_fallback_composite (cairo_operator_t	op,
-				   cairo_pattern_t	*src,
-				   cairo_pattern_t	*mask,
-				   cairo_surface_t	*dst,
-				   int			src_x,
-				   int			src_y,
-				   int			mask_x,
-				   int			mask_y,
-				   int			dst_x,
-				   int			dst_y,
-				   unsigned int		width,
-				   unsigned int		height);
+_cairo_surface_fallback_composite (cairo_operator_t		 op,
+				   const cairo_pattern_t	*src,
+				   cairo_pattern_t		*mask,
+				   cairo_surface_t		*dst,
+				   int				 src_x,
+				   int				 src_y,
+				   int				 mask_x,
+				   int				 mask_y,
+				   int				 dst_x,
+				   int				 dst_y,
+				   unsigned int			 width,
+				   unsigned int			 height);
 
 cairo_private cairo_status_t
 _cairo_surface_fallback_fill_rectangles (cairo_surface_t	*surface,
@@ -104,7 +104,7 @@ _cairo_surface_fallback_fill_rectangles 
 
 cairo_private cairo_status_t
 _cairo_surface_fallback_composite_trapezoids (cairo_operator_t		op,
-					      cairo_pattern_t	       *pattern,
+					      const cairo_pattern_t    *pattern,
 					      cairo_surface_t	       *dst,
 					      cairo_antialias_t		antialias,
 					      int			src_x,
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 54d340f..cf59598 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -100,7 +100,7 @@ _fallback_fini (fallback_state_t *state)
 
 typedef cairo_status_t (*cairo_draw_func_t) (void                    *closure,
 					     cairo_operator_t         op,
-					     cairo_pattern_t         *src,
+					     const cairo_pattern_t   *src,
 					     cairo_surface_t         *dst,
 					     int                      dst_x,
 					     int                      dst_y,
@@ -153,7 +153,7 @@ _create_composite_mask_pattern (cairo_su
 static cairo_status_t
 _clip_and_composite_with_mask (cairo_clip_t            *clip,
 			       cairo_operator_t         op,
-			       cairo_pattern_t         *src,
+			       const cairo_pattern_t   *src,
 			       cairo_draw_func_t        draw_func,
 			       void                    *draw_closure,
 			       cairo_surface_t         *dst,
@@ -187,7 +187,7 @@ _clip_and_composite_with_mask (cairo_cli
 static cairo_status_t
 _clip_and_composite_combine (cairo_clip_t            *clip,
 			     cairo_operator_t         op,
-			     cairo_pattern_t         *src,
+			     const cairo_pattern_t   *src,
 			     cairo_draw_func_t        draw_func,
 			     void                    *draw_closure,
 			     cairo_surface_t         *dst,
@@ -275,7 +275,7 @@ _clip_and_composite_combine (cairo_clip_
  */
 static cairo_status_t
 _clip_and_composite_source (cairo_clip_t            *clip,
-			    cairo_pattern_t         *src,
+			    const cairo_pattern_t   *src,
 			    cairo_draw_func_t        draw_func,
 			    void                    *draw_closure,
 			    cairo_surface_t         *dst,
@@ -349,7 +349,7 @@ _cairo_rectangle_empty (const cairo_rect
 static cairo_status_t
 _clip_and_composite (cairo_clip_t            *clip,
 		     cairo_operator_t         op,
-		     cairo_pattern_t         *src,
+		     const cairo_pattern_t   *src,
 		     cairo_draw_func_t        draw_func,
 		     void                    *draw_closure,
 		     cairo_surface_t         *dst,
@@ -403,12 +403,12 @@ _clip_and_composite (cairo_clip_t       
 /* Composites a region representing a set of trapezoids.
  */
 static cairo_status_t
-_composite_trap_region (cairo_clip_t      *clip,
-			cairo_pattern_t   *src,
-			cairo_operator_t   op,
-			cairo_surface_t   *dst,
-			pixman_region16_t *trap_region,
-			cairo_rectangle_t *extents)
+_composite_trap_region (cairo_clip_t      	*clip,
+			const cairo_pattern_t	*src,
+			cairo_operator_t	 op,
+			cairo_surface_t		*dst,
+			pixman_region16_t	*trap_region,
+			cairo_rectangle_t	*extents)
 {
     cairo_status_t status;
     cairo_pattern_union_t solid_pattern;
@@ -468,7 +468,7 @@ typedef struct {
 static cairo_status_t
 _composite_traps_draw_func (void                    *closure,
 			    cairo_operator_t         op,
-			    cairo_pattern_t         *src,
+			    const cairo_pattern_t   *src,
 			    cairo_surface_t         *dst,
 			    int                      dst_x,
 			    int                      dst_y,
@@ -499,7 +499,7 @@ _composite_traps_draw_func (void        
 
 /* Warning: This call modifies the coordinates of traps */
 static cairo_status_t
-_clip_and_composite_trapezoids (cairo_pattern_t *src,
+_clip_and_composite_trapezoids (const cairo_pattern_t *src,
 				cairo_operator_t op,
 				cairo_surface_t *dst,
 				cairo_traps_t *traps,
@@ -579,7 +579,7 @@ _clip_and_composite_trapezoids (cairo_pa
 	if ((src->type == CAIRO_PATTERN_TYPE_SOLID || op == CAIRO_OPERATOR_CLEAR) &&
 	    !clip_surface)
 	{
-	    cairo_pattern_t *solid_pattern;
+	    const cairo_pattern_t *solid_pattern;
 
 	    if (op == CAIRO_OPERATOR_CLEAR)
 		solid_pattern = CAIRO_PATTERN_TRANSPARENT;
@@ -694,7 +694,7 @@ _cairo_surface_fallback_paint (cairo_sur
 static cairo_status_t
 _cairo_surface_mask_draw_func (void                    *closure,
 			       cairo_operator_t         op,
-			       cairo_pattern_t         *src,
+			       const cairo_pattern_t   *src,
 			       cairo_surface_t         *dst,
 			       int                      dst_x,
 			       int                      dst_y,
@@ -802,7 +802,7 @@ _cairo_surface_fallback_stroke (cairo_su
 cairo_status_t
 _cairo_surface_fallback_fill (cairo_surface_t		*surface,
 			      cairo_operator_t		 op,
-			      cairo_pattern_t		*source,
+			      const cairo_pattern_t	*source,
 			      cairo_path_fixed_t	*path,
 			      cairo_fill_rule_t		 fill_rule,
 			      double			 tolerance,
@@ -843,7 +843,7 @@ typedef struct {
 static cairo_status_t
 _cairo_surface_old_show_glyphs_draw_func (void                    *closure,
 					  cairo_operator_t         op,
-					  cairo_pattern_t         *src,
+					  const cairo_pattern_t   *src,
 					  cairo_surface_t         *dst,
 					  int                      dst_x,
 					  int                      dst_y,
@@ -989,7 +989,7 @@ _cairo_surface_fallback_snapshot (cairo_
 
 cairo_status_t
 _cairo_surface_fallback_composite (cairo_operator_t	op,
-				   cairo_pattern_t	*src,
+				   const cairo_pattern_t	*src,
 				   cairo_pattern_t	*mask,
 				   cairo_surface_t	*dst,
 				   int			src_x,
@@ -1011,7 +1011,10 @@ _cairo_surface_fallback_composite (cairo
 	return status;
     }
 
-    status = state.image->base.backend->composite (op, src, mask,
+    /* XXX: Cast away const, since I'm too lazy to push the
+     * const-correctness down into the backend interface. */
+    status = state.image->base.backend->composite (op,
+						   (cairo_pattern_t *) src, mask,
 						   &state.image->base,
 						   src_x, src_y, mask_x, mask_y,
 						   dst_x - state.image_rect.x,
@@ -1100,7 +1103,7 @@ _cairo_surface_fallback_fill_rectangles 
 
 cairo_status_t
 _cairo_surface_fallback_composite_trapezoids (cairo_operator_t		op,
-					      cairo_pattern_t	       *pattern,
+					      const cairo_pattern_t    *pattern,
 					      cairo_surface_t	       *dst,
 					      cairo_antialias_t		antialias,
 					      int			src_x,
@@ -1153,7 +1156,10 @@ _cairo_surface_fallback_composite_trapez
 	traps = offset_traps;
     }
 
-    state.image->base.backend->composite_trapezoids (op, pattern,
+    /* XXX: Cast away const, since I'm too lazy to push the
+     * const-correctness down into the backend interface. */
+    state.image->base.backend->composite_trapezoids (op,
+						     (cairo_pattern_t *) pattern,
 						     &state.image->base,
 						     antialias,
 						     src_x, src_y,
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index dac95fd..ad1abd0 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -797,7 +797,7 @@ _cairo_surface_snapshot (cairo_surface_t
 
 cairo_status_t
 _cairo_surface_composite (cairo_operator_t	op,
-			  cairo_pattern_t	*src,
+			  const cairo_pattern_t	*src,
 			  cairo_pattern_t	*mask,
 			  cairo_surface_t	*dst,
 			  int			src_x,
@@ -826,9 +826,12 @@ _cairo_surface_composite (cairo_operator
     if (dst->finished)
 	return CAIRO_STATUS_SURFACE_FINISHED;
 
+    /* XXX: Cast away const, since I'm too lazy to push the
+     * const-correctness down into the backend interface. */
     if (dst->backend->composite) {
 	status = dst->backend->composite (op,
-					  src, mask, dst,
+					  (cairo_pattern_t *) src,
+					  mask, dst,
 					  src_x, src_y,
 					  mask_x, mask_y,
 					  dst_x, dst_y,
@@ -1077,13 +1080,13 @@ _cairo_surface_stroke (cairo_surface_t		
 }
 
 cairo_status_t
-_cairo_surface_fill (cairo_surface_t	*surface,
-		     cairo_operator_t	 op,
-		     cairo_pattern_t	*source,
-		     cairo_path_fixed_t	*path,
-		     cairo_fill_rule_t	 fill_rule,
-		     double		 tolerance,
-		     cairo_antialias_t	 antialias)
+_cairo_surface_fill (cairo_surface_t		*surface,
+		     cairo_operator_t		 op,
+		     const cairo_pattern_t	*source,
+		     cairo_path_fixed_t		*path,
+		     cairo_fill_rule_t		 fill_rule,
+		     double			 tolerance,
+		     cairo_antialias_t		 antialias)
 {
     cairo_status_t status;
 
@@ -1104,7 +1107,7 @@ _cairo_surface_fill (cairo_surface_t	*su
   
 cairo_status_t
 _cairo_surface_composite_trapezoids (cairo_operator_t		op,
-				     cairo_pattern_t		*pattern,
+				     const cairo_pattern_t	*pattern,
 				     cairo_surface_t		*dst,
 				     cairo_antialias_t		antialias,
 				     int			src_x,
@@ -1131,9 +1134,11 @@ _cairo_surface_composite_trapezoids (cai
     if (dst->finished)
 	return CAIRO_STATUS_SURFACE_FINISHED;
 
+    /* XXX: Cast away const, since I'm too lazy to push the
+     * const-correctness down into the backend interface. */
     if (dst->backend->composite_trapezoids) {
 	status = dst->backend->composite_trapezoids (op,
-						     pattern, dst,
+						     (cairo_pattern_t *) pattern, dst,
 						     antialias,
 						     src_x, src_y,
 						     dst_x, dst_y,
@@ -1482,7 +1487,7 @@ _cairo_surface_show_glyphs (cairo_surfac
 cairo_status_t
 _cairo_surface_old_show_glyphs (cairo_scaled_font_t	*scaled_font,
 				cairo_operator_t	 op,
-				cairo_pattern_t		*pattern,
+				const cairo_pattern_t	*pattern,
 				cairo_surface_t		*dst,
 				int			 source_x,
 				int			 source_y,
@@ -1503,9 +1508,11 @@ _cairo_surface_old_show_glyphs (cairo_sc
     if (dst->finished)
 	return CAIRO_STATUS_SURFACE_FINISHED;
 
+    /* XXX: Cast away const, since I'm too lazy to push the
+     * const-correctness down into the backend interface. */
     if (dst->backend->old_show_glyphs)
 	status = dst->backend->old_show_glyphs (scaled_font,
-						op, pattern, dst,
+						op, (cairo_pattern_t *) pattern, dst,
 						source_x, source_y,
 						dest_x, dest_y,
 						width, height,
diff --git a/src/cairoint.h b/src/cairoint.h
index bd70f7f..415a60a 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -819,7 +819,7 @@ struct _cairo_surface_backend {
     cairo_int_status_t
     (*fill)			(void			*surface,
 				 cairo_operator_t	 op,
-				 cairo_pattern_t	*source,
+				 const cairo_pattern_t	*source,
 				 cairo_path_fixed_t	*path,
 				 cairo_fill_rule_t	 fill_rule,
 				 double			 tolerance,
@@ -1537,7 +1537,7 @@ _cairo_scaled_font_glyph_device_extents 
 cairo_private cairo_status_t
 _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
 				cairo_operator_t     op,
-				cairo_pattern_t	    *source,
+				const cairo_pattern_t	    *source,
 				cairo_surface_t	    *surface,
 				int		     source_x,
 				int		     source_y,
@@ -1618,7 +1618,7 @@ _cairo_surface_get_clip_mode (cairo_surf
 
 cairo_private cairo_status_t
 _cairo_surface_composite (cairo_operator_t	op,
-			  cairo_pattern_t	*src,
+			  const cairo_pattern_t	*src,
 			  cairo_pattern_t	*mask,
 			  cairo_surface_t	*dst,
 			  int			src_x,
@@ -1631,24 +1631,24 @@ _cairo_surface_composite (cairo_operator
 			  unsigned int		height);
 
 cairo_private cairo_status_t
-_cairo_surface_fill_rectangle (cairo_surface_t	   *surface,
-			       cairo_operator_t	    op,
-			       const cairo_color_t *color,
-			       int		    x,
-			       int		    y,
-			       int		    width,
-			       int		    height);
+_cairo_surface_fill_rectangle (cairo_surface_t		*surface,
+			       cairo_operator_t		 op,
+			       const cairo_pattern_t	*source,
+			       int			 x,
+			       int			 y,
+			       int			 width,
+			       int			 height);
 
 cairo_private cairo_status_t
 _cairo_surface_fill_region (cairo_surface_t	   *surface,
 			    cairo_operator_t	    op,
-			    const cairo_color_t    *color,
+			    const cairo_pattern_t  *source,
 			    pixman_region16_t      *region);
 
 cairo_private cairo_status_t
 _cairo_surface_fill_rectangles (cairo_surface_t		*surface,
 				cairo_operator_t	op,
-				const cairo_color_t	*color,
+				const cairo_pattern_t	*source,
 				cairo_rectangle_t	*rects,
 				int			num_rects);
 
@@ -1675,13 +1675,13 @@ _cairo_surface_stroke (cairo_surface_t		
 		       cairo_antialias_t	 antialias);
 
 cairo_private cairo_status_t
-_cairo_surface_fill (cairo_surface_t	*surface,
-		     cairo_operator_t	 op,
-		     cairo_pattern_t	*source,
-		     cairo_path_fixed_t	*path,
-		     cairo_fill_rule_t	 fill_rule,
-		     double		 tolerance,
-		     cairo_antialias_t	 antialias);
+_cairo_surface_fill (cairo_surface_t		*surface,
+		     cairo_operator_t		 op,
+		     const cairo_pattern_t	*source,
+		     cairo_path_fixed_t		*path,
+		     cairo_fill_rule_t		 fill_rule,
+		     double			 tolerance,
+		     cairo_antialias_t		 antialias);
 
 cairo_private cairo_status_t
 _cairo_surface_show_glyphs (cairo_surface_t	*surface,
@@ -1693,7 +1693,7 @@ _cairo_surface_show_glyphs (cairo_surfac
   
 cairo_private cairo_status_t
 _cairo_surface_composite_trapezoids (cairo_operator_t	op,
-				     cairo_pattern_t	*pattern,
+				     const cairo_pattern_t	*pattern,
 				     cairo_surface_t	*dst,
 				     cairo_antialias_t	antialias,
 				     int		src_x,
@@ -1774,7 +1774,7 @@ _cairo_surface_get_extents (cairo_surfac
 cairo_private cairo_status_t
 _cairo_surface_old_show_glyphs (cairo_scaled_font_t	*scaled_font,
 				cairo_operator_t	 op,
-				cairo_pattern_t		*pattern,
+				const cairo_pattern_t	*pattern,
 				cairo_surface_t		*surface,
 				int			 source_x,
 				int			 source_y,
@@ -2055,6 +2055,9 @@ _cairo_pattern_fini (cairo_pattern_t *pa
 cairo_private cairo_pattern_t *
 _cairo_pattern_create_solid (const cairo_color_t *color);
 
+cairo_private const cairo_color_t *
+_cairo_solid_pattern_get_color (cairo_solid_pattern_t *pattern);
+
 cairo_private void
 _cairo_pattern_transform (cairo_pattern_t      *pattern,
 			  const cairo_matrix_t *ctm_inverse);
diff-tree f27cfb7142262b3f9fcb45d959476e8cd361f573 (from d3915c4fa9e482c2ad9db70d1413ab36c4a3a66d)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Mar 6 12:44:37 2006 -0800

    cairoint.h: Add missing slim_hidden_proto for cairo_pattern_get_type

diff --git a/src/cairoint.h b/src/cairoint.h
index a4b772c..bd70f7f 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2186,6 +2186,7 @@ slim_hidden_proto(cairo_matrix_transform
 slim_hidden_proto(cairo_matrix_transform_point)
 slim_hidden_proto(cairo_move_to)
 slim_hidden_proto(cairo_new_path)
+slim_hidden_proto(cairo_pattern_get_type)
 slim_hidden_proto(cairo_rel_line_to)
 slim_hidden_proto(cairo_restore)
 slim_hidden_proto(cairo_save)


More information about the cairo-commit mailing list