[cairo] cairo on cross-endian architectures

Egon Nijns Egon.Nijns at bib.kuleuven.be
Mon Sep 12 03:17:05 PDT 2005


Hi all,

I'm running into some color problems (red and blue are swapped) with 
cairo (as used by Mozilla's SVG implementation) on a cross-endian 
architecture (these were already discussed earlier on the cairo mailing 
list, I've attached part of the earlier discussion below).

We are using a Sun Ray Server, and I think that this is a cross-endian 
architecture, since I'm seeing the swapped colors problem. I've 
submitted a badly written patch doing the byte-swaps Owen Taylor 
suggested to Mozilla's bugzilla, and want to clean up the code (I hope 
that a fix for this can one day be included in cairo).

The biggest problem I have is that I don't know how to do the 
cross-endian detection (plus I have no experience with Xlib coding 
whatsoever), but maybe someone on this list can give me some clues on 
how to do this properly?

kind regards,
egon.

> On Tue, 2005-05-10 at 15:04 -0600, Peter Dennis Bartok wrote:
>  
>
>>> Hi all,
>>>
>>> Has anyone successfully used Cairo on anything other than a 
>>> Xfree/Xorg X server?
>>>
>>> Two cases where we are seeing problems are Sun's X server and 
>>> Hummingbirds' Exceed Win32 X server. On both or applications usually 
>>> die with a BadMatch (in XPutImage or XGetImage). *Also, on Servers 
>>> that have MSB first, cairo treats it as if they are LSB first, 
>>> thereby swapping red and blue.*
>>>
>>> My understanding of the inner workings of cairo and libpixman sadly 
>>> is quite limited, so I wouldn't know where to start trying to fix this.
>>
>>
>>   
>
>
>
> No libpixman or Cairo knowledge needed. It's all really shallow inside
> cairo-xlib-surface.c.
>
> *For the endianess problems, the code simply needs to byte-swap the
> image after calling XGetImage / before calling XPutImage if you detect 
> cross-endian. (Image byte order not equal to local byte
> order.)*
>
> (In some cases, there are tricks you can play with calling a big 
> endian RGB x888 visual a little endian BGR 888x visual. libpixman can 
> draw to a BGR 888x visual but it's going to be slow. Certainly simpler 
> to just byte-swap than to worry about
> accelerating that.)
>
> It looks to me like the code should work fine on MSB as long
> as the client/server endianess matches.
>
> [...]
>  
>
> Regards,
>                     Owen 





Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the cairo mailing list