summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Harris <peter.harris@hummingbird.com>2008-10-01 23:27:28 -0700
committerBart Massey <bart@cs.pdx.edu>2008-10-01 23:27:28 -0700
commit4d82e387654f86387124cce115cc1660a6d185b1 (patch)
treec0224c962d70d95b1891db221ac8eb9ac968a92a
parent4e6fea8e01761389f1a82ce407005e71cad0cd2c (diff)
more endianness patches
Signed-off-by: Bart Massey <bart@cs.pdx.edu>
-rw-r--r--image/xcb_image.c28
1 files changed, 26 insertions, 2 deletions
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 *