pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/graphics/cairo sync the patch dealing with 8-bit displ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8c2beee73336
branches:  trunk
changeset: 535974:8c2beee73336
user:      drochner <drochner%pkgsrc.org@localhost>
date:      Fri Nov 30 20:49:24 2007 +0000

description:
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

diffstat:

 graphics/cairo/distinfo         |    4 +-
 graphics/cairo/patches/patch-ae |  117 +++++++++++++++++++++++++++++++++------
 2 files changed, 99 insertions(+), 22 deletions(-)

diffs (227 lines):

diff -r 2f388d44d4fb -r 8c2beee73336 graphics/cairo/distinfo
--- a/graphics/cairo/distinfo   Fri Nov 30 20:46:18 2007 +0000
+++ b/graphics/cairo/distinfo   Fri Nov 30 20:49:24 2007 +0000
@@ -1,8 +1,8 @@
-$NetBSD: distinfo,v 1.37 2007/11/29 22:13:58 wiz Exp $
+$NetBSD: distinfo,v 1.38 2007/11/30 20:49:24 drochner Exp $
 
 SHA1 (cairo-1.4.12.tar.gz) = 45d5257e5a0c1524bcc25660a96b2c79d012ad3f
 RMD160 (cairo-1.4.12.tar.gz) = 5ed65d5872c0561f3392e60007898d9360d83d0a
 Size (cairo-1.4.12.tar.gz) = 3276610 bytes
 SHA1 (patch-aa) = 79c04674fde56522e1f09e5896fcef4c6b6a0d36
 SHA1 (patch-ab) = c6b98417270f7165aa3499d92d0ca9c19bdd4318
-SHA1 (patch-ae) = 6d3eea66cbd03007dcdef97b5f5bd033f0b6afcd
+SHA1 (patch-ae) = 0b5c35720f9b675f132ca4da8c7e6e2b69c2f1a1
diff -r 2f388d44d4fb -r 8c2beee73336 graphics/cairo/patches/patch-ae
--- a/graphics/cairo/patches/patch-ae   Fri Nov 30 20:46:18 2007 +0000
+++ b/graphics/cairo/patches/patch-ae   Fri Nov 30 20:49:24 2007 +0000
@@ -1,10 +1,10 @@
-$NetBSD: patch-ae,v 1.8 2007/06/15 17:47:59 drochner Exp $
+$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-05-09 15:37:39.000000000 +0200
-+++ src/cairo-xlib-surface-private.h   2007-06-15 14:15:41.000000000 +0200
+--- 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;
@@ -20,18 +20,30 @@
  struct _cairo_xlib_surface {
      cairo_surface_t base;
  
-@@ -89,6 +97,8 @@ struct _cairo_xlib_surface {
+@@ -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-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)
+--- 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)
      }
  }
  
@@ -106,11 +118,11 @@
  static cairo_status_t
  _get_image_surface (cairo_xlib_surface_t    *surface,
                    cairo_rectangle_int16_t *interest_rect,
-@@ -650,6 +718,36 @@ _get_image_surface (cairo_xlib_surface_t
+@@ -655,18 +727,77 @@ _get_image_surface (cairo_xlib_surface_t
      }
      else
      {
-+        if (surface->clut != NULL) {
++        if ((surface->clut != NULL) && (surface->workaround == WORKAROUND_8BIT_PALETTE)) {
 +          
 +                  /*
 +           * Otherwise, we construct a buffer containing RGB24 data
@@ -122,7 +134,7 @@
 +
 +          data = (uint32_t*)malloc(ximage->height * ximage->width * 4);
 +          if (data == NULL) {
-+              printf("Cannot allocate RGB buffer\n");
++              _cairo_error(CAIRO_STATUS_NO_MEMORY);
 +              goto FAIL;
 +          }
 +
@@ -139,11 +151,45 @@
 +              cairo_image_surface_create_for_data ((unsigned char *)data,
 +                   CAIRO_FORMAT_RGB24, ximage->width, ximage->height,
 +                   ximage->width*4);
-+        } else {
++        } 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
-@@ -662,6 +760,8 @@ _get_image_surface (cairo_xlib_surface_t
+        * 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);
@@ -152,7 +198,7 @@
        if (image->base.status)
            goto FAIL;
      }
-@@ -757,6 +857,31 @@ _cairo_xlib_surface_ensure_gc (cairo_xli
+@@ -770,6 +901,31 @@ _cairo_xlib_surface_ensure_gc (cairo_xli
      return CAIRO_STATUS_SUCCESS;
  }
  
@@ -184,7 +230,7 @@
  static cairo_status_t
  _draw_image_surface (cairo_xlib_surface_t   *surface,
                     cairo_image_surface_t  *image,
-@@ -769,22 +894,54 @@ _draw_image_surface (cairo_xlib_surface_
+@@ -782,22 +938,78 @@ _draw_image_surface (cairo_xlib_surface_
  {
      XImage ximage;
      unsigned int bpp, alpha, red, green, blue;
@@ -196,7 +242,7 @@
      pixman_format_get_masks (pixman_image_get_format (image->pixman_image),
                             &bpp, &alpha, &red, &green, &blue);
  
-+    if (surface->clut != NULL) {
++    if ((surface->clut != NULL) && (surface->workaround == WORKAROUND_8BIT_PALETTE)) {
 +      static unsigned char *buf = NULL;
 +      static int size = 0;
 +      int i, j;
@@ -222,8 +268,32 @@
 +      depth = bpp = 8;
 +              ximage.data = data;
 +
-+    } else {
-+       ximage.data = (char *)image->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;j<image->height;j++) {
++            dst8 = data + j * stride;
++            for (i=0;i<image->width;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;
@@ -242,17 +312,24 @@
      ximage.bits_per_pixel = bpp;
      ximage.red_mask = red;
      ximage.green_mask = green;
-@@ -2029,6 +2186,13 @@ _cairo_xlib_surface_create_internal (Dis
+@@ -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->class == PseudoColor || visual->class == StaticColor)) {
++       (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;
  }



Home | Main Index | Thread Index | Old Index