line-width-zero.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright © 2007 Red Hat, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person
  5. * obtaining a copy of this software and associated documentation
  6. * files (the "Software"), to deal in the Software without
  7. * restriction, including without limitation the rights to use, copy,
  8. * modify, merge, publish, distribute, sublicense, and/or sell copies
  9. * of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. *
  24. * Author: Carl Worth <cworth@cworth.org>
  25. */
  26. #include "cairo-test.h"
  27. /* This is a test case for the following bug:
  28. *
  29. * Crash in cairo_stroke_extents whe line width is 0 and line cap is ROUND
  30. * (_cairo_pen_find_active_cw_vertex_index)
  31. * https://bugs.freedesktop.org/show_bug.cgi?id=10231
  32. */
  33. static cairo_test_status_t
  34. draw (cairo_t *cr, int width, int height)
  35. {
  36. double x1, y1, x2, y2;
  37. cairo_move_to (cr, 0.0, 0.0);
  38. cairo_line_to (cr, 100.0, 100.0);
  39. cairo_set_line_width (cr, 0.0);
  40. cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
  41. cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
  42. cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
  43. cairo_in_stroke (cr, 50, 50);
  44. cairo_stroke_preserve (cr);
  45. cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
  46. cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
  47. cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
  48. cairo_in_stroke (cr, 50, 50);
  49. cairo_stroke_preserve (cr);
  50. cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
  51. cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
  52. cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
  53. cairo_in_stroke (cr, 50, 50);
  54. cairo_stroke (cr);
  55. return CAIRO_TEST_SUCCESS;
  56. }
  57. CAIRO_TEST (line_width_zero,
  58. "Test all stroke operations and all cap,join styles with line width of zero",
  59. "stroke", /* keywords */
  60. NULL, /* requirements */
  61. 0, 0,
  62. NULL, draw)