Add a private getter for the stroke path

We will implement stroking by filling the stroke path.

Compute the stroke path ahead of time, so we don't have
to do it over and over.

This may change in the future, at least for simple
strokes, so keep this private.
This commit is contained in:
Matthias Clasen
2022-04-07 22:51:29 -04:00
parent 3b96b6a3fb
commit 6ba873d3fc
2 changed files with 14 additions and 0 deletions

View File

@@ -4567,6 +4567,7 @@ struct _GskStrokeNode
GskRenderNode *child;
GskPath *path;
GskPath *stroke_path;
GskStroke stroke;
};
@@ -4578,6 +4579,7 @@ gsk_stroke_node_finalize (GskRenderNode *node)
gsk_render_node_unref (self->child);
gsk_path_unref (self->path);
gsk_path_unref (self->stroke_path);
gsk_stroke_clear (&self->stroke);
parent_class->finalize (node);
@@ -4673,6 +4675,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_path = gsk_path_stroke (path, &self->stroke);
if (gsk_path_get_stroke_bounds (self->path, &self->stroke, &stroke_bounds))
graphene_rect_intersection (&stroke_bounds, &child->bounds, &node->bounds);
@@ -4719,6 +4722,16 @@ gsk_stroke_node_get_path (const GskRenderNode *node)
return self->path;
}
GskPath *
gsk_stroke_node_get_stroke_path (const GskRenderNode *node)
{
const GskStrokeNode *self = (const GskStrokeNode *) node;
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_STROKE_NODE), NULL);
return self->stroke_path;
}
/**
* gsk_stroke_node_get_stroke:
* @node: (type GskStrokeNode): a stroke #GskRenderNode

View File

@@ -87,6 +87,7 @@ gboolean gsk_container_node_is_disjoint (const GskRenderNode
gboolean gsk_render_node_use_offscreen_for_opacity (const GskRenderNode *node);
GskPath * gsk_stroke_node_get_stroke_path (const GskRenderNode *node);
G_END_DECLS