[cogl/wip/pixel-format-2101010: 1/5] Add 30-bit color depth pixel formats X101010 and 2101010



commit 8ec6668d8e91f167da8303a5d432b1e9c46c27ff
Author: Damien Leone <dleone nvidia com>
Date:   Mon Nov 21 15:39:49 2011 -0800

    Add 30-bit color depth pixel formats X101010 and 2101010
    
    30-bit color depth formats are defined by using value 11 in the least
    significant nibble of the pixel format enumeration. This nibble
    encodes bytes-per-pixel and byte alignment.
    
    The _cogl_get_format_bpp() function is updated accordingly to support
    these new formats.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660188
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/cogl-bitmap.c |   35 ++++++++++++++++++++++++-----------
 cogl/cogl-types.h  |   16 +++++++++++++++-
 2 files changed, 39 insertions(+), 12 deletions(-)
---
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index a109d03..b80ea18 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -80,20 +80,33 @@ _cogl_bitmap_free (CoglBitmap *bmp)
   g_slice_free (CoglBitmap, bmp);
 }
 
+/*
+ * Returns the number of bytes-per-pixel of a given format. The bpp
+ * can be extracted from the least significant nibble of the pixel
+ * format (see CoglPixelFormat).
+ *
+ * The mapping is the following (see discussion on bug #660188):
+ *
+ * 0     = undefined
+ * 1, 8  = 1 bpp (e.g. A_8, G_8)
+ * 2     = 3 bpp, aligned (e.g. 888)
+ * 3     = 4 bpp, aligned (e.g. 8888)
+ * 4-6   = 2 bpp, not aligned (e.g. 565, 4444, 5551)
+ * 7     = undefined
+ * 9     = 2 bpp, aligned
+ * 10     = undefined
+ * 11     = undefined
+ * 12    = 3 bpp, not aligned
+ * 13    = 4 bpp, not aligned (e.g. 2101010)
+ * 14-15 = undefined
+ */
 int
 _cogl_get_format_bpp (CoglPixelFormat format)
 {
-  int bpp_lut[] = {
-    0, /* invalid  */
-    1, /* A_8      */
-    3, /* 888      */
-    4, /* 8888     */
-    2, /* 565      */
-    2, /* 4444     */
-    2, /* 5551     */
-    2, /* YUV      */
-    1  /* G_8      */
-  };
+  int bpp_lut[] = { 0, 1, 3, 4,
+                    2, 2, 2, 0,
+                    1, 2, 0, 0,
+                    3, 4, 0, 0 };
 
   return bpp_lut [format & COGL_UNORDERED_MASK];
 }
diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h
index b8edb69..d2e1c3c 100644
--- a/cogl/cogl-types.h
+++ b/cogl/cogl-types.h
@@ -183,16 +183,22 @@ typedef struct _CoglTextureVertex       CoglTextureVertex;
  * @COGL_PIXEL_FORMAT_G_8: Single luminance component
  * @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits
  * @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits
+ * @COGL_PIXEL_FORMAT_RGB_101010: RGB, 32 bits, 10 bpc
+ * @COGL_PIXEL_FORMAT_BGR_101010: BGR, 32 bits, 10 bpc
  * @COGL_PIXEL_FORMAT_RGBA_8888: RGBA, 32 bits
  * @COGL_PIXEL_FORMAT_BGRA_8888: BGRA, 32 bits
  * @COGL_PIXEL_FORMAT_ARGB_8888: ARGB, 32 bits
  * @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits
+ * @COGL_PIXEL_FORMAT_ARGB_2101010 : ARGB, 32 bits, 10 bpc
+ * @COGL_PIXEL_FORMAT_ABGR_2101010 : ABGR, 32 bits, 10 bpc
  * @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits
  * @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits
  * @COGL_PIXEL_FORMAT_ARGB_8888_PRE: Premultiplied ARGB, 32 bits
  * @COGL_PIXEL_FORMAT_ABGR_8888_PRE: Premultiplied ABGR, 32 bits
  * @COGL_PIXEL_FORMAT_RGBA_4444_PRE: Premultiplied RGBA, 16 bits
  * @COGL_PIXEL_FORMAT_RGBA_5551_PRE: Premultiplied RGBA, 16 bits
+ * @COGL_PIXEL_FORMAT_ARGB_2101010_PRE: Premultiplied ARGB, 32 bits, 10 bpc
+ * @COGL_PIXEL_FORMAT_ABGR_2101010_PRE: Premultiplied ABGR, 32 bits, 10 bpc
  *
  * Pixel formats used by COGL. For the formats with a byte per
  * component, the order of the components specify the order in
@@ -227,17 +233,25 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
   COGL_PIXEL_FORMAT_RGB_888       =  COGL_PIXEL_FORMAT_24,
   COGL_PIXEL_FORMAT_BGR_888       = (COGL_PIXEL_FORMAT_24 | COGL_BGR_BIT),
 
+  COGL_PIXEL_FORMAT_RGB_101010    =  13,
+  COGL_PIXEL_FORMAT_BGR_101010    = (13 | COGL_BGR_BIT),
+
   COGL_PIXEL_FORMAT_RGBA_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT),
   COGL_PIXEL_FORMAT_BGRA_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_BGR_BIT),
   COGL_PIXEL_FORMAT_ARGB_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_AFIRST_BIT),
   COGL_PIXEL_FORMAT_ABGR_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
 
+  COGL_PIXEL_FORMAT_ARGB_2101010  = (13 | COGL_A_BIT | COGL_AFIRST_BIT),
+  COGL_PIXEL_FORMAT_ABGR_2101010  = (13 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
+
   COGL_PIXEL_FORMAT_RGBA_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT),
   COGL_PIXEL_FORMAT_BGRA_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
   COGL_PIXEL_FORMAT_ARGB_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
   COGL_PIXEL_FORMAT_ABGR_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
   COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT),
-  COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT)
+  COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT),
+  COGL_PIXEL_FORMAT_ARGB_2101010_PRE = (COGL_PIXEL_FORMAT_ARGB_2101010 | COGL_PREMULT_BIT),
+  COGL_PIXEL_FORMAT_ABGR_2101010_PRE = (COGL_PIXEL_FORMAT_ABGR_2101010 | COGL_PREMULT_BIT)
 } CoglPixelFormat;
 
 /**



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