Move computation of extended format code to validate.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Fri, 18 Sep 2009 08:06:30 +0000 (04:06 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Thu, 25 Feb 2010 04:20:27 +0000 (23:20 -0500)
Instead of computing the extended format on every composite, just
compute it once and store it in the image.

pixman/pixman-image.c
pixman/pixman-private.h
pixman/pixman.c

index 880c49f..89a5a09 100644 (file)
@@ -244,8 +244,9 @@ _pixman_image_reset_clip_region (pixman_image_t *image)
 }
 
 static void
-compute_flags (pixman_image_t *image)
+compute_image_info (pixman_image_t *image)
 {
+    pixman_format_code_t code;
     uint32_t flags = 0;
 
     if (!image->common.transform)
@@ -294,7 +295,27 @@ compute_flags (pixman_image_t *image)
     else
        flags |= FAST_PATH_UNIFIED_ALPHA;
 
+    if (_pixman_image_is_solid (image))
+    {
+       code = PIXMAN_solid;
+    }
+    else if (image->common.type == BITS)
+    {
+       code = image->bits.format;
+
+       if (!image->common.transform &&
+           image->common.repeat == PIXMAN_REPEAT_NORMAL)
+       {
+           flags |= FAST_PATH_SIMPLE_REPEAT;
+       }
+    }
+    else
+    {
+       code = PIXMAN_unknown;
+    }
+
     image->common.flags = flags;
+    image->common.extended_format_code = code;
 }
 
 void
@@ -304,7 +325,7 @@ _pixman_image_validate (pixman_image_t *image)
     {
        image->common.property_changed (image);
 
-       compute_flags (image);
+       compute_image_info (image);
 
        image->common.dirty = FALSE;
     }
index f4f0397..edee738 100644 (file)
@@ -105,6 +105,7 @@ struct image_common
     void *                      destroy_data;
 
     uint32_t                   flags;
+    pixman_format_code_t       extended_format_code;
 };
 
 struct source_image
index 09fc7e1..e1bef17 100644 (file)
@@ -448,30 +448,6 @@ walk_region_internal (pixman_implementation_t *imp,
     }
 }
 
-static void
-get_image_info (pixman_image_t       *image,
-               pixman_format_code_t *code,
-               uint32_t             *flags)
-{
-    *flags = image->common.flags;
-
-    if (_pixman_image_is_solid (image))
-    {
-       *code = PIXMAN_solid;
-    }
-    else if (image->common.type == BITS)
-    {
-       *code = image->bits.format;
-
-       if (!image->common.transform && image->common.repeat == PIXMAN_REPEAT_NORMAL)
-           *flags |= FAST_PATH_SIMPLE_REPEAT;
-    }
-    else
-    {
-       *code = PIXMAN_unknown;
-    }
-}
-
 static force_inline pixman_bool_t
 image_covers (pixman_image_t *image,
               pixman_box32_t *extents,
@@ -512,18 +488,23 @@ do_composite (pixman_implementation_t *imp,
     pixman_region32_t region;
     pixman_box32_t *extents;
 
-    get_image_info (src,  &src_format,  &src_flags);
+    src_format = src->common.extended_format_code;
+    src_flags = src->common.flags;
+
     if (mask)
     {
-       get_image_info (mask, &mask_format, &mask_flags);
+       mask_format = mask->common.extended_format_code;
+       mask_flags = mask->common.flags;
     }
     else
     {
        mask_format = PIXMAN_null;
        mask_flags = 0;
     }
-    get_image_info (dest, &dest_format, &dest_flags);
-    
+
+    dest_format = dest->common.extended_format_code;
+    dest_flags = dest->common.flags;
+
     /* Check for pixbufs */
     if ((mask_format == PIXMAN_a8r8g8b8 || mask_format == PIXMAN_a8b8g8r8) &&
        (src->type == BITS && src->bits.bits == mask->bits.bits)           &&