--- cairo-1.12.6/src/cairo-image-surface.c 2012-09-13 13:38:21.000000000 +0200 +++ cairo-1.12.6_ht/src/cairo-image-surface.c 2012-11-06 22:46:21.000000000 +0100 @@ -301,7 +301,7 @@ ret = PIXMAN_a1; break; case CAIRO_FORMAT_A8: - ret = PIXMAN_a8; + ret = PIXMAN_a8; // NOT for color content !! break; case CAIRO_FORMAT_RGB24: ret = PIXMAN_x8r8g8b8; --- cairo-1.12.6/src/cairo-xlib-surface.c 2012-09-27 22:38:56.000000000 +0200 +++ cairo-1.12.6_ht/src/cairo-xlib-surface.c 2012-11-07 13:22:34.000000000 +0100 @@ -536,6 +541,7 @@ ximage->bitmap_bit_order != native_byte_order) { _swap_ximage_bits (ximage); + ximage->bitmap_bit_order = native_byte_order; if (ximage->bitmap_bit_order == ximage->byte_order) return; } @@ -563,7 +569,7 @@ /* This could be hit on some rare but possible cases. */ ASSERT_NOT_REACHED; } - + switch (unit_bytes) { case 1: break; @@ -579,6 +585,7 @@ default: ASSERT_NOT_REACHED; } + ximage->byte_order = native_byte_order; } @@ -1096,27 +1103,22 @@ cairo_bool_t is_rgb_image; GC gc; - ximage.width = image->width; - ximage.height = image->height; - ximage.format = ZPixmap; - ximage.byte_order = native_byte_order; - ximage.bitmap_unit = 32; /* always for libpixman */ - ximage.bitmap_bit_order = native_byte_order; - ximage.bitmap_pad = 32; /* always for libpixman */ - ximage.depth = surface->depth; - ximage.red_mask = surface->r_mask; - ximage.green_mask = surface->g_mask; - ximage.blue_mask = surface->b_mask; - ximage.xoffset = 0; - ximage.obdata = NULL; - status = _cairo_xlib_display_acquire (surface->base.device, &display); if (unlikely (status)) return status; + { + XImage * ximaget; + ximaget = XCreateImage(display->display,surface->visual + ,surface->depth,ZPixmap,0,NULL,width,height,32,image->stride ); + memcpy(&ximage,ximaget,sizeof(ximage)); + XDestroyImage(ximaget); + } + ximage.byte_order = native_byte_order; + is_rgb_image = _pixman_format_to_masks (image->pixman_format, &image_masks); - if (is_rgb_image && + if (ximage.depth > 8 && is_rgb_image && (image_masks.alpha_mask == surface->a_mask || surface->a_mask == 0) && (image_masks.red_mask == surface->r_mask || surface->r_mask == 0) && (image_masks.green_mask == surface->g_mask || surface->g_mask == 0) && --- cairo-1.12.6/src/cairo-xlib-core-compositor.c 2012-04-19 14:17:58.000000000 +0200 +++ cairo-1.12.6_ht/src/cairo-xlib-core-compositor.c 2012-11-06 22:43:44.000000000 +0100 @@ -112,18 +112,43 @@ uint32_t rgba = 0; int width, shift; - _characterize_field (dst->a_mask, &width, &shift); - rgba |= color->alpha_short >> (16 - width) << shift; - - _characterize_field (dst->r_mask, &width, &shift); - rgba |= color->red_short >> (16 - width) << shift; + if(dst->depth <9 ) // pseudo color + { + cairo_status_t status; + cairo_xlib_visual_info_t *visual_info = NULL; + unsigned short r,g,b; + status = _cairo_xlib_screen_get_visual_info (dst->display, + dst->screen, + dst->visual, + &visual_info); + if (unlikely (status)) + return 0xff; + + // part from: _pseudocolor_from_rgb888_dither + r = color->red_short >> 8; + g = color->green_short >> 8; + b = color->blue_short >> 8; + + if (r == g && g == b) { + rgba = visual_info->gray8_to_pseudocolor[r]; + } else { + rgba = visual_info->cube_to_pseudocolor[visual_info->field8_to_cube[r]] + [visual_info->field8_to_cube[g]] + [visual_info->field8_to_cube[b]]; + } + } else { + _characterize_field (dst->a_mask, &width, &shift); + rgba |= color->alpha_short >> (16 - width) << shift; - _characterize_field (dst->g_mask, &width, &shift); - rgba |= color->green_short >> (16 - width) << shift; + _characterize_field (dst->r_mask, &width, &shift); + rgba |= color->red_short >> (16 - width) << shift; - _characterize_field (dst->b_mask, &width, &shift); - rgba |= color->blue_short >> (16 - width) << shift; + _characterize_field (dst->g_mask, &width, &shift); + rgba |= color->green_short >> (16 - width) << shift; + _characterize_field (dst->b_mask, &width, &shift); + rgba |= color->blue_short >> (16 - width) << shift; + } return rgba; } @@ -228,7 +253,7 @@ /* XXX create_similar_image using pixman_format? */ switch (dst->depth) { - case 8: fb.format = CAIRO_FORMAT_A8; break; + case 8: fb.format = CAIRO_FORMAT_ARGB32; break; // CAIRO_FORMAT_A8; break; /* mh: A8 has no color information !!! */ case 16: fb.format = CAIRO_FORMAT_RGB16_565; break; case 24: fb.format = CAIRO_FORMAT_RGB24; break; case 30: fb.format = CAIRO_FORMAT_RGB30; break; --- cairo-1.12.6/src/cairo-xlib-core-compositor.c 2012-04-19 14:17:58.000000000 +0200 +++ cairo-1.12.6_ht/src/cairo-xlib-core-compositor.c 2012-11-06 22:43:44.000000000 +0100 @@ -112,18 +112,43 @@ uint32_t rgba = 0; int width, shift; - _characterize_field (dst->a_mask, &width, &shift); - rgba |= color->alpha_short >> (16 - width) << shift; - - _characterize_field (dst->r_mask, &width, &shift); - rgba |= color->red_short >> (16 - width) << shift; + if(dst->depth <9 ) // pseudo color + { + cairo_status_t status; + cairo_xlib_visual_info_t *visual_info = NULL; + unsigned short r,g,b; + status = _cairo_xlib_screen_get_visual_info (dst->display, + dst->screen, + dst->visual, + &visual_info); + if (unlikely (status)) + return 0xff; + + // part from: _pseudocolor_from_rgb888_dither + r = color->red_short >> 8; + g = color->green_short >> 8; + b = color->blue_short >> 8; + + if (r == g && g == b) { + rgba = visual_info->gray8_to_pseudocolor[r]; + } else { + rgba = visual_info->cube_to_pseudocolor[visual_info->field8_to_cube[r]] + [visual_info->field8_to_cube[g]] + [visual_info->field8_to_cube[b]]; + } + } else { + _characterize_field (dst->a_mask, &width, &shift); + rgba |= color->alpha_short >> (16 - width) << shift; - _characterize_field (dst->g_mask, &width, &shift); - rgba |= color->green_short >> (16 - width) << shift; + _characterize_field (dst->r_mask, &width, &shift); + rgba |= color->red_short >> (16 - width) << shift; - _characterize_field (dst->b_mask, &width, &shift); - rgba |= color->blue_short >> (16 - width) << shift; + _characterize_field (dst->g_mask, &width, &shift); + rgba |= color->green_short >> (16 - width) << shift; + _characterize_field (dst->b_mask, &width, &shift); + rgba |= color->blue_short >> (16 - width) << shift; + } return rgba; } @@ -228,7 +253,7 @@ /* XXX create_similar_image using pixman_format? */ switch (dst->depth) { - case 8: fb.format = CAIRO_FORMAT_A8; break; + case 8: fb.format = CAIRO_FORMAT_ARGB32; break; // CAIRO_FORMAT_A8; break; /* mh: A8 has no color information !!! */ case 16: fb.format = CAIRO_FORMAT_RGB16_565; break; case 24: fb.format = CAIRO_FORMAT_RGB24; break; case 30: fb.format = CAIRO_FORMAT_RGB30; break; --- cairo-1.12.6/src/cairo-xlib-screen.c 2012-04-19 14:17:58.000000000 +0200 +++ cairo-1.12.6_ht/src/cairo-xlib-screen.c 2012-11-07 12:25:29.000000000 +0100 @@ -298,6 +298,7 @@ _cairo_xlib_visual_info_destroy (cairo_list_first_entry (&info->visuals, cairo_xlib_visual_info_t, link)); + cairo_list_del(&info->visuals); // mh } cairo_list_del (&info->link);