[Xcb] [PATCH 1/2] Fix xcb_image_convert fast path

Peter Harris peter.harris at hummingbird.com
Wed Oct 1 16:36:37 PDT 2008


If the image bit order matches the image byte order, then the actual
byte that a given bit falls into will not change.

Also, the bitmap unit is irrelevant when considering ZPixmap pixels.

Signed-off-by: Peter Harris <peter.harris at hummingbird.com>
---
 image/xcb_image.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/image/xcb_image.c b/image/xcb_image.c
index 96a1fd2..6fae30a 100644
--- a/image/xcb_image.c
+++ b/image/xcb_image.c
@@ -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 *
-- 
1.5.6.5



More information about the Xcb mailing list