[librsvg] Switch from cairo::PathSegment to our own PathCommand throughout
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Switch from cairo::PathSegment to our own PathCommand throughout
- Date: Wed, 23 Aug 2017 01:57:33 +0000 (UTC)
commit 177b7401265c1adfd6a973067ded31f17ffb3fe2
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Aug 22 20:33:08 2017 -0500
Switch from cairo::PathSegment to our own PathCommand throughout
rust/src/marker.rs | 12 ++++++------
rust/src/path_builder.rs | 28 ++++++++++++++--------------
rust/src/path_parser.rs | 44 ++++++++++++++++++++++----------------------
3 files changed, 42 insertions(+), 42 deletions(-)
---
diff --git a/rust/src/marker.rs b/rust/src/marker.rs
index 36eddb6..5b9fdda 100644
--- a/rust/src/marker.rs
+++ b/rust/src/marker.rs
@@ -308,12 +308,12 @@ pub fn path_builder_to_segments (builder: &RsvgPathBuilder) -> Vec<Segment> {
segments = Vec::new ();
state = SegmentState::Initial;
- for cairo_segment in builder.get_path_segments () {
+ for path_command in builder.get_path_commands () {
last_x = cur_x;
last_y = cur_y;
- match *cairo_segment {
- cairo::PathSegment::MoveTo ((x, y)) => {
+ match *path_command {
+ PathCommand::MoveTo (x, y) => {
cur_x = x;
cur_y = y;
@@ -353,7 +353,7 @@ pub fn path_builder_to_segments (builder: &RsvgPathBuilder) -> Vec<Segment> {
}
},
- cairo::PathSegment::LineTo ((x, y)) => {
+ PathCommand::LineTo (x, y) => {
cur_x = x;
cur_y = y;
@@ -362,7 +362,7 @@ pub fn path_builder_to_segments (builder: &RsvgPathBuilder) -> Vec<Segment> {
state = SegmentState::InSubpath;
},
- cairo::PathSegment::CurveTo ((x2, y2), (x3, y3), (x4, y4)) => {
+ PathCommand::CurveTo ((x2, y2), (x3, y3), (x4, y4)) => {
cur_x = x4;
cur_y = y4;
@@ -371,7 +371,7 @@ pub fn path_builder_to_segments (builder: &RsvgPathBuilder) -> Vec<Segment> {
state = SegmentState::InSubpath;
},
- cairo::PathSegment::ClosePath => {
+ PathCommand::ClosePath => {
cur_x = subpath_start_x;
cur_y = subpath_start_y;
diff --git a/rust/src/path_builder.rs b/rust/src/path_builder.rs
index a7bda6f..b71f5dd 100644
--- a/rust/src/path_builder.rs
+++ b/rust/src/path_builder.rs
@@ -13,36 +13,36 @@ pub enum PathCommand {
#[repr(C)]
pub struct RsvgPathBuilder {
- path_segments: Vec<cairo::PathSegment>,
+ path_commands: Vec<PathCommand>,
}
impl RsvgPathBuilder {
pub fn new () -> RsvgPathBuilder {
let builder = RsvgPathBuilder {
- path_segments: Vec::new ()
+ path_commands: Vec::new ()
};
builder
}
pub fn move_to (&mut self, x: f64, y: f64) {
- self.path_segments.push (cairo::PathSegment::MoveTo ((x, y)));
+ self.path_commands.push (PathCommand::MoveTo (x, y));
}
pub fn line_to (&mut self, x: f64, y: f64) {
- self.path_segments.push (cairo::PathSegment::LineTo ((x, y)));
+ self.path_commands.push (PathCommand::LineTo (x, y));
}
pub fn curve_to (&mut self, x2: f64, y2: f64, x3: f64, y3: f64, x4: f64, y4: f64) {
- self.path_segments.push (cairo::PathSegment::CurveTo ((x2, y2), (x3, y3), (x4, y4)));
+ self.path_commands.push (PathCommand::CurveTo ((x2, y2), (x3, y3), (x4, y4)));
}
pub fn close_path (&mut self) {
- self.path_segments.push (cairo::PathSegment::ClosePath);
+ self.path_commands.push (PathCommand::ClosePath);
}
- pub fn get_path_segments (&self) -> &Vec<cairo::PathSegment> {
- &self.path_segments
+ pub fn get_path_commands (&self) -> &Vec<PathCommand> {
+ &self.path_commands
}
/**
@@ -240,23 +240,23 @@ pub extern fn rsvg_path_builder_add_to_cairo_context (raw_builder: *mut RsvgPath
let builder: &mut RsvgPathBuilder = unsafe { &mut (*raw_builder) };
unsafe {
- let path_segments = builder.get_path_segments ();
+ let path_commands = builder.get_path_commands ();
- for s in path_segments {
+ for s in path_commands {
match *s {
- cairo::PathSegment::MoveTo ((x, y)) => {
+ PathCommand::MoveTo (x, y) => {
cairo_sys::cairo_move_to (cr, x, y);
},
- cairo::PathSegment::LineTo ((x, y)) => {
+ PathCommand::LineTo (x, y) => {
cairo_sys::cairo_line_to (cr, x, y);
},
- cairo::PathSegment::CurveTo ((x2, y2), (x3, y3), (x4, y4)) => {
+ PathCommand::CurveTo ((x2, y2), (x3, y3), (x4, y4)) => {
cairo_sys::cairo_curve_to (cr, x2, y2, x3, y3, x4, y4);
},
- cairo::PathSegment::ClosePath => {
+ PathCommand::ClosePath => {
cairo_sys::cairo_close_path (cr);
}
}
diff --git a/rust/src/path_parser.rs b/rust/src/path_parser.rs
index 0d4358c..2685f9f 100644
--- a/rust/src/path_parser.rs
+++ b/rust/src/path_parser.rs
@@ -1003,8 +1003,8 @@ mod tests {
extern crate cairo;
- fn path_segment_vectors_are_equal (a: &Vec<cairo::PathSegment>,
- b: &Vec<cairo::PathSegment>) -> bool {
+ fn path_command_vectors_are_equal (a: &Vec<PathCommand>,
+ b: &Vec<PathCommand>) -> bool {
if a.len() != b.len () {
return false;
@@ -1019,8 +1019,8 @@ mod tests {
loop {
if let Some ((seg1, seg2)) = iter.next () {
match *seg1 {
- cairo::PathSegment::MoveTo ((x, y)) => {
- if let cairo::PathSegment::MoveTo ((ox, oy)) = *seg2 {
+ PathCommand::MoveTo (x, y) => {
+ if let PathCommand::MoveTo (ox, oy) = *seg2 {
if (x, y) != (ox, oy) {
return false;
}
@@ -1029,8 +1029,8 @@ mod tests {
}
},
- cairo::PathSegment::LineTo ((x, y)) => {
- if let cairo::PathSegment::LineTo ((ox, oy)) = *seg2 {
+ PathCommand::LineTo (x, y) => {
+ if let PathCommand::LineTo (ox, oy) = *seg2 {
if (x, y) != (ox, oy) {
return false;
}
@@ -1039,8 +1039,8 @@ mod tests {
}
},
- cairo::PathSegment::CurveTo ((x2, y2), (x3, y3), (x4, y4)) => {
- if let cairo::PathSegment::CurveTo ((ox2, oy2), (ox3, oy3), (ox4, oy4)) = *seg2 {
+ PathCommand::CurveTo ((x2, y2), (x3, y3), (x4, y4)) => {
+ if let PathCommand::CurveTo ((ox2, oy2), (ox3, oy3), (ox4, oy4)) = *seg2 {
if (ox2, oy2, ox3, oy3, ox4, oy4) != (x2, y2, x3, y3, x4, y4) {
return false;
}
@@ -1049,8 +1049,8 @@ mod tests {
}
},
- cairo::PathSegment::ClosePath => {
- if let cairo::PathSegment::ClosePath = *seg2 {
+ PathCommand::ClosePath => {
+ if let PathCommand::ClosePath = *seg2 {
/* okay */
} else {
return false;
@@ -1092,33 +1092,33 @@ mod tests {
}
fn test_parser (path_str: &str,
- expected_segments: &Vec<cairo::PathSegment>) {
+ expected_commands: &Vec<PathCommand>) {
let builder = parse_path (path_str);
- let segments = builder.get_path_segments ();
+ let commands = builder.get_path_commands ();
- assert! (path_segment_vectors_are_equal (expected_segments, segments));
+ assert! (path_command_vectors_are_equal (expected_commands, commands));
}
- fn moveto (x: f64, y: f64) -> cairo::PathSegment {
- cairo::PathSegment::MoveTo ((x, y))
+ fn moveto (x: f64, y: f64) -> PathCommand {
+ PathCommand::MoveTo (x, y)
}
- fn lineto (x: f64, y: f64) -> cairo::PathSegment {
- cairo::PathSegment::LineTo ((x, y))
+ fn lineto (x: f64, y: f64) -> PathCommand {
+ PathCommand::LineTo (x, y)
}
- fn curveto (x2: f64, y2: f64, x3: f64, y3: f64, x4: f64, y4: f64) -> cairo::PathSegment {
- cairo::PathSegment::CurveTo ((x2, y2), (x3, y3), (x4, y4))
+ fn curveto (x2: f64, y2: f64, x3: f64, y3: f64, x4: f64, y4: f64) -> PathCommand {
+ PathCommand::CurveTo ((x2, y2), (x3, y3), (x4, y4))
}
- fn closepath () -> cairo::PathSegment {
- cairo::PathSegment::ClosePath
+ fn closepath () -> PathCommand {
+ PathCommand::ClosePath
}
#[test]
fn handles_empty_data () {
test_parser ("",
- &Vec::<cairo::PathSegment>::new ());
+ &Vec::<PathCommand>::new ());
}
#[test]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]