[gtk/path-stroke: 98/103] Add gsk_path_stroke
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-stroke: 98/103] Add gsk_path_stroke
- Date: Sat, 19 Dec 2020 19:09:48 +0000 (UTC)
commit c9f81c7e36e29485217d155e2ca0876c4170b4f0
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 5 13:37:53 2020 -0500
Add gsk_path_stroke
Add the plumbing that will let us do special-case stroking
for rectangles, circles and other special contours. There
is no implementation yet.
gsk/gskcontour.c | 41 ++++++++++++++++++++++++++++++++++++++---
gsk/gskcontourprivate.h | 6 ++++++
gsk/gskpath.c | 25 +++++++++++++++++++++++++
gsk/gskpath.h | 5 +++++
4 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c
index 32bd98ec96..5d7bb699f4 100644
--- a/gsk/gskcontour.c
+++ b/gsk/gskcontour.c
@@ -86,6 +86,9 @@ struct _GskContourClass
gboolean (* get_stroke_bounds) (const GskContour *contour,
const GskStroke *stroke,
graphene_rect_t *bounds);
+ void (* add_stroke) (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke);
};
static gsize
@@ -487,6 +490,13 @@ gsk_rect_contour_get_stroke_bounds (const GskContour *contour,
return TRUE;
}
+static void
+gsk_rect_contour_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
+{
+}
+
static const GskContourClass GSK_RECT_CONTOUR_CLASS =
{
sizeof (GskRectContour),
@@ -504,7 +514,8 @@ static const GskContourClass GSK_RECT_CONTOUR_CLASS =
gsk_rect_contour_copy,
gsk_rect_contour_add_segment,
gsk_rect_contour_get_winding,
- gsk_rect_contour_get_stroke_bounds
+ gsk_rect_contour_get_stroke_bounds,
+ gsk_rect_contour_add_stroke
};
GskContour *
@@ -857,6 +868,13 @@ gsk_circle_contour_get_stroke_bounds (const GskContour *contour,
return TRUE;
}
+static void
+gsk_circle_contour_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
+{
+}
+
static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS =
{
sizeof (GskCircleContour),
@@ -874,7 +892,8 @@ static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS =
gsk_circle_contour_copy,
gsk_circle_contour_add_segment,
gsk_circle_contour_get_winding,
- gsk_circle_contour_get_stroke_bounds
+ gsk_circle_contour_get_stroke_bounds,
+ gsk_circle_contour_add_stroke
};
GskContour *
@@ -1561,6 +1580,13 @@ gsk_standard_contour_get_stroke_bounds (const GskContour *contour,
return TRUE;
}
+static void
+gsk_standard_contour_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
+{
+}
+
static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
{
sizeof (GskStandardContour),
@@ -1578,7 +1604,8 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
gsk_standard_contour_copy,
gsk_standard_contour_add_segment,
gsk_standard_contour_get_winding,
- gsk_standard_contour_get_stroke_bounds
+ gsk_standard_contour_get_stroke_bounds,
+ gsk_standard_contour_add_stroke
};
/* You must ensure the contour has enough size allocated,
@@ -1750,6 +1777,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 927205fdac..a8cea1eb95 100644
--- a/gsk/gskcontourprivate.h
+++ b/gsk/gskcontourprivate.h
@@ -96,6 +96,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 d67fb763d9..ec4fe8e71f 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -1235,3 +1235,28 @@ gsk_path_get_stroke_bounds (GskPath *self,
return TRUE;
}
+
+/**
+ * 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 6df9250a33..d9ad6e4cb5 100644
--- a/gsk/gskpath.h
+++ b/gsk/gskpath.h
@@ -110,6 +110,11 @@ gboolean gsk_path_foreach (GskPath
GskPathForeachFunc func,
gpointer user_data);
+GDK_AVAILABLE_IN_ALL
+GskPath * gsk_path_stroke (GskPath *path,
+ GskStroke *stroke);
+
+
G_END_DECLS
#endif /* __GSK_PATH_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]