1#include <stdlib.h> 2#include <stdio.h> 3#include "utils.h" 4 5static const pixman_fixed_t entries[] = 6{ 7 pixman_double_to_fixed (-1.0), 8 pixman_double_to_fixed (-0.5), 9 pixman_double_to_fixed (-1/3.0), 10 pixman_double_to_fixed (0.0), 11 pixman_double_to_fixed (0.5), 12 pixman_double_to_fixed (1.0), 13 pixman_double_to_fixed (1.5), 14 pixman_double_to_fixed (2.0), 15 pixman_double_to_fixed (3.0), 16}; 17 18#define SIZE 12 19 20static uint32_t 21test_scale (const pixman_transform_t *xform, uint32_t crc) 22{ 23 uint32_t *srcbuf, *dstbuf; 24 pixman_image_t *src, *dest; 25 26 srcbuf = malloc (SIZE * SIZE * 4); 27 prng_randmemset (srcbuf, SIZE * SIZE * 4, 0); 28 src = pixman_image_create_bits ( 29 PIXMAN_a8r8g8b8, SIZE, SIZE, srcbuf, SIZE * 4); 30 31 dstbuf = malloc (SIZE * SIZE * 4); 32 prng_randmemset (dstbuf, SIZE * SIZE * 4, 0); 33 dest = pixman_image_create_bits ( 34 PIXMAN_a8r8g8b8, SIZE, SIZE, dstbuf, SIZE * 4); 35 36 pixman_image_set_transform (src, xform); 37 pixman_image_set_repeat (src, PIXMAN_REPEAT_NORMAL); 38 pixman_image_set_filter (src, PIXMAN_FILTER_BILINEAR, NULL, 0); 39 40 image_endian_swap (src); 41 image_endian_swap (dest); 42 43 pixman_image_composite (PIXMAN_OP_SRC, 44 src, NULL, dest, 45 0, 0, 0, 0, 0, 0, 46 SIZE, SIZE); 47 48 crc = compute_crc32_for_image (crc, dest); 49 50 pixman_image_unref (src); 51 pixman_image_unref (dest); 52 53 free (srcbuf); 54 free (dstbuf); 55 56 return crc; 57} 58 59#if BILINEAR_INTERPOLATION_BITS == 7 60#define CHECKSUM 0x02169677 61#elif BILINEAR_INTERPOLATION_BITS == 4 62#define CHECKSUM 0xE44B29AC 63#else 64#define CHECKSUM 0x00000000 65#endif 66 67int 68main (int argc, const char *argv[]) 69{ 70 const pixman_fixed_t *end = entries + ARRAY_LENGTH (entries); 71 const pixman_fixed_t *t0, *t1, *t2, *t3, *t4, *t5; 72 uint32_t crc = 0; 73 74 prng_srand (0x56EA1DBD); 75 76 for (t0 = entries; t0 < end; ++t0) 77 { 78 for (t1 = entries; t1 < end; ++t1) 79 { 80 for (t2 = entries; t2 < end; ++t2) 81 { 82 for (t3 = entries; t3 < end; ++t3) 83 { 84 for (t4 = entries; t4 < end; ++t4) 85 { 86 for (t5 = entries; t5 < end; ++t5) 87 { 88 pixman_transform_t xform = { 89 { { *t0, *t1, *t2 }, 90 { *t3, *t4, *t5 }, 91 { 0, 0, pixman_fixed_1 } } 92 }; 93 94 crc = test_scale (&xform, crc); 95 } 96 } 97 } 98 } 99 } 100 } 101 102 if (crc != CHECKSUM) 103 { 104 printf ("filter-reduction-test failed! (checksum=0x%08X, expected 0x%08X)\n", crc, CHECKSUM); 105 return 1; 106 } 107 else 108 { 109 printf ("filter-reduction-test passed (checksum=0x%08X)\n", crc); 110 return 0; 111 } 112} 113