renderer/metal: fix kitty image offset on screen

This commit is contained in:
Mitchell Hashimoto
2024-03-13 11:05:03 -07:00
parent d7ee705a7a
commit a697e97e08

View File

@ -1252,14 +1252,12 @@ fn prepKittyGraphics(
// If the top left is outside the viewport we need to calc an offset // If the top left is outside the viewport we need to calc an offset
// so that we render (0, 0) with some offset for the texture. // so that we render (0, 0) with some offset for the texture.
const offset_y: u32 = if (rect.top_left.before(top)) offset_y: { const offset_y: u32 = if (rect.top_left.before(top)) offset_y: {
break :offset_y 0; const vp_y = t.screen.pages.pointFromPin(.screen, top).?.screen.y;
// TODO(paged-terminal) const img_y = t.screen.pages.pointFromPin(.screen, rect.top_left).?.screen.y;
// const vp_y = t.screen.pages.pointFromPin(.screen, top).?.screen.y; std.log.warn("vp_y={} img_y={}", .{ vp_y, img_y });
// const img_y = t.screen.pages.pointFromPin(.screen, rect.top_left).?.screen.y; const offset_cells = vp_y - img_y;
// std.log.warn("vp_y={} img_y={}", .{ vp_y, img_y }); const offset_pixels = offset_cells * self.grid_metrics.cell_height;
// const offset_cells = vp_y - img_y; break :offset_y @intCast(offset_pixels);
// const offset_pixels = offset_cells * self.grid_metrics.cell_height;
// break :offset_y @intCast(offset_pixels);
} else 0; } else 0;
// We need to prep this image for upload if it isn't in the cache OR // We need to prep this image for upload if it isn't in the cache OR
@ -1303,13 +1301,10 @@ fn prepKittyGraphics(
} }
// Convert our screen point to a viewport point // Convert our screen point to a viewport point
const viewport = t.screen.pages.pointFromPin(.viewport, p.pin.*) orelse { const viewport: terminal.point.Point = t.screen.pages.pointFromPin(
log.warn( .viewport,
"failed to convert image point to viewport point image_id={} placement_id={}", p.pin.*,
.{ kv.key_ptr.image_id, kv.key_ptr.placement_id.id }, ) orelse .{ .viewport = .{} };
);
continue;
};
// Calculate the source rectangle // Calculate the source rectangle
const source_x = @min(image.width, p.source_x); const source_x = @min(image.width, p.source_x);