--- cairo-1.12.8/src/cairo-image-surface.c 2012-09-13 13:38:21.000000000 +0200 +++ cairo-1.12.8_ht/src/cairo-image-surface.c 2012-11-07 22:26:50.000000000 +0100 @@ -300,9 +300,9 @@ case CAIRO_FORMAT_A1: 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; break; --- cairo-1.12.8/src/cairo-xlib-surface.c 2012-09-27 22:38:56.000000000 +0200 +++ cairo-1.12.8_ht/src/cairo-xlib-surface.c 2012-11-07 22:28:56.000000000 +0100 @@ -535,8 +535,9 @@ if (ximage->bits_per_pixel == 1 && 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; } @@ -578,8 +579,9 @@ break; default: ASSERT_NOT_REACHED; } + ximage->byte_order = native_byte_order; } /* Given a mask, (with a single sequence of contiguous 1 bits), return @@ -1095,29 +1097,24 @@ cairo_bool_t own_data; 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) && (image_masks.blue_mask == surface->b_mask || surface->b_mask == 0)) --- cairo-1.12.8/src/cairo-xlib-core-compositor.c 2012-04-19 14:17:58.000000000 +0200 +++ cairo-1.12.8_ht/src/cairo-xlib-core-compositor.c 2012-11-07 22:26:50.000000000 +0100 @@ -111,20 +111,45 @@ { 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; } static cairo_int_status_t @@ -227,9 +252,9 @@ struct _fallback_box fb; /* 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; case 32: fb.format = CAIRO_FORMAT_ARGB32; break; --- cairo-1.12.8/src/cairo-xlib-core-compositor.c 2012-04-19 14:17:58.000000000 +0200 +++ cairo-1.12.8_ht/src/cairo-xlib-core-compositor.c 2012-11-07 22:26:50.000000000 +0100 @@ -111,20 +111,45 @@ { 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; } static cairo_int_status_t @@ -227,9 +252,9 @@ struct _fallback_box fb; /* 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; case 32: fb.format = CAIRO_FORMAT_ARGB32; break; --- cairo-1.12.8/src/cairo-xlib-screen.c 2012-04-19 14:17:58.000000000 +0200 +++ cairo-1.12.8_ht/src/cairo-xlib-screen.c 2012-11-07 22:26:50.000000000 +0100 @@ -297,8 +297,9 @@ while (! cairo_list_is_empty (&info->visuals)) { _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);