2 https://cgit.freedesktop.org/cairo/commit/?id=71e8a4c23019b01aa43b334fcb2784c70daae9b5
3 https://bugs.freedesktop.org/show_bug.cgi?id=34177
5 diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
6 --- a/gfx/cairo/cairo/src/cairo-image-surface.c
7 +++ b/gfx/cairo/cairo/src/cairo-image-surface.c
8 @@ -870,17 +870,17 @@ static cairo_bool_t
9 *ty = _pixman_nearest_sample (*ty);
11 if (*tx != floor (*tx) || *ty != floor (*ty))
14 return fabs (*tx) < PIXMAN_MAX_INT && fabs (*ty) < PIXMAN_MAX_INT;
18 +#if PIXMAN_HAS_ATOMIC_OPS
19 static pixman_image_t *__pixman_transparent_image;
20 static pixman_image_t *__pixman_black_image;
21 static pixman_image_t *__pixman_white_image;
23 static pixman_image_t *
24 _pixman_transparent_image (void)
26 pixman_image_t *image;
27 @@ -964,56 +964,59 @@ static pixman_image_t *
28 pixman_image_ref (image);
31 pixman_image_ref (image);
37 -static pixman_image_t *
38 -_pixman_transparent_image (void)
40 - return _pixman_image_for_solid (&_cairo_pattern_clear);
42 -static pixman_image_t *
43 -_pixman_black_image (void)
45 - return _pixman_image_for_solid (&_cairo_pattern_black);
47 -static pixman_image_t *
48 -_pixman_white_image (void)
50 - return _pixman_image_for_solid (&_cairo_pattern_white);
55 hars_petruska_f54_1_random (void)
57 #define rol(x,k) ((x << k) | (x >> (32-k)))
59 return x = (x ^ rol (x, 5) ^ rol (x, 24)) + 0x37798849;
65 pixman_image_t *image;
69 +#else /* !PIXMAN_HAS_ATOMIC_OPS */
70 +static pixman_image_t *
71 +_pixman_transparent_image (void)
73 + return _pixman_image_for_solid (&_cairo_pattern_clear);
76 +static pixman_image_t *
77 +_pixman_black_image (void)
79 + return _pixman_image_for_solid (&_cairo_pattern_black);
82 +static pixman_image_t *
83 +_pixman_white_image (void)
85 + return _pixman_image_for_solid (&_cairo_pattern_white);
87 +#endif /* !PIXMAN_HAS_ATOMIC_OPS */
90 _cairo_image_reset_static_data (void)
92 +#if PIXMAN_HAS_ATOMIC_OPS
94 pixman_image_unref (cache[--n_cached].image);
97 if (__pixman_transparent_image) {
98 pixman_image_unref (__pixman_transparent_image);
99 __pixman_transparent_image = NULL;
102 if (__pixman_black_image) {
103 pixman_image_unref (__pixman_black_image);
104 __pixman_black_image = NULL;
105 @@ -1026,19 +1029,20 @@ void
109 static pixman_image_t *
110 _pixman_image_for_solid (const cairo_solid_pattern_t *pattern)
112 pixman_color_t color;
113 pixman_image_t *image;
115 +#if PIXMAN_HAS_ATOMIC_OPS
119 if (pattern->color.alpha_short <= 0x00ff)
120 return _pixman_transparent_image ();
122 if (pattern->color.alpha_short >= 0xff00) {
123 if (pattern->color.red_short <= 0x00ff &&
124 pattern->color.green_short <= 0x00ff &&
125 pattern->color.blue_short <= 0x00ff)
127 @@ -1047,46 +1051,48 @@ static pixman_image_t *
129 if (pattern->color.red_short >= 0xff00 &&
130 pattern->color.green_short >= 0xff00 &&
131 pattern->color.blue_short >= 0xff00)
133 return _pixman_white_image ();
138 CAIRO_MUTEX_LOCK (_cairo_image_solid_cache_mutex);
139 for (i = 0; i < n_cached; i++) {
140 if (_cairo_color_equal (&cache[i].color, &pattern->color)) {
141 image = pixman_image_ref (cache[i].image);
147 color.red = pattern->color.red_short;
148 color.green = pattern->color.green_short;
149 color.blue = pattern->color.blue_short;
150 color.alpha = pattern->color.alpha_short;
152 image = pixman_image_create_solid_fill (&color);
153 +#if PIXMAN_HAS_ATOMIC_OPS
157 if (n_cached < ARRAY_LENGTH (cache)) {
160 i = hars_petruska_f54_1_random () % ARRAY_LENGTH (cache);
161 pixman_image_unref (cache[i].image);
163 cache[i].image = pixman_image_ref (image);
164 cache[i].color = pattern->color;
167 CAIRO_MUTEX_UNLOCK (_cairo_image_solid_cache_mutex);
173 clamp (double val, double min, double max)
175 return val < min ? min : (val > max ? max : val);
177 @@ -1423,25 +1429,27 @@ static pixman_image_t *
178 return _pixman_transparent_image ();
182 return _pixel_to_solid (source, sample.x, sample.y);
186 +#if PIXMAN_HAS_ATOMIC_OPS
187 /* avoid allocating a 'pattern' image if we can reuse the original */
188 if (extend == CAIRO_EXTEND_NONE &&
189 _cairo_matrix_is_translation (&pattern->base.matrix) &&
190 _nearest_sample (filter, &tx, &ty))
194 return pixman_image_ref (source->pixman_image);
198 pixman_image = pixman_image_create_bits (source->pixman_format,
201 (uint32_t *) source->data,
203 if (unlikely (pixman_image == NULL))
205 @@ -1466,31 +1474,36 @@ static pixman_image_t *
206 sub->extents.x + sample.x,
207 sub->extents.y + sample.y);
209 if (extend == CAIRO_EXTEND_NONE)
210 return _pixman_transparent_image ();
214 +#if PIXMAN_HAS_ATOMIC_OPS
216 _cairo_matrix_is_translation (&pattern->base.matrix) &&
217 _nearest_sample (filter, &tx, &ty))
219 *ix = tx + sub->extents.x;
220 *iy = ty + sub->extents.y;
221 return pixman_image_ref (source->pixman_image);
225 /* Avoid sub-byte offsets, force a copy in that case. */
226 if (PIXMAN_FORMAT_BPP (source->pixman_format) >= 8) {
227 + void *data = source->data
228 + + sub->extents.x * PIXMAN_FORMAT_BPP(source->pixman_format)/8
229 + + sub->extents.y * source->stride;
230 pixman_image = pixman_image_create_bits (source->pixman_format,
233 - (uint32_t *) (source->data + sub->extents.x * PIXMAN_FORMAT_BPP(source->pixman_format)/8 + sub->extents.y * source->stride),
236 if (unlikely (pixman_image == NULL))
242 if (pixman_image == NULL) {