[librsvg: 1/7] clip_path: shorten code



commit 2ea2a92dc671b26382c83f7c3ac07b8a592b09d2
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Jan 2 10:17:15 2020 +0100

    clip_path: shorten code

 rsvg_internals/src/clip_path.rs   |  4 ++--
 rsvg_internals/src/drawing_ctx.rs | 12 +++++-------
 2 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/clip_path.rs b/rsvg_internals/src/clip_path.rs
index 97a512cf..df1997cc 100644
--- a/rsvg_internals/src/clip_path.rs
+++ b/rsvg_internals/src/clip_path.rs
@@ -19,8 +19,8 @@ pub struct ClipPath {
 }
 
 impl ClipPath {
-    pub fn get_units(&self) -> ClipPathUnits {
-        self.units
+    pub fn get_units(&self) -> CoordUnits {
+        CoordUnits::from(self.units)
     }
 
     pub fn to_cairo_context(
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index d10c277c..d58f1031 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -8,7 +8,7 @@ use std::rc::{Rc, Weak};
 use crate::allowed_url::Fragment;
 use crate::aspect_ratio::AspectRatio;
 use crate::bbox::BoundingBox;
-use crate::clip_path::{ClipPath, ClipPathUnits};
+use crate::clip_path::ClipPath;
 use crate::coord_units::CoordUnits;
 use crate::dasharray::Dasharray;
 use crate::document::Document;
@@ -349,13 +349,11 @@ impl DrawingCtx {
             .and_then(|acquired| {
                 let clip_node = acquired.get().clone();
 
-                let ClipPathUnits(units) = clip_node.borrow().get_impl::<ClipPath>().get_units();
+                let units = clip_node.borrow().get_impl::<ClipPath>().get_units();
 
-                if units == CoordUnits::UserSpaceOnUse {
-                    Some((Some(clip_node), None))
-                } else {
-                    assert!(units == CoordUnits::ObjectBoundingBox);
-                    Some((None, Some(clip_node)))
+                match units {
+                    CoordUnits::UserSpaceOnUse => Some((Some(clip_node), None)),
+                    CoordUnits::ObjectBoundingBox => Some((None, Some(clip_node))),
                 }
             })
             .unwrap_or((None, None))


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