[cairo-commit] cairo/src cairo_gstate.c, 1.77, 1.78 cairo_pattern.c, 1.15, 1.16 cairo_png_surface.c, 1.12, 1.13 cairoint.h, 1.90, 1.91

Kristian Hogsberg commit at pdx.freedesktop.org
Fri Jan 28 12:27:25 PST 2005


Committed by: krh

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

Modified Files:
	cairo_gstate.c cairo_pattern.c cairo_png_surface.c cairoint.h 
Log Message:
2005-01-28  Kristian Høgsberg  <krh at redhat.com>

        * src/cairo_png_surface.c (_cairo_png_surface_composite): Update
        prototype to eliminate warning.

        * src/cairo_pattern.c (_cairo_pattern_init_copy): Remember to
        reference surfaces when copying patterns.

        * src/cairo_gstate.c: (_cairo_rectangle_intersect),
        (_cairo_gstate_clip_and_composite_trapezoids),
        (_cairo_gstate_clip), (_cairo_gstate_show_glyphs): Don't call
        _gstate_create_pattern for internally created patterns.
        (_cairo_gstate_show_surface): Don't change the surface matrix
        here, it's done later when we set it up as a pattern.

        * test/Makefile.am: Correct clip_twice-ref.png filename.

        * src/cairoint.h (MIN, MAX): Add these.

        * src/cairo_gstate.c (_cairo_rectangle_intersect): Fix broken
        intersection code.



Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cairo_gstate.c	28 Jan 2005 01:21:13 -0000	1.77
+++ cairo_gstate.c	28 Jan 2005 20:27:23 -0000	1.78
@@ -1413,27 +1413,20 @@
 static void
 _cairo_rectangle_intersect (cairo_rectangle_t *dest, cairo_rectangle_t *src)
 {
-    if (dest->x < src->x)
-	dest->x = src->x;
-
-    if (dest->y < src->y)
-	dest->y = src->y;
-
-    if (dest->x + dest->width < src->x + src->width)
-	dest->width = dest->x + dest->width - dest->x;
-    else
-	dest->width = src->x + src->width - dest->x;
+    cairo_rectangle_t out;
 
-    if (dest->y + dest->height < src->y + src->height)
-	dest->height = dest->y + dest->height - dest->y;
-    else
-	dest->height = src->y + src->height - dest->y;
+    out.x = MAX (dest->x, src->x);
+    out.y = MAX (dest->y, src->y);
+    out.width = MIN (dest->x + dest->width, src->x + src->width) - out.x;
+    out.height = MIN (dest->y + dest->height, src->y + src->height) - out.y;
 
-    if (dest->width <= 0 || dest->height == 0) {
+    if (out.width <= 0 || out.height <= 0) {
 	dest->x = 0;
 	dest->y = 0;
 	dest->width = 0;
 	dest->height = 0;
+    } else {
+	*dest = out;
     }	
 }
 
@@ -1521,9 +1514,6 @@
 	}
 	
 	_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
-	_cairo_gstate_create_pattern (gstate, &pattern);
-	/* Override the alpha set from gstate. */
-	_cairo_pattern_set_alpha (&pattern, 1.0);
 
 	status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_ADD,
 						      &pattern, intermediate,
@@ -1540,8 +1530,6 @@
 
 
 	_cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
-	_cairo_gstate_create_pattern (gstate, &pattern);
-	_cairo_pattern_set_alpha (&pattern, 1.0);
 
 	status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
 					   &pattern,
@@ -1887,8 +1875,6 @@
 
     translate_traps (&traps, -gstate->clip.rect.x, -gstate->clip.rect.y);
     _cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
-    _cairo_gstate_create_pattern (gstate, &pattern);
-    _cairo_pattern_set_alpha (&pattern, 1.0);
     
     status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
 						  &pattern,
@@ -1982,19 +1968,14 @@
      */
 
     cairo_status_t status;
-    cairo_matrix_t user_to_image, image_to_user;
-    cairo_matrix_t image_to_device, device_to_image;
+    cairo_matrix_t image_to_user, image_to_device;
     double device_x, device_y;
     double device_width, device_height;
     cairo_pattern_t pattern;
     cairo_box_t pattern_extents;
     cairo_rectangle_t extents;
         
-    cairo_surface_get_matrix (surface, &user_to_image);
-    cairo_matrix_multiply (&device_to_image, &gstate->ctm_inverse, &user_to_image);
-    cairo_surface_set_matrix (surface, &device_to_image);
-
-    image_to_user = user_to_image;
+    cairo_surface_get_matrix (surface, &image_to_user);
     cairo_matrix_invert (&image_to_user);
     cairo_matrix_multiply (&image_to_device, &image_to_user, &gstate->ctm);
 
@@ -2058,13 +2039,7 @@
 
     _cairo_pattern_fini (&pattern);
     
-    /* restore the matrix originally in the surface */
-    cairo_surface_set_matrix (surface, &user_to_image);
-    
-    if (status)
-	return status;    
-
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 static void
@@ -2455,8 +2430,6 @@
 	}
 
 	_cairo_pattern_init_solid (&pattern, 1.0, 1.0, 1.0);
-	_cairo_gstate_create_pattern (gstate, &pattern);
-	_cairo_pattern_set_alpha (&pattern, 1.0);
     
 	status = _cairo_font_show_glyphs (gstate->font, 
 					  CAIRO_OPERATOR_ADD, 
@@ -2472,8 +2445,6 @@
 	    goto BAIL2;
 
 	_cairo_pattern_init_for_surface (&pattern, gstate->clip.surface);
-	_cairo_gstate_create_pattern (gstate, &pattern);
-	_cairo_pattern_set_alpha (&pattern, 1.0);
     
 	status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
 					   &pattern,

Index: cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pattern.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- cairo_pattern.c	28 Jan 2005 05:14:06 -0000	1.15
+++ cairo_pattern.c	28 Jan 2005 20:27:23 -0000	1.16
@@ -64,6 +64,9 @@
 		sizeof (cairo_color_stop_t) * other->n_stops);
     }
 
+    if (pattern->type == CAIRO_PATTERN_SURFACE)
+	cairo_surface_reference (pattern->u.surface.surface);
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -820,6 +823,7 @@
 	    cairo_surface_set_filter (surface, cairo_surface_get_filter(src));
 	    _cairo_surface_set_image (surface, image);
 	    cairo_surface_set_matrix (surface, &(image->base.matrix));
+	    cairo_surface_set_repeat (surface, image->base.repeat);
 	    cairo_surface_destroy (&image->base);
 
 	    return surface;

Index: cairo_png_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_png_surface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo_png_surface.c	27 Jan 2005 18:46:20 -0000	1.12
+++ cairo_png_surface.c	28 Jan 2005 20:27:23 -0000	1.13
@@ -239,7 +239,7 @@
 
 static cairo_int_status_t
 _cairo_png_surface_composite (cairo_operator_t	operator,
-			      cairo_surface_t	*generic_src,
+			      cairo_pattern_t	*pattern,
 			      cairo_surface_t	*generic_mask,
 			      void		*abstract_dst,
 			      int		src_x,

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- cairoint.h	28 Jan 2005 05:14:06 -0000	1.90
+++ cairoint.h	28 Jan 2005 20:27:23 -0000	1.91
@@ -108,6 +108,9 @@
 #define __attribute__(x)
 #endif
 
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
 #include "cairo-wideint.h"
 
 typedef int32_t		cairo_fixed_16_16_t;




More information about the cairo-commit mailing list