summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2020-12-17 05:00:10 +0100
committerBenjamin Otte <otte@redhat.com>2020-12-19 18:35:12 +0100
commit75f50dd939afd15699559e4bd513812d27036a03 (patch)
tree54cd067704f15cb257e11782df422307ae5cda49
parent4708d17cb88ec4b46287597efa9d99c3ad075b0f (diff)
downloadgtk+-75f50dd939afd15699559e4bd513812d27036a03.tar.gz
path: Add gsk_path_measure_is_closed ()
-rw-r--r--docs/reference/gsk/gsk4-sections.txt1
-rw-r--r--gsk/gskpathmeasure.c24
-rw-r--r--gsk/gskpathmeasure.h2
3 files changed, 27 insertions, 0 deletions
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index 8c8729302b..7c1f1488a1 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -386,6 +386,7 @@ gsk_path_measure_get_n_contours
gsk_path_measure_restrict_to_contour
<SUBSECTION>
gsk_path_measure_get_length
+gsk_path_measure_is_closed
gsk_path_measure_get_point
gsk_path_measure_get_closest_point
gsk_path_measure_get_closest_point_full
diff --git a/gsk/gskpathmeasure.c b/gsk/gskpathmeasure.c
index d9afeffcb4..c227b00838 100644
--- a/gsk/gskpathmeasure.c
+++ b/gsk/gskpathmeasure.c
@@ -275,6 +275,30 @@ gsk_path_measure_get_length (GskPathMeasure *self)
return self->length;
}
+/**
+ * gsk_path_measure_is_closed:
+ * @self: a #GskPathMeasure
+ *
+ * Returns if the path being measured represents a single closed
+ * contour.
+ *
+ * Returns: %TRUE if the current path is closed
+ **/
+gboolean
+gsk_path_measure_is_closed (GskPathMeasure *self)
+{
+ const GskContour *contour;
+
+ g_return_val_if_fail (self != NULL, FALSE);
+
+ /* XXX: is the empty path closed? Currently it's not */
+ if (self->last - self->first != 1)
+ return FALSE;
+
+ contour = gsk_path_get_contour (self->path, self->first);
+ return gsk_contour_get_flags (contour) & GSK_PATH_CLOSED ? TRUE : FALSE;
+}
+
static float
gsk_path_measure_clamp_distance (GskPathMeasure *self,
float distance)
diff --git a/gsk/gskpathmeasure.h b/gsk/gskpathmeasure.h
index 0a3ff9bf17..69c712c8b9 100644
--- a/gsk/gskpathmeasure.h
+++ b/gsk/gskpathmeasure.h
@@ -58,6 +58,8 @@ void gsk_path_measure_restrict_to_contour (GskPathMeasure
GDK_AVAILABLE_IN_ALL
float gsk_path_measure_get_length (GskPathMeasure *self);
GDK_AVAILABLE_IN_ALL
+gboolean gsk_path_measure_is_closed (GskPathMeasure *self);
+GDK_AVAILABLE_IN_ALL
void gsk_path_measure_get_point (GskPathMeasure *self,
float distance,
graphene_point_t *pos,