From 1a89e91630754158a59a60b443baeb8fe08def23 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Fri, 29 May 2015 19:50:33 +0100 Subject: [PATCH] Fast case PremultiplyAlpha for opaque colors. --- OpenRA.Game/Graphics/Util.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenRA.Game/Graphics/Util.cs b/OpenRA.Game/Graphics/Util.cs index b61ee0f1e4..2f968a48ec 100644 --- a/OpenRA.Game/Graphics/Util.cs +++ b/OpenRA.Game/Graphics/Util.cs @@ -114,6 +114,8 @@ namespace OpenRA.Graphics public static Color PremultiplyAlpha(Color c) { + if (c.A == byte.MaxValue) + return c; var a = c.A / 255f; return Color.FromArgb(c.A, (byte)(c.R * a + 0.5f), (byte)(c.G * a + 0.5f), (byte)(c.B * a + 0.5f)); }