[librsvg/rustification] node_is_filter_primitive(): make a private function, not a public macro



commit ce69346a0fa93a59943baba1491d0397bd314739
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Nov 22 09:02:30 2016 -0600

    node_is_filter_primitive(): make a private function, not a public macro
    
    Changed the way filter primitives are tested: they used a bitmask; now
    we have a well-defined range within the RsvgNodeType enum via the
    RSVG_NODE_TYPE_FILTER_PRIMITIVE_FIRST and
    RSVG_NODE_TYPE_FILTER_PRIMITIVE_LAST values.

 rsvg-filter.c  |   10 +++++++++-
 rsvg-private.h |    5 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/rsvg-filter.c b/rsvg-filter.c
index 4ba66d3..d0d8010 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -536,6 +536,14 @@ rsvg_filter_context_free (RsvgFilterContext * ctx)
     g_free (ctx);
 }
 
+static gboolean
+node_is_filter_primitive (RsvgNode *node)
+{
+    RsvgNodeType type = RSVG_NODE_TYPE (node);
+
+    return type > RSVG_NODE_TYPE_FILTER_PRIMITIVE_FIRST && type < RSVG_NODE_TYPE_FILTER_PRIMITIVE_LAST;
+}
+
 /**
  * rsvg_filter_render:
  * @self: a pointer to the filter to use
@@ -580,7 +588,7 @@ rsvg_filter_render (RsvgFilter *self,
 
     for (i = 0; i < self->super.children->len; i++) {
         current = g_ptr_array_index (self->super.children, i);
-        if (RSVG_NODE_IS_FILTER_PRIMITIVE (&current->super))
+        if (node_is_filter_primitive ((RsvgNode *) current))
             rsvg_filter_primitive_render (current, ctx);
     }
 
diff --git a/rsvg-private.h b/rsvg-private.h
index 62ea2cc..6ca51d9 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -307,7 +307,7 @@ typedef enum {
     RSVG_NODE_TYPE_USE,
 
     /* Filter primitives */
-    RSVG_NODE_TYPE_FILTER_PRIMITIVE = 64,
+    RSVG_NODE_TYPE_FILTER_PRIMITIVE_FIRST,              /* just a marker; not a valid type */
     RSVG_NODE_TYPE_FILTER_PRIMITIVE_BLEND,
     RSVG_NODE_TYPE_FILTER_PRIMITIVE_COLOR_MATRIX,
     RSVG_NODE_TYPE_FILTER_PRIMITIVE_COMPONENT_TRANSFER,
@@ -325,7 +325,7 @@ typedef enum {
     RSVG_NODE_TYPE_FILTER_PRIMITIVE_SPECULAR_LIGHTING,
     RSVG_NODE_TYPE_FILTER_PRIMITIVE_TILE,
     RSVG_NODE_TYPE_FILTER_PRIMITIVE_TURBULENCE,
-
+    RSVG_NODE_TYPE_FILTER_PRIMITIVE_LAST                /* just a marker; not a valid type */
 } RsvgNodeType;
 
 struct _RsvgNode {
@@ -339,7 +339,6 @@ struct _RsvgNode {
 };
 
 #define RSVG_NODE_TYPE(node)                ((node)->type)
-#define RSVG_NODE_IS_FILTER_PRIMITIVE(node) (RSVG_NODE_TYPE((node)) & RSVG_NODE_TYPE_FILTER_PRIMITIVE)
 
 struct _RsvgNodeChars {
     RsvgNode super;


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