Commit abf7b21a authored by Alex Butler's avatar Alex Butler

Merge branch 'no-arrayvec' into 'master'

Remove arrayvec dependency

Closes #146

See merge request redox-os/rusttype!149
parents 1346e496 74bd46af
Pipeline #7264 passed with stages
in 4 minutes and 25 seconds
## Unreleased
* Remove arrayvec dependency.
## 0.8.2
* Update crossbeam-utils -> `0.7`.
* Update libm -> `0.2.1`.
......
......@@ -26,7 +26,6 @@ exclude = ["/dev/**"]
features = ["gpu_cache"]
[dependencies]
arrayvec = { version = "0.5", default-features = false }
stb_truetype = { version = "0.3.1", default-features = false }
ordered-float = { version = "1", default-features = false }
approx = { version = "0.3", default-features = false }
......
......@@ -9,7 +9,6 @@ publish = false
rusttype = { path = "../", features = ["gpu_cache"] }
glium = "0.26"
image = { version = "0.23", default-features = false, features = ["png"] }
arrayvec = { version = "0.5", default-features = false }
once_cell = "1"
blake2 = "0.8"
criterion = "0.3"
......
......@@ -196,55 +196,52 @@ You can also try resizing this window."
let origin = point(0.0, 0.0);
let vertices: Vec<Vertex> = glyphs
.iter()
.flat_map(|g| {
if let Ok(Some((uv_rect, screen_rect))) = cache.rect_for(0, g) {
let gl_rect = Rect {
min: origin
+ (vector(
screen_rect.min.x as f32 / screen_width - 0.5,
1.0 - screen_rect.min.y as f32 / screen_height - 0.5,
)) * 2.0,
max: origin
+ (vector(
screen_rect.max.x as f32 / screen_width - 0.5,
1.0 - screen_rect.max.y as f32 / screen_height - 0.5,
)) * 2.0,
};
arrayvec::ArrayVec::<[Vertex; 6]>::from([
Vertex {
position: [gl_rect.min.x, gl_rect.max.y],
tex_coords: [uv_rect.min.x, uv_rect.max.y],
colour,
},
Vertex {
position: [gl_rect.min.x, gl_rect.min.y],
tex_coords: [uv_rect.min.x, uv_rect.min.y],
colour,
},
Vertex {
position: [gl_rect.max.x, gl_rect.min.y],
tex_coords: [uv_rect.max.x, uv_rect.min.y],
colour,
},
Vertex {
position: [gl_rect.max.x, gl_rect.min.y],
tex_coords: [uv_rect.max.x, uv_rect.min.y],
colour,
},
Vertex {
position: [gl_rect.max.x, gl_rect.max.y],
tex_coords: [uv_rect.max.x, uv_rect.max.y],
colour,
},
Vertex {
position: [gl_rect.min.x, gl_rect.max.y],
tex_coords: [uv_rect.min.x, uv_rect.max.y],
colour,
},
])
} else {
arrayvec::ArrayVec::new()
}
.filter_map(|g| cache.rect_for(0, g).ok().flatten())
.flat_map(|(uv_rect, screen_rect)| {
let gl_rect = Rect {
min: origin
+ (vector(
screen_rect.min.x as f32 / screen_width - 0.5,
1.0 - screen_rect.min.y as f32 / screen_height - 0.5,
)) * 2.0,
max: origin
+ (vector(
screen_rect.max.x as f32 / screen_width - 0.5,
1.0 - screen_rect.max.y as f32 / screen_height - 0.5,
)) * 2.0,
};
vec![
Vertex {
position: [gl_rect.min.x, gl_rect.max.y],
tex_coords: [uv_rect.min.x, uv_rect.max.y],
colour,
},
Vertex {
position: [gl_rect.min.x, gl_rect.min.y],
tex_coords: [uv_rect.min.x, uv_rect.min.y],
colour,
},
Vertex {
position: [gl_rect.max.x, gl_rect.min.y],
tex_coords: [uv_rect.max.x, uv_rect.min.y],
colour,
},
Vertex {
position: [gl_rect.max.x, gl_rect.min.y],
tex_coords: [uv_rect.max.x, uv_rect.min.y],
colour,
},
Vertex {
position: [gl_rect.max.x, gl_rect.max.y],
tex_coords: [uv_rect.max.x, uv_rect.max.y],
colour,
},
Vertex {
position: [gl_rect.min.x, gl_rect.max.y],
tex_coords: [uv_rect.min.x, uv_rect.max.y],
colour,
},
]
})
.collect();
......
......@@ -5,6 +5,7 @@ use ordered_float::OrderedFloat;
#[cfg(all(feature = "libm-math", not(feature = "std")))]
use crate::nostd_float::FloatExt;
use alloc::vec::Vec;
use core::iter;
trait SliceUp: Sized {
type PerSlice: Iterator<Item = Self>;
......@@ -86,7 +87,7 @@ impl SliceUp for Line {
}
}
type CurveIter = arrayvec::IntoIter<[Curve; 2]>;
type CurveIter = iter::Chain<iter::Once<Curve>, core::option::IntoIter<Curve>>;
struct CurveSliceIter {
curve: Curve,
......@@ -102,7 +103,6 @@ impl Iterator for CurveSliceIter {
fn next(&mut self) -> Option<Self::Item> {
use crate::geometry::solve_quadratic_real as solve;
use crate::geometry::RealQuadraticSolution as RQS;
use arrayvec::ArrayVec;
if self.i >= self.planes.count {
return None;
}
......@@ -113,7 +113,10 @@ impl Iterator for CurveSliceIter {
let upper_d = self.planes.start + self.planes.step * upper;
let l_sol = solve(self.a, self.b, self.c_shift - lower_d);
let u_sol = solve(self.a, self.b, self.c_shift - upper_d);
let mut result = ArrayVec::<[Curve; 2]>::new();
let mut curve1 = None;
let mut curve2 = None;
match (l_sol.in_order(), u_sol.in_order()) {
(RQS::Two(a, b), RQS::Two(c, d)) => {
// Two pieces
......@@ -128,11 +131,14 @@ impl Iterator for CurveSliceIter {
c.min(1.0).max(0.0),
d.min(1.0).max(0.0),
);
if !relative_eq!(a, b) {
result.push(self.curve.cut_from_to(a, b));
}
if !relative_eq!(c, d) {
result.push(self.curve.cut_from_to(c, d));
match (relative_eq!(a, b), relative_eq!(c, d)) {
(false, false) => {
curve1 = Some(self.curve.cut_from_to(a, b));
curve2 = Some(self.curve.cut_from_to(c, d));
}
(false, true) => curve1 = Some(self.curve.cut_from_to(a, b)),
(true, false) => curve1 = Some(self.curve.cut_from_to(c, d)),
_ => {}
}
}
(RQS::Two(a, b), RQS::None)
......@@ -145,12 +151,12 @@ impl Iterator for CurveSliceIter {
let a = a.min(1.0).max(0.0);
let b = b.min(1.0).max(0.0);
if !relative_eq!(a, b) {
result.push(self.curve.cut_from_to(a, b));
curve1 = Some(self.curve.cut_from_to(a, b));
}
}
(RQS::All, RQS::None) | (RQS::None, RQS::All) => {
// coincident with one plane
result.push(self.curve);
curve1 = Some(self.curve);
}
(RQS::None, RQS::None) => {
if self.a == 0.0
......@@ -159,12 +165,16 @@ impl Iterator for CurveSliceIter {
&& self.c_shift <= upper_d
{
// parallel to planes, inbetween
result.push(self.curve);
curve1 = Some(self.curve);
}
}
_ => unreachable!(), // impossible
}
Some(result.into_iter())
match curve1 {
Some(curve) => Some(iter::once(curve).chain(curve2)),
None => None
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment