diff --git a/demos/gtk-demo/path_text.c b/demos/gtk-demo/path_text.c index 16ebb6daa7..401ef8b717 100644 --- a/demos/gtk-demo/path_text.c +++ b/demos/gtk-demo/path_text.c @@ -501,7 +501,6 @@ pointer_motion (GtkEventControllerMotion *controller, GtkPathWidget *self) { GskPathPoint point; - graphene_point_t pos; if (gsk_path_get_closest_point (self->line_path, &GRAPHENE_POINT_INIT (x, y), diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c index 3689845395..fbfe7f907d 100644 --- a/gsk/gskcontour.c +++ b/gsk/gskcontour.c @@ -51,7 +51,6 @@ struct _GskContourClass const GskStroke *stroke, GskBoundingBox *bounds); gboolean (* foreach) (const GskContour *contour, - float tolerance, GskPathForeachFunc func, gpointer user_data); GskContour * (* reverse) (const GskContour *contour); @@ -169,7 +168,7 @@ convert_to_standard_contour (const GskContour *contour) GskPathBuilder *builder; builder = gsk_path_builder_new (); - gsk_contour_foreach (contour, 0.5, add_segment, builder); + gsk_contour_foreach (contour, add_segment, builder); return gsk_path_builder_free_to_path (builder); } @@ -233,7 +232,7 @@ static void gsk_contour_print_default (const GskContour *contour, GString *string) { - gsk_contour_foreach (contour, 0.5, foreach_print, string); + gsk_contour_foreach (contour, foreach_print, string); } /* }}} */ @@ -295,7 +294,6 @@ gsk_standard_contour_get_size (const GskContour *contour) static gboolean gsk_standard_contour_foreach (const GskContour *contour, - float tolerance, GskPathForeachFunc func, gpointer user_data) { @@ -1151,7 +1149,6 @@ gsk_circle_contour_get_stroke_bounds (const GskContour *contour, static gboolean gsk_circle_contour_foreach (const GskContour *contour, - float tolerance, GskPathForeachFunc func, gpointer user_data) { @@ -1529,7 +1526,6 @@ gsk_rect_contour_get_stroke_bounds (const GskContour *contour, static gboolean gsk_rect_contour_foreach (const GskContour *contour, - float tolerance, GskPathForeachFunc func, gpointer user_data) { @@ -2079,7 +2075,6 @@ get_rounded_rect_points (const GskRoundedRect *rect, static gboolean gsk_rounded_rect_contour_foreach (const GskContour *contour, - float tolerance, GskPathForeachFunc func, gpointer user_data) { @@ -2211,7 +2206,7 @@ gsk_rounded_rect_contour_init_curve (const GskContour *contour, data.idx = idx; data.count = 0; - gsk_contour_foreach (contour, 0.5, init_curve_cb, &data); + gsk_contour_foreach (contour, init_curve_cb, &data); } static void @@ -2430,11 +2425,10 @@ gsk_contour_get_stroke_bounds (const GskContour *self, gboolean gsk_contour_foreach (const GskContour *self, - float tolerance, GskPathForeachFunc func, gpointer user_data) { - return self->klass->foreach (self, tolerance, func, user_data); + return self->klass->foreach (self, func, user_data); } int diff --git a/gsk/gskcontourprivate.h b/gsk/gskcontourprivate.h index 319ec12e33..15bfd80ba3 100644 --- a/gsk/gskcontourprivate.h +++ b/gsk/gskcontourprivate.h @@ -55,7 +55,6 @@ gboolean gsk_contour_get_stroke_bounds (const GskContou const GskStroke *stroke, GskBoundingBox *bounds); gboolean gsk_contour_foreach (const GskContour *self, - float tolerance, GskPathForeachFunc func, gpointer user_data); int gsk_contour_get_winding (const GskContour *self, diff --git a/gsk/gskpath.c b/gsk/gskpath.c index 0c5d6aa026..9bec06637a 100644 --- a/gsk/gskpath.c +++ b/gsk/gskpath.c @@ -66,6 +66,8 @@ struct _GskPath G_DEFINE_BOXED_TYPE (GskPath, gsk_path, gsk_path_ref, gsk_path_unref) +/* {{{ Private API */ + GskPath * gsk_path_new_from_contours (const GSList *contours) { @@ -110,6 +112,31 @@ gsk_path_new_from_contours (const GSList *contours) return path; } +const GskContour * +gsk_path_get_contour (const GskPath *self, + gsize i) +{ + if (i < self->n_contours) + return self->contours[i]; + else + return NULL; +} + +GskPathFlags +gsk_path_get_flags (const GskPath *self) +{ + return self->flags; +} + +gsize +gsk_path_get_n_contours (const GskPath *self) +{ + return self->n_contours; +} + +/* }}} */ +/* {{{ Public API */ + /** * gsk_path_ref: * @self: a `GskPath` @@ -153,22 +180,6 @@ gsk_path_unref (GskPath *self) g_free (self); } -const GskContour * -gsk_path_get_contour (const GskPath *self, - gsize i) -{ - if (i < self->n_contours) - return self->contours[i]; - else - return NULL; -} - -GskPathFlags -gsk_path_get_flags (const GskPath *self) -{ - return self->flags; -} - /** * gsk_path_print: * @self: a `GskPath` @@ -295,20 +306,6 @@ gsk_path_to_cairo (GskPath *self, cr); } -/*< private > - * gsk_path_get_n_contours: - * @path: a `GskPath` - * - * Gets the number of contours @path is composed out of. - * - * Returns: the number of contours in @path - */ -gsize -gsk_path_get_n_contours (const GskPath *self) -{ - return self->n_contours; -} - /** * gsk_path_is_empty: * @self: a `GskPath` @@ -613,6 +610,9 @@ gsk_path_get_closest_point (GskPath *self, return found; } +/* }}} */ +/* {{{ Foreach and decomposition */ + /** * gsk_path_foreach: * @self: a `GskPath` @@ -810,14 +810,15 @@ gsk_path_foreach_with_tolerance (GskPath *self, for (i = 0; i < self->n_contours; i++) { - if (!gsk_contour_foreach (self->contours[i], tolerance, func, user_data)) + if (!gsk_contour_foreach (self->contours[i], func, user_data)) return FALSE; } return TRUE; } -/* path parser and utilities */ +/* }}} */ +/* {{{ Parser and utilities */ static void skip_whitespace (const char **p) @@ -1612,3 +1613,7 @@ error: return NULL; } + +/* }}} */ + +/* vim:set foldmethod=marker expandtab: */ diff --git a/gsk/gskpathmeasure.c b/gsk/gskpathmeasure.c index 73ceddb012..8151f2328d 100644 --- a/gsk/gskpathmeasure.c +++ b/gsk/gskpathmeasure.c @@ -309,18 +309,15 @@ float gsk_path_point_get_distance (const GskPathPoint *point, GskPathMeasure *measure) { - const GskContour *contour; float contour_offset = 0; g_return_val_if_fail (measure != NULL, 0); g_return_val_if_fail (gsk_path_point_valid (point, measure->path), 0); - contour = gsk_path_get_contour (measure->path, point->contour); - for (gsize i = 0; i < measure->n_contours; i++) { - if (contour == gsk_path_get_contour (measure->path, i)) - return contour_offset + gsk_contour_get_distance (contour, + if (i == point->contour) + return contour_offset + gsk_contour_get_distance (gsk_path_get_contour (measure->path, i), point, measure->measures[i].contour_data);