From 23c9932afe9bbf01aa84d780e9030dfb6e333475 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 13:28:13 -0300 Subject: effects out, the theme crossfade: a theme change takes the chrome at once, as it always took the content; colors.ChromeAnimation (its OKLab steps, its retarget, the ticks and the frames it asked of nextWake) goes, Pardes.chrome is the theme's chrome, set as the theme changes, and the `animate` flag goes from loadThemeFile and applyThemeEffect with it, as does the build's -Dtheme-animation option (and its place in the wire's fingerprint); no frontend fades a theme of its own (a window crossfading every cell's colour for 160 ms is a copy of the last frame kept and blended, for one keystroke's change); the fade's tests go, the PDF test loses its ticks through a fade, and `core animation keeps wall time at 60, 120 and 144 Hz and across a stall` goes with the one animation that ran it; the perf baselines lose the option from their build identity; GUI goldens 16-debug and 17-terminal change, the golden session having faded its themes by default: a fade's frames kept the Debug word's announcement up in the picture's pane, which gave up a row to it under the Debug box; the tree before this change built with -Dtheme-animation=false draws exactly these frames, all sixteen byte for byte Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- build.zig | 6 -- src/colors.zig | 195 ++------------------------------------ src/draw.zig | 3 - src/file_watch.zig | 8 +- src/gui/gui.zig | 1 - src/host_io.zig | 2 +- src/ninep/ctl.zig | 8 +- src/pardes.zig | 52 +--------- src/tui/tui.zig | 2 +- src/wire.zig | 7 +- test/gui-goldens.txt | 4 +- test/panes.zig | 4 +- test/pdf.zig | 16 ---- test/perf-baseline-gui-debug.json | 2 +- test/perf-baseline-tui-debug.json | 2 +- test/perf-baseline-tui-fast.json | 2 +- 16 files changed, 30 insertions(+), 284 deletions(-) diff --git a/build.zig b/build.zig index 2a408bbf..f435a39f 100644 --- a/build.zig +++ b/build.zig @@ -40,7 +40,6 @@ const PerfBuild = struct { mupdf: bool, jpx: bool, tracy: bool, - theme_animation: bool, terminal_simd: bool, prebuilt_shaders: bool, }; @@ -265,7 +264,6 @@ pub fn build(b: *std.Build) void { if (target.result.os.tag == .freebsd or target.result.os.tag == .netbsd or target.result.os.tag == .openbsd) root_mod.linkSystemLibrary("util", .{}); - const theme_animation = b.option(bool, "theme-animation", "animate chrome colors across a theme change (default: on)") orelse true; // The macOS shell carries the workspace tag row's commands in its native // menu bar; the row itself goes away. `-Dworkspace-tag=true` puts it back. const workspace_tag = b.option(bool, "workspace-tag", "draw the workspace tag row (default: on except on macOS, whose menu bar carries its commands)"); @@ -283,7 +281,6 @@ pub fn build(b: *std.Build) void { .tree_sitter_grammars = tree_sitter_grammars, .tracy = tracy != null, .mupdf = enable_mupdf, - .theme_animation = theme_animation, .workspace_tag = workspace_tag, .prebuilt_shaders = prebuilt_shaders, .embed_sources = embed_sources, @@ -1341,7 +1338,6 @@ pub fn build(b: *std.Build) void { .mupdf = enable_mupdf, .jpx = enable_mupdf and enable_jpx, .tracy = tracy != null, - .theme_animation = theme_animation, .terminal_simd = ghostty_simd, .prebuilt_shaders = platform == .gui and prebuilt_shaders, }); @@ -1825,7 +1821,6 @@ const ShellConfig = struct { tree_sitter_grammars: TreeSitterGrammars, tracy: bool, mupdf: bool, - theme_animation: bool, /// null = "the platform's own default": the macOS shell hands the row to /// its native menu bar, every other shell keeps the acme topbar. workspace_tag: ?bool, @@ -1844,7 +1839,6 @@ fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build. o.addOption(bool, "enable_tracy", cfg.tracy); o.addOption(bool, "mupdf", cfg.mupdf); o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (platform != .macos)); - o.addOption(bool, "theme_animation", cfg.theme_animation); o.addOption(bool, "embed_sources", cfg.embed_sources); o.addOption([]const u8, "version", display_version); // ...and the commit it was built from, when there is one and the build diff --git a/src/colors.zig b/src/colors.zig index aec2917f..f09bf9db 100644 --- a/src/colors.zig +++ b/src/colors.zig @@ -1,16 +1,14 @@ //! Colour themes: the Theme type, the curated and generated ring, chrome -//! colours and their animation, theme files, and switching themes at runtime. +//! colours, theme files, and switching themes at runtime. const pardes = @import("pardes.zig"); const tagline = @import("tagline.zig"); const panes = @import("panes.zig"); const std = @import("std"); -const animation = @import("animation.zig"); const Color = @import("surface.zig").Color; const FontRole = @import("surface.zig").FontRole; const config = @import("config.zig"); const pdf_enabled = panes.Pdf.enabled; const platform = pardes.platform; -const theme_animation = @import("pardes_config").theme_animation; const MAX_PANES = pardes.MAX_PANES; const BOX_H = pardes.BOX_H; const Pardes = pardes.Pardes; @@ -601,55 +599,6 @@ pub const ChromeTheme = struct { } }; -/// The chrome as it is drawn: the theme's, fading from the last one over -/// `animation.transition_steps` frames, each colour through OKLab (G10: a -/// fade keeps its lightness even, never going muddy or dark between two -/// hues as a mix of sRGB bytes does). A change eases in and out (§8.1); one -/// set off partway through another eases out, moving at once, so it never -/// stalls (§7.2). A build without theme_animation snaps instead -/// (finishThemeInitialization). -pub const ChromeAnimation = struct { - from: ChromeTheme, - to: ChromeTheme, - displayed: ChromeTheme, - step: u16 = animation.transition_steps, - retargeted: bool = false, - - pub fn init(chrome: ChromeTheme) ChromeAnimation { - return .{ .from = chrome, .to = chrome, .displayed = chrome }; - } - - pub fn isActive(a: *const ChromeAnimation) bool { - return a.step < animation.transition_steps; - } - - pub fn retarget(a: *ChromeAnimation, target: ChromeTheme) void { - a.retargeted = a.isActive(); - a.from = a.displayed; - a.to = target; - a.step = if (std.meta.eql(a.from, target)) animation.transition_steps else 0; - if (a.step == animation.transition_steps) a.displayed = target; - } - - pub fn advance(a: *ChromeAnimation) void { - if (!a.isActive()) return; - a.step += 1; - if (a.step == animation.transition_steps) { - a.displayed = a.to; - return; - } - const t = @as(f32, @floatFromInt(a.step)) / @as(f32, @floatFromInt(animation.transition_steps)); - // In thousandths of the way, as the fade has always stepped. - const k = @round(animation.sample(if (a.retargeted) .out_cubic else .smooth, t) * 1000); - inline for (@typeInfo(ChromeTheme).@"struct".field_names) |name| - @field(a.displayed, name) = if (k == 0) @field(a.from, name) else if (k >= 1000) @field(a.to, name) else mixOklab(@field(a.from, name), @field(a.to, name), k / 1000); - } - - pub fn snap(a: *ChromeAnimation, chrome: ChromeTheme) void { - a.* = init(chrome); - } -}; - pub const initial_chrome = ChromeTheme.fromTheme(&themes[0]); fn nextThemeFileGeneration(p: *Pardes) u32 { @@ -743,7 +692,7 @@ fn revertThemeFile(p: *Pardes) void { p.emit(.{ .theme_file = .{ .generation = generation, .on = loaded.len > 0 } }); } -pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8, animate: bool) bool { +pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8) bool { // ZON's generated field dispatch grows with the complete theme schema. @setEvalBranchQuota(10000); const request = themeFileRequest(p, generation) orelse return false; @@ -777,11 +726,7 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8, animate: bo return false; }; - const target_chrome = ChromeTheme.fromTheme(&parsed); - if (animate and p.animate_theme_changes) - p.chrome_animation.retarget(target_chrome) - else - p.chrome_animation.snap(target_chrome); + p.chrome = ChromeTheme.fromTheme(&parsed); const old = p.custom_theme; p.custom_theme = parsed; if (old) |theme_value| p.gpa.free(theme_value.name); @@ -793,8 +738,7 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8, animate: bo } pub fn finishThemeInitialization(p: *Pardes) void { - p.chrome_animation.snap(ChromeTheme.fromTheme(p.theme())); - p.animate_theme_changes = theme_animation; + p.chrome = ChromeTheme.fromTheme(p.theme()); } fn invalidateThemeDependentRasters(p: *Pardes) void { @@ -885,11 +829,7 @@ pub fn setThemeIndex(p: *Pardes, index: usize) void { if (index >= themes.len or (p.custom_theme == null and p.theme_file_path.get().len == 0 and index == @as(usize, p.settings.theme))) return; - const target_chrome = ChromeTheme.fromTheme(&themes[index]); - if (p.animate_theme_changes) - p.chrome_animation.retarget(target_chrome) - else - p.chrome_animation.snap(target_chrome); + p.chrome = ChromeTheme.fromTheme(&themes[index]); if (p.custom_theme) |theme_value| { p.custom_theme = null; p.gpa.free(theme_value.name); @@ -938,13 +878,13 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" { var encoded: std.Io.Writer.Allocating = .init(std.testing.allocator); defer encoded.deinit(); try std.zon.stringify.serialize(custom, .{ .whitespace = true }, &encoded.writer); - try std.testing.expect(loadThemeFile(p, request_effect.generation, encoded.written(), false)); + try std.testing.expect(loadThemeFile(p, request_effect.generation, encoded.written())); try std.testing.expectEqualStrings("mine", p.theme().name); try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), p.theme().bg); try std.testing.expectEqual(ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*); // A half-written save is rejected without disturbing the last good value. - try std.testing.expect(!loadThemeFile(p, request_effect.generation, ".{ .name = ", true)); + try std.testing.expect(!loadThemeFile(p, request_effect.generation, ".{ .name = ")); // Said with its line, in words: never a bare `parse zon`. const said = p.panes[0].?.msg[0..p.panes[0].?.msg_len]; try std.testing.expect(std.mem.indexOf(u8, said, ": line 1: ") != null and std.mem.indexOf(u8, said, "parse zon") == null); @@ -961,127 +901,6 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" { try std.testing.expect(!stop.on); } -test "runtime theme changes animate chrome and retarget without a jump" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); - defer p.deinit(); - const first = p.chromeTheme().*; - try std.testing.expect(!p.animationActive()); - - const dark_index = for (themes, 0..) |th, i| { - if (std.mem.eql(u8, th.name, "dark")) break i; - } else return error.MissingDarkTheme; - const acme_index = for (themes, 0..) |th, i| { - if (std.mem.eql(u8, th.name, "acme")) break i; - } else return error.MissingAcmeTheme; - - setThemeIndex(p, dark_index); - // Target semantics are immediate, while the displayed chrome begins at - // the exact previous frame. - try std.testing.expectEqualStrings("dark", p.theme().name); - try std.testing.expectEqual(first, p.chromeTheme().*); - try std.testing.expect(p.animationActive()); - p.update(.tick); - p.update(.tick); - p.update(.tick); - const midflight = p.chromeTheme().*; - try std.testing.expect(!std.meta.eql(first, midflight)); - - setThemeIndex(p, acme_index); - try std.testing.expectEqualStrings("acme", p.theme().name); - try std.testing.expectEqual(midflight, p.chromeTheme().*); - try std.testing.expect(p.animationActive()); - for (0..animation.transition_steps) |_| p.update(.tick); - try std.testing.expect(!p.animationActive()); - try std.testing.expectEqual(ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*); - // Extra ticks are inert at the exact endpoint. - p.update(.tick); - try std.testing.expectEqual(ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*); -} - -/// A chrome of one colour everywhere, for the fade's tests. -fn chromeOf(rgb: [3]u8) ChromeTheme { - var out: ChromeTheme = undefined; - inline for (@typeInfo(ChromeTheme).@"struct".field_names) |name| @field(out, name) = rgb; - return out; -} - -test "a chrome fade starts where it is, lands exactly with every channel on its way, and goes no further" { - const from = chromeOf(.{ 240, 240, 240 }); - const to = chromeOf(.{ 5, 5, 5 }); - var fade: ChromeAnimation = .init(from); - fade.retarget(to); - try std.testing.expectEqual(from, fade.displayed); - var previous = fade.displayed.tag_bg; - for (0..animation.transition_steps) |_| { - fade.advance(); - for (fade.displayed.tag_bg, previous) |now, was| try std.testing.expect(now <= was); - previous = fade.displayed.tag_bg; - } - try std.testing.expect(!fade.isActive()); - try std.testing.expectEqual(to, fade.displayed); - fade.advance(); - try std.testing.expectEqual(to, fade.displayed); -} - -test "a chrome fade retargeted partway sets off from what is shown" { - const first = chromeOf(.{ 0, 40, 200 }); - const second = chromeOf(.{ 200, 140, 0 }); - const third = chromeOf(.{ 20, 10, 250 }); - var fade: ChromeAnimation = .init(first); - fade.retarget(second); - for (0..3) |_| fade.advance(); - const on_screen = fade.displayed; - fade.retarget(third); - try std.testing.expectEqual(on_screen, fade.from); - try std.testing.expectEqual(on_screen, fade.displayed); - try std.testing.expect(fade.isActive()); - for (0..animation.transition_steps) |_| fade.advance(); - try std.testing.expectEqual(third, fade.displayed); -} - -test "render uses target content colors while chrome is in flight" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 }); - defer p.deinit(); - const source_chrome = p.chromeTheme().*; - const acme_index = for (themes, 0..) |th, i| { - if (std.mem.eql(u8, th.name, "acme")) break i; - } else return error.MissingAcmeTheme; - setThemeIndex(p, acme_index); - - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - const surface = try p.render(frame.allocator()); - // The anchored topbar has not advanced from its source frame. - try std.testing.expectEqual( - Color{ .rgb = source_chrome.tag_bg }, - surface.at(0, 0).style.bg, - ); - const topbar_cell = surface.at(@import("pardes.zig").TAG_TEXT_INSET, 0); - try std.testing.expect(!std.mem.eql(u8, topbar_cell.grapheme(), " ")); - try std.testing.expectEqual(FontRole.tagline, topbar_cell.style.font_role); - const r = p.rects[0]; - const tag_cell = find_tag_cell: { - var x = r.x + config.GUTTER; - while (x < r.x + r.w) : (x += 1) { - const cell = surface.at(x, r.y); - if (!std.mem.eql(u8, cell.grapheme(), " ")) break :find_tag_cell cell; - } - return error.MissingTagText; - }; - try std.testing.expectEqual(FontRole.tagline, tag_cell.style.font_role); - try std.testing.expectEqual(FontRole.tagline, surface.at(r.x, r.y).style.font_role); - try std.testing.expectEqual(FontRole.tagline, surface.at(r.x + r.w - 1, r.y).style.font_role); - // The document/terminal page does not ride the chrome animation: acme's - // target background is already present in the same render. - const body = surface.at(r.x + r.w - 1, r.y + r.h - 1); - try std.testing.expectEqual(FontRole.body, body.style.font_role); - try std.testing.expectEqual( - Color{ .rgb = p.theme().bg.? }, - body.style.bg, - ); - try std.testing.expect(p.animationActive()); -} - test "native themes keep text and UI roles readable on their own surfaces" { const names = [_][]const u8{ "orchard", "dusk", "ink", "paper", "daybreak", "atelier", "forge", "lagoon", "solarium", "spectrum", "harvest", "clay", "forge_black", "forge_soft", "orchard_black" }; try std.testing.expectEqual(names.len, native_theme_count); diff --git a/src/draw.zig b/src/draw.zig index 55fab141..9db5d0ff 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -1086,7 +1086,6 @@ test "an unfocused grip shows on its tag in the grid, in every native theme" { defer p.deinit(); _ = try p.setTestFile("text\n"); p.newScratchBelow(0); - p.animate_theme_changes = false; var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); for (pardes.themes[0..colors.native_count], 0..) |theme, index| { @@ -1109,7 +1108,6 @@ test "a grip's four states, focused or not and clean or dirty, are each its own defer p.deinit(); const pane = try p.setTestFile("text\n"); p.newScratchBelow(0); - p.animate_theme_changes = false; var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); const State = struct { first: Cell, second: Cell, dirty: bool }; @@ -1150,7 +1148,6 @@ test "every theme draws a file's name, a +Errors and a Term word in a tint, neve p.acknowledgeShell(terminal, "/bin/sh", false); try @import("Output.zig").openErrors(p, 0, try gpa.dupe(u8, "oops\n")); while (p.nextEffect()) |_| {} - p.animate_theme_changes = false; const errors = for (p.panes, 0..) |slot, id| { const pane = slot orelse continue; if (pane.file) |f| if (std.mem.endsWith(u8, f.path, "+Errors")) break id; diff --git a/src/file_watch.zig b/src/file_watch.zig index a75383e1..7b8ccbef 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -575,7 +575,6 @@ pub fn applyThemeEffect( watches: *Table, generation: u32, on: bool, - animate: bool, ) bool { watchPane(fd, watches, theme_slot, null, 0, .{ .text = 0 }); if (!on) return false; @@ -589,7 +588,7 @@ pub fn applyThemeEffect( return false; }; defer gpa.free(bytes); - if (!colors.loadThemeFile(core, generation, bytes, animate)) { + if (!colors.loadThemeFile(core, generation, bytes)) { core.noteLateFailure(pane); return false; } @@ -626,7 +625,7 @@ pub fn reloadTheme( .text => |accepted| if (accepted == hash) return false, .pdf => unreachable, } - if (!colors.loadThemeFile(core, watched.serial, bytes, true)) return false; + if (!colors.loadThemeFile(core, watched.serial, bytes)) return false; core.invalidate(); const live = if (watches[theme_slot]) |*entry| entry else return false; if (live.serial != watched.serial) return false; @@ -848,7 +847,7 @@ test "theme watch reloads valid ZON and keeps the last theme across a bad save" if (fd < 0) return error.WatchInitFailed; defer _ = libc.close(fd); var watches: Table = @splat(null); - defer _ = applyThemeEffect(core, gpa, fd, &watches, 0, false, false); + defer _ = applyThemeEffect(core, gpa, fd, &watches, 0, false); try std.testing.expect(!applyThemeEffect( core, gpa, @@ -856,7 +855,6 @@ test "theme watch reloads valid ZON and keeps the last theme across a bad save" &watches, request.generation, true, - false, )); try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), core.theme().bg); try std.testing.expect(watches[theme_slot] != null); diff --git a/src/gui/gui.zig b/src/gui/gui.zig index a81f029f..f5b486c1 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -4205,7 +4205,6 @@ fn watchTheme(ctx: ?*anyopaque, generation: u32, on: bool) void { s.watches, generation, on, - s.threads_ok, )) s.queue.push(.files_changed); } diff --git a/src/host_io.zig b/src/host_io.zig index 86e97876..0c638f71 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -116,7 +116,7 @@ pub fn restoreCore(gpa: std.mem.Allocator, core: *pardes.Pardes, path: []const u return null; }; file_watch.unwatchAll(inotify_fd, watches); - _ = file_watch.applyThemeEffect(core, gpa, inotify_fd, watches, 0, false, false); + _ = file_watch.applyThemeEffect(core, gpa, inotify_fd, watches, 0, false); return nc; } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 2cfee904..ec870253 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1706,7 +1706,7 @@ test "a Restore asks again for the ThemeFile the dump names, as a /ctl write of var encoded: std.Io.Writer.Allocating = .init(gpa); defer encoded.deinit(); try std.zon.stringify.serialize(custom, .{}, &encoded.writer); - try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written(), false)); + try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written())); try pardes.dump.dumpState(p); const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); defer restored.deinit(); @@ -1741,9 +1741,9 @@ test "a ThemeFile that fails to load changes nothing: the root ctl still names t var encoded: std.Io.Writer.Allocating = .init(gpa); defer encoded.deinit(); try std.zon.stringify.serialize(custom, .{}, &encoded.writer); - try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written(), false)); + try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written())); _ = wr(p, root_ctl, "ThemeFile /tmp/pardes-bad-theme.zon\n"); - try testing.expect(!pardes.colors.loadThemeFile(p, p.theme_file_generation, ".{ .name = ", false)); + try testing.expect(!pardes.colors.loadThemeFile(p, p.theme_file_generation, ".{ .name = ")); try testing.expect(std.mem.indexOf(u8, rd(p, root_ctl, 0, 1 << 16).bytes, "ThemeFile " ++ good ++ "\n") != null); try testing.expectEqualStrings(good, p.theme_file_path.get()); } @@ -1760,7 +1760,7 @@ test "after a ThemeFile the root ctl and DumpConfig say ThemeFile and its path, var encoded: std.Io.Writer.Allocating = .init(gpa); defer encoded.deinit(); try std.zon.stringify.serialize(custom, .{}, &encoded.writer); - try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written(), false)); + try testing.expect(pardes.colors.loadThemeFile(p, p.theme_file_generation, encoded.written())); const settings = rd(p, root_ctl, 0, 1 << 16).bytes; try testing.expect(std.mem.indexOf(u8, settings, "ThemeFile " ++ path ++ "\n") != null); try testing.expect(std.mem.indexOf(u8, settings, "Theme mine") == null); diff --git a/src/pardes.zig b/src/pardes.zig index 63f8b61a..8204915d 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1065,7 +1065,6 @@ test "an empty column shows its theme's empty_col under its tag: acme's white, e tagline.exitHeader(p); inline for (.{ "acme", "dark" }) |name| { try std.testing.expect(p.executeBuiltinLine(0, "Theme " ++ name)); - p.chrome_animation.displayed = colors.ChromeTheme.fromTheme(p.theme()); p.sync(); var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); @@ -3367,7 +3366,7 @@ pub const Pardes = struct { theme_file_loaded: config.Runtime.Text(limits.host_path_cap) = .{}, theme_file_generation: u32 = 0, theme_file_pane: u8 = 0, - chrome_animation: colors.ChromeAnimation = colors.ChromeAnimation.init(colors.initial_chrome), + chrome: colors.ChromeTheme = colors.initial_chrome, /// The focused cursor's quad on its springs (animation.CursorGlide), /// the pane and view origin it was last aimed in, and the last key or /// click, which a blink holds for. @@ -3385,7 +3384,6 @@ pub const Pardes = struct { /// cursor waits where it was drawn for the release that places it. cursor_held: bool = false, input_ns: u64 = 0, - animate_theme_changes: bool = false, native_images: bool = false, /// The shell can take a changed image a few rows at a time (a texture row /// upload, a shared-memory hand-off), so a PDF selection is repainted as @@ -3602,7 +3600,7 @@ pub const Pardes = struct { pub const replica = .{ .local = .{ // A frame, and the animations and timings that make it. - "surface", "frames", "chrome_animation", + "surface", "frames", "chrome", "cursor_glide", "cursor_view", "cursor_crossing", "cursor_held", "frame_arena", "scratch", "needs_frame", "present_skipped", "shell_continuous", "native_image_patches", "echo", @@ -5295,7 +5293,6 @@ pub const Pardes = struct { }, .tick => { mouse.edgeScroll(p); - p.chrome_animation.advance(); look.advanceLookHover(p); }, } @@ -6802,10 +6799,9 @@ pub const Pardes = struct { return &themes[p.settings.theme]; } - /// Displayed colors for anchored UI chrome. Unlike `theme()`, this may be - /// between themes while a live transition is active. + /// The colours of the chrome: the theme's, set as it changes. pub fn chromeTheme(p: *const Pardes) *const ChromeTheme { - return &p.chrome_animation.displayed; + return &p.chrome; } /// The theme's own chrome, not a fade's (`theme()`'s, worked out once @@ -6830,7 +6826,6 @@ pub const Pardes = struct { // the next frame (writes served before the shell's clock was first // seen are stamped 0, which `advance` would count back from). if (p.fs.batch.bytes.items.len > 0) return @max(next, p.fs.batch.last_ns + ctlfs.pane.batch_pause_ns); - if (p.chrome_animation.isActive()) return next; // Places still to find resume on the next frame; a picture being // decoded is looked for. for (p.panes) |slot| if (slot) |pane| if (pane.places.busy(pane)) return next; @@ -8066,45 +8061,6 @@ test "jump history terminal rectangle follows output and clears on reflow" { try std.testing.expectEqual(.none, pane.sel[0].state); } -test "core animation keeps wall time at 60, 120 and 144 Hz and across a stall" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - const frame = animation.frame_ns; - // Something that animates for as long as the test wants: the theme - // fade, held at its start before every step. - for ([_]u64{ 60, 120, 144 }) |hz| { - const start: u64 = 5 * std.time.ns_per_s; - p.clock_started = false; - p.advance(start); - var steps: u64 = 0; - var at: u64 = 1; - while (at <= hz) : (at += 1) { - const before = p.stepped_ns; - p.chrome_animation.step = 0; - p.advance(start + at * std.time.ns_per_s / hz); - const taken = (p.stepped_ns - before + frame / 2) / frame; - // Never two steps in one display frame: that is a visible hitch. - try std.testing.expect(taken <= 1); - steps += taken; - } - switch (hz) { - // One step a display frame, every display frame. - 60 => try std.testing.expectEqual(@as(u64, 60), steps), - 120 => try std.testing.expectEqual(@as(u64, 60), steps), - // The frame's own rate: 62 a second, give or take one. - else => try std.testing.expect(steps >= 61 and steps <= 63), - } - } - // A stall of minutes is not minutes of frames. - const before = p.stepped_ns; - p.chrome_animation.step = 0; - p.advance(before + 600 * std.time.ns_per_s); - try std.testing.expectEqual(before + 600 * std.time.ns_per_s, p.stepped_ns); - p.chrome_animation.step = animation.transition_steps; - p.advance(p.stepped_ns + frame); - try std.testing.expectEqual(@as(?u64, null), p.nextWake()); -} - test "a Save the host could not do logs no save record" { const th = @import("ninep/testing.zig"); const p = try th.withFile(std.testing.allocator, "x\n"); diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 2a067ed3..319e6c1b 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -2852,7 +2852,7 @@ const Shell = struct { fn watchTheme(ctx: ?*anyopaque, generation: u32, on: bool) void { const s = of(ctx); - if (file_watch.applyThemeEffect(s.core, s.gpa, s.inotify_fd, &s.watches, generation, on, s.threads_ok)) + if (file_watch.applyThemeEffect(s.core, s.gpa, s.inotify_fd, &s.watches, generation, on)) s.loop.postEvent(.files_changed) catch {}; } diff --git a/src/wire.zig b/src/wire.zig index e29a98b4..3406321b 100644 --- a/src/wire.zig +++ b/src/wire.zig @@ -51,14 +51,13 @@ const family = switch (config.platform) { pub const semantics: u64 = blk: { @setEvalBranchQuota(1_000_000); break :blk std.hash.Wyhash.hash(0, std.fmt.comptimePrint( - "wire {d}\npardes {s} {s}\n{s} grammars {} {} {} {} mupdf {} themes {} workspace_tag {} sources {}\nusize {d} {t}\n{s}\n{s}", + "wire {d}\npardes {s} {s}\n{s} grammars {} {} {} {} mupdf {} workspace_tag {} sources {}\nusize {d} {t}\n{s}\n{s}", .{ version, config.version, config.commit orelse "unstamped", family, config.syntax_highlighting, config.syntax_zig_grammar, config.syntax_minimal_grammars, config.syntax_full_grammars, config.mupdf, - config.theme_animation, config.workspace_tag, config.embed_sources, - @sizeOf(usize), builtin.cpu.arch.endian(), config.deps, - pardes.tape.shape, + config.workspace_tag, config.embed_sources, @sizeOf(usize), + builtin.cpu.arch.endian(), config.deps, pardes.tape.shape, }, )); }; diff --git a/test/gui-goldens.txt b/test/gui-goldens.txt index 9fcc4b2e..02fccf40 100644 --- a/test/gui-goldens.txt +++ b/test/gui-goldens.txt @@ -12,5 +12,5 @@ 13-image 318720734099917fe92694dfb52f9304e61efb53ff76118621762498b9b114c1 14-theme-ink 5ce5d040782d7b019da22109867e07ae212ea175b4527b7d2c1c5bcfca055793 15-theme-acme-light d81855e3204cbb698731cfd72519b7e3454c6b0ac734c01228004c8ee60f8683 -16-debug daef379c743b67f6be556a7302532adae9b426de8f0d75979b54dcfd6f23ff29 -17-terminal e74702198a47fe8c6e1cf07e985cf579546a03658e3662385744bd807c9dbb00 +16-debug 8c0d51dddb4badb908a3975952b3a960bc1f1132ffa94e874be7172d36d997d4 +17-terminal bdd828d94de59aba7ce9e35e80d7b4b9081ec663b0a2489e4076279d9b03e0a4 diff --git a/test/panes.zig b/test/panes.zig index f3ae3cfc..90625e81 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -798,7 +798,7 @@ const TagNameTintTests = struct { theme.tag_active_name_fg = null; theme.tag_fg = tag_fg; p.custom_theme = theme; - p.chrome_animation.snap(pardes.ChromeTheme.fromTheme(p.theme())); + p.chrome = pardes.ChromeTheme.fromTheme(p.theme()); p.settings.focus_tint = false; } @@ -895,7 +895,7 @@ const TagNameTintTests = struct { p.custom_theme.?.tag_name_fg = null; const active_fg = [3]u8{ 175, 183, 194 }; p.custom_theme.?.tag_active_fg = active_fg; - p.chrome_animation.snap(pardes.ChromeTheme.fromTheme(p.theme())); + p.chrome = pardes.ChromeTheme.fromTheme(p.theme()); var arena = std.heap.ArenaAllocator.init(p.gpa); defer arena.deinit(); for ([_]bool{ false, true }) |active| { diff --git a/test/pdf.zig b/test/pdf.zig index af1f3095..f338bfcb 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1381,22 +1381,6 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" { try std.testing.expect(new.checksum != old.checksum); } - // Chrome animation reads a separate palette. Its ticks must never disturb - // the target-theme tint key or ask MuPDF for the same pixels again. - try std.testing.expect(p.animationActive()); - for (0..animation.transition_steps) |_| { - p.update(.tick); - _ = frame.reset(.retain_capacity); - const tick_surface = try p.render(frame.allocator()); - const ticked = try Capture.get(tick_surface); - try Capture.expectGeometry(themed, ticked); - for (themed, ticked) |once, after_tick| { - try std.testing.expectEqual(once.revision, after_tick.revision); - try std.testing.expectEqual(once.checksum, after_tick.checksum); - } - } - try std.testing.expect(!p.animationActive()); - panes.Pdf.toggleTint(pane); try std.testing.expectEqual(PdfTintMode.full, pv.tint); _ = frame.reset(.retain_capacity); diff --git a/test/perf-baseline-gui-debug.json b/test/perf-baseline-gui-debug.json index 6b88a793..ae800a39 100644 --- a/test/perf-baseline-gui-debug.json +++ b/test/perf-baseline-gui-debug.json @@ -1 +1 @@ -{"harness":"de81ad6bc9756a40","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":2290,"med_us":2523,"p90_us":2642,"max_us":2642},{"op":"render","fixture":"medium","min_us":96,"med_us":97,"p90_us":99,"max_us":99},{"op":"key-down","fixture":"medium","min_us":104,"med_us":106,"p90_us":113,"max_us":113},{"op":"key-right","fixture":"medium","min_us":105,"med_us":107,"p90_us":111,"max_us":112},{"op":"page-down","fixture":"medium","min_us":104,"med_us":107,"p90_us":121,"max_us":125},{"op":"wheel","fixture":"medium","min_us":101,"med_us":104,"p90_us":105,"max_us":106},{"op":"edit-char","fixture":"medium","min_us":1023,"med_us":1293,"p90_us":1447,"max_us":1467},{"op":"edit-twin","fixture":"medium","min_us":1089,"med_us":1340,"p90_us":1418,"max_us":1441},{"op":"body-2m","fixture":"medium","min_us":5061,"med_us":8829,"p90_us":11118,"max_us":11667},{"op":"body-appends","fixture":"medium","min_us":149285,"med_us":210882,"p90_us":266047,"max_us":279235},{"op":"deep-sel","fixture":"medium","min_us":87,"med_us":90,"p90_us":96,"max_us":96}]} +{"harness":"de81ad6bc9756a40","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":2290,"med_us":2523,"p90_us":2642,"max_us":2642},{"op":"render","fixture":"medium","min_us":96,"med_us":97,"p90_us":99,"max_us":99},{"op":"key-down","fixture":"medium","min_us":104,"med_us":106,"p90_us":113,"max_us":113},{"op":"key-right","fixture":"medium","min_us":105,"med_us":107,"p90_us":111,"max_us":112},{"op":"page-down","fixture":"medium","min_us":104,"med_us":107,"p90_us":121,"max_us":125},{"op":"wheel","fixture":"medium","min_us":101,"med_us":104,"p90_us":105,"max_us":106},{"op":"edit-char","fixture":"medium","min_us":1023,"med_us":1293,"p90_us":1447,"max_us":1467},{"op":"edit-twin","fixture":"medium","min_us":1089,"med_us":1340,"p90_us":1418,"max_us":1441},{"op":"body-2m","fixture":"medium","min_us":5061,"med_us":8829,"p90_us":11118,"max_us":11667},{"op":"body-appends","fixture":"medium","min_us":149285,"med_us":210882,"p90_us":266047,"max_us":279235},{"op":"deep-sel","fixture":"medium","min_us":87,"med_us":90,"p90_us":96,"max_us":96}]} diff --git a/test/perf-baseline-tui-debug.json b/test/perf-baseline-tui-debug.json index 16b67dbd..b6c766e1 100644 --- a/test/perf-baseline-tui-debug.json +++ b/test/perf-baseline-tui-debug.json @@ -1 +1 @@ -{"harness":"de81ad6bc9756a40","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":1820,"med_us":2128,"p90_us":2500,"max_us":3046},{"op":"render","fixture":"medium","min_us":90,"med_us":96,"p90_us":98,"max_us":101},{"op":"key-down","fixture":"medium","min_us":101,"med_us":103,"p90_us":105,"max_us":114},{"op":"key-right","fixture":"medium","min_us":101,"med_us":103,"p90_us":106,"max_us":112},{"op":"page-down","fixture":"medium","min_us":97,"med_us":102,"p90_us":103,"max_us":105},{"op":"wheel","fixture":"medium","min_us":97,"med_us":102,"p90_us":112,"max_us":160},{"op":"edit-char","fixture":"medium","min_us":838,"med_us":899,"p90_us":1129,"max_us":1167},{"op":"edit-twin","fixture":"medium","min_us":869,"med_us":1099,"p90_us":1321,"max_us":1393},{"op":"body-2m","fixture":"medium","min_us":4820,"med_us":8314,"p90_us":11931,"max_us":12182},{"op":"body-appends","fixture":"medium","min_us":125039,"med_us":170714,"p90_us":213376,"max_us":232728},{"op":"deep-sel","fixture":"medium","min_us":90,"med_us":92,"p90_us":96,"max_us":101}]} +{"harness":"de81ad6bc9756a40","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":1820,"med_us":2128,"p90_us":2500,"max_us":3046},{"op":"render","fixture":"medium","min_us":90,"med_us":96,"p90_us":98,"max_us":101},{"op":"key-down","fixture":"medium","min_us":101,"med_us":103,"p90_us":105,"max_us":114},{"op":"key-right","fixture":"medium","min_us":101,"med_us":103,"p90_us":106,"max_us":112},{"op":"page-down","fixture":"medium","min_us":97,"med_us":102,"p90_us":103,"max_us":105},{"op":"wheel","fixture":"medium","min_us":97,"med_us":102,"p90_us":112,"max_us":160},{"op":"edit-char","fixture":"medium","min_us":838,"med_us":899,"p90_us":1129,"max_us":1167},{"op":"edit-twin","fixture":"medium","min_us":869,"med_us":1099,"p90_us":1321,"max_us":1393},{"op":"body-2m","fixture":"medium","min_us":4820,"med_us":8314,"p90_us":11931,"max_us":12182},{"op":"body-appends","fixture":"medium","min_us":125039,"med_us":170714,"p90_us":213376,"max_us":232728},{"op":"deep-sel","fixture":"medium","min_us":90,"med_us":92,"p90_us":96,"max_us":101}]} diff --git a/test/perf-baseline-tui-fast.json b/test/perf-baseline-tui-fast.json index 8932a150..97138236 100644 --- a/test/perf-baseline-tui-fast.json +++ b/test/perf-baseline-tui-fast.json @@ -1 +1 @@ -{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"fast","c_optimize":"fast","terminal_optimize":"fast","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2096,"med_us":2329,"p90_us":2589,"max_us":2704},{"op":"render","fixture":"medium","min_us":77,"med_us":80,"p90_us":85,"max_us":86},{"op":"key-down","fixture":"medium","min_us":84,"med_us":87,"p90_us":101,"max_us":116},{"op":"key-right","fixture":"medium","min_us":84,"med_us":87,"p90_us":93,"max_us":111},{"op":"page-down","fixture":"medium","min_us":85,"med_us":86,"p90_us":89,"max_us":102},{"op":"wheel","fixture":"medium","min_us":83,"med_us":87,"p90_us":98,"max_us":107},{"op":"edit-char","fixture":"medium","min_us":886,"med_us":1127,"p90_us":1466,"max_us":1503},{"op":"edit-twin","fixture":"medium","min_us":928,"med_us":1282,"p90_us":1489,"max_us":1586},{"op":"body-2m","fixture":"medium","min_us":5327,"med_us":8382,"p90_us":10779,"max_us":11879},{"op":"body-appends","fixture":"medium","min_us":140582,"med_us":203008,"p90_us":242154,"max_us":252106},{"op":"deep-sel","fixture":"medium","min_us":71,"med_us":74,"p90_us":75,"max_us":77}]} +{"harness":"8ecb4caed482b2","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"fast","c_optimize":"fast","terminal_optimize":"fast","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2096,"med_us":2329,"p90_us":2589,"max_us":2704},{"op":"render","fixture":"medium","min_us":77,"med_us":80,"p90_us":85,"max_us":86},{"op":"key-down","fixture":"medium","min_us":84,"med_us":87,"p90_us":101,"max_us":116},{"op":"key-right","fixture":"medium","min_us":84,"med_us":87,"p90_us":93,"max_us":111},{"op":"page-down","fixture":"medium","min_us":85,"med_us":86,"p90_us":89,"max_us":102},{"op":"wheel","fixture":"medium","min_us":83,"med_us":87,"p90_us":98,"max_us":107},{"op":"edit-char","fixture":"medium","min_us":886,"med_us":1127,"p90_us":1466,"max_us":1503},{"op":"edit-twin","fixture":"medium","min_us":928,"med_us":1282,"p90_us":1489,"max_us":1586},{"op":"body-2m","fixture":"medium","min_us":5327,"med_us":8382,"p90_us":10779,"max_us":11879},{"op":"body-appends","fixture":"medium","min_us":140582,"med_us":203008,"p90_us":242154,"max_us":252106},{"op":"deep-sel","fixture":"medium","min_us":71,"med_us":74,"p90_us":75,"max_us":77}]} -- cgit v1.3