2009-11-18 Chris Toshok <toshok@ximian.com>
[moon.git] / cairo-patches / 00-triangle-cap
blob3b2ba7d61a3063134b31f3fd56f8c190d1b3c8d1
1 Index: src/cairo-path-stroke.c
2 ===================================================================
3 --- src/cairo-path-stroke.c     (revision 113075)
4 +++ src/cairo-path-stroke.c     (working copy)
5 @@ -552,6 +552,39 @@
6  
7         return status;
8      }
9 +    case CAIRO_LINE_CAP_TRIANGLE: {
10 +       double dx, dy;
11 +       cairo_slope_t   fvector;
12 +       cairo_point_t   mid;
13 +       cairo_polygon_t polygon;
15 +       dx = f->usr_vector.x;
16 +       dy = f->usr_vector.y;
17 +       dx *= stroker->style->line_width / 2.0;
18 +       dy *= stroker->style->line_width / 2.0;
19 +       cairo_matrix_transform_distance (stroker->ctm, &dx, &dy);
20 +       fvector.dx = _cairo_fixed_from_double (dx);
21 +       fvector.dy = _cairo_fixed_from_double (dy);
22 +       mid.x = ((f->ccw.x + f->cw.x) / 2.0) + fvector.dx;
23 +       mid.y = ((f->ccw.y + f->cw.y) / 2.0) + fvector.dy;
25 +       _cairo_polygon_init (&polygon);
26 +       _cairo_polygon_move_to (&polygon, &f->cw);
27 +       _cairo_polygon_line_to (&polygon, &mid);
28 +       _cairo_polygon_line_to (&polygon, &f->ccw);
29 +       _cairo_polygon_close (&polygon);
30 +       status = _cairo_polygon_status (&polygon);
32 +       if (status == CAIRO_STATUS_SUCCESS) {
33 +           status = _cairo_bentley_ottmann_tessellate_polygon (stroker->traps,
34 +                                                               &polygon,
35 +                                                               CAIRO_FILL_RULE_WINDING);
36 +       }
38 +       _cairo_polygon_fini (&polygon);
40 +       return status;
41 +    }
42      case CAIRO_LINE_CAP_BUTT:
43      default:
44         return CAIRO_STATUS_SUCCESS;
45 Index: src/cairo.h
46 ===================================================================
47 --- src/cairo.h (revision 113075)
48 +++ src/cairo.h (working copy)
49 @@ -497,6 +497,7 @@
50   * @CAIRO_LINE_CAP_BUTT: start(stop) the line exactly at the start(end) point
51   * @CAIRO_LINE_CAP_ROUND: use a round ending, the center of the circle is the end point
52   * @CAIRO_LINE_CAP_SQUARE: use squared ending, the center of the square is the end point
53 + * @CAIRO_LINE_CAP_TRIANGLE: use triangle ending, the center of the triangle is the end point (used in Silverlight)
54   *
55   * Specifies how to render the endpoints of the path when stroking.
56   *
57 @@ -505,7 +506,8 @@
58  typedef enum _cairo_line_cap {
59      CAIRO_LINE_CAP_BUTT,
60      CAIRO_LINE_CAP_ROUND,
61 -    CAIRO_LINE_CAP_SQUARE
62 +    CAIRO_LINE_CAP_SQUARE,
63 +    CAIRO_LINE_CAP_TRIANGLE
64  } cairo_line_cap_t;
66  cairo_public void