diff -r 6077402eaced src/cairo-deprecated.h --- a/src/cairo-deprecated.h Thu Mar 18 13:41:47 2010 +0200 +++ b/src/cairo-deprecated.h Thu Mar 18 13:43:32 2010 +0200 @@ -43,17 +43,17 @@ * backend can work fine with 16-bit visuals in the same way it works * with BGR visuals without any BGR formats in * #cairo_format_t). * * Additionally, the support for the RGB16_565 format was never * completely implemented. So while this format value is currently * deprecated, it may eventually acquire complete support in the future. */ -#define CAIRO_FORMAT_RGB16_565 4 +/* #define CAIRO_FORMAT_RGB16_565 4 */ #define CAIRO_FONT_TYPE_ATSUI CAIRO_FONT_TYPE_QUARTZ /* Obsolete functions. These definitions exist to coerce the compiler * into providing a little bit of guidance with its error * messages. The idea is to help users port their old code without * having to dig through lots of documentation. * diff -r 6077402eaced src/cairo-image-surface.c --- a/src/cairo-image-surface.c Thu Mar 18 13:41:47 2010 +0200 +++ b/src/cairo-image-surface.c Thu Mar 18 13:43:32 2010 +0200 @@ -44,18 +44,20 @@ _cairo_format_from_pixman_format (pixman case PIXMAN_a8r8g8b8: return CAIRO_FORMAT_ARGB32; case PIXMAN_x8r8g8b8: return CAIRO_FORMAT_RGB24; case PIXMAN_a8: return CAIRO_FORMAT_A8; case PIXMAN_a1: return CAIRO_FORMAT_A1; + case PIXMAN_r5g6b5: + return CAIRO_FORMAT_RGB16_565; case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8: - case PIXMAN_b8g8r8: case PIXMAN_r5g6b5: case PIXMAN_b5g6r5: + case PIXMAN_b8g8r8: case PIXMAN_b5g6r5: case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5: case PIXMAN_x1b5g5r5: case PIXMAN_a4r4g4b4: case PIXMAN_x4r4g4b4: case PIXMAN_a4b4g4r4: case PIXMAN_x4b4g4r4: case PIXMAN_r3g3b2: case PIXMAN_b2g3r3: case PIXMAN_a2r2g2b2: case PIXMAN_a2b2g2r2: case PIXMAN_c8: case PIXMAN_g8: case PIXMAN_x4a4: case PIXMAN_a4: case PIXMAN_r1g2b1: case PIXMAN_b1g2r1: case PIXMAN_a1r1g1b1: case PIXMAN_a1b1g1r1: case PIXMAN_c4: case PIXMAN_g4: case PIXMAN_g1: @@ -301,16 +303,19 @@ _cairo_format_to_pixman_format_code (cai ret = PIXMAN_a1; break; case CAIRO_FORMAT_A8: ret = PIXMAN_a8; break; case CAIRO_FORMAT_RGB24: ret = PIXMAN_x8r8g8b8; break; + case CAIRO_FORMAT_RGB16_565: + ret = PIXMAN_r5g6b5; + break; case CAIRO_FORMAT_ARGB32: default: ret = PIXMAN_a8r8g8b8; break; } return ret; } @@ -666,16 +671,18 @@ _cairo_format_from_content (cairo_conten cairo_content_t _cairo_content_from_format (cairo_format_t format) { switch (format) { case CAIRO_FORMAT_ARGB32: return CAIRO_CONTENT_COLOR_ALPHA; case CAIRO_FORMAT_RGB24: return CAIRO_CONTENT_COLOR; + case CAIRO_FORMAT_RGB16_565: + return CAIRO_CONTENT_COLOR; case CAIRO_FORMAT_A8: case CAIRO_FORMAT_A1: return CAIRO_CONTENT_ALPHA; } ASSERT_NOT_REACHED; return CAIRO_CONTENT_COLOR_ALPHA; } @@ -683,16 +690,18 @@ _cairo_content_from_format (cairo_format int _cairo_format_bits_per_pixel (cairo_format_t format) { switch (format) { case CAIRO_FORMAT_ARGB32: return 32; case CAIRO_FORMAT_RGB24: return 32; + case CAIRO_FORMAT_RGB16_565: + return 16; case CAIRO_FORMAT_A8: return 8; case CAIRO_FORMAT_A1: return 1; default: ASSERT_NOT_REACHED; return 0; } @@ -1359,16 +1368,21 @@ _cairo_image_analyze_transparency (cairo if (image->transparency != CAIRO_IMAGE_UNKNOWN) return image->transparency; if (image->format == CAIRO_FORMAT_RGB24) { image->transparency = CAIRO_IMAGE_IS_OPAQUE; return CAIRO_IMAGE_IS_OPAQUE; } + if (image->format == CAIRO_FORMAT_RGB16_565) { + image->transparency = CAIRO_IMAGE_IS_OPAQUE; + return CAIRO_IMAGE_IS_OPAQUE; + } + if (image->format != CAIRO_FORMAT_ARGB32) { image->transparency = CAIRO_IMAGE_HAS_ALPHA; return CAIRO_IMAGE_HAS_ALPHA; } image->transparency = CAIRO_IMAGE_IS_OPAQUE; for (y = 0; y < image->height; y++) { uint32_t *pixel = (uint32_t *) (image->data + y * image->stride); diff -r 6077402eaced src/cairo-xlib-display.c --- a/src/cairo-xlib-display.c Thu Mar 18 13:41:47 2010 +0200 +++ b/src/cairo-xlib-display.c Thu Mar 18 13:43:32 2010 +0200 @@ -505,21 +505,43 @@ _cairo_xlib_display_get_xrender_format ( switch (format) { case CAIRO_FORMAT_A1: pict_format = PictStandardA1; break; case CAIRO_FORMAT_A8: pict_format = PictStandardA8; break; case CAIRO_FORMAT_RGB24: pict_format = PictStandardRGB24; break; + case CAIRO_FORMAT_RGB16_565: { + Visual *visual = NULL; + Screen *screen = DefaultScreenOfDisplay(display->display); + int j; + for (j = 0; j < screen->ndepths; j++) { + Depth *d = &screen->depths[j]; + if (d->depth == 16 && d->nvisuals && &d->visuals[0]) { + if (d->visuals[0].red_mask == 0xf800 && + d->visuals[0].green_mask == 0x7e0 && + d->visuals[0].blue_mask == 0x1f) + visual = &d->visuals[0]; + break; + } + } + if (!visual) { + CAIRO_MUTEX_UNLOCK (display->mutex); + return NULL; + } + xrender_format = XRenderFindVisualFormat(display->display, visual); + break; + } default: ASSERT_NOT_REACHED; case CAIRO_FORMAT_ARGB32: pict_format = PictStandardARGB32; break; } - xrender_format = XRenderFindStandardFormat (display->display, - pict_format); + if (!xrender_format) + xrender_format = XRenderFindStandardFormat (display->display, + pict_format); display->cached_xrender_formats[format] = xrender_format; } CAIRO_MUTEX_UNLOCK (display->mutex); return xrender_format; } diff -r 6077402eaced src/cairo-xlib-private.h --- a/src/cairo-xlib-private.h Thu Mar 18 13:41:47 2010 +0200 +++ b/src/cairo-xlib-private.h Thu Mar 18 13:43:32 2010 +0200 @@ -59,17 +59,17 @@ struct _cairo_xlib_hook { struct _cairo_xlib_display { cairo_xlib_display_t *next; cairo_reference_count_t ref_count; cairo_mutex_t mutex; Display *display; cairo_xlib_screen_info_t *screens; - XRenderPictFormat *cached_xrender_formats[CAIRO_FORMAT_A1 + 1]; + XRenderPictFormat *cached_xrender_formats[CAIRO_FORMAT_RGB16_565 + 1]; cairo_xlib_job_t *workqueue; cairo_freelist_t wq_freelist; cairo_xlib_hook_t *close_display_hooks; unsigned int buggy_repeat :1; unsigned int closed :1; }; diff -r 6077402eaced src/cairo.h --- a/src/cairo.h Thu Mar 18 13:41:47 2010 +0200 +++ b/src/cairo.h Thu Mar 18 13:43:32 2010 +0200 @@ -2019,21 +2019,18 @@ cairo_surface_has_show_text_glyphs (cair * image data. * * New entries may be added in future versions. **/ typedef enum _cairo_format { CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_RGB24, CAIRO_FORMAT_A8, - CAIRO_FORMAT_A1 - /* The value of 4 is reserved by a deprecated enum value. - * The next format added must have an explicit value of 5. - CAIRO_FORMAT_RGB16_565 = 4, - */ + CAIRO_FORMAT_A1, + CAIRO_FORMAT_RGB16_565 } cairo_format_t; cairo_public cairo_surface_t * cairo_image_surface_create (cairo_format_t format, int width, int height); cairo_public int diff -r 6077402eaced src/cairoint.h --- a/src/cairoint.h Thu Mar 18 13:41:47 2010 +0200 +++ b/src/cairoint.h Thu Mar 18 13:43:32 2010 +0200 @@ -1968,17 +1968,17 @@ _cairo_surface_has_device_transform (cai * * If we do decide to start fully supporting RGB16_565 as an external * format, then %CAIRO_FORMAT_VALID needs to be adjusted to include * it. But that should not happen before all necessary code is fixed * to support it (at least cairo_surface_write_to_png() and a few spots * in cairo-xlib-surface.c--again see -Wswitch-enum). */ #define CAIRO_FORMAT_INVALID ((unsigned int) -1) -#define CAIRO_FORMAT_VALID(format) ((format) <= CAIRO_FORMAT_A1) +#define CAIRO_FORMAT_VALID(format) ((format) <= CAIRO_FORMAT_RGB16_565) /* pixman-required stride alignment in bytes. */ #define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t)) #define CAIRO_STRIDE_FOR_WIDTH_BPP(w,bpp) \ (((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & ~(CAIRO_STRIDE_ALIGNMENT-1) #define CAIRO_CONTENT_VALID(content) ((content) && \ (((content) & ~(CAIRO_CONTENT_COLOR | \