[librsvg: 3/7] node: introduce different types for light sources



commit 89d9a213d73c4d4a4919c4bbcc94f3fdc04be9fd
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Dec 2 11:21:48 2018 +0100

    node: introduce different types for light sources

 rsvg_internals/src/create_node.rs            | 10 +++-------
 rsvg_internals/src/filters/light/lighting.rs |  8 ++++----
 rsvg_internals/src/node.rs                   |  4 +++-
 3 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/rsvg_internals/src/create_node.rs b/rsvg_internals/src/create_node.rs
index 4c58450d..8a772aed 100644
--- a/rsvg_internals/src/create_node.rs
+++ b/rsvg_internals/src/create_node.rs
@@ -102,7 +102,7 @@ node_create_fn!(
 );
 node_create_fn!(
     create_distant_light,
-    LightSource,
+    DistantLight,
     LightSource::new_distant_light
 );
 node_create_fn!(
@@ -140,11 +140,7 @@ node_create_fn!(
 node_create_fn!(create_offset, FilterPrimitiveOffset, Offset::new);
 node_create_fn!(create_path, Path, NodePath::new);
 node_create_fn!(create_pattern, Pattern, NodePattern::new);
-node_create_fn!(
-    create_point_light,
-    LightSource,
-    LightSource::new_point_light
-);
+node_create_fn!(create_point_light, PointLight, LightSource::new_point_light);
 node_create_fn!(create_polygon, Polygon, NodePoly::new_closed);
 node_create_fn!(create_polyline, Polyline, NodePoly::new_open);
 node_create_fn!(
@@ -158,7 +154,7 @@ node_create_fn!(
     FilterPrimitiveSpecularLighting,
     Lighting::new_specular
 );
-node_create_fn!(create_spot_light, LightSource, LightSource::new_spot_light);
+node_create_fn!(create_spot_light, SpotLight, LightSource::new_spot_light);
 node_create_fn!(create_stop, Stop, NodeStop::new);
 node_create_fn!(create_style, Style, NodeStyle::new);
 node_create_fn!(create_svg, Svg, NodeSvg::new);
diff --git a/rsvg_internals/src/filters/light/lighting.rs b/rsvg_internals/src/filters/light/lighting.rs
index 1e77f882..06bcca97 100644
--- a/rsvg_internals/src/filters/light/lighting.rs
+++ b/rsvg_internals/src/filters/light/lighting.rs
@@ -226,10 +226,10 @@ impl Filter for Lighting {
             cssparser::Color::RGBA(rgba) => rgba,
         };
 
-        let mut light_sources = node
-            .children()
-            .rev()
-            .filter(|c| c.get_type() == NodeType::LightSource);
+        let mut light_sources = node.children().rev().filter(|c| match c.get_type() {
+            NodeType::DistantLight | NodeType::PointLight | NodeType::SpotLight => true,
+            _ => false,
+        });
         let light_source = light_sources.next();
         if light_source.is_none() || light_sources.next().is_some() {
             return Err(FilterError::InvalidLightSourceCount);
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index 60779b05..6fea2427 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -183,11 +183,11 @@ pub enum NodeType {
     ComponentTransferFunctionG,
     ComponentTransferFunctionR,
     Defs,
+    DistantLight,
     Ellipse,
     Filter,
     Group,
     Image,
-    LightSource,
     Line,
     LinearGradient,
     Link,
@@ -195,10 +195,12 @@ pub enum NodeType {
     Mask,
     Path,
     Pattern,
+    PointLight,
     Polygon,
     Polyline,
     RadialGradient,
     Rect,
+    SpotLight,
     Stop,
     Style,
     Svg,


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