[cogl/wip/pixel-format-2101010: 7/14] Remove COGL_UNORDERED_MASK define



commit 761ecf1a9b83766de7a5948c32cf3b01c5fb12b3
Author: Robert Bragg <robert linux intel com>
Date:   Mon Feb 13 23:55:01 2012 +0000

    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().

 cogl/cogl-bitmap-fallback.c                        |   43 ++++++++++---------
 cogl/cogl-bitmap-private.h                         |    9 ----
 cogl/cogl-types.h                                  |    1 -
 .../cogl-2.0-experimental-sections.txt             |    1 -
 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 be0cf04..150bd82 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 78962bf..7a398d5 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 c5d7592..43b8c25 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 861de90..2f96327 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 962ec84..15b469c 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>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]