[cairo-commit] pixman/src src/cairo.h src/cairo-image-surface.c

Carl Worth cworth at kemper.freedesktop.org
Fri Jun 16 09:24:57 PDT 2006


 pixman/src/icformat.c     |    6 ++++++
 pixman/src/pixman.h       |    3 ++-
 src/cairo-image-surface.c |   17 ++++++++++++++++-
 src/cairo.h               |    6 +++++-
 4 files changed, 29 insertions(+), 3 deletions(-)

New commits:
diff-tree c6164d0d2a9ca16a00c2768f24a0230de6cbc6f6 (from 36e59ca5f854de2740c7ef4f0b6022785dd9dc4c)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 15 16:22:52 2006 -0700

    New API: Add support for new CAIRO_FORMAT_RGB16_565

diff --git a/pixman/src/icformat.c b/pixman/src/icformat.c
index f133283..62a171d 100644
--- a/pixman/src/icformat.c
+++ b/pixman/src/icformat.c
@@ -47,6 +47,12 @@ pixman_format_create (pixman_format_name
     case PIXMAN_FORMAT_NAME_A1:
 	return pixman_format_create_masks (1, 0x1,
 				    0, 0, 0);
+    case PIXMAN_FORMAT_NAME_RGB16_565:
+	return pixman_format_create_masks (16,
+					   0x0,
+					   0xf800,
+					   0x07e0,
+					   0x001f);
     }
 
     return NULL;
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index 1c98fd9..e925227 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -220,7 +220,8 @@ typedef enum pixman_format_name {
     PIXMAN_FORMAT_NAME_ARGB32,
     PIXMAN_FORMAT_NAME_RGB24,
     PIXMAN_FORMAT_NAME_A8,
-    PIXMAN_FORMAT_NAME_A1
+    PIXMAN_FORMAT_NAME_A1,
+    PIXMAN_FORMAT_NAME_RGB16_565
 } pixman_format_name_t;
 
 typedef struct pixman_format pixman_format_t;
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index e94673c..bddf6c1 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -44,11 +44,15 @@ _cairo_format_bpp (cairo_format_t format
 	return 1;
     case CAIRO_FORMAT_A8:
 	return 8;
+    case CAIRO_FORMAT_RGB16_565:
+	return 16;
     case CAIRO_FORMAT_RGB24:
     case CAIRO_FORMAT_ARGB32:
-    default:
 	return 32;
     }
+
+    ASSERT_NOT_REACHED;
+    return 32;
 }
 
 cairo_surface_t *
@@ -103,6 +107,13 @@ _cairo_format_from_pixman_format (pixman
 	    bm == 0x000000ff)
 	    return CAIRO_FORMAT_RGB24;
 	break;
+    case 16:
+	if (am == 0x0 &&
+	    rm == 0xf800 &&
+	    gm == 0x07e0 &&
+	    bm == 0x001f)
+	    return CAIRO_FORMAT_RGB16_565;
+	break;
     case 8:
 	if (am == 0xff &&
 	    rm == 0x0 &&
@@ -185,6 +196,9 @@ _create_pixman_format (cairo_format_t fo
     case CAIRO_FORMAT_A8:
 	return pixman_format_create (PIXMAN_FORMAT_NAME_A8);
 	break;
+    case CAIRO_FORMAT_RGB16_565:
+	return pixman_format_create (PIXMAN_FORMAT_NAME_RGB16_565);
+	break;
     case CAIRO_FORMAT_RGB24:
 	return pixman_format_create (PIXMAN_FORMAT_NAME_RGB24);
 	break;
@@ -475,6 +489,7 @@ _cairo_content_from_format (cairo_format
     case CAIRO_FORMAT_ARGB32:
 	return CAIRO_CONTENT_COLOR_ALPHA;
     case CAIRO_FORMAT_RGB24:
+    case CAIRO_FORMAT_RGB16_565:
 	return CAIRO_CONTENT_COLOR;
     case CAIRO_FORMAT_A8:
     case CAIRO_FORMAT_A1:
diff --git a/src/cairo.h b/src/cairo.h
index 5037b37..bf49069 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1342,6 +1342,9 @@ cairo_surface_set_fallback_resolution (c
  *   endianess of the platform. On a big-endian machine, the
  *   first pixel is in the uppermost bit, on a little-endian
  *   machine the first pixel is in the least-significant bit.
+ * @CAIRO_FORMAT_RGB16_565: each pixel is a 16-bit quantity,
+ *   with red in the upper 5 bits, then green in the next 6,
+ *   then blue in the lowest 5 bits.
  *
  * #cairo_format_t is used to identify the memory format of
  * image data.
@@ -1350,7 +1353,8 @@ typedef enum _cairo_format {
     CAIRO_FORMAT_ARGB32,
     CAIRO_FORMAT_RGB24,
     CAIRO_FORMAT_A8,
-    CAIRO_FORMAT_A1
+    CAIRO_FORMAT_A1,
+    CAIRO_FORMAT_RGB16_565
 } cairo_format_t;
 
 cairo_public cairo_surface_t *


More information about the cairo-commit mailing list