summaryrefslogtreecommitdiff
path: root/test/pdf_scroll_bench.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/pdf_scroll_bench.zig')
-rw-r--r--test/pdf_scroll_bench.zig70
1 files changed, 35 insertions, 35 deletions
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;
}