pixman: app patches to fix scrolling glitches
[openembedded.git] / recipes / xorg-lib / pixman / 0001-Generic-C-implementation-of-pixman_blt-with-overlapp-0-32.patch
1 From 8ea1a333de202018a862a7b04b94479d3109274b Mon Sep 17 00:00:00 2001
2 From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
3 Date: Tue, 16 Mar 2010 16:55:28 +0100
4 Subject: [PATCH 1/5] Generic C implementation of pixman_blt with overlapping support
5
6 Uses memcpy/memmove functions to copy pixels, can handle the
7 case when both source and destination areas are in the same
8 image (this is useful for scrolling).
9
10 It is assumed that copying direction is only important when
11 using the same image for both source and destination (and
12 src_stride == dst_stride). Copying direction is undefined
13 for the images with different source and destination stride
14 which happen to be in the overlapped areas (but this is an
15 unrealistic case anyway).
16
17 [notasas@gmail.com: only ported part needed for NEON patch to 0.32]
18 ---
19
20 diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
21 index 6ca13b2..165c7e2 100644
22 --- a/pixman/pixman-private.h
23 +++ b/pixman/pixman-private.h
24 @@ -1148,6 +1148,48 @@ void pixman_timer_register (pixman_timer_t *timer);
25  
26  #endif /* PIXMAN_TIMERS */
27  
28 +/* a helper function, can blit 8-bit images with src/dst overlapping support */
29 +static inline void
30 +pixman_blt_helper (uint8_t *src_bytes,
31 +                   uint8_t *dst_bytes,
32 +                   int      src_stride,
33 +                   int      dst_stride,
34 +                   int      width,
35 +                   int      height)
36 +{
37 +    /*
38 +     * The second part of this check is not strictly needed, but it prevents
39 +     * unnecessary upside-down processing of areas which belong to different
40 +     * images. Upside-down processing can be slower with fixed-distance-ahead
41 +     * prefetch and perceived as having more tearing.
42 +     */
43 +    if (src_bytes < dst_bytes + width &&
44 +       src_bytes + src_stride * height > dst_bytes)
45 +    {
46 +       src_bytes += src_stride * height - src_stride;
47 +       dst_bytes += dst_stride * height - dst_stride;
48 +       dst_stride = -dst_stride;
49 +       src_stride = -src_stride;
50 +       /* Horizontal scrolling to the left needs memmove */
51 +       if (src_bytes + width > dst_bytes)
52 +       {
53 +           while (--height >= 0)
54 +           {
55 +               memmove (dst_bytes, src_bytes, width);
56 +               dst_bytes += dst_stride;
57 +               src_bytes += src_stride;
58 +           }
59 +           return;
60 +       }
61 +    }
62 +    while (--height >= 0)
63 +    {
64 +       memcpy (dst_bytes, src_bytes, width);
65 +       dst_bytes += dst_stride;
66 +       src_bytes += src_stride;
67 +    }
68 +}
69 +
70  #endif /* __ASSEMBLER__ */
71  
72  #endif /* PIXMAN_PRIVATE_H */