[Xcb-commit] image

Bart Massey bart at kemper.freedesktop.org
Wed Oct 1 23:28:47 PDT 2008


 image/xcb_image.c |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

New commits:
commit a58f567df29c433f5cc7ffd4280aadea10a48fed
Author: Peter Harris <peter.harris at hummingbird.com>
Date:   Wed Oct 1 23:27:28 2008 -0700

    more endianness patches
    
    Signed-off-by: Bart Massey <bart at cs.pdx.edu>

diff --git a/image/xcb_image.c b/image/xcb_image.c
index 96a1fd2..2388948 100644
--- a/image/xcb_image.c
+++ b/image/xcb_image.c
@@ -532,7 +532,7 @@ static uint32_t
 xy_image_byte (xcb_image_t *image, uint32_t x)
 {
     x >>= 3;
-    if (image->byte_order == XCB_IMAGE_ORDER_LSB_FIRST)
+    if (image->byte_order == image->bit_order)
 	return x;
     switch (image->unit) {
     default:
@@ -868,6 +868,22 @@ byte_order(xcb_image_t *i)
 {
     uint32_t flip = i->byte_order == XCB_IMAGE_ORDER_MSB_FIRST;
 
+    switch (i->bpp) {
+    default:
+    case 8:
+	return 0;
+    case 16:
+	return flip;
+    case 32:
+	return flip | (flip << 1);
+    }
+}
+
+static uint32_t
+bit_order(xcb_image_t *i)
+{
+    uint32_t flip = i->byte_order != i->bit_order;
+
     switch (i->unit) {
     default:
     case 8:
@@ -885,7 +901,15 @@ byte_order(xcb_image_t *i)
 static uint32_t 
 conversion_byte_swap(xcb_image_t *src, xcb_image_t *dst)
 {
-    return byte_order(src) ^ byte_order(dst);
+    xcb_image_format_t ef = effective_format(src->format, src->bpp);
+    
+    /* src_ef == dst_ef in all callers of this function */
+    if (ef == XCB_IMAGE_FORMAT_XY_PIXMAP) {
+	return bit_order(src) ^ bit_order(dst);
+    } else {
+	/* src_bpp == dst_bpp in all callers of this function */
+	return byte_order(src) ^ byte_order(dst);
+    }
 }
 
 xcb_image_t *


More information about the xcb-commit mailing list