bug-source-cu.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Permission is hereby granted, free of charge, to any person
  3. * obtaining a copy of this software and associated documentation
  4. * files (the "Software"), to deal in the Software without
  5. * restriction, including without limitation the rights to use, copy,
  6. * modify, merge, publish, distribute, sublicense, and/or sell copies
  7. * of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be
  11. * included in all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  17. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  18. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. #include "cairo-test.h"
  23. static cairo_pattern_t *
  24. create_pattern (cairo_surface_t *target)
  25. {
  26. cairo_surface_t *surface;
  27. cairo_pattern_t *pattern;
  28. cairo_t *cr;
  29. cairo_matrix_t m;
  30. surface = cairo_surface_create_similar(target,
  31. cairo_surface_get_content (target),
  32. 1000, 600);
  33. cr = cairo_create (surface);
  34. cairo_surface_destroy (surface);
  35. cairo_set_source_rgb (cr, 0, 1, 0);
  36. cairo_paint(cr);
  37. pattern = cairo_pattern_create_for_surface (cairo_get_target (cr));
  38. cairo_destroy(cr);
  39. cairo_matrix_init_translate (&m, 0, 0.1); // y offset must be non-integer
  40. cairo_pattern_set_matrix (pattern, &m);
  41. return pattern;
  42. }
  43. static cairo_test_status_t
  44. draw (cairo_t *cr, int width, int height)
  45. {
  46. cairo_pattern_t *pattern;
  47. cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
  48. cairo_set_source_rgb (cr, 1, 0, 0);
  49. cairo_paint (cr);
  50. cairo_new_path (cr);
  51. cairo_move_to (cr, 10, 400.1);
  52. cairo_line_to (cr, 990, 400.1);
  53. cairo_line_to (cr, 990, 600);
  54. cairo_line_to (cr, 10, 600);
  55. cairo_close_path (cr);
  56. pattern = create_pattern (cairo_get_target (cr));
  57. cairo_set_source (cr, pattern);
  58. cairo_pattern_destroy (pattern);
  59. cairo_fill(cr);
  60. return CAIRO_TEST_SUCCESS;
  61. }
  62. CAIRO_TEST (bug_source_cu,
  63. "Exercises a bug discovered in the tracking of unbounded source extents",
  64. "fill", /* keywords */
  65. NULL, /* requirements */
  66. 1000, 600,
  67. NULL, draw)