24
25
#ifdef HAVE_CONFIG_H
25
26
#include <config.h>
28
29
#include <stdlib.h>
30
31
#include "pixman-private.h"
31
#include "pixman-mmx.h"
32
#include "pixman-sse2.h"
34
#if defined(USE_SSE2) && defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
35
__attribute__((__force_align_arg_pointer__))
37
PIXMAN_EXPORT pixman_bool_t
38
pixman_blt (uint32_t *src_bits,
46
int width, int height)
49
if (pixman_have_sse2())
51
return pixmanBltsse2 (src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
52
src_x, src_y, dst_x, dst_y, width, height);
57
if (pixman_have_mmx())
59
return pixman_blt_mmx (src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
60
src_x, src_y, dst_x, dst_y, width, height);
68
pixman_fill8 (uint32_t *bits,
76
int byte_stride = stride * (int) sizeof (uint32_t);
77
uint8_t *dst = (uint8_t *) bits;
78
uint8_t v = xor & 0xff;
81
dst = dst + y * byte_stride + x;
85
for (i = 0; i < width; ++i)
93
pixman_fill16 (uint32_t *bits,
101
int short_stride = (stride * (int) sizeof (uint32_t)) / (int) sizeof (uint16_t);
102
uint16_t *dst = (uint16_t *)bits;
103
uint16_t v = xor & 0xffff;
106
dst = dst + y * short_stride + x;
110
for (i = 0; i < width; ++i)
118
pixman_fill32 (uint32_t *bits,
128
bits = bits + y * stride + x;
132
for (i = 0; i < width; ++i)
139
#if defined(USE_SSE2) && defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
140
__attribute__((__force_align_arg_pointer__))
142
PIXMAN_EXPORT pixman_bool_t
143
pixman_fill (uint32_t *bits,
153
printf ("filling: %d %d %d %d (stride: %d, bpp: %d) pixel: %x\n",
154
x, y, width, height, stride, bpp, xor);
158
if (pixman_have_sse2() && pixmanFillsse2 (bits, stride, bpp, x, y, width, height, xor))
163
if (pixman_have_mmx() && pixman_fill_mmx (bits, stride, bpp, x, y, width, height, xor))
170
pixman_fill8 (bits, stride, x, y, width, height, xor);
174
pixman_fill16 (bits, stride, x, y, width, height, xor);
178
pixman_fill32 (bits, stride, x, y, width, height, xor);
34
* Computing composite region
36
#define BOUND(v) (int16_t) ((v) < INT16_MIN ? INT16_MIN : (v) > INT16_MAX ? INT16_MAX : (v))
38
static inline pixman_bool_t
39
clip_general_image (pixman_region32_t * region,
40
pixman_region32_t * clip,
44
if (pixman_region32_n_rects (region) == 1 &&
45
pixman_region32_n_rects (clip) == 1)
47
pixman_box32_t * rbox = pixman_region32_rectangles (region, NULL);
48
pixman_box32_t * cbox = pixman_region32_rectangles (clip, NULL);
51
if (rbox->x1 < (v = cbox->x1 + dx))
53
if (rbox->x2 > (v = cbox->x2 + dx))
55
if (rbox->y1 < (v = cbox->y1 + dy))
57
if (rbox->y2 > (v = cbox->y2 + dy))
59
if (rbox->x1 >= rbox->x2 ||
62
pixman_region32_init (region);
65
else if (!pixman_region32_not_empty (clip))
72
pixman_region32_translate (region, -dx, -dy);
73
if (!pixman_region32_intersect (region, region, clip))
76
pixman_region32_translate (region, dx, dy);
78
return pixman_region32_not_empty (region);
81
static inline pixman_bool_t
82
clip_source_image (pixman_region32_t * region,
83
pixman_image_t * image,
87
/* Source clips are ignored, unless they are explicitly turned on
88
* and the clip in question was set by an X client. (Because if
89
* the clip was not set by a client, then it is a hierarchy
90
* clip and those should always be ignored for sources).
92
if (!image->common.clip_sources || !image->common.client_clip)
95
return clip_general_image (region,
96
&image->common.clip_region,
101
* returns FALSE if the final region is empty. Indistinguishable from
102
* an allocation failure, but rendering ignores those anyways.
105
pixman_compute_composite_region32 (pixman_region32_t * region,
106
pixman_image_t * src_image,
107
pixman_image_t * mask_image,
108
pixman_image_t * dst_image,
120
region->extents.x1 = dest_x;
122
region->extents.x2 = BOUND (v);
123
region->extents.y1 = dest_y;
125
region->extents.y2 = BOUND (v);
127
region->extents.x1 = MAX (region->extents.x1, 0);
128
region->extents.y1 = MAX (region->extents.y1, 0);
129
region->extents.x2 = MIN (region->extents.x2, dst_image->bits.width);
130
region->extents.y2 = MIN (region->extents.y2, dst_image->bits.height);
134
/* Check for empty operation */
135
if (region->extents.x1 >= region->extents.x2 ||
136
region->extents.y1 >= region->extents.y2)
138
pixman_region32_init (region);
142
if (dst_image->common.have_clip_region)
144
if (!clip_general_image (region, &dst_image->common.clip_region, 0, 0))
146
pixman_region32_fini (region);
151
if (dst_image->common.alpha_map && dst_image->common.alpha_map->common.have_clip_region)
153
if (!clip_general_image (region, &dst_image->common.alpha_map->common.clip_region,
154
-dst_image->common.alpha_origin_x,
155
-dst_image->common.alpha_origin_y))
157
pixman_region32_fini (region);
162
/* clip against src */
163
if (src_image->common.have_clip_region)
165
if (!clip_source_image (region, src_image, dest_x - src_x, dest_y - src_y))
167
pixman_region32_fini (region);
171
if (src_image->common.alpha_map && src_image->common.alpha_map->common.have_clip_region)
173
if (!clip_source_image (region, (pixman_image_t *)src_image->common.alpha_map,
174
dest_x - (src_x - src_image->common.alpha_origin_x),
175
dest_y - (src_y - src_image->common.alpha_origin_y)))
177
pixman_region32_fini (region);
181
/* clip against mask */
182
if (mask_image && mask_image->common.have_clip_region)
184
if (!clip_source_image (region, mask_image, dest_x - mask_x, dest_y - mask_y))
186
pixman_region32_fini (region);
189
if (mask_image->common.alpha_map && mask_image->common.alpha_map->common.have_clip_region)
191
if (!clip_source_image (region, (pixman_image_t *)mask_image->common.alpha_map,
192
dest_x - (mask_x - mask_image->common.alpha_origin_x),
193
dest_y - (mask_y - mask_image->common.alpha_origin_y)))
195
pixman_region32_fini (region);
191
* Compute the smallest value no less than y which is on a
195
PIXMAN_EXPORT pixman_fixed_t
196
pixman_sample_ceil_y (pixman_fixed_t y, int n)
198
pixman_fixed_t f = pixman_fixed_frac(y);
199
pixman_fixed_t i = pixman_fixed_floor(y);
201
f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
202
if (f > Y_FRAC_LAST(n))
210
#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
213
* Compute the largest value no greater than y which is on a
216
PIXMAN_EXPORT pixman_fixed_t
217
pixman_sample_floor_y (pixman_fixed_t y, int n)
219
pixman_fixed_t f = pixman_fixed_frac(y);
220
pixman_fixed_t i = pixman_fixed_floor (y);
222
f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
223
if (f < Y_FRAC_FIRST(n))
232
* Step an edge by any amount (including negative values)
235
pixman_edge_step (pixman_edge_t *e, int n)
237
pixman_fixed_48_16_t ne;
239
e->x += n * e->stepx;
241
ne = e->e + n * (pixman_fixed_48_16_t) e->dx;
247
int nx = (ne + e->dy - 1) / e->dy;
248
e->e = ne - nx * (pixman_fixed_48_16_t) e->dy;
249
e->x += nx * e->signdx;
256
int nx = (-ne) / e->dy;
257
e->e = ne + nx * (pixman_fixed_48_16_t) e->dy;
258
e->x -= nx * e->signdx;
264
* A private routine to initialize the multi-step
265
* elements of an edge structure
268
_pixman_edge_tMultiInit (pixman_edge_t *e, int n, pixman_fixed_t *stepx_p, pixman_fixed_t *dx_p)
270
pixman_fixed_t stepx;
271
pixman_fixed_48_16_t ne;
273
ne = n * (pixman_fixed_48_16_t) e->dx;
274
stepx = n * e->stepx;
279
stepx += nx * e->signdx;
286
* Initialize one edge structure given the line endpoints and a
290
pixman_edge_init (pixman_edge_t *e,
292
pixman_fixed_t y_start,
293
pixman_fixed_t x_top,
294
pixman_fixed_t y_top,
295
pixman_fixed_t x_bot,
296
pixman_fixed_t y_bot)
298
pixman_fixed_t dx, dy;
318
e->stepx = -(-dx / dy);
323
_pixman_edge_tMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
324
_pixman_edge_tMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
326
pixman_edge_step (e, y_start - y_top);
330
* Initialize one edge structure given a line, starting y value
331
* and a pixel offset for the line
334
pixman_line_fixed_edge_init (pixman_edge_t *e,
337
const pixman_line_fixed_t *line,
341
pixman_fixed_t x_off_fixed = pixman_int_to_fixed(x_off);
342
pixman_fixed_t y_off_fixed = pixman_int_to_fixed(y_off);
343
const pixman_point_fixed_t *top, *bot;
345
if (line->p1.y <= line->p2.y)
355
pixman_edge_init (e, n, y,
356
top->x + x_off_fixed,
357
top->y + y_off_fixed,
358
bot->x + x_off_fixed,
359
bot->y + y_off_fixed);
204
PIXMAN_EXPORT pixman_bool_t
205
pixman_compute_composite_region (pixman_region16_t * region,
206
pixman_image_t * src_image,
207
pixman_image_t * mask_image,
208
pixman_image_t * dst_image,
218
pixman_region32_t r32;
219
pixman_bool_t retval;
221
pixman_region32_init (&r32);
223
retval = pixman_compute_composite_region32 (
224
&r32, src_image, mask_image, dst_image,
225
src_x, src_y, mask_x, mask_y, dest_x, dest_y,
230
if (!pixman_region16_copy_from_region32 (region, &r32))
234
pixman_region32_fini (&r32);
363
239
pixman_multiply_overflows_int (unsigned int a,
366
242
return a >= INT32_MAX / b;
370
246
pixman_addition_overflows_int (unsigned int a,
373
249
return a > INT32_MAX - b;
377
pixman_malloc_ab(unsigned int a,
253
pixman_malloc_ab (unsigned int a,
380
256
if (a >= INT32_MAX / b)
396
272
return malloc (a * b * c);
403
* Returns the version of the pixman library encoded in a single
404
* integer as per %PIXMAN_VERSION_ENCODE. The encoding ensures that
405
* later versions compare greater than earlier versions.
407
* A run-time comparison to check that pixman's version is greater than
408
* or equal to version X.Y.Z could be performed as follows:
410
* <informalexample><programlisting>
411
* if (pixman_version() >= PIXMAN_VERSION_ENCODE(X,Y,Z)) {...}
412
* </programlisting></informalexample>
414
* See also pixman_version_string() as well as the compile-time
415
* equivalents %PIXMAN_VERSION and %PIXMAN_VERSION_STRING.
417
* Return value: the encoded version.
420
pixman_version (void)
422
return PIXMAN_VERSION;
426
* pixman_version_string:
428
* Returns the version of the pixman library as a human-readable string
429
* of the form "X.Y.Z".
431
* See also pixman_version() as well as the compile-time equivalents
432
* %PIXMAN_VERSION_STRING and %PIXMAN_VERSION.
434
* Return value: a string containing the version.
436
PIXMAN_EXPORT const char*
437
pixman_version_string (void)
439
return PIXMAN_VERSION_STRING;
443
* pixman_format_supported_destination:
444
* @format: A pixman_format_code_t format
446
* Return value: whether the provided format code is a supported
447
* format for a pixman surface used as a destination in
450
* Currently, all pixman_format_code_t values are supported
451
* except for the YUV formats.
453
PIXMAN_EXPORT pixman_bool_t
454
pixman_format_supported_destination (pixman_format_code_t format)
458
case PIXMAN_a2b10g10r10:
459
case PIXMAN_x2b10g10r10:
460
case PIXMAN_a8r8g8b8:
461
case PIXMAN_x8r8g8b8:
462
case PIXMAN_a8b8g8r8:
463
case PIXMAN_x8b8g8r8:
469
case PIXMAN_a1r5g5b5:
470
case PIXMAN_x1r5g5b5:
471
case PIXMAN_a1b5g5r5:
472
case PIXMAN_x1b5g5r5:
473
case PIXMAN_a4r4g4b4:
474
case PIXMAN_x4r4g4b4:
475
case PIXMAN_a4b4g4r4:
476
case PIXMAN_x4b4g4r4:
481
case PIXMAN_a2r2g2b2:
482
case PIXMAN_a2b2g2r2:
486
/* Collides with PIXMAN_c8
489
/* Collides with PIXMAN_g8
496
case PIXMAN_a1r1g1b1:
497
case PIXMAN_a1b1g1r1:
514
* pixman_format_supported_source:
515
* @format: A pixman_format_code_t format
517
* Return value: whether the provided format code is a supported
518
* format for a pixman surface used as a source in
521
* Currently, all pixman_format_code_t values are supported.
523
PIXMAN_EXPORT pixman_bool_t
524
pixman_format_supported_source (pixman_format_code_t format)
528
case PIXMAN_a2b10g10r10:
529
case PIXMAN_x2b10g10r10:
530
case PIXMAN_a8r8g8b8:
531
case PIXMAN_x8r8g8b8:
532
case PIXMAN_a8b8g8r8:
533
case PIXMAN_x8b8g8r8:
539
case PIXMAN_a1r5g5b5:
540
case PIXMAN_x1r5g5b5:
541
case PIXMAN_a1b5g5r5:
542
case PIXMAN_x1b5g5r5:
543
case PIXMAN_a4r4g4b4:
544
case PIXMAN_x4r4g4b4:
545
case PIXMAN_a4b4g4r4:
546
case PIXMAN_x4b4g4r4:
551
case PIXMAN_a2r2g2b2:
552
case PIXMAN_a2b2g2r2:
556
/* Collides with PIXMAN_c8
559
/* Collides with PIXMAN_g8
566
case PIXMAN_a1r1g1b1:
567
case PIXMAN_a1b1g1r1:
276
* Helper routine to expand a color component from 0 < n <= 8 bits to 16
277
* bits by replication.
279
static inline uint64_t
280
expand16 (const uint8_t val, int nbits)
282
/* Start out with the high bit of val in the high bit of result. */
283
uint16_t result = (uint16_t)val << (16 - nbits);
288
/* Copy the bits in result, doubling the number of bits each time, until
289
* we fill all 16 bits.
293
result |= result >> nbits;
301
* This function expands images from ARGB8 format to ARGB16. To preserve
302
* precision, it needs to know the original source format. For example, if the
303
* source was PIXMAN_x1r5g5b5 and the red component contained bits 12345, then
304
* the expanded value is 12345123. To correctly expand this to 16 bits, it
305
* should be 1234512345123451 and not 1234512312345123.
308
pixman_expand (uint64_t * dst,
309
const uint32_t * src,
310
pixman_format_code_t format,
314
* Determine the sizes of each component and the masks and shifts
315
* required to extract them from the source pixel.
317
const int a_size = PIXMAN_FORMAT_A (format),
318
r_size = PIXMAN_FORMAT_R (format),
319
g_size = PIXMAN_FORMAT_G (format),
320
b_size = PIXMAN_FORMAT_B (format);
321
const int a_shift = 32 - a_size,
322
r_shift = 24 - r_size,
323
g_shift = 16 - g_size,
324
b_shift = 8 - b_size;
325
const uint8_t a_mask = ~(~0 << a_size),
326
r_mask = ~(~0 << r_size),
327
g_mask = ~(~0 << g_size),
328
b_mask = ~(~0 << b_size);
331
/* Start at the end so that we can do the expansion in place
334
for (i = width - 1; i >= 0; i--)
336
const uint32_t pixel = src[i];
337
const uint8_t a = (pixel >> a_shift) & a_mask,
338
r = (pixel >> r_shift) & r_mask,
339
g = (pixel >> g_shift) & g_mask,
340
b = (pixel >> b_shift) & b_mask;
341
const uint64_t a16 = a_size ? expand16 (a, a_size) : 0xffff,
342
r16 = expand16 (r, r_size),
343
g16 = expand16 (g, g_size),
344
b16 = expand16 (b, b_size);
346
dst[i] = a16 << 48 | r16 << 32 | g16 << 16 | b16;
351
* Contracting is easier than expanding. We just need to truncate the
355
pixman_contract (uint32_t * dst,
361
/* Start at the beginning so that we can do the contraction in
362
* place when src == dst
364
for (i = 0; i < width; i++)
366
const uint8_t a = src[i] >> 56,
371
dst[i] = a << 24 | r << 16 | g << 8 | b;
376
walk_region_internal (pixman_implementation_t *imp,
378
pixman_image_t * src_image,
379
pixman_image_t * mask_image,
380
pixman_image_t * dst_image,
389
pixman_bool_t src_repeat,
390
pixman_bool_t mask_repeat,
391
pixman_region32_t * region,
392
pixman_composite_func_t composite_rect)
395
const pixman_box32_t *pbox;
396
int w, h, w_this, h_this;
397
int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
399
pbox = pixman_region32_rectangles (region, &n);
402
h = pbox->y2 - pbox->y1;
403
y_src = pbox->y1 - dest_y + src_y;
404
y_msk = pbox->y1 - dest_y + mask_y;
410
w = pbox->x2 - pbox->x1;
411
x_src = pbox->x1 - dest_x + src_x;
412
x_msk = pbox->x1 - dest_x + mask_x;
417
y_msk = MOD (y_msk, mask_image->bits.height);
418
if (h_this > mask_image->bits.height - y_msk)
419
h_this = mask_image->bits.height - y_msk;
424
y_src = MOD (y_src, src_image->bits.height);
425
if (h_this > src_image->bits.height - y_src)
426
h_this = src_image->bits.height - y_src;
435
x_msk = MOD (x_msk, mask_image->bits.width);
436
if (w_this > mask_image->bits.width - x_msk)
437
w_this = mask_image->bits.width - x_msk;
442
x_src = MOD (x_src, src_image->bits.width);
443
if (w_this > src_image->bits.width - x_src)
444
w_this = src_image->bits.width - x_src;
447
(*composite_rect) (imp, op,
448
src_image, mask_image, dst_image,
449
x_src, y_src, x_msk, y_msk, x_dst, y_dst,
469
_pixman_walk_composite_region (pixman_implementation_t *imp,
471
pixman_image_t * src_image,
472
pixman_image_t * mask_image,
473
pixman_image_t * dst_image,
482
pixman_composite_func_t composite_rect)
484
pixman_region32_t region;
486
pixman_region32_init (®ion);
488
if (pixman_compute_composite_region32 (
489
®ion, src_image, mask_image, dst_image,
490
src_x, src_y, mask_x, mask_y, dest_x, dest_y,
493
walk_region_internal (imp, op,
494
src_image, mask_image, dst_image,
495
src_x, src_y, mask_x, mask_y, dest_x, dest_y,
496
width, height, FALSE, FALSE,
500
pixman_region32_fini (®ion);
505
mask_is_solid (pixman_image_t *mask)
507
if (mask->type == SOLID)
510
if (mask->type == BITS &&
511
mask->common.repeat == PIXMAN_REPEAT_NORMAL &&
512
mask->bits.width == 1 &&
513
mask->bits.height == 1)
521
static const pixman_fast_path_t *
522
get_fast_path (const pixman_fast_path_t *fast_paths,
524
pixman_image_t * src_image,
525
pixman_image_t * mask_image,
526
pixman_image_t * dst_image,
527
pixman_bool_t is_pixbuf)
529
const pixman_fast_path_t *info;
531
for (info = fast_paths; info->op != PIXMAN_OP_NONE; info++)
533
pixman_bool_t valid_src = FALSE;
534
pixman_bool_t valid_mask = FALSE;
539
if ((info->src_format == PIXMAN_solid &&
540
_pixman_image_is_solid (src_image)) ||
541
(src_image->type == BITS &&
542
info->src_format == src_image->bits.format))
550
if ((info->mask_format == PIXMAN_null && !mask_image) ||
551
(mask_image && mask_image->type == BITS &&
552
info->mask_format == mask_image->bits.format))
556
if (info->flags & NEED_SOLID_MASK)
558
if (!mask_image || !mask_is_solid (mask_image))
562
if (info->flags & NEED_COMPONENT_ALPHA)
564
if (!mask_image || !mask_image->common.component_alpha)
572
if (info->dest_format != dst_image->bits.format)
575
if ((info->flags & NEED_PIXBUF) && !is_pixbuf)
584
static force_inline pixman_bool_t
585
image_covers (pixman_image_t *image,
586
pixman_box32_t *extents,
590
if (image->common.type == BITS &&
591
image->common.repeat == PIXMAN_REPEAT_NONE)
593
if (x > extents->x1 || y > extents->y1 ||
594
x + image->bits.width < extents->x2 ||
595
y + image->bits.height < extents->y2)
604
static force_inline pixman_bool_t
605
sources_cover (pixman_image_t *src,
606
pixman_image_t *mask,
607
pixman_box32_t *extents,
615
if (!image_covers (src, extents, dest_x - src_x, dest_y - src_y))
621
if (!image_covers (mask, extents, dest_x - mask_x, dest_y - mask_y))
628
_pixman_run_fast_path (const pixman_fast_path_t *paths,
629
pixman_implementation_t * imp,
631
pixman_image_t * src,
632
pixman_image_t * mask,
633
pixman_image_t * dest,
643
pixman_composite_func_t func = NULL;
644
pixman_bool_t src_repeat =
645
src->common.repeat == PIXMAN_REPEAT_NORMAL;
646
pixman_bool_t mask_repeat =
647
mask && mask->common.repeat == PIXMAN_REPEAT_NORMAL;
648
pixman_bool_t result;
649
pixman_bool_t has_fast_path;
651
has_fast_path = !dest->common.alpha_map &&
652
!dest->bits.read_func &&
653
!dest->bits.write_func;
657
has_fast_path = (src->type == BITS || _pixman_image_is_solid (src)) &&
658
!src->common.transform &&
659
!src->common.alpha_map &&
660
src->common.filter != PIXMAN_FILTER_CONVOLUTION &&
661
src->common.repeat != PIXMAN_REPEAT_PAD &&
662
src->common.repeat != PIXMAN_REPEAT_REFLECT;
663
if (has_fast_path && src->type == BITS)
665
has_fast_path = !src->bits.read_func &&
666
!src->bits.write_func &&
667
!PIXMAN_FORMAT_IS_WIDE (src->bits.format);
671
if (mask && has_fast_path)
674
mask->type == BITS &&
675
!mask->common.transform &&
676
!mask->common.alpha_map &&
677
!mask->bits.read_func &&
678
!mask->bits.write_func &&
679
mask->common.filter != PIXMAN_FILTER_CONVOLUTION &&
680
mask->common.repeat != PIXMAN_REPEAT_PAD &&
681
mask->common.repeat != PIXMAN_REPEAT_REFLECT &&
682
!PIXMAN_FORMAT_IS_WIDE (mask->bits.format);
687
const pixman_fast_path_t *info;
688
pixman_bool_t pixbuf;
691
src && src->type == BITS &&
692
mask && mask->type == BITS &&
693
src->bits.bits == mask->bits.bits &&
696
!mask->common.component_alpha &&
699
info = get_fast_path (paths, op, src, mask, dest, pixbuf);
705
if (info->src_format == PIXMAN_solid)
708
if (info->mask_format == PIXMAN_solid ||
709
info->flags & NEED_SOLID_MASK)
715
src->bits.width == 1 &&
716
src->bits.height == 1) ||
718
mask->bits.width == 1 &&
719
mask->bits.height == 1))
721
/* If src or mask are repeating 1x1 images and src_repeat or
722
* mask_repeat are still TRUE, it means the fast path we
723
* selected does not actually handle repeating images.
725
* So rather than call the "fast path" with a zillion
726
* 1x1 requests, we just fall back to the general code (which
727
* does do something sensible with 1x1 repeating images).
738
pixman_region32_t region;
739
pixman_region32_init (®ion);
741
if (pixman_compute_composite_region32 (
742
®ion, src, mask, dest,
743
src_x, src_y, mask_x, mask_y, dest_x, dest_y, width, height))
745
pixman_box32_t *extents = pixman_region32_extents (®ion);
749
src_x, src_y, mask_x, mask_y, dest_x, dest_y))
751
walk_region_internal (imp, op,
753
src_x, src_y, mask_x, mask_y,
756
src_repeat, mask_repeat,
763
pixman_region32_fini (®ion);
770
#define N_TMP_BOXES (16)
773
pixman_region16_copy_from_region32 (pixman_region16_t *dst,
774
pixman_region32_t *src)
777
pixman_box32_t *boxes32;
778
pixman_box16_t *boxes16;
779
pixman_bool_t retval;
781
boxes32 = pixman_region32_rectangles (src, &n_boxes);
783
boxes16 = pixman_malloc_ab (n_boxes, sizeof (pixman_box16_t));
788
for (i = 0; i < n_boxes; ++i)
790
boxes16[i].x1 = boxes32[i].x1;
791
boxes16[i].y1 = boxes32[i].y1;
792
boxes16[i].x2 = boxes32[i].x2;
793
boxes16[i].y2 = boxes32[i].y2;
796
pixman_region_fini (dst);
797
retval = pixman_region_init_rects (dst, boxes16, n_boxes);
803
pixman_region32_copy_from_region16 (pixman_region32_t *dst,
804
pixman_region16_t *src)
807
pixman_box16_t *boxes16;
808
pixman_box32_t *boxes32;
809
pixman_box32_t tmp_boxes[N_TMP_BOXES];
810
pixman_bool_t retval;
812
boxes16 = pixman_region_rectangles (src, &n_boxes);
814
if (n_boxes > N_TMP_BOXES)
815
boxes32 = pixman_malloc_ab (n_boxes, sizeof (pixman_box32_t));
822
for (i = 0; i < n_boxes; ++i)
824
boxes32[i].x1 = boxes16[i].x1;
825
boxes32[i].y1 = boxes16[i].y1;
826
boxes32[i].x2 = boxes16[i].x2;
827
boxes32[i].y2 = boxes16[i].y2;
830
pixman_region32_fini (dst);
831
retval = pixman_region32_init_rects (dst, boxes32, n_boxes);
833
if (boxes32 != tmp_boxes)