[gtk/path-work-rebased: 74/149] path: Make all private contour APIs take a GskContour




commit c1ed9c43eb37736a1a00a1877e0f9c71aec9bee6
Author: Benjamin Otte <otte redhat com>
Date:   Mon Nov 30 18:05:49 2020 +0100

    path: Make all private contour APIs take a GskContour
    
    ... instead of a path, index tuple.

 gsk/gskpath.c        | 26 +++++++-------------------
 gsk/gskpathmeasure.c | 12 ++++++------
 gsk/gskpathprivate.h | 28 ++++++++++++----------------
 3 files changed, 25 insertions(+), 41 deletions(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index 1585e8f954..edeb8f6052 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -1648,23 +1648,17 @@ gsk_contour_foreach (const GskContour   *contour,
 }
 
 gpointer
-gsk_contour_init_measure (GskPath *path,
-                          gsize    i,
-                          float    tolerance,
-                          float   *out_length)
+gsk_contour_init_measure (const GskContour *self,
+                          float             tolerance,
+                          float            *out_length)
 {
-  GskContour *self = path->contours[i];
-
   return self->klass->init_measure (self, tolerance, out_length);
 }
 
 void
-gsk_contour_free_measure (GskPath  *path,
-                          gsize     i,
-                          gpointer  data)
+gsk_contour_free_measure (const GskContour *self,
+                          gpointer          data)
 {
-  GskContour *self = path->contours[i];
-
   self->klass->free_measure (self, data);
 }
 
@@ -1677,21 +1671,17 @@ gsk_contour_get_start_end (const GskContour *self,
 }
 
 void
-gsk_contour_get_point (GskPath          *path,
-                       gsize             i,
+gsk_contour_get_point (const GskContour *self,
                        gpointer          measure_data,
                        float             distance,
                        graphene_point_t *pos,
                        graphene_vec2_t  *tangent)
 {
-  GskContour *self = path->contours[i];
-
   self->klass->get_point (self, measure_data, distance, pos, tangent);
 }
 
 gboolean
-gsk_contour_get_closest_point (GskPath                *path,
-                               gsize                   i,
+gsk_contour_get_closest_point (const GskContour       *self,
                                gpointer                measure_data,
                                float                   tolerance,
                                const graphene_point_t *point,
@@ -1701,8 +1691,6 @@ gsk_contour_get_closest_point (GskPath                *path,
                                float                  *out_offset,
                                graphene_vec2_t        *out_tangent)
 {
-  GskContour *self = path->contours[i];
-
   return self->klass->get_closest_point (self,
                                          measure_data,
                                          tolerance,
diff --git a/gsk/gskpathmeasure.c b/gsk/gskpathmeasure.c
index ce113ccaec..3c641dfde7 100644
--- a/gsk/gskpathmeasure.c
+++ b/gsk/gskpathmeasure.c
@@ -103,7 +103,7 @@ gsk_path_measure_new_with_tolerance (GskPath *path,
 
   for (i = 0; i < n_contours; i++)
     {
-      self->measures[i].contour_data = gsk_contour_init_measure (path, i,
+      self->measures[i].contour_data = gsk_contour_init_measure (gsk_path_get_contour (path, i),
                                                                  self->tolerance,
                                                                  &self->measures[i].length);
       self->length += self->measures[i].length;
@@ -152,7 +152,8 @@ gsk_path_measure_unref (GskPathMeasure *self)
 
   for (i = 0; i < self->n_contours; i++)
     {
-      gsk_contour_free_measure (self->path, i, self->measures[i].contour_data);
+      gsk_contour_free_measure (gsk_path_get_contour (self->path, i),
+                                self->measures[i].contour_data);
     }
 
   gsk_path_unref (self->path);
@@ -247,8 +248,7 @@ gsk_path_measure_get_point (GskPathMeasure   *self,
       distance = self->measures[i].length;
     }
 
-  gsk_contour_get_point (self->path,
-                         i,
+  gsk_contour_get_point (gsk_path_get_contour (self->path, i),
                          self->measures[i].contour_data,
                          distance,
                          pos,
@@ -340,8 +340,7 @@ gsk_path_measure_get_closest_point_full (GskPathMeasure         *self,
 
   for (i = 0; i < self->n_contours; i++)
     {
-      if (gsk_contour_get_closest_point (self->path,
-                                         i,
+      if (gsk_contour_get_closest_point (gsk_path_get_contour (self->path, i),
                                          self->measures[i].contour_data,
                                          self->tolerance,
                                          point,
@@ -469,3 +468,4 @@ gsk_path_measure_add_segment (GskPathMeasure *self,
         }
     }
 }
+
diff --git a/gsk/gskpathprivate.h b/gsk/gskpathprivate.h
index 310fa38b45..7027267764 100644
--- a/gsk/gskpathprivate.h
+++ b/gsk/gskpathprivate.h
@@ -66,25 +66,21 @@ gboolean                gsk_path_foreach_with_tolerance         (GskPath
                                                                  GskPathForeachFunc    func,
                                                                  gpointer              user_data);
 
-GskContour *            gsk_contour_dup                         (const GskContour     *src);
-gpointer                gsk_contour_init_measure                (GskPath              *path,
-                                                                 gsize                 i,
-                                                                 float                 tolerance,
-                                                                 float                *out_length);
-void                    gsk_contour_free_measure                (GskPath              *path,
-                                                                 gsize                 i,
-                                                                 gpointer              data);
+GskContour *            gsk_contour_dup                         (const GskContour       *src);
+gpointer                gsk_contour_init_measure                (const GskContour       *self,
+                                                                 float                   tolerance,
+                                                                 float                  *out_length);
+void                    gsk_contour_free_measure                (const GskContour       *self,
+                                                                 gpointer                data);
 void                    gsk_contour_get_start_end               (const GskContour       *self,
                                                                  graphene_point_t       *start,
                                                                  graphene_point_t       *end);
-void                    gsk_contour_get_point                   (GskPath              *path,
-                                                                 gsize                 i,
-                                                                 gpointer              measure_data,
-                                                                 float                 distance,
-                                                                 graphene_point_t     *pos,
-                                                                 graphene_vec2_t      *tangent);
-gboolean                gsk_contour_get_closest_point           (GskPath                *path,
-                                                                 gsize                   i,
+void                    gsk_contour_get_point                   (const GskContour       *self,
+                                                                 gpointer                measure_data,
+                                                                 float                   distance,
+                                                                 graphene_point_t       *pos,
+                                                                 graphene_vec2_t        *tangent);
+gboolean                gsk_contour_get_closest_point           (const GskContour       *self,
                                                                  gpointer                measure_data,
                                                                  float                   tolerance,
                                                                  const graphene_point_t *point,


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