Add a dirty bit to the image struct, and validate before using the image.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Fri, 31 Jul 2009 21:27:38 +0000 (17:27 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 8 Aug 2009 20:52:38 +0000 (16:52 -0400)
This cuts down the number of property_changed calls significantly.

pixman/pixman-bits-image.c
pixman/pixman-conical-gradient.c
pixman/pixman-image.c
pixman/pixman-linear-gradient.c
pixman/pixman-private.h
pixman/pixman-radial-gradient.c
pixman/pixman-region.c
pixman/pixman-solid-fill.c
pixman/pixman-trap.c
pixman/pixman.c

index 0be2af3..9e1ee13 100644 (file)
@@ -765,8 +765,6 @@ pixman_image_create_bits (pixman_format_code_t format,
 
     image->common.property_changed = bits_image_property_changed;
 
-    bits_image_property_changed (image);
-
     _pixman_image_reset_clip_region (image);
 
     return image;
index 6a4e31e..d720db3 100644 (file)
@@ -175,8 +175,6 @@ pixman_image_create_conical_gradient (pixman_point_fixed_t *        center,
 
     image->common.property_changed = conical_gradient_property_changed;
 
-    conical_gradient_property_changed (image);
-
     return image;
 }
 
index 163d247..5831953 100644 (file)
@@ -120,6 +120,7 @@ _pixman_image_allocate (void)
        common->destroy_func = NULL;
        common->destroy_data = NULL;
        common->need_workaround = FALSE;
+       common->dirty = TRUE;
     }
 
     return image;
@@ -168,7 +169,7 @@ _pixman_image_get_scanline_64 (pixman_image_t *image,
 static void
 image_property_changed (pixman_image_t *image)
 {
-    image->common.property_changed (image);
+    image->common.dirty = TRUE;
 }
 
 /* Ref Counting */
@@ -238,6 +239,16 @@ _pixman_image_reset_clip_region (pixman_image_t *image)
     image->common.have_clip_region = FALSE;
 }
 
+void
+_pixman_image_validate (pixman_image_t *image)
+{
+    if (image->common.dirty)
+    {
+       image->common.property_changed (image);
+       image->common.dirty = FALSE;
+    }
+}
+
 PIXMAN_EXPORT pixman_bool_t
 pixman_image_set_clip_region32 (pixman_image_t *   image,
                                 pixman_region32_t *region)
index aafdd3b..d9409fe 100644 (file)
@@ -289,8 +289,6 @@ pixman_image_create_linear_gradient (pixman_point_fixed_t *        p1,
     image->common.classify = linear_gradient_classify;
     image->common.property_changed = linear_gradient_property_changed;
 
-    linear_gradient_property_changed (image);
-
     return image;
 }
 
index a4e6cbd..ff7a65f 100644 (file)
@@ -82,6 +82,7 @@ struct image_common
     pixman_bool_t               clip_sources;       /* Whether the clip applies when
                                                     * the image is used as a source
                                                     */
+    pixman_bool_t              dirty;
     pixman_bool_t               need_workaround;
     pixman_transform_t *        transform;
     pixman_repeat_t             repeat;
@@ -277,6 +278,9 @@ _pixman_init_gradient (gradient_t *                  gradient,
 void
 _pixman_image_reset_clip_region (pixman_image_t *image);
 
+void
+_pixman_image_validate (pixman_image_t *image);
+
 pixman_bool_t
 _pixman_image_is_opaque (pixman_image_t *image);
 
index 67a618d..022157b 100644 (file)
@@ -363,8 +363,6 @@ pixman_image_create_radial_gradient (pixman_point_fixed_t *        inner,
 
     image->common.property_changed = radial_gradient_property_changed;
 
-    radial_gradient_property_changed (image);
-
     return image;
 }
 
index db23be3..f88955f 100644 (file)
@@ -66,7 +66,7 @@
 #define GOOD_RECT(rect) ((rect)->x1 < (rect)->x2 && (rect)->y1 < (rect)->y2)
 #define BAD_RECT(rect) ((rect)->x1 > (rect)->x2 || (rect)->y1 > (rect)->y2)
 
-#define PIXMAN_REGION_LOG_FAILURES
+#define noPIXMAN_REGION_LOG_FAILURES
 
 #if defined PIXMAN_REGION_LOG_FAILURES || defined PIXMAN_REGION_DEBUG
 
index 67aec92..38675dc 100644 (file)
@@ -86,8 +86,6 @@ pixman_image_create_solid_fill (pixman_color_t *color)
     img->common.classify = solid_fill_classify;
     img->common.property_changed = solid_fill_property_changed;
 
-    solid_fill_property_changed (img);
-
     return img;
 }
 
index 4d7a90a..962cbb3 100644 (file)
@@ -243,6 +243,8 @@ pixman_add_traps (pixman_image_t * image,
     pixman_edge_t l, r;
     pixman_fixed_t t, b;
 
+    _pixman_image_validate (image);
+    
     width = image->bits.width;
     height = image->bits.height;
     bpp = PIXMAN_FORMAT_BPP (image->bits.format);
@@ -357,6 +359,8 @@ pixman_rasterize_trapezoid (pixman_image_t *          image,
 
     return_if_fail (image->type == BITS);
 
+    _pixman_image_validate (image);
+    
     if (!pixman_trapezoid_valid (trap))
        return;
 
index 12b4c5a..0edd967 100644 (file)
@@ -173,6 +173,11 @@ pixman_image_composite (pixman_op_t      op,
     uint32_t *dest_bits;
     int dest_dx, dest_dy;
 
+    _pixman_image_validate (src);
+    if (mask)
+       _pixman_image_validate (mask);
+    _pixman_image_validate (dest);
+    
     /*
      * Check if we can replace our operator by a simpler one
      * if the src or dest are opaque. The output operator should be
@@ -322,6 +327,8 @@ pixman_image_fill_rectangles (pixman_op_t                 op,
     pixman_color_t c;
     int i;
 
+    _pixman_image_validate (dest);
+    
     if (color->alpha == 0xffff)
     {
        if (op == PIXMAN_OP_OVER)