[Pixman] [PATCH 2/2] Delete simple repeat code
Søren Sandmann
sandmann at daimi.au.dk
Wed Sep 29 05:40:33 PDT 2010
From: Søren Sandmann Pedersen <ssp at redhat.com>
This was supposedly an optimization, but it has pathological cases
where it definitely isn't. For example it has terrible memory access
patterns when called with a 1 x n image. With small images in general,
it will do lots and lots of modulus operations.
Since no one has ever measure whether it actually is an improvement,
and since it is doing the repeating at the wrong the stage in the
pipeline, just delete it.
---
pixman/pixman-image.c | 6 --
pixman/pixman-private.h | 3 +-
pixman/pixman.c | 148 ++++++----------------------------------------
3 files changed, 21 insertions(+), 136 deletions(-)
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 9802d8c..7a9c423 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -409,12 +409,6 @@ compute_image_info (pixman_image_t *image)
else
{
code = image->bits.format;
-
- if (!image->common.transform &&
- image->common.repeat == PIXMAN_REPEAT_NORMAL)
- {
- flags |= FAST_PATH_SIMPLE_REPEAT;
- }
}
if (!PIXMAN_FORMAT_A (image->bits.format) &&
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 59d9c5d..3979f60 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -560,7 +560,7 @@ _pixman_choose_implementation (void);
#define FAST_PATH_UNIFIED_ALPHA (1 << 9)
#define FAST_PATH_SCALE_TRANSFORM (1 << 10)
#define FAST_PATH_NEAREST_FILTER (1 << 11)
-#define FAST_PATH_SIMPLE_REPEAT (1 << 12)
+#define FAST_PATH_HAS_TRANSFORM (1 << 12)
#define FAST_PATH_IS_OPAQUE (1 << 13)
#define FAST_PATH_NEEDS_WORKAROUND (1 << 14)
#define FAST_PATH_NO_NONE_REPEAT (1 << 15)
@@ -570,7 +570,6 @@ _pixman_choose_implementation (void);
#define FAST_PATH_Y_UNIT_ZERO (1 << 19)
#define FAST_PATH_BILINEAR_FILTER (1 << 20)
#define FAST_PATH_NO_NORMAL_REPEAT (1 << 21)
-#define FAST_PATH_HAS_TRANSFORM (1 << 22)
#define FAST_PATH_PAD_REPEAT \
(FAST_PATH_NO_NONE_REPEAT | \
diff --git a/pixman/pixman.c b/pixman/pixman.c
index 15e7fbf..3a62b2d 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -377,126 +377,6 @@ pixman_compute_composite_region32 (pixman_region32_t * region,
return TRUE;
}
-static void
-walk_region_internal (pixman_implementation_t *imp,
- pixman_op_t op,
- pixman_image_t * src_image,
- pixman_image_t * mask_image,
- pixman_image_t * dst_image,
- int32_t src_x,
- int32_t src_y,
- int32_t mask_x,
- int32_t mask_y,
- int32_t dest_x,
- int32_t dest_y,
- int32_t width,
- int32_t height,
- pixman_bool_t src_repeat,
- pixman_bool_t mask_repeat,
- pixman_region32_t * region,
- pixman_composite_func_t composite_rect)
-{
- int w, h, w_this, h_this;
- int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
- int src_dy = src_y - dest_y;
- int src_dx = src_x - dest_x;
- int mask_dy = mask_y - dest_y;
- int mask_dx = mask_x - dest_x;
- const pixman_box32_t *pbox;
- int n;
-
- pbox = pixman_region32_rectangles (region, &n);
-
- /* Fast path for non-repeating sources */
- if (!src_repeat && !mask_repeat)
- {
- while (n--)
- {
- (*composite_rect) (imp, op,
- src_image, mask_image, dst_image,
- pbox->x1 + src_dx,
- pbox->y1 + src_dy,
- pbox->x1 + mask_dx,
- pbox->y1 + mask_dy,
- pbox->x1,
- pbox->y1,
- pbox->x2 - pbox->x1,
- pbox->y2 - pbox->y1);
-
- pbox++;
- }
-
- return;
- }
-
- while (n--)
- {
- h = pbox->y2 - pbox->y1;
- y_src = pbox->y1 + src_dy;
- y_msk = pbox->y1 + mask_dy;
- y_dst = pbox->y1;
-
- while (h)
- {
- h_this = h;
- w = pbox->x2 - pbox->x1;
- x_src = pbox->x1 + src_dx;
- x_msk = pbox->x1 + mask_dx;
- x_dst = pbox->x1;
-
- if (mask_repeat)
- {
- y_msk = MOD (y_msk, mask_image->bits.height);
- if (h_this > mask_image->bits.height - y_msk)
- h_this = mask_image->bits.height - y_msk;
- }
-
- if (src_repeat)
- {
- y_src = MOD (y_src, src_image->bits.height);
- if (h_this > src_image->bits.height - y_src)
- h_this = src_image->bits.height - y_src;
- }
-
- while (w)
- {
- w_this = w;
-
- if (mask_repeat)
- {
- x_msk = MOD (x_msk, mask_image->bits.width);
- if (w_this > mask_image->bits.width - x_msk)
- w_this = mask_image->bits.width - x_msk;
- }
-
- if (src_repeat)
- {
- x_src = MOD (x_src, src_image->bits.width);
- if (w_this > src_image->bits.width - x_src)
- w_this = src_image->bits.width - x_src;
- }
-
- (*composite_rect) (imp, op,
- src_image, mask_image, dst_image,
- x_src, y_src, x_msk, y_msk, x_dst, y_dst,
- w_this, h_this);
- w -= w_this;
-
- x_src += w_this;
- x_msk += w_this;
- x_dst += w_this;
- }
-
- h -= h_this;
- y_src += h_this;
- y_msk += h_this;
- y_dst += h_this;
- }
-
- pbox++;
- }
-}
-
#define N_CACHED_FAST_PATHS 8
typedef struct
@@ -949,14 +829,26 @@ pixman_image_composite32 (pixman_op_t op,
dest_format, dest_flags,
&imp, &func))
{
- walk_region_internal (imp, op,
- src, mask, dest,
- src_x, src_y, mask_x, mask_y,
- dest_x, dest_y,
- width, height,
- (src_flags & FAST_PATH_SIMPLE_REPEAT),
- (mask_flags & FAST_PATH_SIMPLE_REPEAT),
- ®ion, func);
+ const pixman_box32_t *pbox;
+ int n;
+
+ pbox = pixman_region32_rectangles (®ion, &n);
+
+ while (n--)
+ {
+ func (imp, op,
+ src, mask, dest,
+ pbox->x1 + src_x - dest_x,
+ pbox->y1 + src_y - dest_y,
+ pbox->x1 + mask_x - dest_x,
+ pbox->y1 + mask_y - dest_y,
+ pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+
+ pbox++;
+ }
}
out:
--
1.7.1.1
More information about the Pixman
mailing list