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/macos.zig | 78 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'src/macos.zig') diff --git a/src/macos.zig b/src/macos.zig index d46f6cd4..0d79f96b 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -1755,52 +1755,50 @@ fn encodeChanged(diff: pardes.PanelCellDiff) u8 { } fn collectImages(st: *State, surface: *const pardes.Surface) void { - if (comptime !pardes.pdf_enabled) return; - if (surface.images.items.len == 0) return; - if (st.images.len < surface.images.items.len) { + const placements = surface.placements.items; + if (placements.len == 0) return; + if (st.images.len < placements.len) { const resized = if (st.images.len == 0) - st.gpa.alloc(Image, surface.images.items.len) + st.gpa.alloc(Image, placements.len) else - st.gpa.realloc(st.images, surface.images.items.len); + st.gpa.realloc(st.images, placements.len); st.images = resized catch return; } - for (surface.images.items) |place| { - if (place.iw == 0 or place.ih == 0 or place.rgba.len == 0) continue; - const geometry = place.native.geometry orelse image.NativeGeometry{ - .src = .{ .x = 0, .y = 0, .w = @intCast(place.iw), .h = @intCast(place.ih) }, - .dst = .{ - .x = 0, - .y = 0, - .w = @as(u32, place.w) * st.core.cell_pixels.w, - .h = @as(u32, place.h) * st.core.cell_pixels.h, - }, + for (placements) |place| { + if (place.raster.w == 0 or place.raster.h == 0) continue; + const dst = place.at orelse pardes.RectPx{ + .w = @as(u32, place.dst.w) * st.core.cell_pixels.w, + .h = @as(u32, place.dst.h) * st.core.cell_pixels.h, + }; + if (dst.w == 0 or dst.h == 0 or place.src.w == 0 or place.src.h == 0) continue; + var scroll: f64 = 0; + for (surface.regionList()) |r| if (r.kind == .body and r.owner == place.pane) { + scroll = r.scroll_px; + break; }; - if (geometry.dst.w == 0 or geometry.dst.h == 0) continue; - if (geometry.src.w == 0 or geometry.src.h == 0) continue; st.images[st.images_len] = .{ - .serial = place.serial, - .page = place.native.page, - .revision = place.native.revision, - .cell_x = place.x, - .cell_y = place.y, - .cell_w = place.w, - .cell_h = place.h, - .dst_x = geometry.dst.x, - .dst_y = geometry.dst.y, - .dst_w = geometry.dst.w, - .dst_h = geometry.dst.h, - .src_x = geometry.src.x, - .src_y = geometry.src.y, - .src_w = geometry.src.w, - .src_h = geometry.src.h, - .offset_y = place.native.pixel_offset_y, - .iw = @intCast(place.iw), - .ih = @intCast(place.ih), - .rgba = place.rgba.ptr, - .paper_bg = if (place.native.paper_bg) |bg| - @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2] - else - color_default, + // The shell keys its textures by these three: the placement's + // key in two halves keeps them one picture each. + .serial = if (st.core.panes[place.pane]) |pane| pane.serial else 0, + .page = @truncate(place.key), + .revision = @truncate(place.key >> 32), + .cell_x = place.dst.x, + .cell_y = place.dst.y, + .cell_w = place.dst.w, + .cell_h = place.dst.h, + .dst_x = dst.x, + .dst_y = dst.y, + .dst_w = dst.w, + .dst_h = dst.h, + .src_x = place.src.x, + .src_y = place.src.y, + .src_w = place.src.w, + .src_h = place.src.h, + .offset_y = -@as(f32, @floatCast(scroll - @floor(scroll))), + .iw = place.raster.w, + .ih = place.raster.h, + .rgba = place.raster.ptr, + .paper_bg = color_default, }; st.images_len += 1; } -- cgit v1.3