[gtk/path-work-rebased: 149/149] Add gsk_stroke_node_get_stroke_path




commit e8652b21b3d53d8440e24589cf8e71b4095c3ddf
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Apr 7 22:51:29 2022 -0400

    Add gsk_stroke_node_get_stroke_path
    
    We will implement stroking by filling the stroke path.

 gsk/gskrendernode.h     |  2 ++
 gsk/gskrendernodeimpl.c | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index e5243e5143..89f54fa538 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -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
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 269bb03d8a..18256917b3 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -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`


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]