summaryrefslogtreecommitdiff
path: root/core/term/TerminalImages.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/term/TerminalImages.zig')
-rw-r--r--core/term/TerminalImages.zig13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/term/TerminalImages.zig b/core/term/TerminalImages.zig
index 1420d9e3..feba5ddc 100644
--- a/core/term/TerminalImages.zig
+++ b/core/term/TerminalImages.zig
@@ -29,6 +29,8 @@ pub const storage_limit = 64 * 1024 * 1024;
petscii: bool = false,
/// Pixels in RGBA for images ghostty-vt holds in another format (RGB,
/// grey): only for images on screen, dropped the frame they are not.
+/// The emulator's own allocator's, as the emulator is (`draw`'s `own`):
+/// never a client core's, whose rollback would free it under the emulator.
converted: std.AutoHashMapUnmanaged(u32, Converted) = .empty,
/// When the next frame of a playing animation (a=a) is due, in ms on the
/// core's clock (`Pardes.stepped_ns`): the core wakes for it (nextWake).
@@ -160,9 +162,11 @@ fn decodePng(gpa: std.mem.Allocator, bytes: []const u8) ghostty_vt.sys.DecodeErr
/// Draw the active screen's images. `rows_of[v]` is the body row the
/// viewport's row `v` is shown on, if it is shown; `cols` how many of its
-/// columns the body shows, from `tx`.
+/// columns the body shows, from `tx`. The caches are `own`'s (the
+/// emulator's), `out` is `gpa`'s.
pub fn draw(
ti: *TerminalImages,
+ own: std.mem.Allocator,
gpa: std.mem.Allocator,
vt: *ghostty_vt.Terminal,
where: plain.term.ImagesAt,
@@ -173,7 +177,7 @@ pub fn draw(
) void {
var conv = ti.converted.valueIterator();
while (conv.next()) |c| c.used = false;
- defer ti.prune(gpa);
+ defer ti.prune(own);
const screen = vt.screens.active;
const storage = &screen.kitty_images;
@@ -187,7 +191,7 @@ pub fn draw(
const bottom = pages.getBottomRight(.viewport) orelse return;
const cw: u32 = @max(1, where.cell_w);
const ch: u32 = @max(1, where.cell_h);
- const ctx: Ctx = .{ .ti = ti, .gpa = gpa, .out = out, .pane = where.pane, .serial = where.serial, .tx = where.tx, .body_y = where.body_y, .cols = where.cols, .rows_of = rows_of, .cw = cw, .ch = ch };
+ const ctx: Ctx = .{ .ti = ti, .own = own, .gpa = gpa, .out = out, .pane = where.pane, .serial = where.serial, .tx = where.tx, .body_y = where.body_y, .cols = where.cols, .rows_of = rows_of, .cw = cw, .ch = ch };
// Handed on lowest z first (the storage's order is a hash map's), the
// order a shell draws them in; equal z keeps the order they came in.
const first = out.items.len;
@@ -268,6 +272,7 @@ pub fn draw(
const Ctx = struct {
ti: *TerminalImages,
+ own: std.mem.Allocator,
gpa: std.mem.Allocator,
out: *std.ArrayList(plain.Placement),
pane: u8,
@@ -287,7 +292,7 @@ const Ctx = struct {
const x0 = @max(dst.x, 0);
const x1 = @min(dst.x + dst.w, @as(i64, ctx.cols) * cw);
if (x1 <= x0) return;
- const rgba = ctx.ti.pixelsOf(ctx.gpa, img) orelse return;
+ const rgba = ctx.ti.pixelsOf(ctx.own, img) orelse return;
const first_row = @divFloor(@max(dst.y, 0), ch);
const last_row = @min(@divFloor(dst.y + dst.h - 1, ch), @as(i64, @intCast(ctx.rows_of.len)) - 1);
var v = first_row;