diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-02-13 23:55:01 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-02-17 23:48:51 +0000 |
commit | 3581e46ea3f9d468bcb2cf4ae5104b439da4f5dc (patch) | |
tree | c5bb1cc15d491fc21e43de548304dacf1f01e44b | |
parent | 07f679a6f4944fda907e6cd0449a216dabeea4af (diff) | |
download | cogl-3581e46ea3f9d468bcb2cf4ae5104b439da4f5dc.tar.gz |
Remove COGL_UNORDERED_MASK define
Although it's in a public header nothing should be using this define
since it's not documented what it could be used for. The cases where we
were using it internally were quite fragile because they were trying to
mask information from the least significant nibble of CoglPixelFormat
but really that nibble just has to be dealt with using lookup tables.
The least significant nibble of a pixel format gives information about
the bytes per pixel and whether the components are byte aligned but the
information needs to be accessed using
_cogl_pixel_format_get_byes_per_pixel() and
_cogl_pixel_format_is_endian_dependant().
-rw-r--r-- | cogl/cogl-bitmap-fallback.c | 43 | ||||
-rw-r--r-- | cogl/cogl-bitmap-private.h | 9 | ||||
-rw-r--r-- | cogl/cogl-types.h | 1 | ||||
-rw-r--r-- | doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt | 1 | ||||
-rw-r--r-- | doc/reference/cogl/cogl-sections.txt | 1 |
5 files changed, 23 insertions, 32 deletions
diff --git a/cogl/cogl-bitmap-fallback.c b/cogl/cogl-bitmap-fallback.c index be0cf043..150bd822 100644 --- a/cogl/cogl-bitmap-fallback.c +++ b/cogl/cogl-bitmap-fallback.c @@ -300,23 +300,22 @@ _cogl_premult_alpha_last_four_pixels_sse2 (guint8 *p) #endif /* COGL_USE_PREMULT_SSE2 */ -gboolean +static gboolean _cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst) { if (src == dst) return FALSE; - switch (src & COGL_UNORDERED_MASK) + switch (src & ~COGL_PREMULT_BIT) { case COGL_PIXEL_FORMAT_G_8: - case COGL_PIXEL_FORMAT_24: - case COGL_PIXEL_FORMAT_32: - - if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 && - (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 && - (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8) - return FALSE; - break; + case COGL_PIXEL_FORMAT_RGB_888: + case COGL_PIXEL_FORMAT_BGR_888: + case COGL_PIXEL_FORMAT_RGBA_8888: + case COGL_PIXEL_FORMAT_BGRA_8888: + case COGL_PIXEL_FORMAT_ARGB_8888: + case COGL_PIXEL_FORMAT_ABGR_8888: + return TRUE; default: return FALSE; @@ -325,16 +324,20 @@ _cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst) return TRUE; } -gboolean -_cogl_bitmap_fallback_can_unpremult (CoglPixelFormat format) -{ - return ((format & COGL_UNORDERED_MASK) == COGL_PIXEL_FORMAT_32); -} - -gboolean +static gboolean _cogl_bitmap_fallback_can_premult (CoglPixelFormat format) { - return ((format & COGL_UNORDERED_MASK) == COGL_PIXEL_FORMAT_32); + switch (format & ~COGL_PREMULT_BIT) + { + case COGL_PIXEL_FORMAT_RGBA_8888: + case COGL_PIXEL_FORMAT_BGRA_8888: + case COGL_PIXEL_FORMAT_ARGB_8888: + case COGL_PIXEL_FORMAT_ABGR_8888: + return TRUE; + + default: + return FALSE; + } } CoglBitmap * @@ -458,8 +461,8 @@ _cogl_bitmap_fallback_unpremult (CoglBitmap *bmp) height = _cogl_bitmap_get_height (bmp); rowstride = _cogl_bitmap_get_rowstride (bmp); - /* Make sure format supported for un-premultiplication */ - if (!_cogl_bitmap_fallback_can_unpremult (format)) + /* If we can premult that implies we can un-premult too... */ + if (!_cogl_bitmap_fallback_can_premult (format)) return FALSE; if ((data = _cogl_bitmap_map (bmp, diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h index 78962bf0..7a398d59 100644 --- a/cogl/cogl-bitmap-private.h +++ b/cogl/cogl-bitmap-private.h @@ -87,20 +87,11 @@ gboolean _cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst); gboolean -_cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst); - -gboolean _cogl_bitmap_can_unpremult (CoglPixelFormat format); gboolean -_cogl_bitmap_fallback_can_unpremult (CoglPixelFormat format); - -gboolean _cogl_bitmap_can_premult (CoglPixelFormat format); -gboolean -_cogl_bitmap_fallback_can_premult (CoglPixelFormat format); - CoglBitmap * _cogl_bitmap_convert (CoglBitmap *bmp, CoglPixelFormat dst_format); diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h index c5d7592b..43b8c25a 100644 --- a/cogl/cogl-types.h +++ b/cogl/cogl-types.h @@ -169,7 +169,6 @@ typedef struct _CoglTextureVertex CoglTextureVertex; #define COGL_BGR_BIT (1 << 5) #define COGL_AFIRST_BIT (1 << 6) #define COGL_PREMULT_BIT (1 << 7) -#define COGL_UNORDERED_MASK 0x0F /** * CoglPixelFormat: diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt index 861de90a..2f963278 100644 --- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt +++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt @@ -163,7 +163,6 @@ COGL_BGR_BIT COGL_PIXEL_FORMAT_24 COGL_PIXEL_FORMAT_32 COGL_PREMULT_BIT -COGL_UNORDERED_MASK </SECTION> <SECTION> diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index 962ec843..15b469cb 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -125,7 +125,6 @@ COGL_BGR_BIT COGL_PIXEL_FORMAT_24 COGL_PIXEL_FORMAT_32 COGL_PREMULT_BIT -COGL_UNORDERED_MASK </SECTION> <SECTION> |