[librsvg: 3/45] CommonGradient: new struct, a resolved version of CommonGradientData



commit 845cd6ea7e8f7055ad36ef12bcb156e9fd4cc48b
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Sep 26 17:12:16 2019 -0500

    CommonGradient: new struct, a resolved version of CommonGradientData
    
    I.e. without all the Options.

 rsvg_internals/src/gradient.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index a275aae1..6d065799 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -88,6 +88,13 @@ pub struct CommonGradientData {
     pub stops: Option<Vec<ColorStop>>,
 }
 
+pub struct CommonGradient {
+    pub units: GradientUnits,
+    pub affine: cairo::Matrix,
+    pub spread: SpreadMethod,
+    pub stops: Vec<ColorStop>,
+}
+
 impl Resolve for CommonGradientData {
     fn is_resolved(&self) -> bool {
         self.units.is_some()
@@ -130,6 +137,19 @@ impl CommonGradientData {
         Ok(())
     }
 
+    fn to_resolved(self) -> CommonGradient {
+        assert!(self.is_resolved());
+
+        let CommonGradientData { units, affine, spread, stops, .. } = self;
+
+        CommonGradient {
+            units: units.unwrap(),
+            affine: affine.unwrap(),
+            spread: spread.unwrap(),
+            stops: stops.unwrap(),
+        }
+    }
+
     fn clone_stops(&self) -> Option<Vec<ColorStop>> {
         if let Some(ref stops) = self.stops {
             Some(stops.clone())


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