From a203a5e396ffd4e85363e6bd7136af820a8d97e6 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 13 Feb 2012 22:23:27 +0000 Subject: [PATCH] Remove COGL_UNPREMULT_MASK define Since (A & ~COGL_PREMULT_BIT) is basically as readable as (A & COGL_UNPREMULT_MASK) this patch removes the mask define. Without the mask the code is slightly more explicit and there's less risk in error caused by us forgetting to update the COGL_UNPREMULT_MASK if the way CoglPixelFormat is defined evolves. Reviewed-by: Neil Roberts --- cogl/cogl-bitmap-fallback.c | 6 +++--- cogl/cogl-bitmap.c | 4 ++-- cogl/cogl-types.h | 1 - .../cogl-2.0-experimental-sections.txt | 1 - doc/reference/cogl/cogl-sections.txt | 1 - 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cogl/cogl-bitmap-fallback.c b/cogl/cogl-bitmap-fallback.c index 1b5b8ca1d..f575fae7f 100644 --- a/cogl/cogl-bitmap-fallback.c +++ b/cogl/cogl-bitmap-fallback.c @@ -375,7 +375,7 @@ _cogl_bitmap_fallback_convert (CoglBitmap *src_bmp, /* Copy the premult bit if the new format has an alpha channel */ if ((dst_format & COGL_A_BIT)) dst_format = ((src_format & COGL_PREMULT_BIT) | - (dst_format & COGL_UNPREMULT_MASK)); + (dst_format & ~COGL_PREMULT_BIT)); /* Allocate a new buffer to hold converted data */ dst_data = g_malloc (height * dst_rowstride); @@ -391,7 +391,7 @@ _cogl_bitmap_fallback_convert (CoglBitmap *src_bmp, /* FIXME: Would be nice to at least remove this inner * branching, but not sure it can be done without * rewriting of the whole loop */ - switch (src_format & COGL_UNPREMULT_MASK) + switch (src_format & ~COGL_PREMULT_BIT) { case COGL_PIXEL_FORMAT_G_8: _cogl_g_to_rgba (src, temp_rgba); break; @@ -411,7 +411,7 @@ _cogl_bitmap_fallback_convert (CoglBitmap *src_bmp, break; } - switch (dst_format & COGL_UNPREMULT_MASK) + switch (dst_format & ~COGL_PREMULT_BIT) { case COGL_PIXEL_FORMAT_G_8: _cogl_rgba_to_g (temp_rgba, dst); break; diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index 84fd7ac71..a4d0732c0 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -111,8 +111,8 @@ _cogl_bitmap_convert_format_and_premult (CoglBitmap *bmp, CoglBitmap *dst_bmp; /* Is base format different (not considering premult status)? */ - if ((src_format & COGL_UNPREMULT_MASK) != - (dst_format & COGL_UNPREMULT_MASK)) + if ((src_format & ~COGL_PREMULT_BIT) != + (dst_format & ~COGL_PREMULT_BIT)) { /* Try converting using imaging library */ if ((dst_bmp = _cogl_bitmap_convert (bmp, dst_format)) == NULL) diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h index d60c4acc0..c5d7592b7 100644 --- a/cogl/cogl-types.h +++ b/cogl/cogl-types.h @@ -170,7 +170,6 @@ typedef struct _CoglTextureVertex CoglTextureVertex; #define COGL_AFIRST_BIT (1 << 6) #define COGL_PREMULT_BIT (1 << 7) #define COGL_UNORDERED_MASK 0x0F -#define COGL_UNPREMULT_MASK 0x7F /** * 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 8f7d3d713..861de90a0 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 @@ -164,7 +164,6 @@ COGL_PIXEL_FORMAT_24 COGL_PIXEL_FORMAT_32 COGL_PREMULT_BIT COGL_UNORDERED_MASK -COGL_UNPREMULT_MASK
diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index 77240494b..962ec8433 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -126,7 +126,6 @@ COGL_PIXEL_FORMAT_24 COGL_PIXEL_FORMAT_32 COGL_PREMULT_BIT COGL_UNORDERED_MASK -COGL_UNPREMULT_MASK