Add gsk_stroke_node_get_stroke_path

We will implement stroking by filling the stroke path.
This commit is contained in:
Matthias Clasen
2022-04-07 22:51:29 -04:00
parent a88dbb820b
commit a73b6b4392
2 changed files with 24 additions and 1 deletions

View File

@@ -473,6 +473,8 @@ GskRenderNode * gsk_stroke_node_get_child (const GskRender
GDK_AVAILABLE_IN_ALL
GskPath * gsk_stroke_node_get_path (const GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskPath * gsk_stroke_node_get_stroke_path (const GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
const GskStroke * gsk_stroke_node_get_stroke (const GskRenderNode *node);
GDK_AVAILABLE_IN_ALL

View File

@@ -3992,6 +3992,7 @@ struct _GskStrokeNode
GskRenderNode *child;
GskPath *path;
GskPath *stroke_path;
GskStroke stroke;
};
@@ -4003,6 +4004,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);
@@ -4085,6 +4087,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 (path, stroke, &path_bounds))
graphene_rect_intersection (&path_bounds, &child->bounds, &node->bounds);
@@ -4116,7 +4119,7 @@ gsk_stroke_node_get_child (const GskRenderNode *node)
* gsk_stroke_node_get_path:
* @node: (type GskStrokeNode): a stroke `GskRenderNode`
*
* Retrievs the path that will be stroked with the contents of
* Retrieves the path that will be stroked with the contents of
* the @node.
*
* Returns: (transfer none): a `GskPath`
@@ -4131,6 +4134,24 @@ gsk_stroke_node_get_path (const GskRenderNode *node)
return self->path;
}
/**
* gsk_stroke_node_get_stroke_path:
* @node: (type GskStrokeNode): a stroke `GskRenderNode`
*
* Retrieves the stroke path that will be filled.
*
* Returns: (transfer none): a `GskPath`
*/
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`