[Pixman] [PATCH 3/3] analyze_extents: Fast path for non-transformed BITS images

Søren Sandmann sandmann at daimi.au.dk
Thu Sep 16 06:53:41 PDT 2010


From: Søren Sandmann Pedersen <ssp at redhat.com>

Profiling various cairo traces showed that we were spending a lot of
time in analyze_extents and compute_sample_extents(). This was
especially bad for glyphs where all this computation was completely
unnecessary.

This patch adds a fast path for the case of non-transformed BITS
images. The result is approximately a 6% improvement on the
firefox-talos-gfx benchmark:

Before:

[ # ]  backend                         test   min(s) median(s) stddev. count
[  0]    image            firefox-talos-gfx   13.797   13.848   0.20%    6/6

After:

[ # ]  backend                         test   min(s) median(s) stddev. count
[  0]    image            firefox-talos-gfx   12.946   13.018   0.39%    6/6
---
 pixman/pixman.c |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/pixman/pixman.c b/pixman/pixman.c
index bf7de7d..26fe823 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -724,8 +724,21 @@ analyze_extent (pixman_image_t *image, int x, int y,
 	return FALSE;
     }
 
+    transform = image->common.transform;
     if (image->common.type == BITS)
     {
+#define ID_AND_NEAREST (FAST_PATH_ID_TRANSFORM | FAST_PATH_NEAREST_FILTER)
+	
+	if ((image->common.flags & ID_AND_NEAREST) == ID_AND_NEAREST &&
+	    extents->x1 - x >= 0 &&
+	    extents->y1 - y >= 0 &&
+	    extents->x2 - x <= image->bits.width &&
+	    extents->y2 - y <= image->bits.height)
+	{
+	    *flags |= (FAST_PATH_SAMPLES_COVER_CLIP | FAST_PATH_COVERS_CLIP);
+	    return TRUE;
+	}
+    
 	switch (image->common.filter)
 	{
 	case PIXMAN_FILTER_CONVOLUTION:
@@ -756,6 +769,17 @@ analyze_extent (pixman_image_t *image, int x, int y,
 	default:
 	    return FALSE;
 	}
+
+	/* Check whether the non-expanded, transformed extent is entirely within
+	 * the source image, and set the FAST_PATH_SAMPLES_COVER_CLIP if it is.
+	 */
+	ex = *extents;
+	if (compute_sample_extents (transform, &ex, x, y, x_off, y_off, width, height) &&
+	    ex.x1 >= 0 && ex.y1 >= 0 &&
+	    ex.x2 <= image->bits.width && ex.y2 <= image->bits.height)
+	{
+	    *flags |= (FAST_PATH_SAMPLES_COVER_CLIP | FAST_PATH_COVERS_CLIP);
+	}
     }
     else
     {
@@ -774,24 +798,9 @@ analyze_extent (pixman_image_t *image, int x, int y,
     ex.x2 = extents->x2 + 1;
     ex.y2 = extents->y2 + 1;
 
-    transform = image->common.transform;
-
     if (!compute_sample_extents (transform, &ex, x, y, x_off, y_off, width, height))
 	return FALSE;
 
-    if (image->type == BITS)
-    {
-	/* Check whether the non-expanded, transformed extent is entirely within
-	 * the source image, and set the FAST_PATH_SAMPLES_COVER_CLIP if it is.
-	 */
-	ex = *extents;
-	if (compute_sample_extents (transform, &ex, x, y, x_off, y_off, width, height))
-	{
-	    if (ex.x1 >= 0 && ex.y1 >= 0 && ex.x2 <= image->bits.width && ex.y2 <= image->bits.height)
-		*flags |= (FAST_PATH_SAMPLES_COVER_CLIP | FAST_PATH_COVERS_CLIP);
-	}
-    }
-
     return TRUE;
 }
 
-- 
1.7.1.1



More information about the Pixman mailing list