diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c index aab3d9d9db..6694f1243a 100644 --- a/gsk/gskcontour.c +++ b/gsk/gskcontour.c @@ -90,6 +90,9 @@ struct _GskContourClass const GskStroke *stroke, graphene_rect_t *bounds); GskContour * (* reverse) (const GskContour *contour); + void (* add_stroke) (const GskContour *contour, + GskPathBuilder *builder, + GskStroke *stroke); }; static gsize @@ -510,6 +513,13 @@ gsk_rect_contour_reverse (const GskContour *contour) self->height)); } +static void +gsk_rect_contour_add_stroke (const GskContour *contour, + GskPathBuilder *builder, + GskStroke *stroke) +{ +} + static const GskContourClass GSK_RECT_CONTOUR_CLASS = { sizeof (GskRectContour), @@ -530,6 +540,7 @@ static const GskContourClass GSK_RECT_CONTOUR_CLASS = gsk_rect_contour_get_winding, gsk_rect_contour_get_stroke_bounds, gsk_rect_contour_reverse, + gsk_rect_contour_add_stroke, }; GskContour * @@ -906,6 +917,13 @@ gsk_circle_contour_reverse (const GskContour *contour) self->start_angle); } +static void +gsk_circle_contour_add_stroke (const GskContour *contour, + GskPathBuilder *builder, + GskStroke *stroke) +{ +} + static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS = { sizeof (GskCircleContour), @@ -926,6 +944,7 @@ static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS = gsk_circle_contour_get_winding, gsk_circle_contour_get_stroke_bounds, gsk_circle_contour_reverse, + gsk_circle_contour_add_stroke, }; GskContour * @@ -1763,6 +1782,13 @@ gsk_standard_contour_reverse (const GskContour *contour) return res; } +static void +gsk_standard_contour_add_stroke (const GskContour *contour, + GskPathBuilder *builder, + GskStroke *stroke) +{ +} + static const GskContourClass GSK_STANDARD_CONTOUR_CLASS = { sizeof (GskStandardContour), @@ -1783,6 +1809,7 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS = gsk_standard_contour_get_winding, gsk_standard_contour_get_stroke_bounds, gsk_standard_contour_reverse, + gsk_standard_contour_add_stroke, }; /* You must ensure the contour has enough size allocated, @@ -1962,6 +1989,14 @@ gsk_contour_get_stroke_bounds (const GskContour *self, return self->klass->get_stroke_bounds (self, stroke, bounds); } +void +gsk_contour_add_stroke (const GskContour *self, + GskPathBuilder *builder, + GskStroke *stroke) +{ + self->klass->add_stroke (self, builder, stroke); +} + void gsk_contour_copy (GskContour *dest, const GskContour *src) diff --git a/gsk/gskcontourprivate.h b/gsk/gskcontourprivate.h index 1276836552..7ec007c036 100644 --- a/gsk/gskcontourprivate.h +++ b/gsk/gskcontourprivate.h @@ -100,6 +100,12 @@ void gsk_contour_add_segment (const GskContou gboolean gsk_contour_get_stroke_bounds (const GskContour *self, const GskStroke *stroke, graphene_rect_t *bounds); +void gsk_contour_add_stroke (const GskContour *contour, + GskPathBuilder *builder, + GskStroke *stroke); +void gsk_contour_default_add_stroke (const GskContour *contour, + GskPathBuilder *builder, + GskStroke *stroke); G_END_DECLS diff --git a/gsk/gskpath.c b/gsk/gskpath.c index 28b2770529..a75ac7b0ed 100644 --- a/gsk/gskpath.c +++ b/gsk/gskpath.c @@ -1351,3 +1351,28 @@ gsk_path_transform (GskPath *self, return gsk_path_builder_free_to_path (data.builder); } + +/** + * gsk_path_stroke: + * @self: a `GskPath` + * @stroke: stroke parameters + * + * Create a new path that follows the outline of the area + * that would be affected by stroking along @self with + * the given stroke parameters. + * + * Returns: a new `GskPath` + */ +GskPath * +gsk_path_stroke (GskPath *self, + GskStroke *stroke) +{ + GskPathBuilder *builder; + + builder = gsk_path_builder_new (); + + for (int i = 0; i < self->n_contours; i++) + gsk_contour_add_stroke (gsk_path_get_contour (self, i), builder, stroke); + + return gsk_path_builder_free_to_path (builder); +} diff --git a/gsk/gskpath.h b/gsk/gskpath.h index 230786de0a..3908f4c9a4 100644 --- a/gsk/gskpath.h +++ b/gsk/gskpath.h @@ -115,6 +115,10 @@ GDK_AVAILABLE_IN_ALL GskPath * gsk_path_transform (GskPath *self, GskTransform *transform); +GDK_AVAILABLE_IN_ALL +GskPath * gsk_path_stroke (GskPath *self, + GskStroke *stroke); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskPath, gsk_path_unref) G_END_DECLS