1 From 4b5b5a2a832cd67f2a0ec231f75a2825b45571fa Mon Sep 17 00:00:00 2001
2 From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
3 Date: Mon, 15 Nov 2010 18:26:43 +0200
4 Subject: [PATCH 04/24] C fast path for a1 fill operation
6 Can be used as one of the solutions to fix bug
7 https://bugs.freedesktop.org/show_bug.cgi?id=31604
9 pixman/pixman-fast-path.c | 87 ++++++++++++++++++++++++++++++++++++++++++++-
10 pixman/pixman.c | 7 +++-
11 2 files changed, 91 insertions(+), 3 deletions(-)
13 diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
14 index 5d5fa95..37dfbae 100644
15 --- a/pixman/pixman-fast-path.c
16 +++ b/pixman/pixman-fast-path.c
17 @@ -1334,7 +1334,11 @@ fast_composite_solid_fill (pixman_implementation_t *imp,
19 src = _pixman_image_get_solid (src_image, dst_image->bits.format);
21 - if (dst_image->bits.format == PIXMAN_a8)
22 + if (dst_image->bits.format == PIXMAN_a1)
26 + else if (dst_image->bits.format == PIXMAN_a8)
30 @@ -1655,6 +1659,7 @@ static const pixman_fast_path_t c_fast_paths[] =
31 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8r8g8b8, fast_composite_solid_fill),
32 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8b8g8r8, fast_composite_solid_fill),
33 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8b8g8r8, fast_composite_solid_fill),
34 + PIXMAN_STD_FAST_PATH (SRC, solid, null, a1, fast_composite_solid_fill),
35 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8, fast_composite_solid_fill),
36 PIXMAN_STD_FAST_PATH (SRC, solid, null, r5g6b5, fast_composite_solid_fill),
37 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, a8r8g8b8, fast_composite_src_x888_8888),
38 @@ -1733,6 +1738,82 @@ static const pixman_fast_path_t c_fast_paths[] =
42 +#ifdef WORDS_BIGENDIAN
43 +#define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (32 - (offs) - (n)))
45 +#define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (offs))
48 +static force_inline void
49 +pixman_fill1_line (uint32_t *dst, int offs, int width, int v)
53 + int leading_pixels = 32 - offs;
54 + if (leading_pixels >= width)
57 + *dst |= A1_FILL_MASK (width, offs);
59 + *dst &= ~A1_FILL_MASK (width, offs);
65 + *dst++ |= A1_FILL_MASK (leading_pixels, offs);
67 + *dst++ &= ~A1_FILL_MASK (leading_pixels, offs);
68 + width -= leading_pixels;
74 + *dst++ = 0xFFFFFFFF;
82 + *dst |= A1_FILL_MASK (width, 0);
84 + *dst &= ~A1_FILL_MASK (width, 0);
89 +pixman_fill1 (uint32_t *bits,
97 + uint32_t *dst = bits + y * stride + (x >> 5);
104 + pixman_fill1_line (dst, offs, width, 1);
112 + pixman_fill1_line (dst, offs, width, 0);
119 pixman_fill8 (uint32_t *bits,
121 @@ -1819,6 +1900,10 @@ fast_path_fill (pixman_implementation_t *imp,
126 + pixman_fill1 (bits, stride, x, y, width, height, xor);
130 pixman_fill8 (bits, stride, x, y, width, height, xor);
132 diff --git a/pixman/pixman.c b/pixman/pixman.c
133 index 045c556..ec565f9 100644
134 --- a/pixman/pixman.c
135 +++ b/pixman/pixman.c
136 @@ -875,7 +875,8 @@ color_to_pixel (pixman_color_t * color,
137 format == PIXMAN_b8g8r8x8 ||
138 format == PIXMAN_r5g6b5 ||
139 format == PIXMAN_b5g6r5 ||
140 - format == PIXMAN_a8))
141 + format == PIXMAN_a8 ||
142 + format == PIXMAN_a1))
146 @@ -895,7 +896,9 @@ color_to_pixel (pixman_color_t * color,
147 ((c & 0x000000ff) << 24);
150 - if (format == PIXMAN_a8)
151 + if (format == PIXMAN_a1)
153 + else if (format == PIXMAN_a8)
155 else if (format == PIXMAN_r5g6b5 ||
156 format == PIXMAN_b5g6r5)