head 1.10; access; symbols pkgsrc-2013Q2:1.10.0.18 pkgsrc-2013Q2-base:1.10 pkgsrc-2012Q4:1.10.0.16 pkgsrc-2012Q4-base:1.10 pkgsrc-2011Q4:1.10.0.14 pkgsrc-2011Q4-base:1.10 pkgsrc-2011Q2:1.10.0.12 pkgsrc-2011Q2-base:1.10 pkgsrc-2009Q4:1.10.0.10 pkgsrc-2009Q4-base:1.10 pkgsrc-2008Q4:1.10.0.8 pkgsrc-2008Q4-base:1.10 pkgsrc-2008Q3:1.10.0.6 pkgsrc-2008Q3-base:1.10 cube-native-xorg:1.10.0.4 cube-native-xorg-base:1.10 pkgsrc-2008Q2:1.10.0.2 pkgsrc-2008Q2-base:1.10 pkgsrc-2008Q1:1.9.0.4 pkgsrc-2008Q1-base:1.9 pkgsrc-2007Q4:1.9.0.2 pkgsrc-2007Q4-base:1.9 pkgsrc-2007Q3:1.8.0.4 pkgsrc-2007Q3-base:1.8 pkgsrc-2007Q2:1.8.0.2 pkgsrc-2007Q2-base:1.8 pkgsrc-2007Q1:1.6.0.2 pkgsrc-2007Q1-base:1.6 pkgsrc-2006Q4:1.5.0.4 pkgsrc-2006Q4-base:1.5 pkgsrc-2006Q3:1.5.0.2 pkgsrc-2006Q3-base:1.5; locks; strict; comment @# @; 1.10 date 2008.04.21.11.29.33; author tnn; state dead; branches; next 1.9; 1.9 date 2007.11.30.20.49.25; author drochner; state Exp; branches; next 1.8; 1.8 date 2007.06.15.17.47.59; author drochner; state Exp; branches; next 1.7; 1.7 date 2007.06.08.07.20.53; author wiz; state Exp; branches; next 1.6; 1.6 date 2007.03.20.15.29.22; author drochner; state Exp; branches; next 1.5; 1.5 date 2006.09.29.13.43.41; author drochner; state Exp; branches; next 1.4; 1.4 date 2006.08.31.11.17.19; author dmcmahill; state Exp; branches; next 1.3; 1.3 date 2006.08.31.11.12.58; author dmcmahill; state Exp; branches; next 1.2; 1.2 date 2006.08.10.13.50.37; author wiz; state dead; branches; next 1.1; 1.1 date 2006.07.25.01.48.54; author minskim; state Exp; branches; next ; desc @@ 1.10 log @Update to cairo-1.6.4. Major changes between the 1.4 and 1.6 branch: - Now uses external "pixman" library instead of a bundled one. - Improvements to PDF, SVG and PostScript output - New support for arbitrary X server visuals (the 8-bit display support patch (patch-ae in pkgsrc) is integrated) - rendering backend improvements - various new API additions, while maintaining ABI compatibility - New Quartz backend - bug fixes @ text @$NetBSD: patch-ae,v 1.9 2007/11/30 20:49:25 drochner Exp $ Fixes cairo on 8-bit pseudo color and other 8-bit displays. See https://bugs.freedesktop.org/show_bug.cgi?id=4945 --- src/cairo-xlib-surface-private.h.orig 2007-11-27 07:20:12.000000000 +0100 +++ src/cairo-xlib-surface-private.h @@@@ -39,6 +39,14 @@@@ typedef struct _cairo_xlib_surface cairo_xlib_surface_t; +struct clut_r3g3b2 { + struct clut_r3g3b2 *next; + Display *dpy; + Colormap cmap; + uint32_t clut[256]; + unsigned char ilut[256]; +}; + struct _cairo_xlib_surface { cairo_surface_t base; @@@@ -89,6 +97,9 @@@@ struct _cairo_xlib_surface { cairo_filter_t filter; int repeat; XTransform xtransform; + + struct clut_r3g3b2 *clut; + int workaround; }; enum { --- src/cairo-xlib-surface.c.orig 2007-11-27 07:20:12.000000000 +0100 +++ src/cairo-xlib-surface.c @@@@ -108,6 +108,10 @@@@ static const XTransform identity = { { #define CAIRO_SURFACE_RENDER_HAS_PICTURE_TRANSFORM(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 6) #define CAIRO_SURFACE_RENDER_HAS_FILTERS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 6) +#define WORKAROUND_NONE 0 +#define WORKAROUND_8BIT_PALETTE 1 +#define WORKAROUND_8BIT_DIRECT 2 + static int _CAIRO_FORMAT_DEPTH (cairo_format_t format) { @@@@ -494,6 +498,74 @@@@ _swap_ximage_to_native (XImage *ximage) } } +static struct clut_r3g3b2 * _get_clut_r3g3b2(Display *dpy, Colormap cmap) { + static struct clut_r3g3b2 *first = NULL; + int i,j, min, d; + struct clut_r3g3b2 *clut; + unsigned char r,g,b, r2,g2,b2; + + clut = first; + while(clut) { + if ( clut->dpy == dpy && clut->cmap == cmap ) + return clut; + clut = clut->next; + } + + clut = calloc(1, sizeof(*clut)); + if(clut == NULL) + return NULL; + + clut->next = first; + clut->dpy = dpy; + clut->cmap = cmap; + first = clut; + + /* Construct the clut from Colormap */ + for (i = 0; i < 256; i++) { + XColor xcol; + xcol.pixel = i; + XQueryColor(dpy, cmap, &xcol); + clut->clut[i] = ( ( ((uint32_t)xcol.red & 0xff00 ) << 8) | + ( ((uint32_t)xcol.green & 0xff00 ) ) | + ( ((uint32_t)xcol.blue & 0xff00 ) >> 8) ); + } + /* + + Find the best matching color in the colormap for all r3g3b2 + values. The distance is maybe not perceptively valid, but it + should not be too bad. + + */ + for (i = 0; i < 256; i++) { + r = i >> 5; + g = (i >> 2) & 0x7; + b = (i << 1) & 0x7; + min = 255; + for(j = 0; j < 256; j++) { + r2 = (clut->clut[j] & 0xff0000) >> 21; + g2 = (clut->clut[j] & 0x00ff00) >> 13; + b2 = (clut->clut[j] & 0x0000ff) >> 5; + if ( r2 == r && g2 == g && (b2 & 0x6) == b ) { + clut->ilut[i] = j; + break; + } + /* + Squares make higher bits much more important than lower + ones. + */ + d = (r2 ^ r) * (r2 ^ r); + d += (g2 ^ g) * (g2 ^ g); + d += (b2 ^ b) * (b2 ^ b); + if(d < min) { + clut->ilut[i] = j; + min = d; + } + } + } + + return clut; +} + static cairo_status_t _get_image_surface (cairo_xlib_surface_t *surface, cairo_rectangle_int16_t *interest_rect, @@@@ -655,18 +727,77 @@@@ _get_image_surface (cairo_xlib_surface_t } else { + if ((surface->clut != NULL) && (surface->workaround == WORKAROUND_8BIT_PALETTE)) { + + /* + * Otherwise, we construct a buffer containing RGB24 data + * using the specified workaround. + */ + uint32_t *data, *dst, *clut; + uint8_t *src8; + int i,j; + + data = (uint32_t*)malloc(ximage->height * ximage->width * 4); + if (data == NULL) { + _cairo_error(CAIRO_STATUS_NO_MEMORY); + goto FAIL; + } + + clut = surface->clut->clut; + src8 = (uint8_t*) ximage->data; + dst = data; + for (j = 0; j < ximage->height; j++) { + for (i = 0; i < ximage->width; i++) + *dst++ = clut[src8[i]]; + src8 += ximage->bytes_per_line; + } + free(ximage->data); + image = (cairo_image_surface_t*) + cairo_image_surface_create_for_data ((unsigned char *)data, + CAIRO_FORMAT_RGB24, ximage->width, ximage->height, + ximage->width*4); + } else if (surface->workaround == WORKAROUND_8BIT_DIRECT) { + + uint32_t *data, *dst; + uint8_t *src8; + int i,j; + + data = (uint32_t*)malloc(ximage->height * ximage->width * 4); + if (data == NULL) { + _cairo_error(CAIRO_STATUS_NO_MEMORY); + goto FAIL; + } + + src8 = (uint8_t*) ximage->data; + dst = data; + for (j = 0; j < ximage->height; j++) { + for (i = 0; i < ximage->width; i++) + *dst++ = (src8[i] & masks.red_mask << 21) | + (src8[i] & masks.green_mask << 10 ) | + (src8[i] & masks.blue_mask ); + + src8 += ximage->bytes_per_line; + } + free(ximage->data); + image = (cairo_image_surface_t*) + cairo_image_surface_create_for_data ((unsigned char *)data, + CAIRO_FORMAT_RGB24, ximage->width, ximage->height, + ximage->width*4); + }else if (surface->workaround == WORKAROUND_NONE){ /* * XXX This can't work. We must convert the data to one of the * supported pixman formats. Pixman needs another function * which takes data in an arbitrary format and converts it * to something supported by that library. */ - image = (cairo_image_surface_t*) - _cairo_image_surface_create_with_masks ((unsigned char *) ximage->data, + image = (cairo_image_surface_t*) + _cairo_image_surface_create_with_masks ((unsigned char *) ximage->data, &masks, ximage->width, ximage->height, ximage->bytes_per_line); + } + if (image->base.status) goto FAIL; } @@@@ -770,6 +901,31 @@@@ _cairo_xlib_surface_ensure_gc (cairo_xli return CAIRO_STATUS_SUCCESS; } +static int +_make_space_for(unsigned char ** buf, int *size, int *stride, int width, int height, int Bpp) +{ + unsigned char * data; + int l; + + *stride = width * Bpp; + if(*stride%4) + *stride += 4 - *stride % 4; + l = (*stride * height); + if (*size < l) { + if(*buf) + data = realloc(*buf, l); + else + data = malloc(l); + if(data) { + *buf = data; + *size = l; + } else { + return -1; + } + } + return 0; +} + static cairo_status_t _draw_image_surface (cairo_xlib_surface_t *surface, cairo_image_surface_t *image, @@@@ -782,22 +938,78 @@@@ _draw_image_surface (cairo_xlib_surface_ { XImage ximage; unsigned int bpp, alpha, red, green, blue; + unsigned int depth = image->depth; + unsigned int stride = image->stride; int native_byte_order = _native_byte_order_lsb () ? LSBFirst : MSBFirst; cairo_status_t status; pixman_format_get_masks (pixman_image_get_format (image->pixman_image), &bpp, &alpha, &red, &green, &blue); + if ((surface->clut != NULL) && (surface->workaround == WORKAROUND_8BIT_PALETTE)) { + static unsigned char *buf = NULL; + static int size = 0; + int i, j; + unsigned char *data, *ilut; + uint32_t *src; + uint8_t *dst8; + + if (_make_space_for(&buf, &size, &stride, image->width, image->height, 1)) + return CAIRO_STATUS_NO_MEMORY; + data = buf; + src = (uint32_t*)image->data; + ilut = surface->clut->ilut; + for (j=0;jheight;j++) { + dst8 = data + j * stride; + for (i=0;iwidth;i++) { + dst8[i] = ilut[ ((*src >> 16) & 0xe0) | + ((*src >> 11) & 0x1c) | + ((*src >> 6) & 0x03) ]; + src++; + } + } + alpha = red = green = blue = 0; + depth = bpp = 8; + ximage.data = data; + + }else if (surface->workaround == WORKAROUND_8BIT_DIRECT){ + static unsigned char *buf = NULL; + static int size = 0; + int i, j; + unsigned char *data; + uint32_t *src; + uint8_t *dst8; + + if (_make_space_for(&buf, &size, &stride, image->width, image->height, 1)) + return CAIRO_STATUS_NO_MEMORY; + data = buf; + src = (uint32_t*)image->data; + for (j=0;jheight;j++) { + dst8 = data + j * stride; + for (i=0;iwidth;i++) { + dst8[i] = ((*src >> 16) & 0xe0) | + ((*src >> 11) & 0x1c) | + ((*src >> 6) & 0x03) ; + src++; + } + } + alpha = red = green = blue = 0; + depth = bpp = 8; + ximage.data = data; + } else if( surface->workaround == WORKAROUND_NONE){ + ximage.data = (char *)image->data; + } + ximage.width = image->width; ximage.height = image->height; ximage.format = ZPixmap; - ximage.data = (char *)image->data; + // ximage.data is assigned above 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 = image->depth; - ximage.bytes_per_line = image->stride; + ximage.depth = depth; + ximage.bytes_per_line = stride; ximage.bits_per_pixel = bpp; ximage.red_mask = red; ximage.green_mask = green; @@@@ -2043,6 +2255,20 @@@@ _cairo_xlib_surface_create_internal (Dis surface->have_clip_rects = FALSE; surface->clip_rects = surface->embedded_clip_rects; surface->num_clip_rects = 0; + surface->clut = NULL; + + if (xrender_format == NULL && + (visual==NULL?FALSE:(visual->class == PseudoColor || visual->class == StaticColor))) { + surface->clut = _get_clut_r3g3b2(dpy, + DefaultColormapOfScreen(surface->screen)); + }else if (xrender_format == NULL && + (visual==NULL?FALSE:((visual->class == TrueColor) + && (surface->visual->red_mask == 0x07) + && (surface->visual->green_mask == 0x38) + && (surface->visual->blue_mask == 0xc0)))) + surface->workaround = WORKAROUND_8BIT_DIRECT; + else + surface->workaround = WORKAROUND_NONE; return (cairo_surface_t *) surface; } @ 1.9 log @sync the patch dealing with 8-bit displays with the last version from https://bugs.freedesktop.org/show_bug.cgi?id=4945 ride on recent update @ text @d1 1 a1 1 $NetBSD$ @ 1.8 log @update to 1.4.8 This is the fourth update in cairo's stable 1.4 series. It comes just over five weeks after the 1.4.6 release. This release includes a thread-safe surface-cache for solid patterns which significantly improves text rendering with the xlib backend. Also, dozens of error paths in cairo have been fixed thanks to extensive fault-injection testing by Chris Wilson. @ text @d6 2 a7 2 --- src/cairo-xlib-surface-private.h.orig 2007-05-09 15:37:39.000000000 +0200 +++ src/cairo-xlib-surface-private.h 2007-06-15 14:15:41.000000000 +0200 d23 1 a23 1 @@@@ -89,6 +97,8 @@@@ struct _cairo_xlib_surface { d29 1 d33 14 a46 3 --- src/cairo-xlib-surface.c.orig 2007-06-07 19:44:01.000000000 +0200 +++ src/cairo-xlib-surface.c 2007-06-15 14:13:26.000000000 +0200 @@@@ -489,6 +489,74 @@@@ _swap_ximage_to_native (XImage *ximage) d121 1 a121 1 @@@@ -650,6 +718,36 @@@@ _get_image_surface (cairo_xlib_surface_t d125 1 a125 1 + if (surface->clut != NULL) { d137 1 a137 1 + printf("Cannot allocate RGB buffer\n"); d154 28 a181 1 + } else { d185 8 a192 1 @@@@ -662,6 +760,8 @@@@ _get_image_surface (cairo_xlib_surface_t d201 1 a201 1 @@@@ -757,6 +857,31 @@@@ _cairo_xlib_surface_ensure_gc (cairo_xli d233 1 a233 1 @@@@ -769,22 +894,54 @@@@ _draw_image_surface (cairo_xlib_surface_ d245 1 a245 1 + if (surface->clut != NULL) { d271 26 a296 2 + } else { + ximage.data = (char *)image->data; d315 1 a315 1 @@@@ -2029,6 +2186,13 @@@@ _cairo_xlib_surface_create_internal (Dis d322 1 a322 1 + (visual->class == PseudoColor || visual->class == StaticColor)) { d325 8 a332 1 + } @ 1.7 log @Update to 1.4.6: Release 1.4.6 (2007-05-01 Carl Worth ) ========================================================= This is the third update in cairo's stable 1.4 series. It comes a little less than three weeks since the 1.4.4 release. This release fixes the broken mutex initialization that made cairo 1.4.4 unusable on win32, OS/2, and BeOS systems. This release also adds significant improvements to cairo's PDF backend, (native gradients!), and a couple of performance optimizations, (one of which is very significant for users of the xlib backend). Release 1.4.4 (2007-04-13 Carl Worth ) ========================================================= This is the second update release in cairo's stable 1.4 series. It comes just less than a month after 1.4.2. The changes since 1.4.2 consist primarily of bug fixes, but also include at least one optimization. See below for details. There have been lots of individuals doing lots of great work on cairo, but two efforts during the 1.4.4 series deserve particular mention: Internal cleanup of error handling, (Chris Wilson) -------------------------------------------------- Chris contributed a tremendous series of patches (74 patches!) to improve cairo's handling of out-of-memory and other errors. He began by adding gcc's warn_unused_attribute to as many functions as possible, and then launched into the ambitious efforts of adding correct code to quiet the dozens of resulting warnings. Chris also wrote a custom valgrind skin to systematically inject malloc failures into cairo, and did all the work necessary to verify that cairo's performance test suite runs to completion without crashing. The end result is a much more robust implementation. Previously, many error conditions would have gone unnoticed and would have led to assertion failures, segmentation faults, or other harder-to-diagnose problems. Now, more than ever, cairo should cleanly let the user know of problems through cairo_status and other similar status functions. Well done, Chris! More malloc reduction, (Mathias Hasselmann) ------------------------------------------- After 1.4.0, Behdad launched an effort to chase down excessive calls to malloc within the implementation of cairo. He fixed a lot of malloc-happy objects for 1.4.2, but one of the worst offenders, (pixman regions), was left around. Mathias contributed an excellent series of 15 patches to finish off this effort. The end result is a cairo that calls malloc much less often than it did before. Compared to 1.4.2, 55% of the calls to malloc have been eliminate, (and 60% have been eliminated compared to 1.4.0). Well done, Mathias! @ text @d6 2 a7 2 --- src/cairo-xlib-surface-private.h-orig 2007-05-02 14:43:14.184165000 +0800 +++ src/cairo-xlib-surface-private.h 2007-05-02 14:50:38.143706000 +0800 d23 1 a23 1 @@@@ -88,6 +96,8 @@@@ struct _cairo_xlib_surface { d31 4 a34 4 #endif /* CAIRO_XLIB_SURFACE_PRIVATE_H */ --- src/cairo-xlib-surface.c-orig 2007-05-02 14:55:09.281677000 +0800 +++ src/cairo-xlib-surface.c 2007-05-02 14:53:31.401179000 +0800 @@@@ -446,6 +446,74 @@@@ _swap_ximage_to_native (XImage *ximage) d109 1 a109 1 @@@@ -607,6 +675,36 @@@@ _get_image_surface (cairo_xlib_surface_t d146 1 a146 1 @@@@ -619,6 +717,8 @@@@ _get_image_surface (cairo_xlib_surface_t d155 1 a155 1 @@@@ -698,6 +798,31 @@@@ _cairo_xlib_surface_ensure_gc (cairo_xli d187 1 a187 1 @@@@ -710,22 +835,54 @@@@ _draw_image_surface (cairo_xlib_surface_ d245 1 a245 1 @@@@ -1885,6 +2042,13 @@@@ _cairo_xlib_surface_create_internal (Dis @ 1.6 log @update to 1.4.2 This switches to the new stable branch. Too many changes to list here, see the changelog. Most notably: speed improvements, PDF output improvement, API additions, bugfixes. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.5 2006/09/29 13:43:41 drochner Exp $ d6 3 a8 3 --- src/cairo-xlib-surface.c.orig 2007-03-02 01:04:59.000000000 +0000 +++ src/cairo-xlib-surface.c @@@@ -82,6 +82,8 @@@@ _cairo_xlib_surface_show_glyphs (void d10 1 a10 1 #define CAIRO_ASSUME_PIXMAP 20 d12 7 a18 1 +struct clut_r3g3b2; d23 4 a26 4 @@@@ -127,6 +129,8 @@@@ struct _cairo_xlib_surface { int num_clip_rects; XRenderPictFormat *xrender_format; d31 4 a34 2 #define CAIRO_SURFACE_RENDER_AT_LEAST(surface, major, minor) \ @@@@ -503,6 +507,82 @@@@ _swap_ximage_to_native (XImage *ximage) a37 8 +struct clut_r3g3b2 { + struct clut_r3g3b2 *next; + Display *dpy; + Colormap cmap; + uint32_t clut[256]; + unsigned char ilut[256]; +}; + d109 1 a109 1 @@@@ -656,6 +736,35 @@@@ _get_image_surface (cairo_xlib_surface_t d113 1 a113 2 + + if(surface->clut != NULL) { d124 1 a124 1 + if(data == NULL) { d132 2 a133 2 + for(j = 0; j < ximage->height; j++) { + for(i = 0; i < ximage->width; i++) d139 3 a141 1 + cairo_image_surface_create_for_data((unsigned char *)data, CAIRO_FORMAT_RGB24, ximage->width, ximage->height, ximage->width*4); d146 1 a146 1 @@@@ -668,6 +777,8 @@@@ _get_image_surface (cairo_xlib_surface_t d155 2 a156 2 @@@@ -742,6 +853,32 @@@@ _cairo_xlib_surface_ensure_gc (cairo_xli _cairo_xlib_surface_set_gc_clip_rects (surface); a158 1 + d187 1 a187 1 @@@@ -754,21 +891,54 @@@@ _draw_image_surface (cairo_xlib_surface_ d194 1 d199 7 d207 1 a207 9 + if(surface->clut != NULL) { + static unsigned char *buf = NULL; + static int size = 0; + int i, j; + unsigned char *data, *ilut; + uint32_t *src; + uint8_t *dst8; + + if (_make_space_for(&buf, &size, &stride, image->width, image->height, 1)) d209 4 a212 4 + data = buf; + src = (uint32_t*)image->data; + ilut = surface->clut->ilut; + for(j=0;jheight;j++) { d214 5 a218 5 + for(i=0;iwidth;i++) { + dst8[i] = ilut[ ((*src >> 16) & 0xe0) | + ((*src >> 11) & 0x1c) | + ((*src >> 6) & 0x03) ]; + src++; d220 4 a223 4 + } + alpha = red = green = blue = 0; + depth = bpp = 8; + ximage.data = data; d226 1 a226 1 + ximage.data = (char *)image->data; d228 1 a228 1 + d245 1 a245 1 @@@@ -1899,7 +2069,13 @@@@ _cairo_xlib_surface_create_internal (Dis d247 1 a247 1 surface->clip_rects = NULL; d250 6 a256 5 + if (xrender_format == NULL && + (visual->class == PseudoColor || visual->class == StaticColor)) { + surface->clut = _get_clut_r3g3b2(dpy, + DefaultColormapOfScreen(surface->screen)); + } a258 1 @ 1.5 log @The last fix for pseudocolor displays broke 24-bit troecolor displays. Use a new patch from https://bugs.freedesktop.org/show_bug.cgi?id=4945 Bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD$ d3 1 a3 1 Fixes cairo on 8-bit psuedo color and other 8-bit displays. d6 1 a6 1 --- src/cairo-xlib-surface.c.orig 2006-08-18 16:20:16.000000000 +0200 d8 1 a8 1 @@@@ -81,6 +81,8 @@@@ _cairo_xlib_surface_show_glyphs (void d17 1 a17 1 @@@@ -126,6 +128,8 @@@@ struct _cairo_xlib_surface { d26 1 a26 1 @@@@ -504,6 +508,82 @@@@ _swap_ximage_to_native (XImage *ximage) d109 1 a109 1 @@@@ -657,6 +737,35 @@@@ _get_image_surface (cairo_xlib_surface_t d145 1 a145 1 @@@@ -669,6 +778,8 @@@@ _get_image_surface (cairo_xlib_surface_t d154 1 a154 1 @@@@ -743,6 +854,32 @@@@ _cairo_xlib_surface_ensure_gc (cairo_xli d187 1 a187 1 @@@@ -751,21 +888,54 @@@@ _draw_image_surface (cairo_xlib_surface_ d245 1 a245 1 @@@@ -1890,7 +2060,13 @@@@ _cairo_xlib_surface_create_internal (Dis @ 1.4 log @add a pointer to the cairo bug database @ text @d1 1 a1 4 $NetBSD: patch-ae,v 1.3 2006/08/31 11:12:58 dmcmahill Exp $ Adapted from: http://ekyo.nerim.net/software/patch-1.2.0-src_cairo-xlib-surface_c d4 1 d6 4 a9 8 The patch listed above is for 1.2.0 and took some minor modification to apply to 1.2.4. See https://bugs.freedesktop.org/show_bug.cgi?id=4945 for more details. --- src/cairo-xlib-surface.c.orig 2006-08-18 14:20:16.000000000 +0000 +++ src/cairo-xlib-surface.c 2006-08-31 10:53:10.000000000 +0000 @@@@ -82,4 +82,6 @@@@ d16 3 a18 1 @@@@ -127,4 +129,7 @@@@ a22 1 + int workaround; d25 3 a27 1 @@@@ -505,4 +510,158 @@@@ a29 19 +#if 0 +static void _set_optimal_cmap(Display *dpy, Colormap cmap) { + int i, r, g, b; + XColor cm[256]; + + for (i = 0; i < 256; i++) { + r = i >> 5; + g = (i >> 2) & 0x7; + b = (i << 1) & 0x7; + cm[i].pixel = i; + cm[i].flags = DoRed | DoGreen | DoBlue; + cm[i].red = r << 13 | r << 10 | r << 7 | r << 4 | r << 1 | r >> 2; + cm[i].green = g << 13 | g << 10 | g << 7 | g << 4 | g << 1 | g >> 2; + cm[i].blue = b << 13 | b << 10 | b << 7 | b << 4 | b << 1 | b >> 2; + } + XStoreColors(dpy, cmap, cm, 256); +} +#endif + a105 59 +static const char * _visualClass[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; + + +static void _print_visual(Visual *v) { + printf("Visual: class=%s, bpRGB=%i, CM=%i, r=%lx, g=%lx, b=%lx\n", + _visualClass[v->class], + v->bits_per_rgb, + v->map_entries, + v->red_mask, v->green_mask, v->blue_mask); +} + + +#if 0 +static void _print_ximage(XImage *x) { + const char * format[] = { "XYBitmap", "XYPixmap", "ZPixmap" }; + printf("XImage: size=(%i,%i), xoffset=%i, format=%s, depth=%i, bpp=%i, stride=%i\n r=%lx, g=%lx, b=%lx, unit=%i, pad=%i\n", + x->width, + x->height, + x->xoffset, + format[x->format], + x->depth, + x->bits_per_pixel, + x->bytes_per_line, + x->red_mask, x->green_mask, x->blue_mask, + x->bitmap_unit, x->bitmap_pad); +} + +const char * _cairoFormats[] = { "ARGB32", "RGB24", "A8", "A1" }; + +static void _print_cairoimage(cairo_image_surface_t *i) { + + printf("CairoImage: size=(%i,%i), format=%s, depth=%i, stride=%i\n", + i->width, + i->height, + _cairoFormats[i->format], + i->depth, + i->stride); +} + +static void _print_cairomasks(cairo_format_masks_t *m) { + printf("CairoFormatMask: bpp=%i, a=%lx, r=%lx, g=%lx, b=%lx\n", + m->bpp, m->alpha_mask, m->red_mask, m->green_mask, m->blue_mask); +} +#endif + +#define WORKAROUND_NONE 0 +#define WORKAROUND_8BIT_GRAYLEVEL 1 +#define WORKAROUND_8BIT_PALETTE 2 +#if 1 +#define WORKAROUND_R5G6B5 3 +#endif + d108 4 a111 1 @@@@ -659,17 +818,94 @@@@ a112 12 /* - * XXX This can't work. We must convert the data to one of the - * supported pixman formats. Pixman needs another function - * which takes data in an arbitrary format and converts it - * to something supported by that library. + * Otherwise, we construct a buffer containing RGB24 data + * using the specified workaround. */ + uint32_t *data, *dst, *clut; + uint8_t *src8; + uint16_t *src16; + int i,j; d114 1 a114 30 + if(surface->visual == NULL) { + printf("No visual for surface\n"); + goto FAIL; + } + + if (surface->workaround == WORKAROUND_NONE) { + printf("No workaround for this pixel format: "); + _print_visual(surface->visual); + goto FAIL; + } + + data = (uint32_t*)malloc(ximage->height * ximage->width * 4); + if(data == NULL) { + printf("Cannot allocate RGB buffer\n"); + goto FAIL; + } + + switch (surface->workaround) { + + case WORKAROUND_8BIT_GRAYLEVEL: + + dst = data; + for(j = 0; j < ximage->height; j++) { + src8 = (uint8_t *) (ximage->data + ximage->bytes_per_line * j); + for(i = 0; i < ximage->width; i++) { + *dst++ = (*src8 << 16) | (*src8 << 8) | *src8; + src8++; + } + } + break; d116 11 a126 10 + case WORKAROUND_8BIT_PALETTE: + + if(surface->clut == NULL) { + surface->clut = _get_clut_r3g3b2( + surface->dpy, + DefaultColormapOfScreen(surface->screen)); + } + + if(surface->clut == NULL) { + free(data); d138 11 a148 20 + break; +#if 1 + case WORKAROUND_R5G6B5: + + src16 = (uint16_t*)ximage->data; + dst = data; + for(j = 0; j < ximage->height; j++) { + for(i = 0; i < ximage->width; i++) { + *dst++ = ( ( ((src16[i] & 0xf800) << 8) | ((src16[i] & 0xe000) << 3) ) | + ( ((src16[i] & 0x07e0) << 5) | ((src16[i] & 0x0600) >> 1) ) | + ( ((src16[i] & 0x001f) << 3) | ((src16[i] & 0x001f) >> 2) ) ); + } + src16 += ximage->bytes_per_line / sizeof(*src16); + } + break; +#endif + default: + printf("Dunno what to do with: "); + _print_visual(surface->visual); + goto FAIL; a149 9 + free(ximage->data); image = (cairo_image_surface_t*) - _cairo_image_surface_create_with_masks ((unsigned char *) ximage->data, - &masks, - ximage->width, - ximage->height, - ximage->bytes_per_line); - if (image->base.status) + cairo_image_surface_create_for_data((unsigned char *)data, CAIRO_FORMAT_RGB24, ximage->width, ximage->height, ximage->width*4); d151 1 a151 3 + if (image->base.status) { + printf("Failed!\n"); + free(data); a152 1 + } d154 2 a155 2 @@@@ -744,4 +980,30 @@@@ d160 1 a160 1 +make_space_for(unsigned char ** buf, int *size, int *stride, int width, int height, int Bpp) d186 2 a187 2 @@@@ -750,6 +1012,12 @@@@ int dst_y) a188 2 + static unsigned char *buf = NULL; + static int size = 0; d190 3 a192 6 - unsigned int bpp, alpha, red, green, blue; + unsigned int bpp, alpha, red, green, blue, stride, depth, i, j; + unsigned char *data, *ilut; + uint32_t *src; + uint8_t *dst8; + uint16_t *dst16; d195 1 a195 1 @@@@ -757,14 +1025,87 @@@@ d199 25 a223 25 + switch(surface->workaround) { + case WORKAROUND_NONE: + /* Default behaviour is supposed to work */ + stride = image->width * 4; + depth = image->depth; + data = image->data; + break; + + case WORKAROUND_8BIT_GRAYLEVEL: + + if (make_space_for(&buf, &size, &stride, image->width, image->height, 1)) + return CAIRO_STATUS_NO_MEMORY; + data = buf; + + for(j=0;jheight;j++) { + src = (uint32_t*)(image->data); + dst8 = data + j * stride; + for(i=0;iwidth;i++) { + /* XXX use correct factor for each channel */ + dst8[i] = ( ((*src >> 16) & 0xff) + + ((*src >> 8) & 0xff) + + (*src & 0xff) ) / 3; + src++; + } + } d225 2 a226 41 + alpha = red = green = blue = 0; + depth = bpp = 8; + break; + + case WORKAROUND_8BIT_PALETTE: + + if (make_space_for(&buf, &size, &stride, image->width, image->height, 1)) + return CAIRO_STATUS_NO_MEMORY; + data = buf; + src = (uint32_t*)image->data; + ilut = surface->clut->ilut; + for(j=0;jheight;j++) { + dst8 = data + j * stride; + for(i=0;iwidth;i++) { + dst8[i] = ilut[ ((*src >> 16) & 0xe0) | + ((*src >> 11) & 0x1c) | + ((*src >> 6) & 0x03) ]; + src++; + } + } + alpha = red = green = blue = 0; + depth = bpp = 8; + break; + + case WORKAROUND_R5G6B5: + if (make_space_for(&buf, &size, &stride, image->width, image->height, 2)) + return CAIRO_STATUS_NO_MEMORY; + data = buf; + src = (uint32_t*)image->data; + for(j=0;jheight;j++) { + dst16 = (uint16_t*)(data + j * stride); + for(i=0;iwidth;i++) { + dst16[i] = ( ((*src >> 8) & 0xf800) | + ((*src >> 5) & 0x07e0) | + ((*src >> 3) & 0x001f) ); + src++; + } + } + alpha = 0; red = 0xf800; green = 0x07e0; blue = 0x001f; + depth = bpp = 16; + break; d233 1 a233 2 + //ximage.data = (char *)image->data; + ximage.data = data; a239 1 + //ximage.depth = image->depth; a240 1 + //ximage.bytes_per_line = image->stride; d244 3 a246 1 @@@@ -1891,4 +2232,28 @@@@ d250 5 a254 22 + surface->workaround = WORKAROUND_NONE; + + if (surface->xrender_format == NULL) { + /* Install the correct workaround */ + switch (visual->class) { + case StaticGray: + case GrayScale: + surface->workaround = WORKAROUND_8BIT_GRAYLEVEL; + break; + case PseudoColor: + case StaticColor: + surface->workaround = WORKAROUND_8BIT_PALETTE; + break; + case TrueColor: +#if 1 + if (visual->red_mask == 0xf800 && + visual->green_mask == 0x07e0 && + visual->blue_mask == 0x001f) { + surface->workaround = WORKAROUND_R5G6B5; + } +#endif + } d256 2 a258 1 return (cairo_surface_t *) surface; @ 1.3 log @Fix cairo on 8-bit psuedocolor displays. Finally I can use gtk again... @ text @d1 1 a1 1 $NetBSD$ d11 2 @ 1.2 log @Update to 1.2.2, some pkglint cleanup: Release 1.2.2 (2006-08-08 Carl Worth) ========================================================= This is the first bug fix release in the 1.2 series since the original 1.2.0 release made six weeks ago. There were some very serious bugs in the 1.2.0 release, (see below), so everybody is encouraged to upgrade from 1.2.0 to 1.2.2. The 1.2.2 release maintains source and binary compatibility with 1.2.0 and does not make any API additions. Fix crashes with BGR X servers ------------------------------ With cairo 1.2.0 many people reported problems with all cairo-using programs, (including all GTK+ programs with GTK+ >= 2.8) immediately crashing with a complaint about an unsupported image format. This bug affected X servers that do not provide the Render extension and that provide a visual with BGR rather than RGB channel order. report: https://bugs.freedesktop.org/show_bug.cgi?id=7294 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9ae66174e774b57f16ad791452ed44efc2770a59 Fix the "disappearing text" bug ------------------------------- With cairo 1.2.0 many people reported that text would disappear from applications, sometimes reappearing with mouse motion or selection. The text would disappear after the first space in a string of text. This bug was caused by an underlying bug in (very common) X servers, and only affected text rendered without antialiasing, (either a bitmap font or a vector font with antialiasing disabled). The bug was also exacerbated by a KDE migration bug that caused antialiasing to be disabled more than desired. report: https://bugs.freedesktop.org/show_bug.cgi?id=7494 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=456cdb3058f3b416109a9600167cd8842300ae14 see also: Xorg: https://bugs.freedesktop.org/show_bug.cgi?id=7681 KDE: http://qa.mandriva.com/show_bug.cgi?id=23990 Fix broken image fallback scaling (aka. "broken printing") ---------------------------------------------------------- The various "print" backends, (pdf, ps, and svg), sometimes fallback to using image-based rendering for some operations. In cairo 1.2.0 these image fallbacks were scaled improperly. Applications using cairo can influence the resolution of the image fallbacks with cairo_surface_set_fallback_resolution. With the bug, any calue other than 72.0 would lead to incorrect results, (larger values would lead to increasingly shrunken output). report: https://bugs.freedesktop.org/show_bug.cgi?id=7533 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=1feb4291cf7813494355459bb547eec604c54ffb Fix inadvertent semantic change of font matrix translation (Behdad Esfahbod) ---------------------------------------------------------------------------- The 1.2.0 release introduced an inadvertent change to how the translation components of a font matrix are interpreted. In the 1.0 series, font matrix translation could be used to offset the glyph origin, (though glyph metrics were reported incorrectly in 1.0). However in 1.2.0, the translation was applied to the advance values betwen each glyph. The 1.2.0 behavior is fairly useless in practice, and it was not intentional to introduce a semantic change. With 1.2.2 we return to the 1.0 semantics, with a much better implementation that provides correct glyph metrics. fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=84840e6bba6e72aa88fad7a0ee929e8955ba9051 Fix create_similar to preserve fallback resolution and font options (Behdad Esfahbod) ------------------------------------------------------------------------------------- There has been a long-standing issue with cairo_surface_create_similar such that font options and other settings from the original destination surface would not be preserved to the intermediate "similar" surface. This could result in incorrect rendering (particulary with respect to text hinting/antialiasing) with fallbacks, for example. report: https://bugs.freedesktop.org/show_bug.cgi?id=4106 fixes: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9fcb3c32c1f16fe6ab913e27eb54d18b7d9a06b0 http://gitweb.freedesktop.org/?p=cairo;a=commit;h=bdb4e1edadb78a2118ff70b28163f8bd4317f1ec xlib: Fix text performance regression from 1.0 to 1.2.0 (Vladimir Vukicevic) ---------------------------------------------------------------------------- Several people noticed that upgrading from cairo 1.0 to cairo 1.2.0 caused a significant peformance regression when using the xlib backend. This performance regression was particularly noticeable when doing lots of text rendering and when using a high-latency connection to the X server, (such as a remote X server over an ssh connection). The slowdown was identified and fixed in 1.2.2. report: https://bugs.freedesktop.org/show_bug.cgi?id=7514 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=b7191885c88068dad57d68ced69a752d1162b12c PDF: Eliminate dependency on FreeType library dependency (Adrian Johnson) ------------------------------------------------------------------------- The cairo 1.2 series adds a supported pdf backend to cairo. In cairo 1.2.0 this backend required the freetype library, which was an undesirable dependency on systems such as win32, (cairo is designed to always prefer the "native" font system). As of cairo 1.2.2 the freetype library is not required to use the pdf backend on the win32 platform. report: https://bugs.freedesktop.org/show_bug.cgi?id=7538 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=a0989f427be87c60415963dd6822b3c5c3781691 PDF: Fix broken output on amd64 (Adrian Johnson) ------------------------------------------------ report: http://bugzilla.gnome.org/show_bug.cgi?id=349826 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=f4b12e497b7ac282b2f6831b8fb68deebc412e60 PS: Fix broken output for truetype fonts > 64k (Adrian Johnson) --------------------------------------------------------------- fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=067d97eb1793a6b0d0dddfbd0b54117844511a94 PDF: Fix so that dashing doesn't get stuck on (Kent Worsnop) ------------------------------------------------------------ Kent notices that with the PDF backend in cairo 1.2.0 as soon as a stroke was performed with dashing, all subsequent strokes would also be dashed. There was no way to turn dashing off again. fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=778c4730a86296bf0a71080cf7008d7291792256 Fix memory leaks in failure paths in gradient creation (Alfred Peng) -------------------------------------------------------------------- fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=db06681b487873788b51a6766894fc619eb8d8f2 Fix memory leak in _cairo_surface_show_glyphs (Chris Wilson) ------------------------------------------------------------ report: https://bugs.freedesktop.org/show_bug.cgi?id=7766 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=e2fddcccb43d06486d3680a19cfdd5a54963fcbd Solaris: Add definition of cairo_private for some Sun compilers (Alfred Peng) ----------------------------------------------------------------------------- report: https://bugzilla.mozilla.org/show_bug.cgi?id=341874 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=04757a3aa8deeff3265719ebe01b021638990ec6 Solaris: Change version number of Sun's Xorg server with buggy repeat (Brian Cameron) ------------------------------------------------------------------------------------- report: https://bugs.freedesktop.org/show_bug.cgi?id=7483 fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=e0ad1aa995bcec4246c0b8ab0d5a5a79871ce235 Various memory leak fixes ------------------------- Fix memory leak in _cairo_surface_show_glyphs (bug 7766) Fix file handle leak in failure path (bug 7616) Fix some memory leaks in the test cases. Fix some memory leaks in font subsetting code used in print backends. Documentation improvements (Behdad Esfahbod) -------------------------------------------- Added new documentation for several functions (cairo_show_page, cairo_copy_page, cairo_in_stroke, cairo_in_fill). Fixed some syntax errors that were preventing some existing documentation from being published. Fixed several minor typographical errors. Added an index for new symbols in 1.2. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.1 2006/07/25 01:48:54 minskim Exp $ d3 2 a4 1 https://bugs.freedesktop.org/show_bug.cgi?id=7401 d6 319 a324 3 --- test/cairo-test.c.orig 2006-06-30 17:03:52.000000000 -0700 +++ test/cairo-test.c @@@@ -1635,7 +1635,7 @@@@ cairo_test_expecting (cairo_test_t *test d326 129 a454 19 volatile int i, j, num_targets; const char *tname; - sighandler_t old_segfault_handler; + void (*old_segfault_handler)(int); cairo_test_status_t status, ret; cairo_test_target_t **targets_to_test; cairo_test_target_t targets[] = @@@@ -1841,12 +1841,12 @@@@ cairo_test_expecting (cairo_test_t *test dev_offset); /* Set up a checkpoint to get back to in case of segfaults. */ - old_segfault_handler = signal (SIGSEGV, (sighandler_t) segfault_handler); + old_segfault_handler = signal (SIGSEGV, segfault_handler); if (0 == setjmp (jmpbuf)) status = cairo_test_for_target (test, draw, target, dev_offset); else status = CAIRO_TEST_CRASHED; - signal (SIGSEGV, (sighandler_t) old_segfault_handler); + signal (SIGSEGV, old_segfault_handler); d456 1 a456 2 cairo_test_log ("TEST: %s TARGET: %s FORMAT: %s OFFSET: %d RESULT: ", test->name, target->name, @ 1.1 log @Add a workaround for freedesktop.org bug 7401, so that 'make test' works. Patch from cairo cvs. @ text @d1 1 a1 1 $NetBSD$ @