[librsvg] rsvg-mask.[ch]: Move over to rsvg_rust_cnode_new()



commit 935af237ddee0df61b5257aa5e5e87d34c567f88
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Feb 14 18:28:10 2017 -0600

    rsvg-mask.[ch]: Move over to rsvg_rust_cnode_new()

 rsvg-mask.c |   62 +++++++++++++++++++++++++++++++++-------------------------
 rsvg-mask.h |    6 +---
 2 files changed, 37 insertions(+), 31 deletions(-)
---
diff --git a/rsvg-mask.c b/rsvg-mask.c
index e7792b7..218e459 100644
--- a/rsvg-mask.c
+++ b/rsvg-mask.c
@@ -30,13 +30,11 @@
 #include <string.h>
 
 static void
-rsvg_mask_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
+rsvg_mask_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPropertyBag *atts)
 {
-    RsvgMask *mask;
+    RsvgMask *mask = impl;
     const char *value;
 
-    mask = (RsvgMask *) self;
-
     if ((value = rsvg_property_bag_lookup (atts, "maskUnits"))) {
         if (!strcmp (value, "userSpaceOnUse"))
             mask->maskunits = userSpaceOnUse;
@@ -59,36 +57,40 @@ rsvg_mask_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
         mask->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
 }
 
+static void
+rsvg_mask_draw (RsvgNode *node, gpointer impl, RsvgDrawingCtx *ctx, int dominate)
+{
+    /* nothing; this gets drawn specially in rsvg-cairo-draw.c */
+}
+
 RsvgNode *
-rsvg_new_mask (const char *element_name)
+rsvg_new_mask (const char *element_name, RsvgNode *parent)
 {
     RsvgMask *mask;
-    RsvgNodeVtable vtable = {
-        NULL,
-        NULL,
-        rsvg_mask_set_atts
-    };
-
-    mask = g_new (RsvgMask, 1);
-    _rsvg_node_init (&mask->super, RSVG_NODE_TYPE_MASK, &vtable);
 
+    mask = g_new0 (RsvgMask, 1);
     mask->maskunits = objectBoundingBox;
     mask->contentunits = userSpaceOnUse;
     mask->x = rsvg_length_parse ("0", LENGTH_DIR_HORIZONTAL);
     mask->y = rsvg_length_parse ("0", LENGTH_DIR_VERTICAL);
     mask->width = rsvg_length_parse ("1", LENGTH_DIR_HORIZONTAL);
     mask->height = rsvg_length_parse ("1", LENGTH_DIR_VERTICAL);
-    return &mask->super;
+
+    return rsvg_rust_cnode_new (RSVG_NODE_TYPE_MASK,
+                                parent,
+                                rsvg_state_new (),
+                                mask,
+                                rsvg_mask_set_atts,
+                                rsvg_mask_draw,
+                                g_free);
 }
 
 static void
-rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
+rsvg_clip_path_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPropertyBag *atts)
 {
-    RsvgClipPath *clip_path;
+    RsvgClipPath *clip_path = impl;
     const char *value;
 
-    clip_path = (RsvgClipPath *) self;
-
     if ((value = rsvg_property_bag_lookup (atts, "clipPathUnits"))) {
         if (!strcmp (value, "objectBoundingBox"))
             clip_path->units = objectBoundingBox;
@@ -97,19 +99,25 @@ rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
     }
 }
 
+static void
+rsvg_clip_path_draw (RsvgNode *node, gpointer impl, RsvgDrawingCtx *ctx, int dominate)
+{
+    /* nothing; this gets drawn specially in rsvg-cairo-draw.c */
+}
+
 RsvgNode *
-rsvg_new_clip_path (const char *element_name)
+rsvg_new_clip_path (const char *element_name, RsvgNode *parent)
 {
     RsvgClipPath *clip_path;
-    RsvgNodeVtable vtable = {
-        NULL,
-        NULL,
-        rsvg_clip_path_set_atts
-    };
 
     clip_path = g_new (RsvgClipPath, 1);
-    _rsvg_node_init (&clip_path->super, RSVG_NODE_TYPE_CLIP_PATH, &vtable);
-
     clip_path->units = userSpaceOnUse;
-    return &clip_path->super;
+
+    return rsvg_rust_cnode_new (RSVG_NODE_TYPE_CLIP_PATH,
+                                parent,
+                                rsvg_state_new (),
+                                clip_path,
+                                rsvg_clip_path_set_atts,
+                                rsvg_clip_path_draw,
+                                g_free); 
 }
diff --git a/rsvg-mask.h b/rsvg-mask.h
index d15697a..8f1b96e 100644
--- a/rsvg-mask.h
+++ b/rsvg-mask.h
@@ -40,24 +40,22 @@ typedef RsvgCoordUnits RsvgMaskUnits;
 typedef struct _RsvgMask RsvgMask;
 
 struct _RsvgMask {
-    RsvgNode super;
     RsvgLength x, y, width, height;
     RsvgMaskUnits maskunits;
     RsvgMaskUnits contentunits;
 };
 
 G_GNUC_INTERNAL
-RsvgNode *rsvg_new_mask            (const char *element_name);
+RsvgNode *rsvg_new_mask            (const char *element_name, RsvgNode *node);
 
 typedef struct _RsvgClipPath RsvgClipPath;
 
 struct _RsvgClipPath {
-    RsvgNode super;
     RsvgCoordUnits units;
 };
 
 G_GNUC_INTERNAL
-RsvgNode *rsvg_new_clip_path   (const char *element_name);
+RsvgNode *rsvg_new_clip_path   (const char *element_name, RsvgNode *node);
 
 G_END_DECLS
 #endif


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