[gtk/path-work-rebased: 73/118] path: Add gsk_path_measure_is_closed ()




commit 5db928c7f74f53705d48c9aed591b2fae8de97d0
Author: Benjamin Otte <otte redhat com>
Date:   Thu Dec 17 05:00:10 2020 +0100

    path: Add gsk_path_measure_is_closed ()

 gsk/gskpathmeasure.c | 24 ++++++++++++++++++++++++
 gsk/gskpathmeasure.h |  2 ++
 2 files changed, 26 insertions(+)
---
diff --git a/gsk/gskpathmeasure.c b/gsk/gskpathmeasure.c
index b67a7eb1f2..7fd599f948 100644
--- a/gsk/gskpathmeasure.c
+++ b/gsk/gskpathmeasure.c
@@ -270,6 +270,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 18ed926bac..4ea83af1c5 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]