73
static pixman_image_t *
74
create_image (pixman_format_code_t format, pixman_format_code_t alpha_format,
75
int alpha_origin_x, int alpha_origin_y)
77
pixman_image_t *image = make_image (format);
79
if (alpha_format != PIXMAN_null)
81
pixman_image_t *alpha = make_image (alpha_format);
83
pixman_image_set_alpha_map (image, alpha,
84
alpha_origin_x, alpha_origin_y);
85
pixman_image_unref (alpha);
92
74
get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
142
#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
125
get_red (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
130
bits = (uint8_t *)image->bits.bits;
132
if (image->bits.format == PIXMAN_a8)
136
else if (image->bits.format == PIXMAN_a2r10g10b10)
138
r = ((uint32_t *)bits)[y * WIDTH + x] >> 14;
142
else if (image->bits.format == PIXMAN_a8r8g8b8)
144
r = ((uint32_t *)bits)[y * WIDTH + x] >> 16;
148
else if (image->bits.format == PIXMAN_a4r4g4b4)
150
r = ((uint16_t *)bits)[y * WIDTH + x] >> 8;
145
164
run_test (int s, int d, int sa, int da, int soff, int doff)
148
167
pixman_format_code_t df = formats[d];
149
168
pixman_format_code_t saf = alpha_formats[sa];
150
169
pixman_format_code_t daf = alpha_formats[da];
151
pixman_image_t *src, *dst, *orig_dst;
170
pixman_image_t *src, *dst, *orig_dst, *alpha, *orig_alpha;
152
171
pixman_transform_t t1;
173
int n_alpha_bits, n_red_bits;
156
175
soff = origins[soff];
157
176
doff = origins[doff];
160
179
if (daf != PIXMAN_null)
161
180
n_alpha_bits = PIXMAN_FORMAT_A (daf);
164
src = create_image (sf, saf, soff, soff);
165
orig_dst = create_image (df, daf, doff, doff);
166
dst = create_image (df, daf, doff, doff);
182
n_red_bits = PIXMAN_FORMAT_R (df);
185
src = make_image (sf);
186
if (saf != PIXMAN_null)
188
alpha = make_image (saf);
189
pixman_image_set_alpha_map (src, alpha, soff, soff);
190
pixman_image_unref (alpha);
194
orig_dst = make_image (df);
195
dst = make_image (df);
196
pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst,
197
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
199
if (daf != PIXMAN_null)
201
orig_alpha = make_image (daf);
202
alpha = make_image (daf);
204
pixman_image_composite (PIXMAN_OP_SRC, orig_alpha, NULL, alpha,
205
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
207
pixman_image_set_alpha_map (orig_dst, orig_alpha, doff, doff);
208
pixman_image_set_alpha_map (dst, alpha, doff, doff);
210
pixman_image_unref (orig_alpha);
211
pixman_image_unref (alpha);
168
214
/* Transformations, repeats and filters on destinations should be ignored,
169
215
* so just set some random ones.
177
223
pixman_image_set_filter (dst, PIXMAN_FILTER_BILINEAR, NULL, 0);
178
224
pixman_image_set_repeat (dst, PIXMAN_REPEAT_REFLECT);
180
pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst,
181
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
183
226
pixman_image_composite (PIXMAN_OP_ADD, src, NULL, dst,
184
227
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
188
231
for (k = MAX (doff, 0); k < MIN (WIDTH, WIDTH + doff); ++k)
190
uint8_t sa, da, oda, ref;
233
uint8_t sa, da, oda, refa;
234
uint16_t sr, dr, odr, refr;
192
236
sa = get_alpha (src, k, j, soff, soff);
193
237
da = get_alpha (dst, k, j, doff, doff);
194
238
oda = get_alpha (orig_dst, k, j, doff, doff);
196
240
if (sa + oda > 255)
201
if (da >> (8 - n_alpha_bits) != ref >> (8 - n_alpha_bits))
245
if (da >> (8 - n_alpha_bits) != refa >> (8 - n_alpha_bits))
203
247
printf ("\nWrong alpha value at (%d, %d). Should be 0x%x; got 0x%x. Source was 0x%x, original dest was 0x%x\n",
204
k, j, ref, da, sa, oda);
248
k, j, refa, da, sa, oda);
206
250
printf ("src: %s, alpha: %s, origin %d %d\ndst: %s, alpha: %s, origin: %d %d\n\n",
207
251
format_name (sf),
260
/* There are cases where we go through the 8 bit compositing
261
* path even with 10bpc formats. This results in incorrect
262
* results here, so only do the red check for narrow formats
266
sr = get_red (src, k, j, soff, soff);
267
dr = get_red (dst, k, j, doff, doff);
268
odr = get_red (orig_dst, k, j, doff, doff);
270
if (sr + odr > 0xffff)
275
if (abs ((dr >> (16 - n_red_bits)) - (refr >> (16 - n_red_bits))) > 1)
277
printf ("%d red bits\n", n_red_bits);
278
printf ("\nWrong red value at (%d, %d). Should be 0x%x; got 0x%x. Source was 0x%x, original dest was 0x%x\n",
279
k, j, refr, dr, sr, odr);
281
printf ("src: %s, alpha: %s, origin %d %d\ndst: %s, alpha: %s, origin: %d %d\n\n",