bf6e58c9e4a9270eae2f3288dd5bdcb8b29474af
[openembedded.git] /
1 From f607cd0250d398077b0c51201258775e372cb3c3 Mon Sep 17 00:00:00 2001
2 From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
3 Date: Thu, 22 Oct 2009 05:45:47 +0300
4 Subject: [PATCH 2/5] Support of overlapping src/dst for pixman_blt_mmx
5
6 ---
7  pixman/pixman-mmx.c |   55 +++++++++++++++++++++++++++++---------------------
8  1 files changed, 32 insertions(+), 23 deletions(-)
9
10 diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
11 index e084e7f..6212b31 100644
12 --- a/pixman/pixman-mmx.c
13 +++ b/pixman/pixman-mmx.c
14 @@ -2994,34 +2994,43 @@ pixman_blt_mmx (uint32_t *src_bits,
15  {
16      uint8_t *   src_bytes;
17      uint8_t *   dst_bytes;
18 -    int byte_width;
19 +    int         bpp;
20  
21 -    if (src_bpp != dst_bpp)
22 +    if (src_bpp != dst_bpp || src_bpp & 7)
23         return FALSE;
24  
25 -    if (src_bpp == 16)
26 -    {
27 -       src_stride = src_stride * (int) sizeof (uint32_t) / 2;
28 -       dst_stride = dst_stride * (int) sizeof (uint32_t) / 2;
29 -       src_bytes = (uint8_t *)(((uint16_t *)src_bits) + src_stride * (src_y) + (src_x));
30 -       dst_bytes = (uint8_t *)(((uint16_t *)dst_bits) + dst_stride * (dst_y) + (dst_x));
31 -       byte_width = 2 * width;
32 -       src_stride *= 2;
33 -       dst_stride *= 2;
34 -    }
35 -    else if (src_bpp == 32)
36 +    bpp = src_bpp >> 3;
37 +    width *= bpp;
38 +    src_stride *= 4;
39 +    dst_stride *= 4;
40 +    src_bytes = (uint8_t *)src_bits + src_y * src_stride + src_x * bpp;
41 +    dst_bytes = (uint8_t *)dst_bits + dst_y * dst_stride + dst_x * bpp;
42 +
43 +    if (src_bpp != 16 && src_bpp != 32)
44      {
45 -       src_stride = src_stride * (int) sizeof (uint32_t) / 4;
46 -       dst_stride = dst_stride * (int) sizeof (uint32_t) / 4;
47 -       src_bytes = (uint8_t *)(((uint32_t *)src_bits) + src_stride * (src_y) + (src_x));
48 -       dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + dst_stride * (dst_y) + (dst_x));
49 -       byte_width = 4 * width;
50 -       src_stride *= 4;
51 -       dst_stride *= 4;
52 +       pixman_blt_helper (src_bytes, dst_bytes, src_stride, dst_stride,
53 +                          width, height);
54 +       return TRUE;
55      }
56 -    else
57 +
58 +    if (src_bytes < dst_bytes && src_bytes + src_stride * height > dst_bytes)
59      {
60 -       return FALSE;
61 +       src_bytes += src_stride * height - src_stride;
62 +       dst_bytes += dst_stride * height - dst_stride;
63 +       dst_stride = -dst_stride;
64 +       src_stride = -src_stride;
65 +
66 +       if (src_bytes + width > dst_bytes)
67 +       {
68 +           /* TODO: reverse scanline copy using MMX */
69 +           while (--height >= 0)
70 +           {
71 +               memmove (dst_bytes, src_bytes, width);
72 +               dst_bytes += dst_stride;
73 +               src_bytes += src_stride;
74 +           }
75 +           return TRUE;
76 +       }
77      }
78  
79      while (height--)
80 @@ -3031,7 +3040,7 @@ pixman_blt_mmx (uint32_t *src_bits,
81         uint8_t *d = dst_bytes;
82         src_bytes += src_stride;
83         dst_bytes += dst_stride;
84 -       w = byte_width;
85 +       w = width;
86  
87         while (w >= 2 && ((unsigned long)d & 3))
88         {
89 -- 
90 1.6.6.1
91