Use premultiplied alpha for renderer clearColor

Fixes #3324
This commit is contained in:
Xiaoyan Li
2024-12-27 17:00:40 +08:00
committed by Mitchell Hashimoto
parent b50e087581
commit 2993d12de7
2 changed files with 6 additions and 6 deletions

View File

@ -1186,9 +1186,9 @@ pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void {
attachment.setProperty("storeAction", @intFromEnum(mtl.MTLStoreAction.store)); attachment.setProperty("storeAction", @intFromEnum(mtl.MTLStoreAction.store));
attachment.setProperty("texture", screen_texture.value); attachment.setProperty("texture", screen_texture.value);
attachment.setProperty("clearColor", mtl.MTLClearColor{ attachment.setProperty("clearColor", mtl.MTLClearColor{
.red = @as(f32, @floatFromInt(self.current_background_color.r)) / 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, .green = @as(f32, @floatFromInt(self.current_background_color.g)) / 255 * self.config.background_opacity,
.blue = @as(f32, @floatFromInt(self.current_background_color.b)) / 255, .blue = @as(f32, @floatFromInt(self.current_background_color.b)) / 255 * self.config.background_opacity,
.alpha = self.config.background_opacity, .alpha = self.config.background_opacity,
}); });
} }

View File

@ -2344,9 +2344,9 @@ fn drawCellProgram(
// Clear the surface // Clear the surface
gl.clearColor( gl.clearColor(
@as(f32, @floatFromInt(self.draw_background.r)) / 255, @as(f32, @floatFromInt(self.draw_background.r)) / 255 * self.config.background_opacity,
@as(f32, @floatFromInt(self.draw_background.g)) / 255, @as(f32, @floatFromInt(self.draw_background.g)) / 255 * self.config.background_opacity,
@as(f32, @floatFromInt(self.draw_background.b)) / 255, @as(f32, @floatFromInt(self.draw_background.b)) / 255 * self.config.background_opacity,
@floatCast(self.config.background_opacity), @floatCast(self.config.background_opacity),
); );
gl.clear(gl.c.GL_COLOR_BUFFER_BIT); gl.clear(gl.c.GL_COLOR_BUFFER_BIT);