[librsvg] rsvg-structure: Make RsvgNodeSvg an opaque structure



commit db81b26045d20b92c667347447c82e6873d7693b
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Mar 22 13:55:05 2017 -0600

    rsvg-structure: Make RsvgNodeSvg an opaque structure
    
    Add accessor functions rsvg_node_svg_get_size(),
    rsvg_node_svg_get_view_box().

 rsvg-base.c      |   17 ++++++++++-------
 rsvg-structure.c |   30 ++++++++++++++++++++++++++++++
 rsvg-structure.h |   11 +++++------
 3 files changed, 45 insertions(+), 13 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 653a665..07c59f5 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1524,9 +1524,10 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
     cairo_t *cr;
     cairo_surface_t *target;
     RsvgDrawingCtx *draw;
-    RsvgNodeSvg *root = NULL;
     RsvgNode *sself = NULL;
     RsvgBbox bbox;
+    RsvgLength root_width, root_height;
+    RsvgViewBox root_vbox;
 
     gboolean handle_subelement = TRUE;
 
@@ -1551,13 +1552,15 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
         return FALSE;
 
     g_assert (rsvg_node_get_type (handle->priv->treebase) == RSVG_NODE_TYPE_SVG);
-    root = rsvg_rust_cnode_get_impl (handle->priv->treebase);
 
     bbox.rect.x = bbox.rect.y = 0;
     bbox.rect.width = bbox.rect.height = 1;
 
+    rsvg_node_svg_get_size (handle->priv->treebase, &root_width, &root_height);
+    root_vbox = rsvg_node_svg_get_view_box (handle->priv->treebase);
+
     if (!id) {
-        if ((root->w.unit == LENGTH_UNIT_PERCENT || root->h.unit == LENGTH_UNIT_PERCENT) && 
!root->vbox.active)
+        if ((root_width.unit == LENGTH_UNIT_PERCENT || root_height.unit == LENGTH_UNIT_PERCENT) && 
!root_vbox.active)
             handle_subelement = TRUE;
         else
             handle_subelement = FALSE;
@@ -1590,12 +1593,12 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
         dimension_data->width = bbox.rect.width;
         dimension_data->height = bbox.rect.height;
     } else {
-        bbox.rect.width = root->vbox.rect.width;
-        bbox.rect.height = root->vbox.rect.height;
+        bbox.rect.width = root_vbox.rect.width;
+        bbox.rect.height = root_vbox.rect.height;
 
-        dimension_data->width = (int) (rsvg_length_hand_normalize (&root->w, handle->priv->dpi_x,
+        dimension_data->width = (int) (rsvg_length_hand_normalize (&root_width, handle->priv->dpi_x,
                                                                    bbox.rect.width, 12) + 0.5);
-        dimension_data->height = (int) (rsvg_length_hand_normalize (&root->h, handle->priv->dpi_y,
+        dimension_data->height = (int) (rsvg_length_hand_normalize (&root_height, handle->priv->dpi_y,
                                                                     bbox.rect.height, 12) + 0.5);
     }
 
diff --git a/rsvg-structure.c b/rsvg-structure.c
index 492c333..991e62a 100644
--- a/rsvg-structure.c
+++ b/rsvg-structure.c
@@ -47,6 +47,13 @@ struct _RsvgNodeUse {
     RsvgLength x, y, w, h;
 };
 
+struct _RsvgNodeSvg {
+    guint32 preserve_aspect_ratio;
+    RsvgLength x, y, w, h;
+    RsvgViewBox vbox;
+    RsvgPropertyBag *atts;
+};
+
 static gboolean
 draw_child (RsvgNode *node, gpointer data)
 {
@@ -162,6 +169,29 @@ rsvg_node_svg_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgP
 }
 
 void
+rsvg_node_svg_get_size (RsvgNode *node, RsvgLength *out_width, RsvgLength *out_height)
+{
+    RsvgNodeSvg *svg;
+
+    g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_SVG);
+    svg = rsvg_rust_cnode_get_impl (node);
+
+    *out_width  = svg->w;
+    *out_height = svg->h;
+}
+
+RsvgViewBox
+rsvg_node_svg_get_view_box (RsvgNode *node)
+{
+    RsvgNodeSvg *svg;
+
+    g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_SVG);
+    svg = rsvg_rust_cnode_get_impl (node);
+
+    return svg->vbox;
+}
+
+void
 _rsvg_node_svg_apply_atts (RsvgNode *node, RsvgNodeSvg *svg, RsvgHandle *ctx)
 {
     const char *id = NULL, *klazz = NULL, *value;
diff --git a/rsvg-structure.h b/rsvg-structure.h
index b8c8878..2064366 100644
--- a/rsvg-structure.h
+++ b/rsvg-structure.h
@@ -57,12 +57,11 @@ RsvgNode *rsvg_node_switch_new (const char *element_name, RsvgNode *parent);
 
 typedef struct _RsvgNodeSvg RsvgNodeSvg;
 
-struct _RsvgNodeSvg {
-    guint32 preserve_aspect_ratio;
-    RsvgLength x, y, w, h;
-    RsvgViewBox vbox;
-    RsvgPropertyBag *atts;
-};
+G_GNUC_INTERNAL
+void rsvg_node_svg_get_size (RsvgNode *node, RsvgLength *out_width, RsvgLength *out_height);
+
+G_GNUC_INTERNAL
+RsvgViewBox rsvg_node_svg_get_view_box (RsvgNode *node);
 
 G_GNUC_INTERNAL
 void _rsvg_node_svg_apply_atts  (RsvgNode *node, RsvgNodeSvg *svg, RsvgHandle * ctx);


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