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




commit a41b9ebec75351d66d332e8e39441a8880d91c50
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 fbeee8e2d7..62af8f43c6 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -1653,23 +1653,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);
 }
 
@@ -1682,21 +1676,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,
@@ -1706,8 +1696,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]