summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/replicas.zig38
-rw-r--r--test/rollback_bench.zig2
2 files changed, 21 insertions, 19 deletions
diff --git a/test/replicas.zig b/test/replicas.zig
index d9834209..857dcd75 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -467,49 +467,51 @@ const Client = struct {
script: Script = .{},
/// gui.zig `Client.posted`: a size posted once while it waits.
posted: ?@FieldType(pardes.Event, "resize") = null,
+ /// What its last frame showed beside the cells (gui.zig `Gui.facts`),
+ /// and its frame timings (Pardes.frames), its own.
+ facts: pardes.Facts = .{},
+ frames: pardes.FrameStats = .{},
resizes: u32 = 0,
- fn present(ctx: ?*anyopaque, _: *const pardes.Surface) void {
+ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) bool {
const cl: *Client = @ptrCast(@alignCast(ctx.?));
cl.drew = true;
+ cl.facts = surface.facts.*;
+ return true;
}
/// tui.zig `Client.draw` (gui.zig's is the same): its own view drawn
- /// outside any step, what presenting writes in the core put back.
+ /// outside any step, its timings its own.
fn draw(cl: *Client) void {
const r = cl.r.?;
- const core = r.core();
- const skipped = core.present_skipped;
- const needs = core.needs_frame;
- core.frames.mark_start = pardes.FrameStats.nowNs();
- core.frames.mark_update = core.frames.mark_start;
+ cl.frames.mark_start = pardes.FrameStats.nowNs();
+ cl.frames.mark_update = cl.frames.mark_start;
cl.drew = false;
- r.draw(.{ .ctx = cl, .f = present });
- core.frames.mark_render = core.frames.mark_update;
- cl.link.owed = core.present_skipped;
- core.frames.record(pardes.FrameStats.nowNs(), false, cl.link.owed);
- core.present_skipped = skipped;
- core.needs_frame = needs;
+ cl.link.owed = !r.draw(.{ .ctx = cl, .f = present });
+ cl.frames.mark_render = cl.frames.mark_update;
+ cl.frames.record(pardes.FrameStats.nowNs(), false, cl.link.owed);
cl.link.drawn(cl.drew);
}
- /// gui.zig `OwnView.run` over its own view (`Replica.within`): the
+ /// gui.zig's client pass over the frame it shows (Gui.facts): the
/// window's size against the view's, a resize posted when they differ.
- fn own(cl: *Client, core: *pardes.Pardes) anyerror!void {
- const v = core.view();
+ fn own(cl: *Client) void {
+ const v = &cl.facts;
const metrics: pardes.RowMetrics = .{ .body_w = 9, .body_h = 18, .tagline_w = 9, .tagline_h = 18 };
if (cl.cols == v.screen_w and cl.rows == v.screen_h and v.cell_pixels.w == 9 and v.cell_pixels.h == 18 and std.meta.eql(metrics, v.row_metrics)) return;
cl.resize = .{ .resize = .{ .cols = cl.cols, .rows = cl.rows, .cell_pixels = .{ .w = 9, .h = 18 }, .row_metrics = metrics } };
}
- /// The window's own pass over its view, and what it posted fed.
+ /// The window's own pass over its frame, and what it posted applied.
fn within(cl: *Client) void {
if (cl.kind != .window) return;
- cl.r.?.within(cl, own);
+ cl.own();
if (cl.resize) |ev| {
if (cl.posted == null or !std.meta.eql(cl.posted.?, ev.resize)) {
cl.link.input(ev);
cl.resizes += 1;
+ const r = cl.r.?;
+ if (r.core().live == r.view) pardes.draw.facts(r.core(), &cl.facts);
}
cl.posted = ev.resize;
} else cl.posted = null;
diff --git a/test/rollback_bench.zig b/test/rollback_bench.zig
index 796f7135..d750871e 100644
--- a/test/rollback_bench.zig
+++ b/test/rollback_bench.zig
@@ -99,7 +99,7 @@ fn build(s: Session, dir: []const u8, a: std.mem.Allocator) !*pardes.Pardes {
};
if (nopened == 0) return error.NothingOpened;
for (0..s.edits) |e| {
- core.active = opened[e % nopened];
+ core.view().active = opened[e % nopened];
key(core, 'i', "i");
key(core, 'x', "x");
key(core, pardes.Key.escape, "");