From 7962bd061b24ac2316e924038b5aba1a5cf1cc84 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 26 Feb 2023 17:44:14 -0800 Subject: [PATCH] metal: use the screen size reported in the callback to resize We were previously using the bounds which might be updated later if the view is in the middle of an animation. Just use the size that represents our target state. --- src/renderer/Metal.zig | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 5e8fcff18..c4ea43841 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -695,23 +695,7 @@ fn drawCells( } /// Resize the screen. -pub fn setScreenSize(self: *Metal, _: renderer.ScreenSize) !void { - // We use the bounds of our view which should be updated by now. - const unscaled = self.swapchain.getProperty(macos.graphics.Rect, "bounds"); - const bounds: macos.graphics.Size = scaled: { - const scaleFactor = self.swapchain.getProperty(macos.graphics.c.CGFloat, "contentsScale"); - break :scaled .{ - .width = unscaled.size.width * scaleFactor, - .height = unscaled.size.height * scaleFactor, - }; - }; - - // Easier to work with our own types - const dim: renderer.ScreenSize = .{ - .width = @floatToInt(u32, bounds.width), - .height = @floatToInt(u32, bounds.height), - }; - +pub fn setScreenSize(self: *Metal, dim: renderer.ScreenSize) !void { // Recalculate the rows/columns. const grid_size = self.gridSize(dim); @@ -732,7 +716,10 @@ pub fn setScreenSize(self: *Metal, _: renderer.ScreenSize) !void { self.font_shaper.cell_buf = shape_buf; // Set the size of the drawable surface to the bounds - self.swapchain.setProperty("drawableSize", bounds); + self.swapchain.setProperty("drawableSize", macos.graphics.Size{ + .width = @intToFloat(f64, dim.width), + .height = @intToFloat(f64, dim.height), + }); // Setup our uniforms const old = self.uniforms;