[Pixman] [PATCH] When converting indexed formats to 64 bits, don't correct for channel widths

Søren Sandmann sandmann at daimi.au.dk
Tue Jul 13 12:36:35 PDT 2010


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

Indexed formats are mapped to a8r8g8b8 with full precision, so when
expanding we shouldn't correct for the width of the channels
---
 pixman/pixman-access.c |   31 +++++++++++++++++++++++++++++--
 test/blitters-test.c   |    2 +-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 9708b10..80fa9e8 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -2683,12 +2683,26 @@ fetch_scanline_generic_64 (pixman_image_t *image,
                            uint32_t *      buffer,
                            const uint32_t *mask)
 {
+    pixman_format_code_t format;
+    
     /* Fetch the pixels into the first half of buffer and then expand them in
      * place.
      */
     image->bits.fetch_scanline_raw_32 (image, x, y, width, buffer, NULL);
+
+    format = image->bits.format;
+    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR	||
+	PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
+    {
+	/* Indexed formats are mapped to a8r8g8b8 with full
+	 * precision, so when expanding we shouldn't correct
+	 * for the width of the channels
+	 */
+	
+	format = PIXMAN_a8r8g8b8;
+    }
     
-    pixman_expand ((uint64_t *)buffer, buffer, image->bits.format, width);
+    pixman_expand ((uint64_t *)buffer, buffer, format, width);
 }
 
 /* Despite the type, this function expects a uint64_t *buffer */
@@ -2699,8 +2713,21 @@ fetch_pixel_generic_64 (bits_image_t *image,
 {
     uint32_t pixel32 = image->fetch_pixel_raw_32 (image, offset, line);
     uint64_t result;
+    pixman_format_code_t format;
+
+    format = image->format;
+    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR	||
+	PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
+    {
+	/* Indexed formats are mapped to a8r8g8b8 with full
+	 * precision, so when expanding we shouldn't correct
+	 * for the width of the channels
+	 */
+	
+	format = PIXMAN_a8r8g8b8;
+    }
     
-    pixman_expand ((uint64_t *)&result, &pixel32, image->format, 1);
+    pixman_expand ((uint64_t *)&result, &pixel32, format, 1);
 
     return result;
 }
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 5becada..2c6334a 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -478,6 +478,6 @@ main (int argc, const char *argv[])
     }
 
     return fuzzer_test_main("blitters", 2000000,
-			    0xD0B050B1,
+			    0xD5833506,
 			    test_composite, argc, argv);
 }
-- 
1.6.0.6



More information about the Pixman mailing list