[librsvg] Replace state.join/state.has_join with an Option
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Replace state.join/state.has_join with an Option
- Date: Mon, 26 Mar 2018 19:56:25 +0000 (UTC)
commit 6ec84c9dacbddb8a5161c63af0a44ab8e60990dc
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Mar 26 11:40:10 2018 -0600
Replace state.join/state.has_join with an Option
It's a bit strange that the caller (in draw.rs) needs to
unwrap_or_default() - we'll refactor this later.
rsvg_internals/src/draw.rs | 4 +++-
rsvg_internals/src/state.rs | 15 +++++----------
2 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/rsvg_internals/src/draw.rs b/rsvg_internals/src/draw.rs
index efea67d1..50656747 100644
--- a/rsvg_internals/src/draw.rs
+++ b/rsvg_internals/src/draw.rs
@@ -126,7 +126,9 @@ fn setup_cr_for_stroke(cr: &cairo::Context, draw_ctx: *mut RsvgDrawingCtx, state
cr.set_line_width(state::get_stroke_width(state).normalize(draw_ctx));
cr.set_miter_limit(state::get_miter_limit(state));
cr.set_line_cap(cairo::LineCap::from(state::get_state_rust(state).cap));
- cr.set_line_join(cairo::LineJoin::from(state::get_state_rust(state).join));
+ cr.set_line_join(cairo::LineJoin::from(
+ state::get_state_rust(state).join.unwrap_or_default(),
+ ));
let dash = state::get_stroke_dasharray(state);
diff --git a/rsvg_internals/src/state.rs b/rsvg_internals/src/state.rs
index e1dd2188..4c5fd02b 100644
--- a/rsvg_internals/src/state.rs
+++ b/rsvg_internals/src/state.rs
@@ -30,8 +30,7 @@ pub enum RsvgState {}
pub struct State {
pub affine: cairo::Matrix,
- pub join: StrokeLinejoin,
- has_join: bool,
+ pub join: Option<StrokeLinejoin>,
pub cap: StrokeLinecap,
has_cap: bool,
@@ -52,7 +51,6 @@ impl State {
affine: cairo::Matrix::identity(),
join: Default::default(),
- has_join: Default::default(),
cap: Default::default(),
has_cap: Default::default(),
@@ -73,20 +71,17 @@ impl State {
Attribute::StrokeLinejoin => {
match StrokeLinejoin::parse(value, ()) {
Ok(StrokeLinejoin::Inherit) => {
- self.join = StrokeLinejoin::default();
- self.has_join = false;
+ self.join = None;
Ok(())
}
Ok(j) => {
- self.join = j;
- self.has_join = true;
+ self.join = Some(j);
Ok(())
}
Err(e) => {
- self.join = StrokeLinejoin::default();
- self.has_join = false; // FIXME - propagate errors instead of defaulting
+ self.join = None; // FIXME - propagate errors instead of defaulting
Err(e)
}
}
@@ -567,7 +562,7 @@ pub extern "C" fn rsvg_state_rust_inherit_run(
let dst = &mut *dst;
let src = &*src;
- if inherit_from_src(inherit_fn, dst.has_join, src.has_join) {
+ if inherit_from_src(inherit_fn, dst.join.is_some(), src.join.is_some()) {
dst.join = src.join;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]