From 71e5a0f4a8685b385fac762995d45575b638179f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 22:21:45 -0300 Subject: kinds #1, the paint contract: a picture over the cells is one Placement (raster: ptr, w, h, stride; src in pixels; dst in the frame's cells; at, where in them in pixels, or none for the frontend to fit; key, the pixels' identity by pane serial, page and revision; a terminal program's kitty z; dirty, the rows changed since an older key; art, the pane's Petscii, Palette and Ascii), where ImagePlace carried native.{revision, page, fit, pan_x, pan_y, geometry, pixel_offset_y, paper_bg, exact}, cell rects and an ImageCacheKey of three shapes by build; a PDF strip's scroll is its body region's scroll_px, whose fraction the window draws as pixel_offset_y was; glyph art leaves the core for src/Art.zig, the frontends' (the matcher, both palettes and a cache by key, ex image.zig's GlyphArt and TerminalImages' glyph cache): the core always hands an image pane, a PDF's pages and a terminal's kitty images as placements, whatever the frontend shows, and the tty draws them as glyph art without kitty graphics or when the pane asks, the window when the pane asks; the four words set the same pane bytes as before and the frontend reads them off the placement, so config.zig, builtins.zig and exec.zig are untouched; /screen lists a frame's placements as images (only a frame with pictures has the field); no golden changes: the snapshot goldens are the tty's, which draws the same art (images.snap and tagbottomimage.snap pass unchanged, and the tty's bytes for an image, its Palette and its Ascii are byte-identical to the base's), no /screen golden holds a picture, and the window's goldens hash the same; tests: kitty.zig's glyph-art case becomes its core half (a placement over the 8x4 cells, the cells the pane's) with the art in tui.zig's own test, terminal.zig's glyph-art case the same, surface.zig's two ImageCacheKey cases one keyOf case, the GlyphArt cases move to Art.zig with a frame case; gates: core-test 959/959, behaviour-test 244/244, unit-test 1486/1487 tui and 1530/1531 gui, pane-test 171/172, snap all ok, process-test 0 of 37 failed on both, hxdiff 19 and hxparity 6 mismatches by the base's names, replicas, gui-golden, monkey-gui, kitty-test 44/44, kitty-harness and image-harness on both, daemon.py main and window-clients Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/pdf_scroll_bench.zig | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'test/pdf_scroll_bench.zig') diff --git a/test/pdf_scroll_bench.zig b/test/pdf_scroll_bench.zig index 9ef11a1c..837e3acb 100644 --- a/test/pdf_scroll_bench.zig +++ b/test/pdf_scroll_bench.zig @@ -381,7 +381,7 @@ fn measure(config: Config, plan: Plan) !Result { drainEffects(core); const elapsed = nowNs() -| started; total += elapsed; - recorder.observe(frame, surface); + recorder.observe(frame, surface, pane); peak_raster_bytes = @max(peak_raster_bytes, rasterBytes(pv)); // The same frame boundary src/tui/tui.zig marks, so a Tracy capture // of this benchmark reads like a capture of the real shell. @@ -458,43 +458,42 @@ const Recorder = struct { /// and they live in the other checksum on purpose: fast scrolling is /// ALLOWED to change how pixels are carried and is never allowed to change /// which pixels arrive. - fn observe(self: *Recorder, frame: usize, surface: *const pardes.Surface) void { + fn observe(self: *Recorder, frame: usize, surface: *const pardes.Surface, pane: *const pardes.Pane) void { self.frames += 1; - self.visual = mix(self.visual, surface.images.items.len); - self.transport = mix(self.transport, surface.images.items.len); + self.visual = mix(self.visual, surface.placements.items.len); + self.transport = mix(self.transport, surface.placements.items.len); const full = frame % full_rgba_stride == 0; - for (surface.images.items) |place| { + for (surface.placements.items) |place| { self.images += 1; self.visual = mix(self.visual, place.pane); - self.visual = mix(self.visual, place.x); - self.visual = mix(self.visual, place.y); - self.visual = mix(self.visual, place.w); - self.visual = mix(self.visual, place.h); - self.visual = mix(self.visual, place.native.page); - self.visual = mix(self.visual, @backingInt(place.native.fit)); - self.visual = mix(self.visual, place.native.pan_x); - self.visual = mix(self.visual, place.native.pan_y); - self.visual = mix(self.visual, @as(u32, @bitCast(place.native.pixel_offset_y))); - if (place.native.geometry) |geometry| { - inline for (.{geometry.dst}) |rect| { - self.visual = mix(self.visual, rect.x); - self.visual = mix(self.visual, rect.y); - self.visual = mix(self.visual, rect.w); - self.visual = mix(self.visual, rect.h); - } - self.visual = self.hashSource(self.visual, place, geometry.src, full); + self.visual = mix(self.visual, place.dst.x); + self.visual = mix(self.visual, place.dst.y); + self.visual = mix(self.visual, place.dst.w); + self.visual = mix(self.visual, place.dst.h); + for (surface.regionList()) |r| if (r.kind == .body and r.owner == place.pane) { + self.visual = mix(self.visual, @as(u64, @bitCast(r.scroll_px - @floor(r.scroll_px)))); + }; + if (place.at) |rect| { + self.visual = mix(self.visual, rect.x); + self.visual = mix(self.visual, rect.y); + self.visual = mix(self.visual, rect.w); + self.visual = mix(self.visual, rect.h); + self.visual = self.hashSource(self.visual, place, place.src, full); } else { self.visual = mix(self.visual, std.math.maxInt(u64)); self.visual = if (full) - std.hash.Wyhash.hash(self.visual, place.rgba) + std.hash.Wyhash.hash(self.visual, place.raster.bytes()) else - stridedHash(self.visual, place.rgba); + stridedHash(self.visual, place.raster.bytes()); } - self.transport = mix(self.transport, place.native.page); - self.transport = mix(self.transport, place.iw); - self.transport = mix(self.transport, place.ih); - self.transport = mix(self.transport, place.rgba.len); - self.transport = mix(self.transport, place.native.revision -% self.base_revision); + // The revision the key is of, from the slot holding it (0: a + // page's paper before it lands). + const revision = for (pane.pdf.?.rasters[0..pane.pdf.?.rasters_len]) |r| { + if (r.valid and pardes.Placement.keyOf(pane.serial, @intCast(r.page), r.revision) == place.key) break r.revision; + } else 0; + self.transport = mix(self.transport, revision -% self.base_revision); + self.transport = mix(self.transport, place.raster.w); + self.transport = mix(self.transport, place.raster.h); } } @@ -504,21 +503,22 @@ const Recorder = struct { fn hashSource( self: *Recorder, seed: u64, - place: pardes.ImagePlace, + place: pardes.Placement, src: anytype, full: bool, ) u64 { _ = self; - const stride = place.iw * 4; - if (stride == 0 or place.rgba.len < stride) return mix(seed, std.math.maxInt(u64)); - const rows = @min(src.h, @as(u32, @intCast(place.rgba.len / stride)) -| src.y); + const rgba = place.raster.bytes(); + const stride: usize = place.raster.stride; + if (stride == 0 or rgba.len < stride) return mix(seed, std.math.maxInt(u64)); + const rows = @min(src.h, @as(u32, @intCast(rgba.len / stride)) -| src.y); var hash = mix(seed, rows); var row: u32 = 0; while (row < rows) : (row += if (full) 1 else 7) { const start = (@as(usize, src.y) + row) * stride + @as(usize, src.x) * 4; - const len = @min(@as(usize, src.w) * 4, place.rgba.len -| start); + const len = @min(@as(usize, src.w) * 4, rgba.len -| start); if (len == 0) break; - hash = std.hash.Wyhash.hash(hash, place.rgba[start..][0..len]); + hash = std.hash.Wyhash.hash(hash, rgba[start..][0..len]); } return hash; } -- cgit v1.3