path: Make all private contour APIs take a GskContour

... instead of a path, index tuple.
This commit is contained in:
Benjamin Otte
2020-11-30 18:05:49 +01:00
parent 25f9eadb0d
commit 15e8f2bacc
3 changed files with 25 additions and 41 deletions

View File

@@ -1656,23 +1656,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);
}
@@ -1685,21 +1679,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,
@@ -1709,8 +1699,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,

View File

@@ -109,7 +109,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;
@@ -157,7 +157,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);
@@ -252,8 +253,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,
@@ -345,8 +345,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,
@@ -475,3 +474,4 @@ gsk_path_measure_add_segment (GskPathMeasure *self,
}
}
}

View File

@@ -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,