Move some of the FAST_PATH_COVERS_CLIP computation to pixman-image.c
authorSøren Sandmann Pedersen <ssp@redhat.com>
Thu, 16 Sep 2010 12:35:05 +0000 (08:35 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Tue, 21 Sep 2010 12:31:09 +0000 (08:31 -0400)
When an image is solid or repeating, the FAST_PATH_COVERS_CLIP flag
can be set in compute_image_info().

Also the code that turned this flag off in pixman.c was not correct;
it didn't take transformations into account. With this patch, pixman.c
doesn't set the flag by default, but instead relies on the call to
compute_samples_extents() to set it when possible.

pixman/pixman-image.c
pixman/pixman.c

index 029a1df..8397f6a 100644 (file)
@@ -353,19 +353,34 @@ compute_image_info (pixman_image_t *image)
     switch (image->common.repeat)
     {
     case PIXMAN_REPEAT_NONE:
-       flags |= FAST_PATH_NO_REFLECT_REPEAT | FAST_PATH_NO_PAD_REPEAT | FAST_PATH_NO_NORMAL_REPEAT;
+       flags |=
+           FAST_PATH_NO_REFLECT_REPEAT         |
+           FAST_PATH_NO_PAD_REPEAT             |
+           FAST_PATH_NO_NORMAL_REPEAT;
        break;
 
     case PIXMAN_REPEAT_REFLECT:
-       flags |= FAST_PATH_NO_PAD_REPEAT | FAST_PATH_NO_NONE_REPEAT | FAST_PATH_NO_NORMAL_REPEAT;
+       flags |=
+           FAST_PATH_NO_PAD_REPEAT             |
+           FAST_PATH_NO_NONE_REPEAT            |
+           FAST_PATH_NO_NORMAL_REPEAT          |
+           FAST_PATH_COVERS_CLIP;
        break;
 
     case PIXMAN_REPEAT_PAD:
-       flags |= FAST_PATH_NO_REFLECT_REPEAT | FAST_PATH_NO_NONE_REPEAT | FAST_PATH_NO_NORMAL_REPEAT;
+       flags |=
+           FAST_PATH_NO_REFLECT_REPEAT         |
+           FAST_PATH_NO_NONE_REPEAT            |
+           FAST_PATH_NO_NORMAL_REPEAT          |
+           FAST_PATH_COVERS_CLIP;
        break;
 
     default:
-       flags |= FAST_PATH_NO_REFLECT_REPEAT | FAST_PATH_NO_PAD_REPEAT | FAST_PATH_NO_NONE_REPEAT;
+       flags |=
+           FAST_PATH_NO_REFLECT_REPEAT         |
+           FAST_PATH_NO_PAD_REPEAT             |
+           FAST_PATH_NO_NONE_REPEAT            |
+           FAST_PATH_COVERS_CLIP;
        break;
     }
 
@@ -385,6 +400,8 @@ compute_image_info (pixman_image_t *image)
 
        if (image->solid.color.alpha == 0xffff)
            flags |= FAST_PATH_IS_OPAQUE;
+
+       flags |= FAST_PATH_COVERS_CLIP;
        break;
 
     case BITS:
index 285bbfc..72779c8 100644 (file)
@@ -708,29 +708,9 @@ analyze_extent (pixman_image_t *image, int x, int y,
     pixman_fixed_t width, height;
     pixman_box32_t ex;
 
-    *flags |= FAST_PATH_COVERS_CLIP;
     if (!image)
        return TRUE;
 
-    transform = image->common.transform;
-    if (image->common.type == BITS)
-    {
-       /* During repeat mode calculations we might convert the
-        * width/height of an image to fixed 16.16, so we need
-        * them to be smaller than 16 bits.
-        */
-       if (image->bits.width >= 0x7fff || image->bits.height >= 0x7fff)
-           return FALSE;
-
-       if (image->common.repeat == PIXMAN_REPEAT_NONE &&
-           (x > extents->x1 || y > extents->y1 ||
-            x + image->bits.width < extents->x2 ||
-            y + image->bits.height < extents->y2))
-       {
-           (*flags) &= ~FAST_PATH_COVERS_CLIP;
-       }
-    }
-
     /* Some compositing functions walk one step
      * outside the destination rectangle, so we
      * check here that the expanded-by-one source
@@ -746,6 +726,13 @@ analyze_extent (pixman_image_t *image, int x, int y,
 
     if (image->common.type == BITS)
     {
+       /* During repeat mode calculations we might convert the
+        * width/height of an image to fixed 16.16, so we need
+        * them to be smaller than 16 bits.
+        */
+       if (image->bits.width >= 0x7fff || image->bits.height >= 0x7fff)
+           return FALSE;
+
        switch (image->common.filter)
        {
        case PIXMAN_FILTER_CONVOLUTION:
@@ -786,14 +773,16 @@ analyze_extent (pixman_image_t *image, int x, int y,
     }
 
     /* Check that the extents expanded by one don't overflow. This ensures that
-     * compositing functions can simply walk the source space using 16.16 variables
-     * without worrying about overflow.
+     * compositing functions can simply walk the source space using 16.16
+     * variables without worrying about overflow.
      */
     ex.x1 = extents->x1 - 1;
     ex.y1 = extents->y1 - 1;
     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;
 
@@ -806,7 +795,7 @@ analyze_extent (pixman_image_t *image, int x, int y,
        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;
+               *flags |= (FAST_PATH_SAMPLES_COVER_CLIP | FAST_PATH_COVERS_CLIP);
        }
     }