aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs')
-rw-r--r--Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs24
1 files changed, 12 insertions, 12 deletions
diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs
index c16b861e..dfd10925 100644
--- a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs
+++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs
@@ -1,12 +1,14 @@
using Ryujinx.HLE.Ui;
using Ryujinx.Memory;
using System;
+using System.Buffers.Binary;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
+using System.Numerics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
@@ -652,7 +654,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
DrawString(graphics, ControllerToggleText, _labelsTextFont, _textNormalBrush, labelPosition);
}
- private unsafe bool TryCopyTo(IVirtualMemoryManager destination, ulong position)
+ private bool TryCopyTo(IVirtualMemoryManager destination, ulong position)
{
if (_surface == null)
{
@@ -666,23 +668,21 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
Debug.Assert(surfaceData.Stride * surfaceData.Height == _surfaceInfo.Size);
// Convert the pixel format used in System.Drawing to the one required by a Switch Surface.
- int dataLength = surfaceData.Stride * surfaceData.Height;
- byte* dataPointer = (byte*)surfaceData.Scan0;
- byte* dataEnd = dataPointer + dataLength;
+ int dataLength = surfaceData.Stride * surfaceData.Height;
- for (; dataPointer < dataEnd; dataPointer += 4)
+ byte[] data = new byte[dataLength];
+ Span<uint> dataConvert = MemoryMarshal.Cast<byte, uint>(data);
+
+ Marshal.Copy(surfaceData.Scan0, data, 0, dataLength);
+
+ for (int i = 0; i < dataConvert.Length; i++)
{
- *(uint*)dataPointer = (uint)(
- (*(dataPointer + 0) << 16) |
- (*(dataPointer + 1) << 8 ) |
- (*(dataPointer + 2) << 0 ) |
- (*(dataPointer + 3) << 24));
+ dataConvert[i] = BitOperations.RotateRight(BinaryPrimitives.ReverseEndianness(dataConvert[i]), 8);
}
try
{
- Span<byte> dataSpan = new Span<byte>((void*)surfaceData.Scan0, dataLength);
- destination.Write(position, dataSpan);
+ destination.Write(position, data);
}
finally
{