mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
pathbuilder: Treat current point consistently
Arrange that none of the 'add' methods change the current point.
This commit is contained in:
parent
fff1645060
commit
f2835bb48b
@ -54,6 +54,9 @@
|
||||
* either common shapes like [method@Gsk.PathBuilder.add_circle]
|
||||
* or by adding from other paths like [method@Gsk.PathBuilder.add_path].
|
||||
*
|
||||
* The `gsk_path_builder_add_*` methods always add complete contours,
|
||||
* and do not use or modify the current point.
|
||||
*
|
||||
* The other option is to define each line and curve manually with
|
||||
* the `gsk_path_builder_*_to` group of functions. You start with
|
||||
* a call to [method@Gsk.PathBuilder.move_to] to set the starting point
|
||||
@ -390,9 +393,13 @@ void
|
||||
gsk_path_builder_add_cairo_path (GskPathBuilder *self,
|
||||
const cairo_path_t *path)
|
||||
{
|
||||
graphene_point_t current;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
current = self->current_point;
|
||||
|
||||
for (gsize i = 0; i < path->num_data; i += path->data[i].header.length)
|
||||
{
|
||||
const cairo_path_data_t *data = &path->data[i];
|
||||
@ -425,6 +432,7 @@ gsk_path_builder_add_cairo_path (GskPathBuilder *self,
|
||||
}
|
||||
|
||||
gsk_path_builder_end_current (self);
|
||||
self->current_point = current;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -446,8 +454,12 @@ void
|
||||
gsk_path_builder_add_rect (GskPathBuilder *self,
|
||||
const graphene_rect_t *rect)
|
||||
{
|
||||
graphene_point_t current;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
current = self->current_point;
|
||||
|
||||
gsk_path_builder_move_to (self, rect->origin.x, rect->origin.y);
|
||||
|
||||
gsk_path_builder_rel_line_to (self, rect->size.width, 0);
|
||||
@ -455,6 +467,7 @@ gsk_path_builder_add_rect (GskPathBuilder *self,
|
||||
gsk_path_builder_rel_line_to (self, - rect->size.width, 0);
|
||||
|
||||
gsk_path_builder_close (self);
|
||||
self->current_point = current;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -486,16 +499,22 @@ gsk_path_builder_add_circle (GskPathBuilder *self,
|
||||
const graphene_point_t *center,
|
||||
float radius)
|
||||
{
|
||||
graphene_point_t current;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (center != NULL);
|
||||
g_return_if_fail (radius > 0);
|
||||
|
||||
current = self->current_point;
|
||||
|
||||
gsk_path_builder_move_to (self, center->x + radius, center->y);
|
||||
gsk_spline_decompose_arc (center, radius,
|
||||
GSK_PATH_TOLERANCE_DEFAULT,
|
||||
0, 2 * M_PI,
|
||||
circle_contour_curve, self);
|
||||
|
||||
gsk_path_builder_close (self);
|
||||
self->current_point = current;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1017,6 +1036,7 @@ gsk_path_builder_add_segment (GskPathBuilder *self,
|
||||
GskRealPathPoint *e = (GskRealPathPoint *) end;
|
||||
const GskContour *contour;
|
||||
gsize n_contours = gsk_path_get_n_contours (path);
|
||||
graphene_point_t current;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (path != NULL);
|
||||
@ -1025,6 +1045,8 @@ gsk_path_builder_add_segment (GskPathBuilder *self,
|
||||
g_return_if_fail (s->contour < n_contours);
|
||||
g_return_if_fail (e->contour < n_contours);
|
||||
|
||||
current = self->current_point;
|
||||
|
||||
contour = gsk_path_get_contour (path, s->contour);
|
||||
|
||||
if (s->contour == e->contour)
|
||||
@ -1060,4 +1082,5 @@ gsk_path_builder_add_segment (GskPathBuilder *self,
|
||||
|
||||
out:
|
||||
gsk_path_builder_end_current (self);
|
||||
self->current_point = current;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user