diff options
| -rw-r--r-- | src/FrameStats.zig | 1 | ||||
| -rw-r--r-- | src/Layer.zig | 4 | ||||
| -rw-r--r-- | src/animation.zig | 21 | ||||
| -rw-r--r-- | src/colors.zig | 13 | ||||
| -rw-r--r-- | src/glide.zig | 8 |
5 files changed, 9 insertions, 38 deletions
diff --git a/src/FrameStats.zig b/src/FrameStats.zig index c27e74af..33ffd300 100644 --- a/src/FrameStats.zig +++ b/src/FrameStats.zig @@ -267,7 +267,6 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void { const s = Spread.of(all, what); write.line(fd, &buf, "# {t} n {d} mean {d:.0} p50 {d} p90 {d} p99 {d} max {d}\n", .{ what, s.n, s.mean, s.p50, s.p90, s.p99, s.max }); } - write.line(fd, &buf, "# start_ms\tupdate_us\trender_us\tpresent_us\tgap_us\tmoving\tskipped\tscroll\n", .{}); const t0 = if (all[0].len != 0) all[0][0].start_ns else 0; // The monotonic clock is the machine's: a driver lines its own times // up with the frames' by this. diff --git a/src/Layer.zig b/src/Layer.zig index 609ddbc4..c43cab03 100644 --- a/src/Layer.zig +++ b/src/Layer.zig @@ -120,10 +120,6 @@ pub fn place(layer: *const Layer) Place { return .{ .viewport = layer.viewport, .cols = layer.cols, .rows = layer.rows, .context_rows = layer.context_rows }; } -fn pointAt(layer: *const Layer, x: f32, y: f32, body_w: f32, body_h: f32, tagline_w: f32, tagline_h: f32) ?Point { - return pointIn(layer.kind, layer.place(), x, y, body_w, body_h, tagline_w, tagline_h); -} - fn pointIn(kind: Kind, layer: Place, x: f32, y: f32, body_w: f32, body_h: f32, tagline_w: f32, tagline_h: f32) ?Point { if (layer.rows == 0 or !std.math.isFinite(x) or !std.math.isFinite(y)) return null; // A band's hit is refused outright on metrics no host could have; a diff --git a/src/animation.zig b/src/animation.zig index 37d74813..ce0b382a 100644 --- a/src/animation.zig +++ b/src/animation.zig @@ -280,10 +280,6 @@ pub fn sample(easing: Easing, raw: f32) f32 { }; } -pub fn progress(effect: Transition, frame: u16) f32 { - return progressEased(effect.easing(), effect.frames(), frame); -} - fn progressEased(easing: Easing, frames: u16, frame: u16) f32 { if (frames <= 1 or frame >= frames - 1) return 1.0; return sample(easing, @as(f32, @floatFromInt(frame)) / @as(f32, @floatFromInt(frames - 1))); @@ -460,12 +456,12 @@ test "easing presets have exact endpoints and intended shapes" { test "transition progress completes exactly" { inline for (std.enums.values(Transition)) |effect| { - try std.testing.expectEqual(@as(f32, 1), progress(effect, effect.frames())); + try std.testing.expectEqual(@as(f32, 1), progressEased(effect.easing(), effect.frames(), effect.frames())); if (effect.frames() > 0) - try std.testing.expectEqual(@as(f32, 1), progress(effect, effect.frames() - 1)); - try std.testing.expectEqual(@as(f32, 1), progress(effect, std.math.maxInt(u16))); + try std.testing.expectEqual(@as(f32, 1), progressEased(effect.easing(), effect.frames(), effect.frames() - 1)); + try std.testing.expectEqual(@as(f32, 1), progressEased(effect.easing(), effect.frames(), std.math.maxInt(u16))); } - try std.testing.expectEqual(@as(f32, 1), progress(.off, 0)); + try std.testing.expectEqual(@as(f32, 1), progressEased(Transition.off.easing(), Transition.off.frames(), 0)); const shrinking = lerpBox(.{ .w = 100, .h = 40 }, .{}, sample(.out_back, 0.8)); try std.testing.expectEqual(@as(f32, 0), shrinking.w); @@ -639,7 +635,7 @@ test "opening presets separate geometry and content transitions" { }; try std.testing.expectEqual(target, closing.contentBox()); closing.frame = 2; - try std.testing.expect(closing.amount() < progress(.vertical, closing.frame)); + try std.testing.expect(closing.amount() < progressEased(Transition.vertical.easing(), Transition.vertical.frames(), closing.frame)); } test "the ordered dissolve reveals a 4x4 block evenly, each cell once" { @@ -740,11 +736,8 @@ pub const Motion = struct { return spring.value(@intFromFloat(u * std.time.ns_per_s)); } - /// The same move's speed at `u`, in lengths per unit of `u`. - pub fn speed(motion: Motion, u: f32) f32 { - return motion.speedFrom(u, 0); - } - + /// The same move's speed at `u`, in lengths per unit of `u`, set off at + /// `launch` as `easeFrom` is. pub fn speedFrom(motion: Motion, u: f32, launch: f32) f32 { const h: f32 = 1.0 / 256.0; return (motion.easeFrom(@min(1, u + h), launch) - motion.easeFrom(@max(0, u - h), launch)) / (@min(1, u + h) - @max(0, u - h)); diff --git a/src/colors.zig b/src/colors.zig index 9c666d9b..3d4bed8c 100644 --- a/src/colors.zig +++ b/src/colors.zig @@ -803,19 +803,6 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8, animate: bo return true; } -/// A Restore's: the theme `old` showed, its loaded theme file's included, -/// for one that is to load a ThemeFile and keep this if it fails; -/// `index` too when the dump names no Theme. -pub fn carryTheme(p: *Pardes, old: *const Pardes, index: bool) !void { - if (index) p.settings.theme = old.settings.theme; - const t = old.custom_theme orelse return; - var copy = t; - copy.name = try p.gpa.dupe(u8, t.name); - if (p.custom_theme) |mine| p.gpa.free(mine.name); - p.custom_theme = copy; - _ = p.theme_file_loaded.set(old.theme_file_loaded.get()); -} - pub fn finishThemeInitialization(p: *Pardes) void { p.chrome_animation.snap(ChromeTheme.fromTheme(p.theme())); p.animate_theme_changes = true; diff --git a/src/glide.zig b/src/glide.zig index 1d128dd0..1605b2d3 100644 --- a/src/glide.zig +++ b/src/glide.zig @@ -106,11 +106,6 @@ pub const Glide = struct { return pardes.animation.Follow.pace(motion, @floatFromInt(glide.body_h), 5e-3); } - /// An input: the core's rows moved by `rows` (down positive). - pub fn kick(glide: *Glide, rows: f32, now_ns: u64, motion: pardes.animation.Motion) void { - glide.follow.kick(rows, now_ns, glide.pace(motion)); - } - pub fn advance(glide: *Glide, now_ns: u64, motion: pardes.animation.Motion) void { glide.follow.advance(now_ns, glide.pace(motion)); } @@ -191,7 +186,8 @@ pub const Glide = struct { const dropped = if (far) other_n.* else @min(other_n.*, shift); std.mem.copyForwards(pardes.Cell, other.*[0 .. @as(usize, other_n.* - dropped) * w], other.*[@as(usize, dropped) * w ..][0 .. @as(usize, other_n.* - dropped) * w]); other_n.* -= dropped; - glide.kick(@as(f32, @floatFromInt(shift)) * @as(f32, @floatFromInt(glide.dir)), glide.now_ns, glide.motion); + // An input: the core's rows moved by as many (down positive). + glide.follow.kick(@as(f32, @floatFromInt(shift)) * @as(f32, @floatFromInt(glide.dir)), glide.now_ns, glide.pace(glide.motion)); } /// Finds the text whose view moved since the last loop step, however |
