fix: pixel-identical rendering (z2d stroker port) and last P3 items
Resolves the 3 P3 items in docs/rewrite/notes/review-rv12-codex.md (final-Z15.md): - Sprite strokes: tiny-skia is replaced by a port of z2d 0.10's stroke plotter (sprite/stroke.rs) plus z2d's arc segmentation and truncating integer compositing, feeding the ported 4x4 multisample rasterizer. All 36 reference sprite sheets now match Ghostty's byte for byte (test tolerance 0), and `just visual-parity` with a production build shows 0 differing pixels (max delta 0) against the installed Ghostty 1.3.1 for the test page (block and bar cursor) and the tabs+splits scenario, terminal area and chrome alike. tiny-skia dependency removed. - zig_error maps errno values per target via libc (Linux, Darwin/BSD) and Win32 codes the way Zig std does on Windows. - theme=. / theme=.. report "it is a directory" via a port of std.fs.path.basename, matching Ghostty. Test Plan: - cargo test --workspace --no-fail-fast (3498 passed, exit 0) - cargo build --profile production && just visual-parity - just check-macos (both), just check-windows, just check-wasm
This commit is contained in:
1 parent
7dd54833b9
commit
6befc09cc8
10 files changed
+1339
-191
No files matched your search
@@ -151,6 +151,38 @@ fn check_regular(file: &File, theme: &str, diags: &mut DiagnosticList) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// `std.fs.path.basename` (last `ComponentIterator` component; `.` and `..`
|
||||
/// are ordinary names). The caller only passes non-absolute paths, so the root
|
||||
/// is empty on POSIX and an optional `X:` drive designator on Windows.
|
||||
fn zig_basename(path: &str) -> &str {
|
||||
let is_sep = |b: u8| b == b'/' || (cfg!(windows) && b == b'\\');
|
||||
let bytes = path.as_bytes();
|
||||
let root_end = if cfg!(windows)
|
||||
&& bytes.len() >= 2
|
||||
&& bytes[0].is_ascii_alphabetic()
|
||||
&& bytes[1] == b':'
|
||||
{
|
||||
2
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let mut end = bytes.len();
|
||||
loop {
|
||||
if end == root_end {
|
||||
return "";
|
||||
}
|
||||
if !is_sep(bytes[end - 1]) {
|
||||
break;
|
||||
}
|
||||
end -= 1;
|
||||
}
|
||||
let mut start = end;
|
||||
while start != root_end && !is_sep(bytes[start - 1]) {
|
||||
start -= 1;
|
||||
}
|
||||
&path[start..end]
|
||||
}
|
||||
|
||||
/// Open the given named theme. If there are any errors then messages
|
||||
/// will be appended to the given error list and None is returned. If
|
||||
/// a Some return value is returned, there are never any errors added.
|
||||
@@ -184,11 +216,7 @@ pub fn open(
|
||||
});
|
||||
}
|
||||
|
||||
let basename = theme_path
|
||||
.file_name()
|
||||
.map(EncodedOs::from_os)
|
||||
.unwrap_or_default();
|
||||
if *theme != basename {
|
||||
if theme_text != zig_basename(theme_text) {
|
||||
diag(
|
||||
diags,
|
||||
format!(
|
||||
@@ -335,6 +363,33 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zig_basename_matches_std() {
|
||||
assert_eq!(zig_basename(""), "");
|
||||
assert_eq!(zig_basename("."), ".");
|
||||
assert_eq!(zig_basename(".."), "..");
|
||||
assert_eq!(zig_basename("a/"), "a");
|
||||
assert_eq!(zig_basename("a/b"), "b");
|
||||
assert_eq!(zig_basename("a//"), "a");
|
||||
assert_eq!(zig_basename("./"), ".");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dot_theme_names_are_directories() {
|
||||
let dir = std::env::temp_dir().join(format!("ghostty-theme-dot-{}", std::process::id()));
|
||||
std::fs::create_dir_all(dir.join("themes")).unwrap();
|
||||
for name in [".", ".."] {
|
||||
let mut d = DiagnosticList::default();
|
||||
assert!(open(&e(name), Some(&EncodedOs::from_path(&dir)), &mut d).is_none());
|
||||
assert!(
|
||||
d.items()[0].message.ends_with("it is a directory"),
|
||||
"{}",
|
||||
d.items()[0].message
|
||||
);
|
||||
}
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn theme_found_in_resources() {
|
||||
let dir = std::env::temp_dir().join(format!("ghostty-theme-test-{}", std::process::id()));
|
||||
|
||||
Reference in new issue
Block a user