[librsvg] Remove the C binding to AspectRatio; it's no longer used
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Remove the C binding to AspectRatio; it's no longer used
- Date: Mon, 4 Dec 2017 03:13:35 +0000 (UTC)
commit 75c1080d640ea925c5057efd1052105f37625c13
Author: Federico Mena Quintero <federico gnome org>
Date: Sun Dec 3 21:12:14 2017 -0600
Remove the C binding to AspectRatio; it's no longer used
This also lets us remove the dependency on the bitflags crate.
rsvg-css.h | 27 ---------
rust/Cargo.lock | 1 -
rust/Cargo.toml | 1 -
rust/src/aspect_ratio.rs | 139 +---------------------------------------------
rust/src/lib.rs | 7 --
5 files changed, 1 insertions(+), 174 deletions(-)
---
diff --git a/rsvg-css.h b/rsvg-css.h
index 74c3220..088521d 100644
--- a/rsvg-css.h
+++ b/rsvg-css.h
@@ -35,19 +35,6 @@
G_BEGIN_DECLS
-#define RSVG_ASPECT_RATIO_NONE (0)
-#define RSVG_ASPECT_RATIO_XMIN_YMIN (1 << 0)
-#define RSVG_ASPECT_RATIO_XMID_YMIN (1 << 1)
-#define RSVG_ASPECT_RATIO_XMAX_YMIN (1 << 2)
-#define RSVG_ASPECT_RATIO_XMIN_YMID (1 << 3)
-#define RSVG_ASPECT_RATIO_XMID_YMID (1 << 4)
-#define RSVG_ASPECT_RATIO_XMAX_YMID (1 << 5)
-#define RSVG_ASPECT_RATIO_XMIN_YMAX (1 << 6)
-#define RSVG_ASPECT_RATIO_XMID_YMAX (1 << 7)
-#define RSVG_ASPECT_RATIO_XMAX_YMAX (1 << 8)
-#define RSVG_ASPECT_RATIO_SLICE (1 << 30)
-#define RSVG_ASPECT_RATIO_DEFER (1 << 31)
-
/* Keep this in sync with rust/src/color.rs:ColorKind */
typedef enum {
RSVG_CSS_COLOR_SPEC_INHERIT,
@@ -102,20 +89,6 @@ typedef struct {
G_GNUC_INTERNAL
RsvgOpacitySpec rsvg_css_parse_opacity (const char *str);
-/* This is implemented in rust/src/aspect_ratio.rs */
-G_GNUC_INTERNAL
-guint32 rsvg_aspect_ratio_parse (const char *str);
-
-/* This is implemented in rust/src/aspect_ratio.rs */
-G_GNUC_INTERNAL
-void rsvg_aspect_ratio_compute (guint32 aspect,
- double object_width,
- double object_height,
- double *dest_x,
- double *dest_y,
- double *dest_width,
- double *dest_height);
-
G_GNUC_INTERNAL
PangoStyle rsvg_css_parse_font_style (const char *str, gboolean * inherit);
G_GNUC_INTERNAL
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 7111483..0397ba7 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -386,7 +386,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "rsvg_internals"
version = "0.0.1"
dependencies = [
- "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-rs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-sys-rs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.18.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 532a9e0..d84d7fa 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -6,7 +6,6 @@ build = "build.rs"
[dependencies]
libc = "0.2"
-bitflags = "^0.9.1"
#glib = "^0.1.3"
#glib-sys = "^0.3.4"
downcast-rs = "^1.0.0"
diff --git a/rust/src/aspect_ratio.rs b/rust/src/aspect_ratio.rs
index 63482ba..9cad1ba 100644
--- a/rust/src/aspect_ratio.rs
+++ b/rust/src/aspect_ratio.rs
@@ -3,10 +3,8 @@
//! This module handles preserveAspectRatio values [per the SVG specification][spec].
//! We have an [`AspectRatio`] struct which encapsulates such a value.
//!
-//! [`AspectRatio`] implements `FromStr`, so it can be parsed easily:
-//!
//! ```
-//! assert_eq! (AspectRatio::from_str ("xMidYMid"),
+//! assert_eq! (AspectRatio::parse ("xMidYMid", ()),
//! Ok (AspectRatio { defer: false,
//! align: Align::Aligned { align: AlignMode::XmidYmid,
//! fit: FitMode::Meet } }));
@@ -15,9 +13,6 @@
//! [`AspectRatio`]: struct.AspectRatio.html
//! [spec]: https://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
-use ::libc;
-use ::glib::translate::*;
-
use parsers::Parse;
use parsers::ParseError;
use error::*;
@@ -71,75 +66,6 @@ fn align_1d (a: Align1D, dest_pos: f64, dest_size: f64, obj_size: f64) -> f64 {
}
impl AspectRatio {
- pub fn from_u32 (val: u32) -> AspectRatio {
- let val = AspectRatioFlags::from_bits (val).unwrap ();
-
- let defer = val.contains (DEFER);
-
- let mut aligned: bool = true;
-
- let align: AlignMode = {
- if val.contains (XMIN_YMIN) { AlignMode::XminYmin }
- else if val.contains (XMID_YMIN) { AlignMode::XmidYmin }
- else if val.contains (XMAX_YMIN) { AlignMode::XmaxYmin }
- else if val.contains (XMIN_YMID) { AlignMode::XminYmid }
- else if val.contains (XMID_YMID) { AlignMode::XmidYmid }
- else if val.contains (XMAX_YMID) { AlignMode::XmaxYmid }
- else if val.contains (XMIN_YMAX) { AlignMode::XminYmax }
- else if val.contains (XMID_YMAX) { AlignMode::XmidYmax }
- else if val.contains (XMAX_YMAX) { AlignMode::XmaxYmax }
- else {
- aligned = false;
- AlignMode::XmidYmid
- }
- };
-
- let fit: FitMode = if val.contains(SLICE) { FitMode::Slice } else { FitMode::Meet };
-
- AspectRatio {
- defer: defer,
- align: if aligned {
- Align::Aligned {
- align: align,
- fit: fit
- }
- } else {
- Align::None
- }
- }
- }
-
- pub fn to_u32 (&self) -> u32 {
- let mut val = AspectRatioFlags::empty ();
-
- if self.defer { val = val | DEFER; }
-
- match self.align {
- Align::None => { },
-
- Align::Aligned { align, fit } => {
- match align {
- AlignMode::XminYmin => { val = val | XMIN_YMIN; },
- AlignMode::XmidYmin => { val = val | XMID_YMIN; },
- AlignMode::XmaxYmin => { val = val | XMAX_YMIN; },
- AlignMode::XminYmid => { val = val | XMIN_YMID; },
- AlignMode::XmidYmid => { val = val | XMID_YMID; },
- AlignMode::XmaxYmid => { val = val | XMAX_YMID; },
- AlignMode::XminYmax => { val = val | XMIN_YMAX; },
- AlignMode::XmidYmax => { val = val | XMID_YMAX; },
- AlignMode::XmaxYmax => { val = val | XMAX_YMAX; },
- }
-
- match fit {
- FitMode::Meet => { },
- FitMode::Slice => { val = val | SLICE; }
- }
- }
- }
-
- val.bits ()
- }
-
pub fn compute (&self,
object_width: f64,
object_height: f64,
@@ -205,23 +131,6 @@ impl Default for AspectRatio {
}
}
-bitflags! {
- struct AspectRatioFlags: u32 {
- const XMIN_YMIN = (1 << 0);
- const XMID_YMIN = (1 << 1);
- const XMAX_YMIN = (1 << 2);
- const XMIN_YMID = (1 << 3);
- const XMID_YMID = (1 << 4);
- const XMAX_YMID = (1 << 5);
- const XMIN_YMAX = (1 << 6);
- const XMID_YMAX = (1 << 7);
- const XMAX_YMAX = (1 << 8);
- const SLICE = (1 << 30);
- const DEFER = (1 << 31);
- }
-}
-
-
fn parse_align_mode (s: &str) -> Option<Align> {
match s {
"none" => { Some (Align::None) },
@@ -330,38 +239,6 @@ impl Parse for AspectRatio {
}
}
-#[no_mangle]
-pub extern fn rsvg_aspect_ratio_parse (c_str: *const libc::c_char) -> u32 {
- let my_str = unsafe { &String::from_glib_none (c_str) };
- let parsed = AspectRatio::parse (my_str, ());
-
- match parsed {
- Ok (aspect_ratio) => { aspect_ratio.to_u32 () },
- Err (_) => {
- // We can't propagate the error here, so just return a default value
- let a: AspectRatio = Default::default ();
- a.to_u32 ()
- }
- }
-}
-
-#[no_mangle]
-pub extern fn rsvg_aspect_ratio_compute (aspect: u32,
- object_width: f64,
- object_height: f64,
- dest_x: *mut f64,
- dest_y: *mut f64,
- dest_width: *mut f64,
- dest_height: *mut f64) {
- unsafe {
- let (x, y, w, h) = AspectRatio::from_u32 (aspect).compute (object_width, object_height, *dest_x,
*dest_y, *dest_width, *dest_height);
- *dest_x = x;
- *dest_y = y;
- *dest_width = w;
- *dest_height = h;
- }
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -417,20 +294,6 @@ mod tests {
fit: FitMode::Slice } }));
}
- fn test_roundtrip (s: &str) {
- let a = AspectRatio::parse (s, ()).unwrap ();
-
- assert_eq! (AspectRatio::from_u32 (a.to_u32 ()), a);
- }
-
- #[test]
- fn conversion_to_u32_roundtrips () {
- test_roundtrip ("defer xMidYMid");
- test_roundtrip ("defer xMinYMax slice");
- test_roundtrip ("xMaxYMax meet");
- test_roundtrip ("xMinYMid slice");
- }
-
#[test]
fn aligns () {
assert_eq! (AspectRatio::parse ("xMinYMin meet", ()).unwrap().compute (1.0, 10.0, 0.0, 0.0, 10.0,
1.0), (0.0, 0.0, 0.1, 1.0));
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 46f1059..70aba0d 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -6,15 +6,8 @@ extern crate glib_sys;
extern crate libc;
#[macro_use]
-extern crate bitflags;
-#[macro_use]
extern crate downcast_rs;
-pub use aspect_ratio::{
- rsvg_aspect_ratio_parse,
- rsvg_aspect_ratio_compute
-};
-
pub use bbox::{
RsvgBbox,
rsvg_bbox_init,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]