diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 5a7b2da0b..deb88f9ff 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -252,7 +252,7 @@ pub fn deinit(self: *Surface) void { } fn render(self: *Surface) !void { - try self.core_surface.renderer.draw(); + try self.core_surface.renderer.drawFrame(self); } /// Queue the inspector to render if we have one. diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 275184de0..bc97f3b93 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -574,7 +574,9 @@ pub fn updateFrame( } /// Draw the frame to the screen. -pub fn drawFrame(self: *Metal) !void { +pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void { + _ = surface; + // @autoreleasepool {} const pool = objc.AutoreleasePool.init(); defer pool.deinit(); diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 07e1d030c..32781a7eb 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -576,12 +576,14 @@ fn resetFontMetrics( } /// The primary render callback that is completely thread-safe. -pub fn render( +pub fn updateFrame( self: *OpenGL, surface: *apprt.Surface, state: *renderer.State, cursor_blink_visible: bool, ) !void { + _ = surface; + // Data we extract out of the critical area. const Critical = struct { gl_bg: terminal.color.RGB, @@ -669,19 +671,6 @@ pub fn render( critical.cursor_style, ); } - - // We're out of the critical path now. Let's render. We only render if - // we're not single threaded. If we're single threaded we expect the - // runtime to call draw. - if (single_threaded_draw) return; - - try self.draw(); - - // Swap our window buffers - switch (apprt.runtime) { - else => @compileError("unsupported runtime"), - apprt.glfw => surface.window.swapBuffers(), - } } /// rebuildCells rebuilds all the GPU cells from our CPU state. This is a @@ -1448,7 +1437,7 @@ fn flushAtlas(self: *OpenGL) !void { /// Render renders the current cell state. This will not modify any of /// the cells. -pub fn draw(self: *OpenGL) !void { +pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void { const t = trace(@src()); defer t.end(); @@ -1507,6 +1496,13 @@ pub fn draw(self: *OpenGL) !void { try self.drawCells(binding, self.cells_bg); try self.drawCells(binding, self.cells); + + // Swap our window buffers + switch (apprt.runtime) { + apprt.glfw => surface.window.swapBuffers(), + apprt.gtk => {}, + else => @compileError("unsupported runtime"), + } } /// Loads some set of cell data into our buffer and issues a draw call. diff --git a/src/renderer/Thread.zig b/src/renderer/Thread.zig index 3a41f593d..926bd8e42 100644 --- a/src/renderer/Thread.zig +++ b/src/renderer/Thread.zig @@ -364,7 +364,7 @@ fn renderCallback( } // Draw - t.renderer.drawFrame() catch |err| + t.renderer.drawFrame(t.surface) catch |err| log.warn("error drawing err={}", .{err}); return .disarm;