stroke: Turn stroke copy intialization into a macro

That way I can use it in static initializers.
This commit is contained in:
Benjamin Otte 2023-12-27 22:26:35 +01:00
parent ea5768cb42
commit 0c3c8a6a85
4 changed files with 13 additions and 11 deletions

View File

@ -4829,7 +4829,7 @@ gsk_stroke_node_new (GskRenderNode *child,
self->child = gsk_render_node_ref (child);
self->path = gsk_path_ref (path);
gsk_stroke_init_copy (&self->stroke, stroke);
self->stroke = GSK_STROKE_INIT_COPY (stroke);
if (gsk_path_get_stroke_bounds (self->path, &self->stroke, &stroke_bounds))
gsk_rect_intersection (&stroke_bounds, &child->bounds, &node->bounds);

View File

@ -79,7 +79,7 @@ gsk_stroke_copy (const GskStroke *other)
self = g_new (GskStroke, 1);
gsk_stroke_init_copy (self, other);
*self = GSK_STROKE_INIT_COPY (other);
return self;
}

View File

@ -37,14 +37,16 @@ struct _GskStroke
float dash_offset;
};
static inline void
gsk_stroke_init_copy (GskStroke *stroke,
const GskStroke *other)
{
*stroke = *other;
stroke->dash = g_memdup (other->dash, stroke->n_dash * sizeof (float));
}
#define GSK_STROKE_INIT_COPY(_stroke) ((GskStroke) {\
.line_width = _stroke->line_width, \
.line_cap = _stroke->line_cap, \
.line_join = _stroke->line_join, \
.miter_limit = _stroke->miter_limit, \
.dash = g_memdup (_stroke->dash, _stroke->n_dash * sizeof (float)), \
.n_dash = _stroke->n_dash, \
.dash_length = _stroke->dash_length, \
.dash_offset = _stroke->dash_offset, \
})
static inline void
gsk_stroke_clear (GskStroke *stroke)

View File

@ -1301,7 +1301,7 @@ gtk_snapshot_push_stroke (GtkSnapshot *snapshot,
gtk_snapshot_clear_stroke);
state->data.stroke.path = gsk_path_ref (path);
gsk_stroke_init_copy (&state->data.stroke.stroke, stroke);
state->data.stroke.stroke = GSK_STROKE_INIT_COPY (stroke);
}
static GskRenderNode *