Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / x11 / pixman / patches / patch-bc
blob16cf0ffc241f9bf58a3a205ce14a1a154363743b
1 $NetBSD: patch-bc,v 1.2 2012/05/12 17:38:32 wiz Exp $
3 --- pixman/pixman.c.orig        2012-12-10 11:34:13.000000000 +0000
4 +++ pixman/pixman.c
5 @@ -152,6 +152,57 @@ optimize_operator (pixman_op_t     op,
6      return operator_table[op].opaque_info[is_dest_opaque | is_source_opaque];
7  }
8  
9 +static void
10 +apply_workaround (pixman_image_t *image,
11 +                 int32_t *       x,
12 +                 int32_t *       y,
13 +                 uint32_t **     save_bits,
14 +                 int *           save_dx,
15 +                 int *           save_dy)
17 +    if (image && (image->common.flags & FAST_PATH_NEEDS_WORKAROUND))
18 +    {
19 +       /* Some X servers generate images that point to the
20 +        * wrong place in memory, but then set the clip region
21 +        * to point to the right place. Because of an old bug
22 +        * in pixman, this would actually work.
23 +        *
24 +        * Here we try and undo the damage
25 +        */
26 +       int bpp = PIXMAN_FORMAT_BPP (image->bits.format) / 8;
27 +       pixman_box32_t *extents;
28 +       uint8_t *t;
29 +       int dx, dy;
30 +       
31 +       extents = pixman_region32_extents (&(image->common.clip_region));
32 +       dx = extents->x1;
33 +       dy = extents->y1;
34 +       
35 +       *save_bits = image->bits.bits;
36 +       
37 +       *x -= dx;
38 +       *y -= dy;
39 +       pixman_region32_translate (&(image->common.clip_region), -dx, -dy);
40 +       
41 +       t = (uint8_t *)image->bits.bits;
42 +       t += dy * image->bits.rowstride * 4 + dx * bpp;
43 +       image->bits.bits = (uint32_t *)t;
44 +       
45 +       *save_dx = dx;
46 +       *save_dy = dy;
47 +    }
50 +static void
51 +unapply_workaround (pixman_image_t *image, uint32_t *bits, int dx, int dy)
53 +    if (image && (image->common.flags & FAST_PATH_NEEDS_WORKAROUND))
54 +    {
55 +       image->bits.bits = bits;
56 +       pixman_region32_translate (&image->common.clip_region, dx, dy);
57 +    }
60  /*
61   * Computing composite region
62   */
63 @@ -576,6 +627,13 @@ pixman_image_composite32 (pixman_op_t   
64      uint32_t src_flags, mask_flags, dest_flags;
65      pixman_region32_t region;
66      pixman_box32_t extents;
67 +    uint32_t *src_bits;
68 +    int src_dx, src_dy;
69 +    uint32_t *mask_bits;
70 +    int mask_dx, mask_dy;
71 +    uint32_t *dest_bits;
72 +    int dest_dx, dest_dy;
73 +    pixman_bool_t need_workaround;
74      pixman_implementation_t *imp;
75      pixman_composite_func_t func;
77 @@ -614,6 +672,16 @@ pixman_image_composite32 (pixman_op_t   
78             src_format = mask_format = PIXMAN_rpixbuf;
79      }
81 +    /* Check for workaround */
82 +    need_workaround = (src_flags | mask_flags | dest_flags) & FAST_PATH_NEEDS_WORKAROUND;
84 +    if (need_workaround)
85 +    {
86 +       apply_workaround (src, &src_x, &src_y, &src_bits, &src_dx, &src_dy);
87 +       apply_workaround (mask, &mask_x, &mask_y, &mask_bits, &mask_dx, &mask_dy);
88 +       apply_workaround (dest, &dest_x, &dest_y, &dest_bits, &dest_dx, &dest_dy);
89 +    }
91      pixman_region32_init (&region);
93      if (!_pixman_compute_composite_region32 (
94 @@ -707,6 +775,13 @@ pixman_image_composite32 (pixman_op_t   
95      }
97  out:
98 +    if (need_workaround)
99 +    {
100 +       unapply_workaround (src, src_bits, src_dx, src_dy);
101 +       unapply_workaround (mask, mask_bits, mask_dx, mask_dy);
102 +       unapply_workaround (dest, dest_bits, dest_dx, dest_dy);
103 +    }
105      pixman_region32_fini (&region);