Comment 0 for bug 1236254

Revision history for this message
Daniel van Vugt (vanvugt) wrote : MirPixelFormat does not encode details of the pixel format

MirPixelFormat does not encode details of the pixel format. This is annoying because we frequently need to switch/case for each supported pixel format. What would be nicer is encoding the instructions for formatting a pixel into the pixelformat itself. Something like...

#define PIXEL_FORMAT(redsize, redshift, greensize, greenshift, bluesize, blueshift, alphasize, alphashift) \
( \
    (redsize << 28) | \
    (redshift << 24) | \
    (greensize << 20) | \
    (greenshift << 16) | \
    (bluesize << 12) | \
    (blueshift << 8) | \
    (alphasize << 4) | \
    (alphashift << 0) | \
)

#define ABGR8888 PIXEL_FORMAT(8, 0, 8, 8, 8, 16, 8, 24)
#define XBGR8888 PIXEL_FORMAT(8, 0, 8, 8, 8, 16, 0, 24)
#define HAS_ALPHA_CHANNEL(pf) ((pf) & 0xf0)