From 763e7fab8abf4613c49214ddd993582dde99867f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 24 Jul 2024 11:52:49 -0700 Subject: [PATCH] renderer: skip virtual placements --- src/renderer/Metal.zig | 9 ++++++--- src/renderer/OpenGL.zig | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index d6c2514cc..07c5956ec 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1598,8 +1598,11 @@ fn prepKittyGraphics( continue; }; + // Get the rect for the placement. If this placement doesn't have + // a rect then its virtual or something so skip it. + const rect = p.rect(image, t) orelse continue; + // If the selection isn't within our viewport then skip it. - const rect = p.rect(image, t); if (bot.before(rect.top_left)) continue; if (rect.bottom_right.before(top)) continue; @@ -1656,7 +1659,7 @@ fn prepKittyGraphics( // Convert our screen point to a viewport point const viewport: terminal.point.Point = t.screen.pages.pointFromPin( .viewport, - p.pin.*, + rect.top_left, ) orelse .{ .viewport = .{} }; // Calculate the source rectangle @@ -1679,7 +1682,7 @@ fn prepKittyGraphics( if (image.width > 0 and image.height > 0) { try self.image_placements.append(self.alloc, .{ .image_id = kv.key_ptr.image_id, - .x = @intCast(p.pin.x), + .x = @intCast(rect.top_left.x), .y = @intCast(viewport.viewport.y), .z = p.z, .width = dest_width, diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 46acff1a9..fd9261874 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -785,8 +785,11 @@ fn prepKittyGraphics( continue; }; + // Get the rect for the placement. If this placement doesn't have + // a rect then its virtual or something so skip it. + const rect = p.rect(image, t) orelse continue; + // If the selection isn't within our viewport then skip it. - const rect = p.rect(image, t); if (bot.before(rect.top_left)) continue; if (rect.bottom_right.before(top)) continue; @@ -843,7 +846,7 @@ fn prepKittyGraphics( // Convert our screen point to a viewport point const viewport: terminal.point.Point = t.screen.pages.pointFromPin( .viewport, - p.pin.*, + rect.top_left, ) orelse .{ .viewport = .{} }; // Calculate the source rectangle @@ -866,7 +869,7 @@ fn prepKittyGraphics( if (image.width > 0 and image.height > 0) { try self.image_placements.append(self.alloc, .{ .image_id = kv.key_ptr.image_id, - .x = @intCast(p.pin.x), + .x = @intCast(rect.top_left.x), .y = @intCast(viewport.viewport.y), .z = p.z, .width = dest_width,