[gtk/path-work-rebased: 52/121] path: Rename to gtk_path_builder_add_segment()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-work-rebased: 52/121] path: Rename to gtk_path_builder_add_segment()
- Date: Sun, 5 Dec 2021 03:58:55 +0000 (UTC)
commit 51d645168f237e7330f7363e7b7b4d467e934775
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 ++--
gsk/gskpathbuilder.h | 7 +++++++
gsk/gskpathmeasure.c | 42 +++++++++++++++++++++---------------------
gsk/gskpathmeasure.h | 6 ------
testsuite/gsk/path.c | 12 ++++++------
5 files changed, 36 insertions(+), 35 deletions(-)
---
diff --git a/demos/gtk-demo/path_fill.c b/demos/gtk-demo/path_fill.c
index 5c9bcdeb5a..b4597851c4 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/gsk/gskpathbuilder.h b/gsk/gskpathbuilder.h
index 4868ccf25e..4d80f22a24 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 *measure,
+ 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 3c641dfde7..01ecb0a920 100644
--- a/gsk/gskpathmeasure.c
+++ b/gsk/gskpathmeasure.c
@@ -21,6 +21,7 @@
#include "gskpathmeasure.h"
+#include "gskpathbuilder.h"
#include "gskpathprivate.h"
/**
@@ -411,49 +412,49 @@ 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:
+ * @builder: 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 @builder the segment of @measure from @start to @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 [method@Gsk.PathMeasure.get_length]
* for the end of the path. The values will be clamped to that range.
*
* 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 *builder,
+ 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),
+ float len = MIN (end, measure->measures[i].length);
+ gsk_contour_add_segment (gsk_path_get_contour (measure->path, i),
builder,
- self->measures[i].contour_data,
+ measure->measures[i].contour_data,
start,
len);
end -= len;
@@ -463,9 +464,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 (builder, gsk_contour_dup (gsk_path_get_contour (measure->path, i)));
}
}
}
-
diff --git a/gsk/gskpathmeasure.h b/gsk/gskpathmeasure.h
index 6d1829caba..5d93167be5 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,
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]