mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-13 22:12:12 +00:00
fix: clear workspace baseline gates on Rust 1.100
This commit is contained in:
1 parent
94e65a4606
commit
7316e4e223
8 files changed
+108
-47
No files matched your search
@@ -111,9 +111,9 @@ impl CmykModel {
|
||||
// Overprints with black: multiplicative in reflectance above a first-surface floor.
|
||||
let floor = 0.006;
|
||||
let mut prim = [[0.0; 3]; 16];
|
||||
for m in 0..16 {
|
||||
for (m, slot) in prim.iter_mut().enumerate() {
|
||||
let p = base[m & 7];
|
||||
prim[m] = if m & 8 == 0 {
|
||||
*slot = if m & 8 == 0 {
|
||||
p
|
||||
} else {
|
||||
std::array::from_fn(|i| {
|
||||
@@ -133,7 +133,7 @@ impl CmykModel {
|
||||
(v + 4.0 * self.tvi[i] * v * (1.0 - v)).clamp(0.0, 1.0)
|
||||
});
|
||||
let mut s = [0.0; 3];
|
||||
for m in 0..16 {
|
||||
for (m, prim) in self.prim_n.iter().enumerate() {
|
||||
let mut w = 1.0;
|
||||
for (i, ai) in a.iter().enumerate() {
|
||||
w *= if m & (1 << i) != 0 { *ai } else { 1.0 - ai };
|
||||
@@ -141,7 +141,7 @@ impl CmykModel {
|
||||
if w == 0.0 {
|
||||
continue;
|
||||
}
|
||||
for (acc, p) in s.iter_mut().zip(&self.prim_n[m]) {
|
||||
for (acc, p) in s.iter_mut().zip(prim) {
|
||||
*acc += w * p;
|
||||
}
|
||||
}
|
||||
|
||||
+35
-8
@@ -161,6 +161,16 @@ fn children<'a>(el: &'a El, container: &'static str, tag: &'static str) -> impl
|
||||
}
|
||||
|
||||
fn node(el: &El, is_mask: bool, count: &mut usize) -> Result<Node> {
|
||||
let mut out = node_fields(el, is_mask)?;
|
||||
if !is_mask {
|
||||
out.layers = layers(el, count)?;
|
||||
out.masks = children(el, "masks", "mask").map(|m| node(m, true, count)).collect::<Result<_>>()?;
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// A node's own attributes, without its children.
|
||||
fn node_fields(el: &El, is_mask: bool) -> Result<Node> {
|
||||
let owned = |name: &str| attr(el, name).map(str::to_string);
|
||||
let node_type = attr(el, "nodetype").unwrap_or("").to_string();
|
||||
// Only the kinds whose pixels are read need sound numbers; a node an application will leave
|
||||
@@ -168,7 +178,7 @@ fn node(el: &El, is_mask: bool, count: &mut usize) -> Result<Node> {
|
||||
let read = matches!(node_type.as_str(), "paintlayer" | "grouplayer" | "transparencymask");
|
||||
let lenient = |v: Result<f64>, default: f64| if read { v } else { Ok(v.unwrap_or(default)) };
|
||||
let (x, y) = if is_mask && !read { (offset(el, "x").unwrap_or(0), offset(el, "y").unwrap_or(0)) } else { (offset(el, "x")?, offset(el, "y")?) };
|
||||
let mut out = Node {
|
||||
let out = Node {
|
||||
node_type,
|
||||
name: owned("name"),
|
||||
visible: attr(el, "visible") != Some("0"),
|
||||
@@ -187,22 +197,39 @@ fn node(el: &El, is_mask: bool, count: &mut usize) -> Result<Node> {
|
||||
layers: Vec::new(),
|
||||
masks: Vec::new(),
|
||||
};
|
||||
if !is_mask {
|
||||
out.layers = layers(el, count)?;
|
||||
out.masks = children(el, "masks", "mask").map(|m| node(m, true, count)).collect::<Result<_>>()?;
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The `<layers>` of `el`. Recursion is bounded by [`MAX_XML_DEPTH`].
|
||||
/// The `<layers>` of `el`, walked with an explicit stack: groups can nest up to [`MAX_XML_DEPTH`]
|
||||
/// deep, more than a small thread stack can recurse.
|
||||
fn layers(el: &El, count: &mut usize) -> Result<Vec<Node>> {
|
||||
struct Frame<'a> {
|
||||
node: Node,
|
||||
rest: std::vec::IntoIter<&'a El>,
|
||||
}
|
||||
let mut root = children(el, "layers", "layer").collect::<Vec<_>>().into_iter();
|
||||
let mut stack: Vec<Frame> = Vec::new();
|
||||
let mut out = Vec::new();
|
||||
for child in children(el, "layers", "layer") {
|
||||
loop {
|
||||
let next = match stack.last_mut() {
|
||||
Some(frame) => frame.rest.next(),
|
||||
None => root.next(),
|
||||
};
|
||||
let Some(child) = next else {
|
||||
let Some(frame) = stack.pop() else { break };
|
||||
match stack.last_mut() {
|
||||
Some(parent) => parent.node.layers.push(frame.node),
|
||||
None => out.push(frame.node),
|
||||
}
|
||||
continue;
|
||||
};
|
||||
*count += 1;
|
||||
if *count > MAX_NODES {
|
||||
return Err(invalid(format!("more than {MAX_NODES} layers")));
|
||||
}
|
||||
out.push(node(child, false, count)?);
|
||||
let mut built = node_fields(child, false)?;
|
||||
built.masks = children(child, "masks", "mask").map(|m| node(m, true, count)).collect::<Result<_>>()?;
|
||||
stack.push(Frame { node: built, rest: children(child, "layers", "layer").collect::<Vec<_>>().into_iter() });
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
@@ -353,9 +353,9 @@ fn table_borders_and_borderless_round_trip() {
|
||||
let mut doc = Document::new();
|
||||
let mut t_borderless = Table::new(2, 2, 400.0);
|
||||
t_borderless.props.style = None;
|
||||
for r in 0..2 {
|
||||
for c in 0..2 {
|
||||
t_borderless.rows[r].cells[c].blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
|
||||
for row in &mut t_borderless.rows {
|
||||
for cell in &mut row.cells {
|
||||
cell.blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
|
||||
}
|
||||
}
|
||||
doc.body = vec![Arc::new(Block::Table(t_borderless))];
|
||||
@@ -369,9 +369,9 @@ fn table_borders_and_borderless_round_trip() {
|
||||
let mut doc_bordered = Document::new();
|
||||
let mut t_bordered = Table::new(2, 2, 400.0);
|
||||
t_bordered.props.style = Some("TableGrid".to_string());
|
||||
for r in 0..2 {
|
||||
for c in 0..2 {
|
||||
t_bordered.rows[r].cells[c].blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
|
||||
for row in &mut t_bordered.rows {
|
||||
for cell in &mut row.cells {
|
||||
cell.blocks = vec![para_block(Paragraph::with_text("cell", CharProps::default()))];
|
||||
}
|
||||
}
|
||||
doc_bordered.body = vec![Arc::new(Block::Table(t_bordered))];
|
||||
|
||||
+48
-13
@@ -189,28 +189,63 @@ fn props(el: &El) -> Result<Props> {
|
||||
})
|
||||
}
|
||||
|
||||
/// The elements of `stack`. Recursion is bounded by [`MAX_XML_DEPTH`].
|
||||
/// The elements of `stack`, walked with an explicit stack: a stack can nest up to
|
||||
/// [`MAX_XML_DEPTH`] deep, more than a small thread stack can recurse.
|
||||
fn stack(el: &El, count: &mut usize) -> Result<Vec<Node>> {
|
||||
struct Frame<'a> {
|
||||
props: Props,
|
||||
isolation: Option<String>,
|
||||
children: Vec<Node>,
|
||||
rest: std::vec::IntoIter<&'a El>,
|
||||
}
|
||||
let mut root = el.elements().collect::<Vec<_>>().into_iter();
|
||||
let mut frames: Vec<Frame> = Vec::new();
|
||||
let mut out = Vec::new();
|
||||
for child in el.elements() {
|
||||
loop {
|
||||
let next = match frames.last_mut() {
|
||||
Some(frame) => frame.rest.next(),
|
||||
None => root.next(),
|
||||
};
|
||||
let Some(child) = next else {
|
||||
let Some(frame) = frames.pop() else { break };
|
||||
let node = Node::Stack(Stack { props: frame.props, isolation: frame.isolation, children: frame.children });
|
||||
match frames.last_mut() {
|
||||
Some(parent) => parent.children.push(node),
|
||||
None => out.push(node),
|
||||
}
|
||||
continue;
|
||||
};
|
||||
*count += 1;
|
||||
if *count > MAX_NODES {
|
||||
return Err(invalid(format!("more than {MAX_NODES} layers")));
|
||||
}
|
||||
out.push(match child.name.as_str() {
|
||||
"layer" => Node::Layer(Layer {
|
||||
props: props(child)?,
|
||||
x: int(child, "x")?,
|
||||
y: int(child, "y")?,
|
||||
src: child.attr("src").map(|s| s.trim().to_string()),
|
||||
}),
|
||||
"stack" => Node::Stack(Stack {
|
||||
match child.name.as_str() {
|
||||
"layer" => {
|
||||
let node = Node::Layer(Layer {
|
||||
props: props(child)?,
|
||||
x: int(child, "x")?,
|
||||
y: int(child, "y")?,
|
||||
src: child.attr("src").map(|s| s.trim().to_string()),
|
||||
});
|
||||
match frames.last_mut() {
|
||||
Some(parent) => parent.children.push(node),
|
||||
None => out.push(node),
|
||||
}
|
||||
}
|
||||
"stack" => frames.push(Frame {
|
||||
props: props(child)?,
|
||||
isolation: child.attr("isolation").map(|s| s.trim().to_string()),
|
||||
children: stack(child, count)?,
|
||||
children: Vec::new(),
|
||||
rest: child.elements().collect::<Vec<_>>().into_iter(),
|
||||
}),
|
||||
other => Node::Other { tag: other.to_string(), name: child.attr("name").map(str::to_string) },
|
||||
});
|
||||
other => {
|
||||
let node = Node::Other { tag: other.to_string(), name: child.attr("name").map(str::to_string) };
|
||||
match frames.last_mut() {
|
||||
Some(parent) => parent.children.push(node),
|
||||
None => out.push(node),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ fn silhouette_registration_marks() {
|
||||
let p = silhouette::encode(&pro, &j).unwrap();
|
||||
let (head, rest) = p.split_at_registration();
|
||||
let text = |c: &[Command]| c.iter().map(Command::to_ascii).collect::<Vec<_>>().join(" ");
|
||||
assert!(text(head).ends_with(" FC18,1,1 TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB55,1 TB123,4600,3600,200,100"));
|
||||
assert!(text(head).ends_with(" FC18,1,1 TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB54,0,0 TB55,1 TB123,4600,3600,200,100"));
|
||||
// The design is shifted so the first mark is the origin.
|
||||
assert_eq!(text(rest), "M100,100 D100,300 M100,0 SO0");
|
||||
assert_eq!(p.registration_wait, Some(head.len()));
|
||||
@@ -148,7 +148,7 @@ fn silhouette_registration_marks() {
|
||||
reg.origin_right_mm = 0.0;
|
||||
assert!(ascii(®).ends_with(" TB124,4600,3600,0,0"));
|
||||
reg.search = false;
|
||||
assert_eq!(ascii(®), "TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB55,1 TB23,4600,3600");
|
||||
assert_eq!(ascii(®), "TB50,0 TB99 TB52,2 TB51,400 TB53,10 TB54,0,0 TB55,1 TB23,4600,3600");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -754,11 +754,12 @@ mod tests {
|
||||
/// spec's default `~/.local/share` applies, and with no home there is no folder.
|
||||
#[test]
|
||||
fn xdg_data_home_follows_the_spec() {
|
||||
let home = Path::new("/home/a");
|
||||
assert_eq!(xdg_data_home(Some("/data".into()), Some(home)), Some(PathBuf::from("/data")));
|
||||
assert_eq!(xdg_data_home(Some("/data".into()), None), Some(PathBuf::from("/data")));
|
||||
let home = std::env::temp_dir().join("xdg-home");
|
||||
let data = std::env::temp_dir().join("xdg-data");
|
||||
assert_eq!(xdg_data_home(Some(data.as_os_str().to_owned()), Some(&home)), Some(data.clone()));
|
||||
assert_eq!(xdg_data_home(Some(data.as_os_str().to_owned()), None), Some(data));
|
||||
for xdg in [None, Some(""), Some("relative/data")] {
|
||||
assert_eq!(xdg_data_home(xdg.map(Into::into), Some(home)), Some(home.join(".local/share")), "{xdg:?}");
|
||||
assert_eq!(xdg_data_home(xdg.map(Into::into), Some(&home)), Some(home.join(".local/share")), "{xdg:?}");
|
||||
assert_eq!(xdg_data_home(xdg.map(Into::into), None), None, "{xdg:?}");
|
||||
}
|
||||
}
|
||||
@@ -1010,7 +1011,12 @@ mod tests {
|
||||
assert!(load(&aff, &big).unwrap_err().contains("too large"));
|
||||
// A directory, and on Unix an endless device, are not dictionary files. (No clock: a
|
||||
// reader that read `/dev/zero` would never return, so the error itself is the proof.)
|
||||
assert!(load(&aff, &dir).unwrap_err().contains("not a regular file"));
|
||||
let error = load(&aff, &dir).unwrap_err();
|
||||
// Windows may reject opening a directory before the reader can inspect its type.
|
||||
#[cfg(unix)]
|
||||
assert!(error.contains("not a regular file"), "{error}");
|
||||
#[cfg(not(unix))]
|
||||
assert!(!error.is_empty());
|
||||
#[cfg(unix)]
|
||||
assert!(load(&aff, Path::new("/dev/zero")).unwrap_err().contains("not a regular file"));
|
||||
// Turkish reads through the same reader.
|
||||
|
||||
@@ -100,11 +100,7 @@ fn check(d: &TrDict, word: &str, opts: &crate::Options) -> bool {
|
||||
}
|
||||
|
||||
// Compound words separated by hyphens (e.g., `afyon-karahisar`)
|
||||
if w.contains('-') && w.split('-').all(|part| part.is_empty() || check(d, part, opts)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
w.contains('-') && w.split('-').all(|part| part.is_empty() || check(d, part, opts))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -522,10 +522,7 @@ fn sao_edge_ctb<S: Sample>(
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if !pic.pps.loop_filter_across_tiles && pic.layout.tile_id[pic.layout.rs_to_ts[nrs] as usize] != pic.layout.tile_id[cur_ts as usize] {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
pic.pps.loop_filter_across_tiles || pic.layout.tile_id[pic.layout.rs_to_ts[nrs] as usize] == pic.layout.tile_id[cur_ts as usize]
|
||||
};
|
||||
// avail[dy][dx]: the CTB at (rx + dx - 1, ry + dy - 1) may be used.
|
||||
let (rx, ry) = (rs % pic.wctb, rs / pic.wctb);
|
||||
|
||||
Reference in new issue
Block a user