|
@@ -1,12 +1,14 @@
|
|
|
using Ryujinx.HLE.Ui;
|
|
using Ryujinx.HLE.Ui;
|
|
|
using Ryujinx.Memory;
|
|
using Ryujinx.Memory;
|
|
|
using System;
|
|
using System;
|
|
|
|
|
+using System.Buffers.Binary;
|
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
using System.Drawing;
|
|
|
using System.Drawing.Drawing2D;
|
|
using System.Drawing.Drawing2D;
|
|
|
using System.Drawing.Imaging;
|
|
using System.Drawing.Imaging;
|
|
|
using System.Drawing.Text;
|
|
using System.Drawing.Text;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
|
|
+using System.Numerics;
|
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.InteropServices;
|
|
|
using System.Threading;
|
|
using System.Threading;
|
|
@@ -652,7 +654,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|
|
DrawString(graphics, ControllerToggleText, _labelsTextFont, _textNormalBrush, labelPosition);
|
|
DrawString(graphics, ControllerToggleText, _labelsTextFont, _textNormalBrush, labelPosition);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private unsafe bool TryCopyTo(IVirtualMemoryManager destination, ulong position)
|
|
|
|
|
|
|
+ private bool TryCopyTo(IVirtualMemoryManager destination, ulong position)
|
|
|
{
|
|
{
|
|
|
if (_surface == null)
|
|
if (_surface == null)
|
|
|
{
|
|
{
|
|
@@ -666,23 +668,21 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|
|
Debug.Assert(surfaceData.Stride * surfaceData.Height == _surfaceInfo.Size);
|
|
Debug.Assert(surfaceData.Stride * surfaceData.Height == _surfaceInfo.Size);
|
|
|
|
|
|
|
|
// Convert the pixel format used in System.Drawing to the one required by a Switch Surface.
|
|
// 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
|
|
try
|
|
|
{
|
|
{
|
|
|
- Span<byte> dataSpan = new Span<byte>((void*)surfaceData.Scan0, dataLength);
|
|
|
|
|
- destination.Write(position, dataSpan);
|
|
|
|
|
|
|
+ destination.Write(position, data);
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|