diff --git a/pixman/src/icformat.c b/pixman/src/icformat.c index f13328363..62a171da8 100644 --- a/pixman/src/icformat.c +++ b/pixman/src/icformat.c @@ -47,6 +47,12 @@ pixman_format_create (pixman_format_name_t 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 1c98fd9ac..e92522799 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 e94673c38..bddf6c16b 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_format_t *pixman_format) 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 format) 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_t 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 5037b37fa..bf49069e3 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -1342,6 +1342,9 @@ cairo_surface_set_fallback_resolution (cairo_surface_t *surface, * 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 *