[cairo-commit] cairo/src cairo-gstate.c, 1.174, 1.175 cairo-surface.c, 1.104, 1.105 cairoint.h, 1.217, 1.218

Carl Worth commit at pdx.freedesktop.org
Thu Oct 27 17:16:49 PDT 2005


Committed by: cworth

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

Modified Files:
	cairo-gstate.c cairo-surface.c cairoint.h 
Log Message:

2005-10-27  Carl Worth  <cworth at cworth.org>

        * src/cairo-gstate.c: (_cairo_gstate_paint):
        Fix leak of pattern (missing _cairo_pattern_fini).

        * src/cairoint.h:
        * src/cairo-gstate.c: (_cairo_gstate_paint),
        (_cairo_gstate_clip_and_composite), (_cairo_gstate_mask):
        * src/cairo-pattern.c:
        * src/cairo-surface.c: (_cairo_surface_mask_draw_func),
        (_fallback_mask), (_cairo_surface_mask):
        Move mask fallback from gstate to surface where it belongs.

        * src/cairoint.h: Temporarily export some previously private
        cairo_gstate functions, (soon to become private cairo_fallback
        functions).


Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- cairo-gstate.c	27 Oct 2005 22:06:53 -0000	1.174
+++ cairo-gstate.c	28 Oct 2005 00:16:47 -0000	1.175
@@ -744,6 +744,8 @@
 				   &pattern.base,
 				   gstate->target);
 
+    _cairo_pattern_fini (&pattern.base);
+
     return status;
 }
 
@@ -786,14 +788,6 @@
     return FALSE;
 }
 
-typedef cairo_status_t (*cairo_draw_func_t) (void                    *closure,
-					     cairo_operator_t         operator,
-					     cairo_pattern_t         *src,
-					     cairo_surface_t         *dst,
-					     int                      dst_x,
-					     int                      dst_y,
-					     const cairo_rectangle_t *extents);
-
 static cairo_status_t
 _create_composite_mask_pattern (cairo_surface_pattern_t *mask_pattern,
 				cairo_clip_t            *clip,
@@ -1034,7 +1028,7 @@
  * 
  * Return value: %CAIRO_STATUS_SUCCESS if the drawing succeeded.
  **/
-static cairo_status_t
+cairo_status_t
 _cairo_gstate_clip_and_composite (cairo_clip_t            *clip,
 				  cairo_operator_t         operator,
 				  cairo_pattern_t         *src,
@@ -1087,62 +1081,13 @@
 
     return status;
 }
-			       
-
-static cairo_status_t
-_get_mask_extents (cairo_gstate_t    *gstate,
-		   cairo_pattern_t   *mask,
-		   cairo_rectangle_t *extents)
-{
-    cairo_status_t status;
-
-    /*
-     * XXX should take mask extents into account, but
-     * that involves checking the transform and
-     * _cairo_operator_bounded (operator)...  For now,
-     * be lazy and just use the destination extents
-     */
-    status = _cairo_surface_get_extents (gstate->target, extents);
-    if (status)
-	return status;
-
-    return _cairo_clip_intersect_to_rectangle (&gstate->clip, extents);
-}
-
-static cairo_status_t
-_cairo_gstate_mask_draw_func (void                    *closure,
-			      cairo_operator_t         operator,
-			      cairo_pattern_t         *src,
-			      cairo_surface_t         *dst,
-			      int                      dst_x,
-			      int                      dst_y,
-			      const cairo_rectangle_t *extents)
-{
-    cairo_pattern_t *mask = closure;
-
-    if (src)
-	return _cairo_surface_composite (operator,
-					 src, mask, dst,
-					 extents->x,         extents->y,
-					 extents->x,         extents->y,
-					 extents->x - dst_x, extents->y - dst_y,
-					 extents->width,     extents->height);
-    else
-	return _cairo_surface_composite (operator,
-					 mask, NULL, dst,
-					 extents->x,         extents->y,
-					 0,                  0, /* unused */
-					 extents->x - dst_x, extents->y - dst_y,
-					 extents->width,     extents->height);
-}
 
 cairo_status_t
 _cairo_gstate_mask (cairo_gstate_t  *gstate,
 		    cairo_pattern_t *mask)
 {
-    cairo_rectangle_t extents;
-    cairo_pattern_union_t source_pattern, mask_pattern;
     cairo_status_t status;
+    cairo_pattern_union_t source_pattern, mask_pattern;
 
     if (mask->status)
 	return mask->status;
@@ -1156,14 +1101,11 @@
 
     _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
     _cairo_gstate_copy_transformed_mask (gstate, &mask_pattern.base, mask);
-    
-    _get_mask_extents (gstate, &mask_pattern.base, &extents);
-    
-    status = _cairo_gstate_clip_and_composite (&gstate->clip, gstate->operator,
-					       &source_pattern.base, 
-					       _cairo_gstate_mask_draw_func, &mask_pattern.base,
-					       gstate->target,
-					       &extents);
+
+    status = _cairo_surface_mask (gstate->operator,
+				  &source_pattern.base,
+				  &mask_pattern.base,
+				  gstate->target);
 
     _cairo_pattern_fini (&source_pattern.base);
     _cairo_pattern_fini (&mask_pattern.base);

Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- cairo-surface.c	27 Oct 2005 22:06:53 -0000	1.104
+++ cairo-surface.c	28 Oct 2005 00:16:47 -0000	1.105
@@ -1202,6 +1202,87 @@
     return _fallback_paint (operator, pattern, dst);
 }
 
+static cairo_status_t
+_cairo_surface_mask_draw_func (void                    *closure,
+			       cairo_operator_t         operator,
+			       cairo_pattern_t         *src,
+			       cairo_surface_t         *dst,
+			       int                      dst_x,
+			       int                      dst_y,
+			       const cairo_rectangle_t *extents)
+{
+    cairo_pattern_t *mask = closure;
+
+    if (src)
+	return _cairo_surface_composite (operator,
+					 src, mask, dst,
+					 extents->x,         extents->y,
+					 extents->x,         extents->y,
+					 extents->x - dst_x, extents->y - dst_y,
+					 extents->width,     extents->height);
+    else
+	return _cairo_surface_composite (operator,
+					 mask, NULL, dst,
+					 extents->x,         extents->y,
+					 0,                  0, /* unused */
+					 extents->x - dst_x, extents->y - dst_y,
+					 extents->width,     extents->height);
+}
+
+static cairo_status_t
+_fallback_mask (cairo_operator_t	 operator,
+		cairo_pattern_t		*source_pattern,
+		cairo_pattern_t		*mask_pattern,
+		cairo_surface_t		*dst)
+{
+    cairo_status_t status;
+    cairo_rectangle_t extents;
+
+    status = _cairo_surface_get_extents (dst, &extents);
+    if (status)
+	return status;
+
+    /*
+     * XXX should take mask extents into account, but
+     * that involves checking the transform and
+     * _cairo_operator_bounded (operator)...  For now,
+     * be lazy and just use the destination extents
+     */
+
+    status = _cairo_clip_intersect_to_rectangle (dst->clip, &extents);
+    if (status)
+	return status;
+
+    status = _cairo_gstate_clip_and_composite (dst->clip, operator,
+					       source_pattern,
+					       _cairo_surface_mask_draw_func,
+					       mask_pattern,
+					       dst,
+					       &extents);
+
+    return status;
+}
+
+cairo_status_t
+_cairo_surface_mask (cairo_operator_t	 operator,
+		     cairo_pattern_t	*source_pattern,
+		     cairo_pattern_t	*mask_pattern,
+		     cairo_surface_t	*dst)
+{
+    /* cairo_status_t status; */
+
+    assert (! dst->is_snapshot);
+
+    /* XXX: Need to add this to the backend.
+    if (dst->backend->mask) {
+	status = dst->backend->mask (operator, pattern, dst);
+	if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	    return status;
+    }
+    */
+
+    return _fallback_mask (operator, source_pattern, mask_pattern, dst);
+}
 
 static cairo_status_t
 _fallback_fill_path (cairo_operator_t	 operator,

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -d -r1.217 -r1.218
--- cairoint.h	27 Oct 2005 22:06:53 -0000	1.217
+++ cairoint.h	28 Oct 2005 00:16:47 -0000	1.218
@@ -1225,6 +1225,23 @@
 			  int		      num_glyphs,
 			  cairo_path_fixed_t *path);
 
+typedef cairo_status_t (*cairo_draw_func_t) (void                    *closure,
+					     cairo_operator_t         operator,
+					     cairo_pattern_t         *src,
+					     cairo_surface_t         *dst,
+					     int                      dst_x,
+					     int                      dst_y,
+					     const cairo_rectangle_t *extents);
+
+cairo_private cairo_status_t
+_cairo_gstate_clip_and_composite (cairo_clip_t            *clip,
+				  cairo_operator_t         operator,
+				  cairo_pattern_t         *src,
+				  cairo_draw_func_t        draw_func,
+				  void                    *draw_closure,
+				  cairo_surface_t         *dst,
+				  const cairo_rectangle_t *extents);
+
 cairo_private cairo_bool_t
 _cairo_operator_bounded (cairo_operator_t operator);
 
@@ -1550,12 +1567,18 @@
 				cairo_rectangle_t	*rects,
 				int			num_rects);
 
-cairo_status_t
+cairo_private cairo_status_t
 _cairo_surface_paint (cairo_operator_t	 operator,
 		      cairo_pattern_t	*pattern,
 		      cairo_surface_t	*dst);
 
 cairo_private cairo_status_t
+_cairo_surface_mask (cairo_operator_t	 operator,
+		     cairo_pattern_t	*source_pattern,
+		     cairo_pattern_t	*mask_pattern,
+		     cairo_surface_t	*dst);
+
+cairo_private cairo_status_t
 _cairo_surface_fill_path (cairo_operator_t	operator,
 			  cairo_pattern_t      *pattern,
 			  cairo_surface_t      *dst,



More information about the cairo-commit mailing list