From 18d2454306bb1be5196b86888da6b45608f5ddf1 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 24 Dec 2016 01:33:29 +0000 Subject: [PATCH] Pixel double hardware cursors on non-OSX. --- .../Sdl2GraphicsDevice.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OpenRA.Platforms.Default/Sdl2GraphicsDevice.cs b/OpenRA.Platforms.Default/Sdl2GraphicsDevice.cs index 7b743e2aaa..01466c0c79 100644 --- a/OpenRA.Platforms.Default/Sdl2GraphicsDevice.cs +++ b/OpenRA.Platforms.Default/Sdl2GraphicsDevice.cs @@ -141,6 +141,29 @@ namespace OpenRA.Platforms.Default VerifyThreadAffinity(); try { + // Pixel double the cursor on non-OSX if the window scale is large enough + // OSX does this for us automatically + if (Platform.CurrentPlatform != PlatformType.OSX && WindowScale > 1.5) + { + var scaledData = new byte[4 * data.Length]; + for (var y = 0; y < size.Height * 4; y += 4) + { + for (var x = 0; x < size.Width * 4; x += 4) + { + var a = 4 * (y * size.Width + x); + var b = 4 * ((y + 1) * size.Width + x); + for (var i = 0; i < 4; i++) + { + scaledData[2 * a + i] = scaledData[2 * a + 4 + i] = data[a + i]; + scaledData[2 * b + i] = scaledData[2 * b + 4 + i] = data[b + i]; + } + } + } + + size = new Size(2 * size.Width, 2 * size.Height); + data = scaledData; + } + return new SDL2HardwareCursor(size, data, hotspot); } catch (Exception ex)