[librsvg/rustification] path_builder.rs: Actually put a ClosePath in our array of cairo::PathSegment
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] path_builder.rs: Actually put a ClosePath in our array of cairo::PathSegment
- Date: Wed, 2 Nov 2016 01:32:29 +0000 (UTC)
commit 379dea0418fbfdd47910055579d8cced847e6bb7
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 1 19:08:55 2016 -0600
path_builder.rs: Actually put a ClosePath in our array of cairo::PathSegment
Don't handle Cairo's close_path semantics, of adding an extra move_to,
by ourselves. This will happen inside Cairo itself when we
_add_to_cairo_context().
This makes the Rust tests pass.
But do we now have states we don't need in marker.rs...?
rust/src/path_builder.rs | 18 ++----------------
1 files changed, 2 insertions(+), 16 deletions(-)
---
diff --git a/rust/src/path_builder.rs b/rust/src/path_builder.rs
index 1323f09..2f1ebcb 100644
--- a/rust/src/path_builder.rs
+++ b/rust/src/path_builder.rs
@@ -4,14 +4,12 @@ extern crate cairo_sys;
#[repr(C)]
pub struct RsvgPathBuilder {
path_segments: Vec<cairo::PathSegment>,
- last_move_to_index: Option<usize>
}
impl RsvgPathBuilder {
pub fn new () -> RsvgPathBuilder {
let builder = RsvgPathBuilder {
- path_segments: Vec::new (),
- last_move_to_index: None
+ path_segments: Vec::new ()
};
builder
@@ -19,7 +17,6 @@ impl RsvgPathBuilder {
pub fn move_to (&mut self, x: f64, y: f64) {
self.path_segments.push (cairo::PathSegment::MoveTo ((x, y)));
- self.last_move_to_index = Some (self.path_segments.len () - 1);
}
pub fn line_to (&mut self, x: f64, y: f64) {
@@ -31,15 +28,7 @@ impl RsvgPathBuilder {
}
pub fn close_path (&mut self) {
- if let Some (idx) = self.last_move_to_index {
- let segment = self.path_segments[idx];
-
- if let cairo::PathSegment::MoveTo ((x, y)) = segment {
- self.move_to (x, y);
- } else {
- unreachable! ();
- }
- }
+ self.path_segments.push (cairo::PathSegment::ClosePath);
}
pub fn get_path_segments (&self) -> &Vec<cairo::PathSegment> {
@@ -131,9 +120,6 @@ pub extern fn rsvg_path_builder_add_to_cairo_context (raw_builder: *mut RsvgPath
cairo::PathSegment::ClosePath => {
cairo_sys::cairo_close_path (cr);
- /* FIXME: we'll get a MoveTo from the path builder. Do we need to omit it
- * if Cairo will add a similar Moveto by itself?
- */
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]