aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/renderer/image.zig
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-16 23:28:05 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-16 23:29:28 +0300
commit4a3302d19a2baa3a33e910e0088c24e780905b90 (patch)
treedcaf76fae1c82102d933c9225b17ca7ac5d3a847 /vendor/libghostty-vt/src/renderer/image.zig
parent550e9f8cc085f428429f5cf2da0bb2dba897e8b8 (diff)
chore: update vendored libghostty-vt
refs #276
Diffstat (limited to 'vendor/libghostty-vt/src/renderer/image.zig')
-rw-r--r--vendor/libghostty-vt/src/renderer/image.zig30
1 files changed, 18 insertions, 12 deletions
diff --git a/vendor/libghostty-vt/src/renderer/image.zig b/vendor/libghostty-vt/src/renderer/image.zig
index 442b7543..f8269354 100644
--- a/vendor/libghostty-vt/src/renderer/image.zig
+++ b/vendor/libghostty-vt/src/renderer/image.zig
@@ -192,9 +192,9 @@ pub const State = struct {
return;
};
- // For transmit time we always just use the current time
- // and overwrite the overlay.
- const transmit_time = try std.time.Instant.now();
+ // Overlays are always considered new content, so we take a
+ // fresh generation stamp to force replacing any existing one.
+ const generation = terminal.kitty.graphics.nextGeneration();
// Ensure we have space for our overlay placement. Do this before
// we upload our image so we don't have to deal with cleaning
@@ -207,7 +207,7 @@ pub const State = struct {
try self.prepImage(
alloc,
.overlay,
- transmit_time,
+ generation,
pending,
);
errdefer comptime unreachable;
@@ -525,14 +525,14 @@ pub const State = struct {
self: *State,
alloc: Allocator,
id: Id,
- transmit_time: std.time.Instant,
+ generation: u64,
pending: Image.Pending,
) PrepImageError!void {
- // If this image exists and its transmit time is the same we assume
- // it is the identical image so we don't need to send it to the GPU.
+ // If this image exists and its generation is the same it is the
+ // identical image so we don't need to send it to the GPU.
const gop = try self.images.getOrPut(alloc, id);
if (gop.found_existing and
- gop.value_ptr.transmit_time.order(transmit_time) == .eq)
+ gop.value_ptr.generation == generation)
{
return;
}
@@ -570,7 +570,7 @@ pub const State = struct {
if (!gop.found_existing) {
gop.value_ptr.* = .{
.image = new_image,
- .transmit_time = undefined,
+ .generation = 0,
};
} else {
gop.value_ptr.image.markForReplace(
@@ -586,7 +586,7 @@ pub const State = struct {
log.warn("error preparing image for upload err={}", .{err});
return error.ImageConversionError;
};
- gop.value_ptr.transmit_time = transmit_time;
+ gop.value_ptr.generation = generation;
}
/// Prepare the provided Kitty image for upload to the GPU by copying its
@@ -599,7 +599,7 @@ pub const State = struct {
try self.prepImage(
alloc,
.{ .kitty = image.id },
- image.transmit_time,
+ image.generation,
.{
.width = image.width,
.height = image.height,
@@ -688,7 +688,13 @@ pub const Id = union(enum) {
/// The map used for storing images.
pub const ImageMap = std.AutoHashMapUnmanaged(Id, struct {
image: Image,
- transmit_time: std.time.Instant,
+
+ /// The generation of the terminal image this was created from
+ /// (see terminal.kitty.graphics.Image.generation). Used to detect
+ /// staleness: a differing generation for the same ID means the
+ /// contents changed and the texture must be replaced. Zero is
+ /// never a valid stored generation so it marks "not yet uploaded".
+ generation: u64,
});
/// The state for a single image that is to be rendered.