[Pixman] [PATCH 6/7] Add support for 8bpp to pixman_fill_sse2()

Søren Sandmann sandmann at daimi.au.dk
Sat Apr 24 13:48:57 PDT 2010


From: Søren Sandmann Pedersen <ssp at redhat.com>

---
 pixman/pixman-sse2.c |   39 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index 3f474d7..d5349d7 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -3981,24 +3981,40 @@ pixman_fill_sse2 (uint32_t *bits,
 
     __m128i xmm_def;
 
-    if (bpp != 16 && bpp != 32)
-	return FALSE;
+    if (bpp == 8)
+    {
+	uint8_t b;
+	uint16_t w;
+
+	stride = stride * (int) sizeof (uint32_t) / 1;
+	byte_line = (uint8_t *)(((uint8_t *)bits) + stride * y + x);
+	byte_width = width;
+	stride *= 1;
 
-    if (bpp == 16)
+	b = data & 0xff;
+	w = (b << 8) | b;
+	data = (w << 16) | w;
+    }
+    else if (bpp == 16)
     {
 	stride = stride * (int) sizeof (uint32_t) / 2;
 	byte_line = (uint8_t *)(((uint16_t *)bits) + stride * y + x);
 	byte_width = 2 * width;
 	stride *= 2;
+
         data = (data & 0xffff) * 0x00010001;
     }
-    else
+    else if (bpp == 32)
     {
 	stride = stride * (int) sizeof (uint32_t) / 4;
 	byte_line = (uint8_t *)(((uint32_t *)bits) + stride * y + x);
 	byte_width = 4 * width;
 	stride *= 4;
     }
+    else
+    {
+	return FALSE;
+    }
 
     cache_prefetch ((__m128i*)byte_line);
     xmm_def = create_mask_2x32_128 (data, data);
@@ -4010,9 +4026,15 @@ pixman_fill_sse2 (uint32_t *bits,
 	byte_line += stride;
 	w = byte_width;
 
-
 	cache_prefetch_next ((__m128i*)d);
 
+	while (w >= 1 && ((unsigned long)d & 1))
+	{
+	    *(uint8_t *)d = data;
+	    w -= 1;
+	    d += 1;
+	}
+
 	while (w >= 2 && ((unsigned long)d & 3))
 	{
 	    *(uint16_t *)d = data;
@@ -4095,6 +4117,13 @@ pixman_fill_sse2 (uint32_t *bits,
 	    w -= 2;
 	    d += 2;
 	}
+
+	if (w >= 1)
+	{
+	    *(uint8_t *)d = data;
+	    w -= 1;
+	    d += 1;
+	}
     }
 
     _mm_empty ();
-- 
1.7.0.1



More information about the Pixman mailing list