| 1 |
#include <stdio.h> |
| 2 |
#include <stdlib.h> |
| 3 |
#include "utils.h" |
| 4 |
#include <sys/types.h> |
| 5 |
#include "pixman-private.h" |
| 6 |
|
| 7 |
static const pixman_op_t op_list[] = |
| 8 |
{ |
| 9 |
PIXMAN_OP_SRC, |
| 10 |
PIXMAN_OP_OVER, |
| 11 |
PIXMAN_OP_ADD, |
| 12 |
PIXMAN_OP_CLEAR, |
| 13 |
PIXMAN_OP_SRC, |
| 14 |
PIXMAN_OP_DST, |
| 15 |
PIXMAN_OP_OVER, |
| 16 |
PIXMAN_OP_OVER_REVERSE, |
| 17 |
PIXMAN_OP_IN, |
| 18 |
PIXMAN_OP_IN_REVERSE, |
| 19 |
PIXMAN_OP_OUT, |
| 20 |
PIXMAN_OP_OUT_REVERSE, |
| 21 |
PIXMAN_OP_ATOP, |
| 22 |
PIXMAN_OP_ATOP_REVERSE, |
| 23 |
PIXMAN_OP_XOR, |
| 24 |
PIXMAN_OP_ADD, |
| 25 |
PIXMAN_OP_SATURATE, |
| 26 |
PIXMAN_OP_DISJOINT_CLEAR, |
| 27 |
PIXMAN_OP_DISJOINT_SRC, |
| 28 |
PIXMAN_OP_DISJOINT_DST, |
| 29 |
PIXMAN_OP_DISJOINT_OVER, |
| 30 |
PIXMAN_OP_DISJOINT_OVER_REVERSE, |
| 31 |
PIXMAN_OP_DISJOINT_IN, |
| 32 |
PIXMAN_OP_DISJOINT_IN_REVERSE, |
| 33 |
PIXMAN_OP_DISJOINT_OUT, |
| 34 |
PIXMAN_OP_DISJOINT_OUT_REVERSE, |
| 35 |
PIXMAN_OP_DISJOINT_ATOP, |
| 36 |
PIXMAN_OP_DISJOINT_ATOP_REVERSE, |
| 37 |
PIXMAN_OP_DISJOINT_XOR, |
| 38 |
PIXMAN_OP_CONJOINT_CLEAR, |
| 39 |
PIXMAN_OP_CONJOINT_SRC, |
| 40 |
PIXMAN_OP_CONJOINT_DST, |
| 41 |
PIXMAN_OP_CONJOINT_OVER, |
| 42 |
PIXMAN_OP_CONJOINT_OVER_REVERSE, |
| 43 |
PIXMAN_OP_CONJOINT_IN, |
| 44 |
PIXMAN_OP_CONJOINT_IN_REVERSE, |
| 45 |
PIXMAN_OP_CONJOINT_OUT, |
| 46 |
PIXMAN_OP_CONJOINT_OUT_REVERSE, |
| 47 |
PIXMAN_OP_CONJOINT_ATOP, |
| 48 |
PIXMAN_OP_CONJOINT_ATOP_REVERSE, |
| 49 |
PIXMAN_OP_CONJOINT_XOR, |
| 50 |
PIXMAN_OP_MULTIPLY, |
| 51 |
PIXMAN_OP_SCREEN, |
| 52 |
PIXMAN_OP_OVERLAY, |
| 53 |
PIXMAN_OP_DARKEN, |
| 54 |
PIXMAN_OP_LIGHTEN, |
| 55 |
PIXMAN_OP_COLOR_DODGE, |
| 56 |
PIXMAN_OP_COLOR_BURN, |
| 57 |
PIXMAN_OP_HARD_LIGHT, |
| 58 |
PIXMAN_OP_DIFFERENCE, |
| 59 |
PIXMAN_OP_EXCLUSION, |
| 60 |
PIXMAN_OP_SOFT_LIGHT, |
| 61 |
PIXMAN_OP_HSL_HUE, |
| 62 |
PIXMAN_OP_HSL_SATURATION, |
| 63 |
PIXMAN_OP_HSL_COLOR, |
| 64 |
PIXMAN_OP_HSL_LUMINOSITY, |
| 65 |
}; |
| 66 |
|
| 67 |
static float |
| 68 |
rand_float (void) |
| 69 |
{ |
| 70 |
uint32_t u = prng_rand(); |
| 71 |
|
| 72 |
return *(float *)&u; |
| 73 |
} |
| 74 |
|
| 75 |
static void |
| 76 |
random_floats (argb_t *argb, int width) |
| 77 |
{ |
| 78 |
int i; |
| 79 |
|
| 80 |
for (i = 0; i < width; ++i) |
| 81 |
{ |
| 82 |
argb_t *p = argb + i; |
| 83 |
|
| 84 |
p->a = rand_float(); |
| 85 |
p->r = rand_float(); |
| 86 |
p->g = rand_float(); |
| 87 |
p->b = rand_float(); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
#define WIDTH 512 |
| 92 |
|
| 93 |
static pixman_combine_float_func_t |
| 94 |
lookup_combiner (pixman_implementation_t *imp, pixman_op_t op, |
| 95 |
pixman_bool_t component_alpha) |
| 96 |
{ |
| 97 |
pixman_combine_float_func_t f; |
| 98 |
|
| 99 |
do |
| 100 |
{ |
| 101 |
if (component_alpha) |
| 102 |
f = imp->combine_float_ca[op]; |
| 103 |
else |
| 104 |
f = imp->combine_float[op]; |
| 105 |
|
| 106 |
imp = imp->fallback; |
| 107 |
} |
| 108 |
while (!f); |
| 109 |
|
| 110 |
return f; |
| 111 |
} |
| 112 |
|
| 113 |
int |
| 114 |
main () |
| 115 |
{ |
| 116 |
pixman_implementation_t *impl; |
| 117 |
argb_t *src_bytes = malloc (WIDTH * sizeof (argb_t)); |
| 118 |
argb_t *mask_bytes = malloc (WIDTH * sizeof (argb_t)); |
| 119 |
argb_t *dest_bytes = malloc (WIDTH * sizeof (argb_t)); |
| 120 |
int i; |
| 121 |
|
| 122 |
enable_divbyzero_exceptions(); |
| 123 |
|
| 124 |
impl = _pixman_internal_only_get_implementation(); |
| 125 |
|
| 126 |
prng_srand (0); |
| 127 |
|
| 128 |
for (i = 0; i < ARRAY_LENGTH (op_list); ++i) |
| 129 |
{ |
| 130 |
pixman_op_t op = op_list[i]; |
| 131 |
pixman_combine_float_func_t combiner; |
| 132 |
int ca; |
| 133 |
|
| 134 |
for (ca = 0; ca < 2; ++ca) |
| 135 |
{ |
| 136 |
combiner = lookup_combiner (impl, op, ca); |
| 137 |
|
| 138 |
random_floats (src_bytes, WIDTH); |
| 139 |
random_floats (mask_bytes, WIDTH); |
| 140 |
random_floats (dest_bytes, WIDTH); |
| 141 |
|
| 142 |
combiner (impl, op, |
| 143 |
(float *)dest_bytes, |
| 144 |
(float *)mask_bytes, |
| 145 |
(float *)src_bytes, |
| 146 |
WIDTH); |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
free (src_bytes); |
| 151 |
free (mask_bytes); |
| 152 |
free (dest_bytes); |
| 153 |
|
| 154 |
return 0; |
| 155 |
} |