alpha-loop.c 966 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "utils.h"
  4. #define WIDTH 400
  5. #define HEIGHT 200
  6. int
  7. main (int argc, char **argv)
  8. {
  9. pixman_image_t *a, *d, *s;
  10. uint8_t *alpha;
  11. uint32_t *src, *dest;
  12. prng_srand (0);
  13. alpha = make_random_bytes (WIDTH * HEIGHT);
  14. src = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4);
  15. dest = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4);
  16. a = pixman_image_create_bits (PIXMAN_a8, WIDTH, HEIGHT, (uint32_t *)alpha, WIDTH);
  17. d = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4);
  18. s = pixman_image_create_bits (PIXMAN_a2r10g10b10, WIDTH, HEIGHT, src, WIDTH * 4);
  19. fail_after (5, "Infinite loop detected: 5 seconds without progress\n");
  20. pixman_image_set_alpha_map (s, a, 0, 0);
  21. pixman_image_set_alpha_map (a, s, 0, 0);
  22. pixman_image_composite (PIXMAN_OP_SRC, s, NULL, d, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
  23. pixman_image_unref (s);
  24. return 0;
  25. }