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 --- src/pdf_view.zig | 78 ++++++++++++++++++-------------------------------------- 1 file changed, 25 insertions(+), 53 deletions(-) (limited to 'src/pdf_view.zig') diff --git a/src/pdf_view.zig b/src/pdf_view.zig index bb960139..4da382fd 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -3338,6 +3338,15 @@ pub fn draw( state.far, ); if (state.document_scroll_y != shown) state.drawn_y = state.document_scroll_y; + // Below the notice chips, like an image: a placed page is drawn after + // the cells and would paint a chip out. + const body: pardes.RectCell = .{ + .x = text_x, + .y = core.bodyTop(pane, rect) + pane.notices.span(), + .w = text_width, + .h = (rect.h -| pane.tag_rows) -| pane.notices.span(), + }; + if (s.region(.body, pane_id)) |region| region.scroll_px = state.document_scroll_y; var placed_any = false; var page = visible.first; const visible_end = visible.first + visible.len; @@ -3352,73 +3361,36 @@ pub fn draw( if (workers == null or pardes.platform == .macos) continue; const size = state.page_sizes[page]; const rows = visibleRows(state, view, page, @intFromFloat(@max(1, @round(size.width * 8))), @intFromFloat(@max(1, @round(size.height * 8)))) orelse continue; - if (!core.appendImagePlace(.{ + if (!core.appendPlacement(.{ .pane = @intCast(pane_id), - .serial = pane.serial, - .native = .{ - .revision = 0, - .page = @intCast(page), - .fit = switch (state.fit) { - .width => .width, - .height => .height, - }, - .pan_x = state.pan_x, - .geometry = .{ - .src = .{ .x = 0, .y = 0, .w = 1, .h = 1 }, - .dst = .{ .x = rows.base.dst.x, .y = rows.dst_y, .w = rows.base.dst.w, .h = rows.dst_h }, - }, - .pixel_offset_y = rows.pixel_offset_y, - }, - .x = text_x, - .y = core.bodyTop(pane, rect) + pane.notices.span(), - .w = text_width, - .h = (rect.h -| pane.tag_rows) -| pane.notices.span(), - .rgba = &state.blank, - .iw = 1, - .ih = 1, + .raster = .of(&state.blank, 1, 1), + .src = .{ .w = 1, .h = 1 }, + .dst = body, + .at = .{ .x = rows.base.dst.x, .y = rows.dst_y, .w = rows.base.dst.w, .h = rows.dst_h }, + .key = pardes.Placement.keyOf(pane.serial, @intCast(page), 0), })) break; placed_any = true; continue; }; const slot = rasterForPage(state, page).?; - const patch: ?pardes.ImagePatch = if (slot.patch_from != 0 and + const dirty: ?pardes.Placement.Dirty = if (slot.patch_from != 0 and slot.patch_rows.start < slot.patch_rows.end) .{ - .from = slot.patch_from, + .from = pardes.Placement.keyOf(pane.serial, @intCast(placed.page), slot.patch_from), .y = @intCast(slot.patch_rows.start - slot.band_y), .h = @intCast(slot.patch_rows.end - slot.patch_rows.start), } else null; - if (!core.appendImagePlace(.{ + if (!core.appendPlacement(.{ .pane = @intCast(pane_id), - .serial = pane.serial, - .native = .{ - .revision = placed.revision, - .page = @intCast(placed.page), - .fit = switch (placed.fit) { - .width => .width, - .height => .height, - }, - .pan_x = placed.pan_x, - .geometry = placed.geometry, - .pixel_offset_y = placed.pixel_offset_y, - .paper_bg = if (pardes.platform == .macos) - (if (key.mode == .disabled) .{ 255, 255, 255 } else key.colors.background) - else - null, - }, - .x = text_x, - // Below the notice chips, like an image: a placed page is - // drawn after the cells and would paint a chip out. - .y = core.bodyTop(pane, rect) + pane.notices.span(), - .w = text_width, - .h = (rect.h -| pane.tag_rows) -| pane.notices.span(), - .rgba = placed.rgba, - .iw = placed.width, - // The texture contains the retained band, not the full page. - .ih = placed.band_height, - .patch = patch, + // The texture is the retained band, not the full page. + .raster = .of(placed.rgba, placed.width, placed.band_height), + .src = placed.geometry.src, + .dst = body, + .at = placed.geometry.dst, + .key = pardes.Placement.keyOf(pane.serial, @intCast(placed.page), placed.revision), + .dirty = dirty, })) break; // A shell now holds (or will fetch whole) this revision. slot.patch_from = slot.revision; -- cgit v1.3