[librsvg: 4/15] impl BasicShape for Path
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/15] impl BasicShape for Path
- Date: Tue, 1 Dec 2020 22:17:53 +0000 (UTC)
commit 9c63a3b77fb49eb9da0a807ff958a78037139731
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 1 14:28:34 2020 -0600
impl BasicShape for Path
src/shapes.rs | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/src/shapes.rs b/src/shapes.rs
index 5de72d3e..9e7d5580 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -138,6 +138,15 @@ impl SetAttributes for Path {
}
}
+impl BasicShape for Path {
+ fn make_path(&self, _values: &ComputedValues, _draw_ctx: &mut DrawingCtx) -> Rc<SvgPath> {
+ self.path
+ .as_ref()
+ .map(Rc::clone)
+ .unwrap_or_else(|| Rc::new(PathBuilder::default().into_path()))
+ }
+}
+
impl Draw for Path {
fn draw(
&self,
@@ -147,18 +156,14 @@ impl Draw for Path {
draw_ctx: &mut DrawingCtx,
clipping: bool,
) -> Result<BoundingBox, RenderingError> {
- if let Some(path) = self.path.as_ref() {
- let values = cascaded.get();
- Shape::new(path.clone(), Markers::Yes).draw(
- node,
- acquired_nodes,
- values,
- draw_ctx,
- clipping,
- )
- } else {
- Ok(draw_ctx.empty_bbox())
- }
+ let values = cascaded.get();
+ Shape::new(self.make_path(values, draw_ctx), Markers::Yes).draw(
+ node,
+ acquired_nodes,
+ values,
+ draw_ctx,
+ clipping,
+ )
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]