summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index fb5b7f43..ec684b78 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -1,6 +1,9 @@
const std = @import("std");
pub const layout = @import("layout.zig");
-pub const animation = @import("animation.zig");
+/// The core's step: `advance` runs a `.tick` a frame of this, and
+/// `nextWake` answers in whole frames of it.
+pub const frame_ms: u32 = 16;
+pub const frame_ns: u64 = frame_ms * std.time.ns_per_ms;
pub const glide = @import("glide.zig");
pub const FrameStats = @import("FrameStats.zig");
pub const modal = @import("modal.zig");
@@ -446,7 +449,6 @@ test {
_ = @import("upgrade.zig");
_ = @import("recent.zig");
_ = @import("Store.zig");
- _ = @import("animation.zig");
_ = @import("pager.zig");
_ = @import("Places.zig");
_ = @import("FrameStats.zig");
@@ -3369,10 +3371,6 @@ pub const Pardes = struct {
chrome: colors.ChromeTheme = colors.initial_chrome,
/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES).
frames: FrameStats = .{},
- /// A pixel shell's own render-time motion is under way (its smooth
- /// scroll, G6): the core then keeps the continuous path running, so the
- /// shell draws every loop and a virtual clock moves on, as for a lift.
- shell_continuous: 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
@@ -3499,7 +3497,7 @@ pub const Pardes = struct {
present_skipped: bool = false,
/// Core time. `now_ns` is the shell's monotonic clock as `advance` was
/// last given it; `stepped_ns` is how far animation has been stepped
- /// along it, in whole frames of `animation.frame_ns`. Idle, the two are
+ /// along it, in whole frames of `frame_ns`. Idle, the two are
/// the same instant.
now_ns: u64 = 0,
stepped_ns: u64 = 0,
@@ -3591,7 +3589,7 @@ pub const Pardes = struct {
// A frame, and the animations and timings that make it.
"surface", "frames", "chrome",
"frame_arena", "scratch",
- "needs_frame", "present_skipped", "shell_continuous", "native_image_patches",
+ "needs_frame", "present_skipped", "native_image_patches",
"echo",
// Drained by every pump before its digest; a replica's queues
// are its own.
@@ -5016,7 +5014,7 @@ pub const Pardes = struct {
// waits on is its own (a picture decoding wakes only a frame
// that draws it), and the tape has the same calls either way.
const now = if (v.now) |clock| clock(h.ctx) else p.now_ns;
- const timeout: u32 = if (p.continuous()) 1 else if (p.nextWake()) |due| wake: {
+ const timeout: u32 = if (p.nextWake()) |due| wake: {
const ms = ((due -| now) + std.time.ns_per_ms - 1) / std.time.ns_per_ms;
break :wake @intCast(std.math.clamp(ms, 1, std.math.maxInt(u32)));
} else 0;
@@ -5038,7 +5036,7 @@ pub const Pardes = struct {
// rendering and nothing else.
// A shell with a clock draws what `advance` stepped; one without
// steps its own `.tick`s and draws while anything animates.
- if (!p.needs_frame and !p.continuous() and (v.now != null or !p.animationActive())) return p.frames.idle();
+ if (!p.needs_frame and (v.now != null or !p.animationActive())) return p.frames.idle();
// No one to see it: the frame stays owed (needs_frame), not drawn.
// A pty streaming into an unwatched session spent most of its time
// drawing what nobody looked at.
@@ -5063,8 +5061,8 @@ pub const Pardes = struct {
p.present_skipped = false;
if (v.post_present) |f| f(h.ctx);
// Still moving: the next frame is owed a period from now.
- const owed = if (p.nextWake()) |due| due <= p.stepped_ns + animation.frame_ns else false;
- p.frames.record(FrameStats.nowNs(), owed or p.continuous(), skipped);
+ const owed = if (p.nextWake()) |due| due <= p.stepped_ns + frame_ns else false;
+ p.frames.record(FrameStats.nowNs(), owed, skipped);
}
/// What a pump does between its wait and its frame: the queued inputs
@@ -6809,7 +6807,7 @@ pub const Pardes = struct {
/// the core owns is in this one list, which is what lets every shell
/// sleep exactly as long as nothing changes.
pub fn nextWake(p: *const Pardes) ?u64 {
- const next = p.stepped_ns + animation.frame_ns;
+ const next = p.stepped_ns + frame_ns;
// Held 9P writes go in when they pause: wake for it, never before
// the next frame (writes served before the shell's clock was first
// seen are stamped 0, which `advance` would count back from).
@@ -6827,7 +6825,7 @@ pub const Pardes = struct {
const streaming = p.stream.wake(next);
if (streaming) |due| if (due <= next) return next;
var frames: ?u64 = null;
- if (streaming) |due| frames = @max(1, (due -| p.stepped_ns + animation.frame_ns - 1) / animation.frame_ns);
+ if (streaming) |due| frames = @max(1, (due -| p.stepped_ns + frame_ns - 1) / frame_ns);
if (p.look_hover_wait) |waiting| {
const delay = config.look_preview_delay_frames;
frames = @max(1, delay -| waiting.frames);
@@ -6839,13 +6837,13 @@ pub const Pardes = struct {
// Del's question goes up at the end of its delay: a frame then, and
// none after (stepped time has reached it).
for (p.panes) |slot| if (slot) |pane| if (pane.prompt == .del_side and pane.question_due_ns > p.stepped_ns) {
- const wait = @max(1, (pane.question_due_ns - p.stepped_ns + animation.frame_ns - 1) / animation.frame_ns);
+ const wait = @max(1, (pane.question_due_ns - p.stepped_ns + frame_ns - 1) / frame_ns);
frames = if (frames) |soonest| @min(soonest, wait) else wait;
};
// A paste's Enter waiting on its REPL goes at the end of its wait,
// a time on the clock: the frames from `stepped_ns` that reach it.
for (p.panes) |slot| if (slot) |pane| if (pane.repl_enter > 0) {
- const wait = @max(1, (pane.repl_enter_due_ns -| p.stepped_ns + animation.frame_ns - 1) / animation.frame_ns);
+ const wait = @max(1, (pane.repl_enter_due_ns -| p.stepped_ns + frame_ns - 1) / frame_ns);
frames = if (frames) |soonest| @min(soonest, wait) else wait;
};
// A terminal's kitty animation, at its next frame. Only a time still
@@ -6854,25 +6852,17 @@ pub const Pardes = struct {
for (p.panes) |slot| if (slot) |pane| if (panes.terminal.animationDueMs(pane)) |due_ms| {
const due = due_ms *| std.time.ns_per_ms;
if (due > p.stepped_ns) {
- const wait = @max(1, (due - p.stepped_ns + animation.frame_ns - 1) / animation.frame_ns);
+ const wait = @max(1, (due - p.stepped_ns + frame_ns - 1) / frame_ns);
frames = if (frames) |soonest| @min(soonest, wait) else wait;
}
};
- return if (frames) |n| p.stepped_ns + n * animation.frame_ns else null;
- }
-
- /// A render-time animation is moving (a pane's lift): it is sampled at
- /// each frame's own `now`, so while it moves the shell draws every loop
- /// and its present (vsync) paces it, at the display's rate. `nextWake`
- /// is for the stepped animations, which count frames of `frame_ns`.
- pub fn continuous(p: *const Pardes) bool {
- return p.shell_continuous or panes.Pdf.moving(p);
+ return if (frames) |n| p.stepped_ns + n * frame_ns else null;
}
/// For shells that only need a yes or no: macOS, which keeps its own
/// frame bank.
pub fn animationActive(p: *const Pardes) bool {
- return p.nextWake() != null or p.continuous();
+ return p.nextWake() != null;
}
/// Bring core animation up to `now_ns`, the shell's monotonic clock: one
@@ -6889,7 +6879,7 @@ pub const Pardes = struct {
p.clock_started = true;
p.now_ns = now_ns;
if (!started) p.stepped_ns = now_ns;
- const frame = animation.frame_ns;
+ const frame = frame_ns;
var moving: u32 = 0;
// The session's ticks are the recording session's: a picture still
// decoding or a fade still moving asks for frames the way a message
@@ -7503,7 +7493,7 @@ test "the Del question shows only once its delay is up: a quick SPC d j never se
for (pane.notices.kinds[0..pane.notices.len]) |kind| try std.testing.expect(kind != .prompt);
// The loop wakes for it, at the end of the delay and not before.
const wake = p.nextWake().?;
- try std.testing.expect(wake >= pane.question_due_ns and wake < pane.question_due_ns + animation.frame_ns);
+ try std.testing.expect(wake >= pane.question_due_ns and wake < pane.question_due_ns + frame_ns);
p.now_ns = pane.question_due_ns - 1;
_ = try p.render(frame.allocator());
for (pane.notices.kinds[0..pane.notices.len]) |kind| try std.testing.expect(kind != .prompt);