diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-02-13 23:28:28 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-02-20 23:12:44 +0000 |
commit | 07e972505cc7b999519240c87664d3de993e623b (patch) | |
tree | 6f1b144cec73a8dd606bb3dfc2c5c5e2433bfaf3 /cogl/cogl.c | |
parent | fbec2a5ad74e42ec4290e691b9d7653d30686c4e (diff) | |
download | cogl-07e972505cc7b999519240c87664d3de993e623b.tar.gz |
Adds _cogl_pixel_format_is_endian_dependant api
This adds an internal utility function
_cogl_pixel_format_is_endian_dependant() that can query whether
accessing the components of a given format depends on the endianness of
the current host CPU or whether a pixel can be loaded as a word and
channels accessed using bit masking and shifting.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/cogl.c')
-rw-r--r-- | cogl/cogl.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cogl/cogl.c b/cogl/cogl.c index d22a91fa..82a7f771 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -1024,3 +1024,24 @@ _cogl_pixel_format_get_bytes_per_pixel (CoglPixelFormat format) return bpp_lut [format & 0xf]; } + +/* Note: this also refers to the mapping defined above for + * _cogl_pixel_format_get_bytes_per_pixel() */ +gboolean +_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format) +{ + int aligned_lut[] = { -1, 1, 1, 1, + 0, 0, 0, -1, + 1, 1, -1, -1, + 0, 0, -1, -1}; + int aligned = aligned_lut[format & 0xf]; + + _COGL_RETURN_VAL_IF_FAIL (aligned != -1, FALSE); + + /* NB: currently checking whether the format components are aligned + * or not determines whether the format is endian dependent or not. + * In the future though we might consider adding formats with + * aligned components that are also endian independant. */ + + return aligned; +} |