[gtk/wip/otte/lottie: 52/86] path: Rename to gtk_path_builder_add_segment()




commit 70b84a7cc8599bc7c0cd497718e45458dbd9ea7b
Author: Benjamin Otte <otte redhat com>
Date:   Tue Dec 1 13:24:20 2020 +0100

    path: Rename to gtk_path_builder_add_segment()
    
    It's about bulding paths, not about measuring them.

 demos/gtk-demo/path_fill.c           |  4 ++--
 docs/reference/gsk/gsk4-sections.txt |  2 +-
 gsk/gskpathbuilder.h                 |  7 ++++++
 gsk/gskpathmeasure.c                 | 43 ++++++++++++++++++------------------
 gsk/gskpathmeasure.h                 |  6 -----
 testsuite/gsk/path.c                 | 12 +++++-----
 6 files changed, 38 insertions(+), 36 deletions(-)
---
diff --git a/demos/gtk-demo/path_fill.c b/demos/gtk-demo/path_fill.c
index d6f722339e..fbb48f040e 100644
--- a/demos/gtk-demo/path_fill.c
+++ b/demos/gtk-demo/path_fill.c
@@ -227,8 +227,8 @@ update_path (GtkWidget     *widget,
   graphene_vec2_t tangent;
 
   builder = gsk_path_builder_new ();
-  gsk_path_measure_add_segment (measure,
-                                builder,
+  gsk_path_builder_add_segment (builder,
+                                measure,
                                 progress > 1 ? (progress - 1) * gsk_path_measure_get_length (measure) : 0.0,
                                 (progress < 1 ? progress : 1.0) * gsk_path_measure_get_length (measure));
 
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index d7f0891c57..098f2fe82b 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -354,6 +354,7 @@ gsk_path_builder_get_current_point
 gsk_path_builder_add_rect
 gsk_path_builder_add_circle
 gsk_path_builder_add_path
+gtk_path_builder_add_segment
 <SUBSECTION>
 gsk_path_builder_move_to
 gsk_path_builder_rel_move_to
@@ -380,7 +381,6 @@ gsk_path_measure_get_point
 gsk_path_measure_get_closest_point
 gsk_path_measure_get_closest_point_full
 gsk_path_measure_in_fill
-gsk_path_measure_add_segment
 <SUBSECTION Private>
 GSK_TYPE_PATH_MEASURE
 gsk_path_measure_get_type
diff --git a/gsk/gskpathbuilder.h b/gsk/gskpathbuilder.h
index 4868ccf25e..c2ee8157ba 100644
--- a/gsk/gskpathbuilder.h
+++ b/gsk/gskpathbuilder.h
@@ -58,6 +58,13 @@ GDK_AVAILABLE_IN_ALL
 void                    gsk_path_builder_add_circle             (GskPathBuilder         *builder,
                                                                  const graphene_point_t *center,
                                                                  float                   radius);
+/* next function implemented in gskpathmeasure.c */
+GDK_AVAILABLE_IN_ALL
+void                    gsk_path_builder_add_segment            (GskPathBuilder         *builder,
+                                                                 GskPathMeasure         *self,
+                                                                 float                   start,
+                                                                 float                   end);
+
 
 GDK_AVAILABLE_IN_ALL
 void                    gsk_path_builder_move_to                (GskPathBuilder         *builder,
diff --git a/gsk/gskpathmeasure.c b/gsk/gskpathmeasure.c
index 1b1cc8b670..73bc567edc 100644
--- a/gsk/gskpathmeasure.c
+++ b/gsk/gskpathmeasure.c
@@ -21,6 +21,7 @@
 
 #include "gskpathmeasure.h"
 
+#include "gskpathbuilder.h"
 #include "gskpathprivate.h"
 
 /**
@@ -416,15 +417,15 @@ gsk_path_measure_in_fill (GskPathMeasure         *self,
 
 
 /**
- * gsk_path_measure_add_segment:
- * @self: a #GskPathMeasure
- * @builder: the builder to add the segment to
+ * gsk_path_builder_add_segment:
+ * @self: a #GskPathBuilder 
+ * @measure: the #GskPathMeasure to take the segment to
  * @start: start distance into the path
  * @end: end distance into the path
  *
- * Adds to @builder the segment of @path inbetween @start and @end.
+ * Adds to @self the segment of @measure inbetween @start and @end.
  *
- * The distances are given relative to the length of @self's path,
+ * The distances are given relative to the length of @measure's path,
  * from 0 for the beginning of the path to
  * gsk_path_measure_get_length() for the end of the path. The values
  * will be clamped to that range.
@@ -432,34 +433,34 @@ gsk_path_measure_in_fill (GskPathMeasure         *self,
  * If @start >= @end after clamping, no path will be added.
  **/
 void
-gsk_path_measure_add_segment (GskPathMeasure *self,
-                              GskPathBuilder *builder,
+gsk_path_builder_add_segment (GskPathBuilder *self,
+                              GskPathMeasure *measure,
                               float           start,
                               float           end)
 {
   gsize i;
 
   g_return_if_fail (self != NULL);
-  g_return_if_fail (builder != NULL);
+  g_return_if_fail (measure != NULL);
 
-  start = gsk_path_measure_clamp_distance (self, start);
-  end = gsk_path_measure_clamp_distance (self, end);
+  start = gsk_path_measure_clamp_distance (measure, start);
+  end = gsk_path_measure_clamp_distance (measure, end);
   if (start >= end)
     return;
 
-  for (i = 0; i < self->n_contours; i++)
+  for (i = 0; i < measure->n_contours; i++)
     {
-      if (self->measures[i].length < start)
+      if (measure->measures[i].length < start)
         {
-          start -= self->measures[i].length;
-          end -= self->measures[i].length;
+          start -= measure->measures[i].length;
+          end -= measure->measures[i].length;
         }
-      else if (start > 0 || end < self->measures[i].length)
+      else if (start > 0 || end < measure->measures[i].length)
         {
-          float len = MIN (end, self->measures[i].length);
-          gsk_contour_add_segment (gsk_path_get_contour (self->path, i),
-                                   builder,
-                                   self->measures[i].contour_data,
+          float len = MIN (end, measure->measures[i].length);
+          gsk_contour_add_segment (gsk_path_get_contour (measure->path, i),
+                                   self,
+                                   measure->measures[i].contour_data,
                                    start,
                                    len);
           end -= len;
@@ -469,8 +470,8 @@ gsk_path_measure_add_segment (GskPathMeasure *self,
         }
       else
         {
-          end -= self->measures[i].length;
-          gsk_path_builder_add_contour (builder, gsk_contour_dup (gsk_path_get_contour (self->path, i)));
+          end -= measure->measures[i].length;
+          gsk_path_builder_add_contour (self, gsk_contour_dup (gsk_path_get_contour (measure->path, i)));
         }
     }
 }
diff --git a/gsk/gskpathmeasure.h b/gsk/gskpathmeasure.h
index c20e79bef1..3cc4f74224 100644
--- a/gsk/gskpathmeasure.h
+++ b/gsk/gskpathmeasure.h
@@ -64,12 +64,6 @@ gboolean                gsk_path_measure_get_closest_point_full (GskPathMeasure
                                                                  float                  *out_offset,
                                                                  graphene_vec2_t        *out_tangent);
 
-GDK_AVAILABLE_IN_ALL
-void                    gsk_path_measure_add_segment            (GskPathMeasure         *self,
-                                                                 GskPathBuilder         *builder,
-                                                                 float                   start,
-                                                                 float                   end);
-
 GDK_AVAILABLE_IN_ALL
 gboolean                gsk_path_measure_in_fill                (GskPathMeasure         *self,
                                                                  const graphene_point_t *point,
diff --git a/testsuite/gsk/path.c b/testsuite/gsk/path.c
index 1390fd4364..193c2e045c 100644
--- a/testsuite/gsk/path.c
+++ b/testsuite/gsk/path.c
@@ -547,7 +547,7 @@ test_segment_start (void)
       float seg_length = length * i / 100.0f;
 
       builder = gsk_path_builder_new ();
-      gsk_path_measure_add_segment (measure, builder, 0, seg_length);
+      gsk_path_builder_add_segment (builder, measure, 0, seg_length);
       path1 = gsk_path_builder_free_to_path (builder);
       measure1 = gsk_path_measure_new (path1);
 
@@ -580,7 +580,7 @@ test_segment_end (void)
       float seg_length = length * i / 100.0f;
 
       builder = gsk_path_builder_new ();
-      gsk_path_measure_add_segment (measure, builder, length - seg_length, length);
+      gsk_path_builder_add_segment (builder, measure, length - seg_length, length);
       path1 = gsk_path_builder_free_to_path (builder);
       measure1 = gsk_path_measure_new (path1);
 
@@ -613,7 +613,7 @@ test_segment_chunk (void)
       float seg_start = length * i / 200.0f;
 
       builder = gsk_path_builder_new ();
-      gsk_path_measure_add_segment (measure, builder, seg_start, seg_start + length / 2);
+      gsk_path_builder_add_segment (builder, measure, seg_start, seg_start + length / 2);
       path1 = gsk_path_builder_free_to_path (builder);
       measure1 = gsk_path_measure_new (path1);
 
@@ -648,17 +648,17 @@ test_segment (void)
       split2 = g_test_rand_double_range (split1, length);
 
       builder = gsk_path_builder_new ();
-      gsk_path_measure_add_segment (measure, builder, 0, split1);
+      gsk_path_builder_add_segment (builder, measure, 0, split1);
       path1 = gsk_path_builder_free_to_path (builder);
       measure1 = gsk_path_measure_new (path1);
 
       builder = gsk_path_builder_new ();
-      gsk_path_measure_add_segment (measure, builder, split1, split2);
+      gsk_path_builder_add_segment (builder, measure, split1, split2);
       path2 = gsk_path_builder_free_to_path (builder);
       measure2 = gsk_path_measure_new (path2);
 
       builder = gsk_path_builder_new ();
-      gsk_path_measure_add_segment (measure, builder, split2, length);
+      gsk_path_builder_add_segment (builder, measure, split2, length);
       path3 = gsk_path_builder_free_to_path (builder);
       measure3 = gsk_path_measure_new (path3);
 


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