summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@redhat.com>2010-02-14 19:14:44 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-02-24 23:20:28 -0500
commitac44db334066f68a837914a52d8d1368c85161ad (patch)
treed246e3b854a96e4dbf38209cd2c78f319825a6b4
parent35af45d5e3d3f893ccaa4ab2f947100eb9d840ac (diff)
Move workaround code to pixman-image.c
It is more natural to put it where all the other flags are computed.
-rw-r--r--pixman/pixman-bits-image.c54
-rw-r--r--pixman/pixman-image.c59
2 files changed, 55 insertions, 58 deletions
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 90d6ad91..3d78ff07 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -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 *
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index ef029934..e66ae882 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -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);