Move workaround code to pixman-image.c
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 15 Feb 2010 00:14:44 +0000 (19:14 -0500)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Thu, 25 Feb 2010 04:20:28 +0000 (23:20 -0500)
It is more natural to put it where all the other flags are computed.

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

index 90d6ad9..3d78ff0 100644 (file)
@@ -875,55 +875,6 @@ bits_image_fetch_untransformed_64 (pixman_image_t * image,
     }
 }
 
-static pixman_bool_t out_of_bounds_workaround = TRUE;
-
-/* Old X servers rely on out-of-bounds accesses when they are asked
- * to composite with a window as the source. They create a pixman image
- * pointing to some bogus position in memory, but then they set a clip
- * region to the position where the actual bits are.
- *
- * Due to a bug in old versions of pixman, where it would not clip
- * against the image bounds when a clip region was set, this would
- * actually work. So by default we allow certain out-of-bound access
- * to happen unless explicitly disabled.
- *
- * Fixed X servers should call this function to disable the workaround.
- */
-PIXMAN_EXPORT void
-pixman_disable_out_of_bounds_workaround (void)
-{
-    out_of_bounds_workaround = FALSE;
-}
-
-static pixman_bool_t
-source_image_needs_out_of_bounds_workaround (bits_image_t *image)
-{
-    if (image->common.clip_sources                      &&
-        image->common.repeat == PIXMAN_REPEAT_NONE      &&
-       image->common.have_clip_region                  &&
-        out_of_bounds_workaround)
-    {
-       if (!image->common.client_clip)
-       {
-           /* There is no client clip, so if the clip region extends beyond the
-            * drawable geometry, it must be because the X server generated the
-            * bogus clip region.
-            */
-           const pixman_box32_t *extents = pixman_region32_extents (&image->common.clip_region);
-
-           if (extents->x1 >= 0 && extents->x2 <= image->width &&
-               extents->y1 >= 0 && extents->y2 <= image->height)
-           {
-               return FALSE;
-           }
-       }
-
-       return TRUE;
-    }
-
-    return FALSE;
-}
-
 static void
 bits_image_property_changed (pixman_image_t *image)
 {
@@ -985,11 +936,6 @@ bits_image_property_changed (pixman_image_t *image)
 
     bits->store_scanline_64 = bits_image_store_scanline_64;
     bits->store_scanline_32 = bits_image_store_scanline_32;
-
-    if (source_image_needs_out_of_bounds_workaround (bits))
-       bits->common.flags |= FAST_PATH_NEEDS_WORKAROUND;
-    else
-       bits->common.flags &= ~FAST_PATH_NEEDS_WORKAROUND;
 }
 
 static uint32_t *
index ef02993..e66ae88 100644 (file)
@@ -242,6 +242,55 @@ _pixman_image_reset_clip_region (pixman_image_t *image)
     image->common.have_clip_region = FALSE;
 }
 
+static pixman_bool_t out_of_bounds_workaround = TRUE;
+
+/* Old X servers rely on out-of-bounds accesses when they are asked
+ * to composite with a window as the source. They create a pixman image
+ * pointing to some bogus position in memory, but then they set a clip
+ * region to the position where the actual bits are.
+ *
+ * Due to a bug in old versions of pixman, where it would not clip
+ * against the image bounds when a clip region was set, this would
+ * actually work. So by default we allow certain out-of-bound access
+ * to happen unless explicitly disabled.
+ *
+ * Fixed X servers should call this function to disable the workaround.
+ */
+PIXMAN_EXPORT void
+pixman_disable_out_of_bounds_workaround (void)
+{
+    out_of_bounds_workaround = FALSE;
+}
+
+static pixman_bool_t
+source_image_needs_out_of_bounds_workaround (bits_image_t *image)
+{
+    if (image->common.clip_sources                      &&
+        image->common.repeat == PIXMAN_REPEAT_NONE      &&
+       image->common.have_clip_region                  &&
+        out_of_bounds_workaround)
+    {
+       if (!image->common.client_clip)
+       {
+           /* There is no client clip, so if the clip region extends beyond the
+            * drawable geometry, it must be because the X server generated the
+            * bogus clip region.
+            */
+           const pixman_box32_t *extents = pixman_region32_extents (&image->common.clip_region);
+
+           if (extents->x1 >= 0 && extents->x2 <= image->width &&
+               extents->y1 >= 0 && extents->y2 <= image->height)
+           {
+               return FALSE;
+           }
+       }
+
+       return TRUE;
+    }
+
+    return FALSE;
+}
+
 static void
 compute_image_info (pixman_image_t *image)
 {
@@ -325,6 +374,9 @@ compute_image_info (pixman_image_t *image)
        {
            flags |= FAST_PATH_IS_OPAQUE;
        }
+
+       if (source_image_needs_out_of_bounds_workaround (&image->bits))
+           flags |= FAST_PATH_NEEDS_WORKAROUND;
     }
     else
     {
@@ -374,11 +426,10 @@ _pixman_image_validate (pixman_image_t *image)
     {
        compute_image_info (image);
 
-       /* It is important that property_changed is 
+       /* It is important that property_changed is
         * called *after* compute_image_info() because
-        * the NEEDS_WORKAROUND flag is computed in
-        * property_changed(). And compute_image_info()
-        * completely overwrites the flags field
+        * property_changed() can make use of the flags
+        * to set up accessors etc.
         */
        image->common.property_changed (image);