~ubuntu-branches/ubuntu/quantal/pixman/quantal-proposed

« back to all changes in this revision

Viewing changes to test/blitters-test.c

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst
  • Date: 2013-12-10 13:26:08 UTC
  • mfrom: (30.1.4 saucy-security)
  • Revision ID: package-import@ubuntu.com-20131210132608-8dfmczm1fjrm99jh
Tags: 0.30.2-1ubuntu0.0.0.1
Copy saucy package back to quantal. (LP: #1253041)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
                     int                   max_extra_stride,
26
26
                     pixman_format_code_t *used_fmt)
27
27
{
28
 
    int n = 0, i, width, height, stride;
 
28
    int n = 0, width, height, stride;
29
29
    pixman_format_code_t fmt;
30
30
    uint32_t *buf;
31
31
    pixman_image_t *img;
33
33
    while (allowed_formats[n] != PIXMAN_null)
34
34
        n++;
35
35
 
36
 
    if (n > N_MOST_LIKELY_FORMATS && lcg_rand_n (4) != 0)
 
36
    if (n > N_MOST_LIKELY_FORMATS && prng_rand_n (4) != 0)
37
37
        n = N_MOST_LIKELY_FORMATS;
38
 
    fmt = allowed_formats[lcg_rand_n (n)];
 
38
    fmt = allowed_formats[prng_rand_n (n)];
39
39
 
40
 
    width = lcg_rand_n (max_width) + 1;
41
 
    height = lcg_rand_n (max_height) + 1;
 
40
    width = prng_rand_n (max_width) + 1;
 
41
    height = prng_rand_n (max_height) + 1;
42
42
    stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 +
43
 
        lcg_rand_n (max_extra_stride + 1);
 
43
        prng_rand_n (max_extra_stride + 1);
44
44
    stride = (stride + 3) & ~3;
45
45
 
46
46
    /* do the allocation */
47
47
    buf = aligned_malloc (64, stride * height);
48
48
 
49
 
    /* initialize image with random data */
50
 
    for (i = 0; i < stride * height; i++)
51
 
    {
52
 
        /* generation is biased to having more 0 or 255 bytes as
53
 
         * they are more likely to be special-cased in code
54
 
         */
55
 
        *((uint8_t *)buf + i) = lcg_rand_n (4) ? lcg_rand_n (256) :
56
 
            (lcg_rand_n (2) ? 0 : 255);
 
49
    if (prng_rand_n (4) == 0)
 
50
    {
 
51
        /* uniform distribution */
 
52
        prng_randmemset (buf, stride * height, 0);
 
53
    }
 
54
    else
 
55
    {
 
56
        /* significantly increased probability for 0x00 and 0xFF */
 
57
        prng_randmemset (buf, stride * height, RANDMEMSET_MORE_00_AND_FF);
57
58
    }
58
59
 
59
60
    img = pixman_image_create_bits (fmt, width, height, buf, stride);
67
68
        pixman_image_set_indexed (img, &(y_palette[PIXMAN_FORMAT_BPP (fmt)]));
68
69
    }
69
70
 
70
 
    if (lcg_rand_n (16) == 0)
 
71
    if (prng_rand_n (16) == 0)
71
72
        pixman_image_set_filter (img, PIXMAN_FILTER_BILINEAR, NULL, 0);
72
73
 
73
74
    image_endian_swap (img);
83
84
                   pixman_format_code_t fmt)
84
85
{
85
86
    uint32_t crc32 = 0;
86
 
    int stride = pixman_image_get_stride (img);
87
87
    uint32_t *data = pixman_image_get_data (img);
88
 
    int height = pixman_image_get_height (img);
89
88
 
90
89
    if (fmt != PIXMAN_null)
91
 
    {
92
 
        /* mask unused 'x' part */
93
 
        if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
94
 
            PIXMAN_FORMAT_DEPTH (fmt) != 0)
95
 
        {
96
 
            int i;
97
 
            uint32_t *data = pixman_image_get_data (img);
98
 
            uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
99
 
 
100
 
            if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
101
 
                PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
102
 
            {
103
 
                mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
104
 
            }
105
 
 
106
 
            for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 32; i++)
107
 
                mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
108
 
 
109
 
            for (i = 0; i < stride * height / 4; i++)
110
 
                data[i] &= mask;
111
 
        }
112
 
 
113
 
        /* swap endiannes in order to provide identical results on both big
114
 
         * and litte endian systems
115
 
         */
116
 
        image_endian_swap (img);
117
 
        crc32 = compute_crc32 (initcrc, data, stride * height);
118
 
    }
 
90
        crc32 = compute_crc32_for_image (initcrc, img);
119
91
 
120
92
    pixman_image_unref (img);
121
93
    free (data);
201
173
    PIXMAN_x14r6g6b6,
202
174
    PIXMAN_r8g8b8,
203
175
    PIXMAN_b8g8r8,
 
176
#if 0 /* These are going to use floating point in the near future */
204
177
    PIXMAN_x2r10g10b10,
205
178
    PIXMAN_a2r10g10b10,
206
179
    PIXMAN_x2b10g10r10,
207
180
    PIXMAN_a2b10g10r10,
 
181
#endif
208
182
    PIXMAN_a1r5g5b5,
209
183
    PIXMAN_x1r5g5b5,
210
184
    PIXMAN_a1b5g5r5,
278
252
    if (max_extra_stride > 8)
279
253
        max_extra_stride = 8;
280
254
 
281
 
    lcg_srand (testnum);
282
 
 
283
 
    op = op_list[lcg_rand_n (ARRAY_LENGTH (op_list))];
284
 
 
285
 
    if (lcg_rand_n (8))
 
255
    prng_srand (testnum);
 
256
 
 
257
    op = op_list[prng_rand_n (ARRAY_LENGTH (op_list))];
 
258
 
 
259
    if (prng_rand_n (8))
286
260
    {
287
261
        /* normal image */
288
262
        src_img = create_random_image (img_fmt_list, max_width, max_height,
311
285
    dstbuf = pixman_image_get_data (dst_img);
312
286
    srcbuf = pixman_image_get_data (src_img);
313
287
 
314
 
    src_x = lcg_rand_n (src_width);
315
 
    src_y = lcg_rand_n (src_height);
316
 
    dst_x = lcg_rand_n (dst_width);
317
 
    dst_y = lcg_rand_n (dst_height);
 
288
    src_x = prng_rand_n (src_width);
 
289
    src_y = prng_rand_n (src_height);
 
290
    dst_x = prng_rand_n (dst_width);
 
291
    dst_y = prng_rand_n (dst_height);
318
292
 
319
293
    mask_img = NULL;
320
294
    mask_fmt = PIXMAN_null;
323
297
    maskbuf = NULL;
324
298
 
325
299
    if ((src_fmt == PIXMAN_x8r8g8b8 || src_fmt == PIXMAN_x8b8g8r8) &&
326
 
        (lcg_rand_n (4) == 0))
 
300
        (prng_rand_n (4) == 0))
327
301
    {
328
302
        /* PIXBUF */
329
 
        mask_fmt = lcg_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8;
 
303
        mask_fmt = prng_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8;
330
304
        mask_img = pixman_image_create_bits (mask_fmt,
331
305
                                             src_width,
332
306
                                             src_height,
336
310
        mask_y = src_y;
337
311
        maskbuf = srcbuf;
338
312
    }
339
 
    else if (lcg_rand_n (2))
 
313
    else if (prng_rand_n (2))
340
314
    {
341
 
        if (lcg_rand_n (2))
 
315
        if (prng_rand_n (2))
342
316
        {
343
317
            mask_img = create_random_image (mask_fmt_list, max_width, max_height,
344
318
                                           max_extra_stride, &mask_fmt);
351
325
            pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL);
352
326
        }
353
327
 
354
 
        if (lcg_rand_n (2))
 
328
        if (prng_rand_n (2))
355
329
            pixman_image_set_component_alpha (mask_img, 1);
356
330
 
357
 
        mask_x = lcg_rand_n (pixman_image_get_width (mask_img));
358
 
        mask_y = lcg_rand_n (pixman_image_get_height (mask_img));
 
331
        mask_x = prng_rand_n (pixman_image_get_width (mask_img));
 
332
        mask_y = prng_rand_n (pixman_image_get_height (mask_img));
359
333
    }
360
334
 
361
335
 
362
 
    w = lcg_rand_n (dst_width - dst_x + 1);
363
 
    h = lcg_rand_n (dst_height - dst_y + 1);
 
336
    w = prng_rand_n (dst_width - dst_x + 1);
 
337
    h = prng_rand_n (dst_height - dst_y + 1);
364
338
 
365
339
    if (verbose)
366
340
    {
367
 
        printf ("op=%d, src_fmt=%08X, dst_fmt=%08X, mask_fmt=%08X\n",
368
 
            op, src_fmt, dst_fmt, mask_fmt);
 
341
        printf ("op=%s\n", operator_name (op));
 
342
        printf ("src_fmt=%s, dst_fmt=%s, mask_fmt=%s\n",
 
343
            format_name (src_fmt), format_name (dst_fmt),
 
344
            format_name (mask_fmt));
369
345
        printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
370
346
            src_width, src_height, dst_width, dst_height);
371
347
        printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",
417
393
{
418
394
    int i;
419
395
 
 
396
    prng_srand (0);
 
397
 
420
398
    for (i = 1; i <= 8; i++)
421
399
    {
422
400
        initialize_palette (&(rgb_palette[i]), i, TRUE);
424
402
    }
425
403
 
426
404
    return fuzzer_test_main("blitters", 2000000,
427
 
                            0xA364B5BF,
 
405
                            0x0CF3283B,
428
406
                            test_composite, argc, argv);
429
407
}