Cairo is working! So far I have
ARGB surfaces working, and so still have alpha-only surfaces and fonts to do, but that is enough to make the majority of the test suite work. I actually had the basics working on Thursday, but the colours were all messed up, and it took five days to track down all the issues and fix them. I won't go into the process, because its peppered with dead ends and misunderstandings, but here's what I've learnt:
- CyberGraphics is a big-endian interface. That is to say, when you request
ARGB, you will always get the same byte ordering on little and big-endian machines. This is different to cairo, where specifying
ARGBwill get you the ordering of the local machine. What this means is that on little-endian machines when converting from AROS bitmaps to cairo surfaces, I have to request BGRA format from
ReadPixelArray()but then tell cairo its
ARGB, and vice-versa.
- When AROS converts from a bitmap with no alpha channel (eg
RGB) to one with alpha (eg
ARGB24), it will set the alpha in the target bitmap to 0 (fully-transparent). When feeding the target into cairo, which knows about alpha, it basically does nothing as it sees that all the pixels are fully transparent. I've already done a rather naive fix in AROS for one case, but there's still a case where the graphics library, realising that a conversion from a non-alpha format to a 32-bit with-alpha format is requested, rewrites the target format to be 32-bit no-alpha (eg
0RGB), thus leaving the alpha set to 0 again. I'm working on a more generic fix.
WritePixelArray()has no support for software alpha compositing. That is, when using it to blit a 32-bit with-alpha bitmap to another bitmap without alpha, the alpha component is ignored rather than computed in software. Ironically, alpha compositing code exists for
WritePixelArrayAlpha(), so I'll also be looking at factoring this code out into a generic function and having both calls use it.
Once I get this sorted, I have a very cute piece of eyecandy in the works to demonstrate to you all just how powerful cairo is, and just how easy it is to use. Hopefully I'll have something to show in a few days, then I'll get back onto the font support.