1 From 211b2bcdb19f86f3868a18520df7dcb4fd122f05 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
3 Date: Sun, 19 Aug 2012 14:48:00 +0200
4 Subject: [PATCH 2/2] Generic C implementation of pixman_blt with overlapping
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 This was ported from meta-oe's patch [1]:
11 Uses memcpy/memmove functions to copy pixels, can handle the
12 case when both source and destination areas are in the same
13 image (this is useful for scrolling).
15 It is assumed that copying direction is only important when
16 using the same image for both source and destination (and
17 src_stride == dst_stride). Copying direction is undefined
18 for the images with different source and destination stride
19 which happen to be in the overlapped areas (but this is an
20 unrealistic case anyway).
22 [1] http://cgit.openembedded.org/meta-openembedded/tree/meta-oe/recipes-graphics/xorg-lib/pixman-0.26.2/0008-Generic-C-implementation-of-pixman_blt-with-overlapp.patch
24 Upstream-Status: Unknown - this patch is in meta-oe for a while
26 Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
28 pixman/pixman-general.c | 21 ++++++++++++++++++---
29 pixman/pixman-private.h | 43 +++++++++++++++++++++++++++++++++++++++++++
30 2 files changed, 61 insertions(+), 3 deletions(-)
32 diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
33 index d4b2daa..a86b206 100644
34 --- a/pixman/pixman-general.c
35 +++ b/pixman/pixman-general.c
36 @@ -215,9 +215,24 @@ general_blt (pixman_implementation_t *imp,
40 - /* We can't blit unless we have sse2 or mmx */
43 + uint8_t *dst_bytes = (uint8_t *)dst_bits;
44 + uint8_t *src_bytes = (uint8_t *)src_bits;
47 + if (src_bpp != dst_bpp || src_bpp & 7)
54 + pixman_blt_helper (src_bytes + src_y * src_stride + src_x * bpp,
55 + dst_bytes + dest_y * dst_stride + dest_x * bpp,
64 diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
65 index d5e6a72..c77d256 100644
66 --- a/pixman/pixman-private.h
67 +++ b/pixman/pixman-private.h
76 @@ -1096,6 +1097,48 @@ void pixman_timer_register (pixman_timer_t *timer);
77 extern const uint8_t linear_to_srgb[4096];
78 extern const uint16_t srgb_to_linear[256];
80 +/* a helper function, can blit 8-bit images with src/dst overlapping support */
82 +pixman_blt_helper (uint8_t *src_bytes,
90 + * The second part of this check is not strictly needed, but it prevents
91 + * unnecessary upside-down processing of areas which belong to different
92 + * images. Upside-down processing can be slower with fixed-distance-ahead
93 + * prefetch and perceived as having more tearing.
95 + if (src_bytes < dst_bytes + width &&
96 + src_bytes + src_stride * height > dst_bytes)
98 + src_bytes += src_stride * height - src_stride;
99 + dst_bytes += dst_stride * height - dst_stride;
100 + dst_stride = -dst_stride;
101 + src_stride = -src_stride;
102 + /* Horizontal scrolling to the left needs memmove */
103 + if (src_bytes + width > dst_bytes)
105 + while (--height >= 0)
107 + memmove (dst_bytes, src_bytes, width);
108 + dst_bytes += dst_stride;
109 + src_bytes += src_stride;
114 + while (--height >= 0)
116 + memcpy (dst_bytes, src_bytes, width);
117 + dst_bytes += dst_stride;
118 + src_bytes += src_stride;
122 #endif /* __ASSEMBLER__ */
124 #endif /* PIXMAN_PRIVATE_H */