[gtk/wip/matthiasc/lottie-stroke: 16/17] Add a vfunc for per-contour stroking
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/lottie-stroke: 16/17] Add a vfunc for per-contour stroking
- Date: Sat, 5 Dec 2020 19:22:55 +0000 (UTC)
commit 40f04cbd086d6feef7381707a3970269a49c72b6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 5 13:37:53 2020 -0500
Add a vfunc for per-contour stroking
Add the plumbing that will let us special-case stroking
for rectangles, circles and other special contours.
gsk/gskcontour.c | 44 +++++++++++++++++++++++++++++++++++++++++---
gsk/gskcontourprivate.h | 9 ++++++---
gsk/gskpathmeasure.c | 2 +-
gsk/gskpathstroke.c | 7 ++++---
4 files changed, 52 insertions(+), 10 deletions(-)
---
diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c
index b7f8c533ff..c69b247ad9 100644
--- a/gsk/gskcontour.c
+++ b/gsk/gskcontour.c
@@ -80,6 +80,9 @@ struct _GskContourClass
gpointer measure_data,
const graphene_point_t *point,
gboolean *on_edge);
+ void (* add_stroke) (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke);
};
static gsize
@@ -473,6 +476,14 @@ gsk_rect_contour_get_winding (const GskContour *contour,
return 0;
}
+static void
+gsk_rect_contour_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
+{
+ gsk_contour_default_add_stroke (contour, builder, stroke);
+}
+
static const GskContourClass GSK_RECT_CONTOUR_CLASS =
{
sizeof (GskRectContour),
@@ -489,7 +500,8 @@ static const GskContourClass GSK_RECT_CONTOUR_CLASS =
gsk_rect_contour_get_closest_point,
gsk_rect_contour_copy,
gsk_rect_contour_add_segment,
- gsk_rect_contour_get_winding
+ gsk_rect_contour_get_winding,
+ gsk_rect_contour_add_stroke
};
GskContour *
@@ -822,6 +834,14 @@ gsk_circle_contour_get_winding (const GskContour *contour,
return 0;
}
+static void
+gsk_circle_contour_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
+{
+ gsk_contour_default_add_stroke (contour, builder, stroke);
+}
+
static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS =
{
sizeof (GskCircleContour),
@@ -838,7 +858,8 @@ static const GskContourClass GSK_CIRCLE_CONTOUR_CLASS =
gsk_circle_contour_get_closest_point,
gsk_circle_contour_copy,
gsk_circle_contour_add_segment,
- gsk_circle_contour_get_winding
+ gsk_circle_contour_get_winding,
+ gsk_circle_contour_add_stroke
};
GskContour *
@@ -1601,6 +1622,14 @@ gsk_standard_contour_get_winding (const GskContour *contour,
return winding;
}
+static void
+gsk_standard_contour_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
+{
+ gsk_contour_default_add_stroke (contour, builder, stroke);
+}
+
static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
{
sizeof (GskStandardContour),
@@ -1617,7 +1646,8 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
gsk_standard_contour_get_closest_point,
gsk_standard_contour_copy,
gsk_standard_contour_add_segment,
- gsk_standard_contour_get_winding
+ gsk_standard_contour_get_winding,
+ gsk_standard_contour_add_stroke
};
/* You must ensure the contour has enough size allocated,
@@ -1780,6 +1810,14 @@ gsk_contour_get_winding (const GskContour *self,
return self->klass->get_winding (self, measure_data, point, on_edge);
}
+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 9ed3e8ea54..24851ee79b 100644
--- a/gsk/gskcontourprivate.h
+++ b/gsk/gskcontourprivate.h
@@ -92,9 +92,12 @@ void gsk_contour_add_segment (const GskContou
gpointer measure_data,
float start,
float end);
-void gsk_contour_stroke (const GskContour *contour,
- GskStroke *stroke,
- GskPathBuilder *builder);
+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/gskpathmeasure.c b/gsk/gskpathmeasure.c
index d497304998..c39fb7beb9 100644
--- a/gsk/gskpathmeasure.c
+++ b/gsk/gskpathmeasure.c
@@ -498,7 +498,7 @@ gsk_path_measure_stroke (GskPathMeasure *self,
for (i = 0; i < self->n_contours; i++)
{
- gsk_contour_stroke (gsk_path_get_contour (self->path, i), stroke, builder);
+ gsk_contour_add_stroke (gsk_path_get_contour (self->path, i), builder, stroke);
}
return gsk_path_builder_free_to_path (builder);
diff --git a/gsk/gskpathstroke.c b/gsk/gskpathstroke.c
index 94ffe66af4..d1c4c13c40 100644
--- a/gsk/gskpathstroke.c
+++ b/gsk/gskpathstroke.c
@@ -27,6 +27,7 @@
#include "gsksplineprivate.h"
#include "gskstrokeprivate.h"
+#include "gskcontourprivate.h"
#include "gdk/gdk-private.h"
@@ -1481,9 +1482,9 @@ add_cap (GskPathBuilder *builder,
}
void
-gsk_contour_stroke (const GskContour *contour,
- GskStroke *stroke,
- GskPathBuilder *builder)
+gsk_contour_default_add_stroke (const GskContour *contour,
+ GskPathBuilder *builder,
+ GskStroke *stroke)
{
GList *ops, *l;
GList *last = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]