From 2993d12de76d4870d568d002355e4c7ede7c8d5b Mon Sep 17 00:00:00 2001 From: Xiaoyan Li Date: Fri, 27 Dec 2024 17:00:40 +0800 Subject: [PATCH] Use premultiplied alpha for renderer clearColor Fixes #3324 --- src/renderer/Metal.zig | 6 +++--- src/renderer/OpenGL.zig | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 3f24c3d2d..4247b8213 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1186,9 +1186,9 @@ pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void { attachment.setProperty("storeAction", @intFromEnum(mtl.MTLStoreAction.store)); attachment.setProperty("texture", screen_texture.value); attachment.setProperty("clearColor", mtl.MTLClearColor{ - .red = @as(f32, @floatFromInt(self.current_background_color.r)) / 255, - .green = @as(f32, @floatFromInt(self.current_background_color.g)) / 255, - .blue = @as(f32, @floatFromInt(self.current_background_color.b)) / 255, + .red = @as(f32, @floatFromInt(self.current_background_color.r)) / 255 * self.config.background_opacity, + .green = @as(f32, @floatFromInt(self.current_background_color.g)) / 255 * self.config.background_opacity, + .blue = @as(f32, @floatFromInt(self.current_background_color.b)) / 255 * self.config.background_opacity, .alpha = self.config.background_opacity, }); } diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 19843062c..0fe5538eb 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -2344,9 +2344,9 @@ fn drawCellProgram( // Clear the surface gl.clearColor( - @as(f32, @floatFromInt(self.draw_background.r)) / 255, - @as(f32, @floatFromInt(self.draw_background.g)) / 255, - @as(f32, @floatFromInt(self.draw_background.b)) / 255, + @as(f32, @floatFromInt(self.draw_background.r)) / 255 * self.config.background_opacity, + @as(f32, @floatFromInt(self.draw_background.g)) / 255 * self.config.background_opacity, + @as(f32, @floatFromInt(self.draw_background.b)) / 255 * self.config.background_opacity, @floatCast(self.config.background_opacity), ); gl.clear(gl.c.GL_COLOR_BUFFER_BIT);