2018-08-04 17:38:49 -04:00
|
|
|
using Ryujinx.HLE.Font;
|
2018-06-10 20:46:42 -04:00
|
|
|
using Ryujinx.HLE.OsHle.Ipc;
|
2018-02-24 23:34:16 -05:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-06-10 20:46:42 -04:00
|
|
|
namespace Ryujinx.HLE.OsHle.Services.Pl
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
2018-04-06 00:01:52 -04:00
|
|
|
class ISharedFontManager : IpcService
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 14:58:46 -04:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-02-24 23:34:16 -05:00
|
|
|
|
2018-04-06 00:01:52 -04:00
|
|
|
public ISharedFontManager()
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
2018-08-04 17:38:49 -04:00
|
|
|
{ 0, RequestLoad },
|
|
|
|
{ 1, GetLoadState },
|
|
|
|
{ 2, GetFontSize },
|
|
|
|
{ 3, GetSharedMemoryAddressOffset },
|
|
|
|
{ 4, GetSharedMemoryNativeHandle },
|
|
|
|
{ 5, GetSharedFontInOrderOfPriority }
|
2018-02-24 23:34:16 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-03-13 20:24:17 -04:00
|
|
|
public long RequestLoad(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
|
|
|
|
|
2018-08-04 17:38:49 -04:00
|
|
|
Context.Ns.Font.Load(FontType);
|
|
|
|
|
2018-03-13 20:24:17 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 00:04:52 -04:00
|
|
|
public long GetLoadState(ServiceCtx Context)
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
2018-08-04 17:38:49 -04:00
|
|
|
SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
|
|
|
|
|
|
|
|
Context.ResponseData.Write(Context.Ns.Font.GetLoadState(FontType));
|
2018-02-24 23:34:16 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 00:04:52 -04:00
|
|
|
public long GetFontSize(ServiceCtx Context)
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
2018-08-04 17:38:49 -04:00
|
|
|
SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
|
|
|
|
|
|
|
|
Context.ResponseData.Write(Context.Ns.Font.GetFontSize(FontType));
|
2018-02-24 23:34:16 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 00:04:52 -04:00
|
|
|
public long GetSharedMemoryAddressOffset(ServiceCtx Context)
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
2018-08-04 17:38:49 -04:00
|
|
|
SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32();
|
|
|
|
|
|
|
|
Context.ResponseData.Write(Context.Ns.Font.GetSharedMemoryAddressOffset(FontType));
|
2018-02-24 23:34:16 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 00:04:52 -04:00
|
|
|
public long GetSharedMemoryNativeHandle(ServiceCtx Context)
|
2018-02-24 23:34:16 -05:00
|
|
|
{
|
2018-03-12 00:04:52 -04:00
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(Context.Ns.Os.FontSharedMem);
|
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
2018-02-24 23:34:16 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-08-04 17:38:49 -04:00
|
|
|
|
|
|
|
private uint AddFontToOrderOfPriorityList(ServiceCtx Context, SharedFontType FontType, uint BufferPos, out uint LoadState)
|
|
|
|
{
|
|
|
|
long TypesPosition = Context.Request.ReceiveBuff[0].Position;
|
|
|
|
long TypesSize = Context.Request.ReceiveBuff[0].Size;
|
|
|
|
|
|
|
|
long OffsetsPosition = Context.Request.ReceiveBuff[1].Position;
|
|
|
|
long OffsetsSize = Context.Request.ReceiveBuff[1].Size;
|
|
|
|
|
|
|
|
long FontSizeBufferPosition = Context.Request.ReceiveBuff[2].Position;
|
|
|
|
long FontSizeBufferSize = Context.Request.ReceiveBuff[2].Size;
|
|
|
|
|
|
|
|
LoadState = Context.Ns.Font.GetLoadState(FontType);
|
|
|
|
|
|
|
|
if (BufferPos >= TypesSize || BufferPos >= OffsetsSize || BufferPos >= FontSizeBufferSize)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Context.Memory.WriteUInt32(TypesPosition + BufferPos, (uint)FontType);
|
|
|
|
Context.Memory.WriteUInt32(OffsetsPosition + BufferPos, Context.Ns.Font.GetSharedMemoryAddressOffset(FontType));
|
|
|
|
Context.Memory.WriteUInt32(FontSizeBufferPosition + BufferPos, Context.Ns.Font.GetFontSize(FontType));
|
|
|
|
|
|
|
|
BufferPos += 4;
|
|
|
|
|
|
|
|
return BufferPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long GetSharedFontInOrderOfPriority(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
ulong LanguageCode = Context.RequestData.ReadUInt64();
|
|
|
|
uint LoadedCount = 0;
|
|
|
|
uint BufferPos = 0;
|
|
|
|
uint Loaded = 0;
|
|
|
|
|
|
|
|
for (int Type = 0; Type < Context.Ns.Font.Count; Type++)
|
|
|
|
{
|
|
|
|
BufferPos = AddFontToOrderOfPriorityList(Context, (SharedFontType)Type, BufferPos, out Loaded);
|
|
|
|
LoadedCount += Loaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
Context.ResponseData.Write(LoadedCount);
|
|
|
|
Context.ResponseData.Write(Context.Ns.Font.Count);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-24 23:34:16 -05:00
|
|
|
}
|
|
|
|
}
|