mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Format RenderApi code
This commit is contained in:
@@ -8,24 +8,24 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[ComVisible(false)]
|
||||
internal struct BLOBREF
|
||||
{
|
||||
public static readonly BLOBREF NULL = new BLOBREF();
|
||||
private uint value;
|
||||
[ComVisible(false)]
|
||||
internal struct BLOBREF
|
||||
{
|
||||
public static readonly BLOBREF NULL = new BLOBREF();
|
||||
private uint value;
|
||||
|
||||
private BLOBREF(uint value) => this.value = value;
|
||||
private BLOBREF(uint value) => this.value = value;
|
||||
|
||||
public static bool operator ==(BLOBREF hl, BLOBREF hr) => (int) hl.value == (int) hr.value;
|
||||
public static bool operator ==(BLOBREF hl, BLOBREF hr) => (int)hl.value == (int)hr.value;
|
||||
|
||||
public static bool operator !=(BLOBREF hl, BLOBREF hr) => (int) hl.value != (int) hr.value;
|
||||
public static bool operator !=(BLOBREF hl, BLOBREF hr) => (int)hl.value != (int)hr.value;
|
||||
|
||||
public override bool Equals(object oCompare) => (int) this.value == (int) (uint) oCompare;
|
||||
public override bool Equals(object oCompare) => (int)this.value == (int)(uint)oCompare;
|
||||
|
||||
public override int GetHashCode() => (int) this.value;
|
||||
public override int GetHashCode() => (int)this.value;
|
||||
|
||||
public static BLOBREF FromUInt32(uint value) => new BLOBREF(value);
|
||||
public static BLOBREF FromUInt32(uint value) => new BLOBREF(value);
|
||||
|
||||
public static uint ToUInt32(BLOBREF handle) => handle.value;
|
||||
}
|
||||
public static uint ToUInt32(BLOBREF handle) => handle.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal delegate void BatchCallback();
|
||||
internal delegate void BatchCallback();
|
||||
}
|
||||
|
||||
@@ -9,143 +9,143 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal struct BlobInfo
|
||||
{
|
||||
private const int c_SizeOfChar = 2;
|
||||
private const int c_SizeOfUInt = 4;
|
||||
private Vector m_data;
|
||||
private unsafe Message* m_pmsgBlob;
|
||||
private uint m_totalSize;
|
||||
private uint m_blobsOffset;
|
||||
private bool m_foreignByteOrder;
|
||||
private static object s_msgBlobSentinal = new object();
|
||||
private static Vector s_cache;
|
||||
|
||||
public unsafe BlobInfo(RenderPort port, uint origTotal)
|
||||
internal struct BlobInfo
|
||||
{
|
||||
this.m_foreignByteOrder = port.ForeignByteOrder;
|
||||
this.m_data = BlobInfo.s_cache;
|
||||
BlobInfo.s_cache = (Vector) null;
|
||||
if (this.m_data == null)
|
||||
this.m_data = new Vector();
|
||||
this.m_totalSize = origTotal;
|
||||
this.m_blobsOffset = origTotal;
|
||||
this.m_pmsgBlob = (Message*) null;
|
||||
}
|
||||
private const int c_SizeOfChar = 2;
|
||||
private const int c_SizeOfUInt = 4;
|
||||
private Vector m_data;
|
||||
private unsafe Message* m_pmsgBlob;
|
||||
private uint m_totalSize;
|
||||
private uint m_blobsOffset;
|
||||
private bool m_foreignByteOrder;
|
||||
private static object s_msgBlobSentinal = new object();
|
||||
private static Vector s_cache;
|
||||
|
||||
public uint AdjustedTotalSize => this.m_totalSize;
|
||||
|
||||
public uint BlobDataSize => this.m_totalSize - this.m_blobsOffset;
|
||||
|
||||
public BLOBREF Add(RENDERHANDLE[] param)
|
||||
{
|
||||
uint cbData = param == null ? 0U : (uint) (param.Length * 4);
|
||||
return this.Add((object) param, cbData);
|
||||
}
|
||||
|
||||
public BLOBREF Add(string param)
|
||||
{
|
||||
if (param == null)
|
||||
param = "";
|
||||
uint cbData = (uint) ((param.Length + 1) * 2);
|
||||
return this.Add((object) param, cbData);
|
||||
}
|
||||
|
||||
public unsafe BLOBREF Add(Message* pmsg)
|
||||
{
|
||||
uint cbData = 0;
|
||||
if ((IntPtr) pmsg != IntPtr.Zero)
|
||||
{
|
||||
this.m_pmsgBlob = pmsg;
|
||||
cbData = pmsg->cbSize;
|
||||
}
|
||||
return this.Add(BlobInfo.s_msgBlobSentinal, cbData);
|
||||
}
|
||||
|
||||
private BLOBREF Add(object param, uint cbData)
|
||||
{
|
||||
Debug2.Validate(cbData < (uint) ushort.MaxValue, typeof (ArgumentException), (object) "data blob too large", (object) nameof (param));
|
||||
BLOBREF blobref = BLOBREF.FromUInt32(this.m_totalSize | cbData << 16);
|
||||
if (cbData != 0U)
|
||||
{
|
||||
if (this.m_totalSize + cbData > (uint) ushort.MaxValue)
|
||||
throw new InvalidOperationException("insufficient space in message for data blob");
|
||||
this.m_totalSize += cbData;
|
||||
this.m_data.Add(param);
|
||||
}
|
||||
return blobref;
|
||||
}
|
||||
|
||||
public unsafe void Attach(Message* pMessage)
|
||||
{
|
||||
byte* numPtr1 = (byte*) ((IntPtr) pMessage + (int) this.m_blobsOffset);
|
||||
foreach (object obj in this.m_data)
|
||||
{
|
||||
if (obj is string)
|
||||
public unsafe BlobInfo(RenderPort port, uint origTotal)
|
||||
{
|
||||
string str = (string) obj;
|
||||
fixed (char* chPtr1 = str)
|
||||
{
|
||||
if (!this.m_foreignByteOrder)
|
||||
{
|
||||
char* chPtr2 = (char*) numPtr1;
|
||||
char* chPtr3 = chPtr1;
|
||||
char* chPtr4 = chPtr1 + (str.Length + 1);
|
||||
while (chPtr3 < chPtr4)
|
||||
*chPtr2++ = *chPtr3++;
|
||||
numPtr1 = (byte*) chPtr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte* numPtr2 = (byte*) chPtr1;
|
||||
for (byte* numPtr3 = numPtr2 + ((IntPtr) (str.Length + 1) * 2).ToInt64(); numPtr2 < numPtr3; numPtr2 += 2)
|
||||
{
|
||||
*numPtr1++ = numPtr2[1];
|
||||
*numPtr1++ = *numPtr2;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.m_foreignByteOrder = port.ForeignByteOrder;
|
||||
this.m_data = BlobInfo.s_cache;
|
||||
BlobInfo.s_cache = (Vector)null;
|
||||
if (this.m_data == null)
|
||||
this.m_data = new Vector();
|
||||
this.m_totalSize = origTotal;
|
||||
this.m_blobsOffset = origTotal;
|
||||
this.m_pmsgBlob = (Message*)null;
|
||||
}
|
||||
else if (obj is RENDERHANDLE[])
|
||||
|
||||
public uint AdjustedTotalSize => this.m_totalSize;
|
||||
|
||||
public uint BlobDataSize => this.m_totalSize - this.m_blobsOffset;
|
||||
|
||||
public BLOBREF Add(RENDERHANDLE[] param)
|
||||
{
|
||||
RENDERHANDLE[] renderhandleArray = (RENDERHANDLE[]) obj;
|
||||
fixed (RENDERHANDLE* renderhandlePtr = renderhandleArray)
|
||||
{
|
||||
if (!this.m_foreignByteOrder)
|
||||
{
|
||||
uint* numPtr2 = (uint*) numPtr1;
|
||||
uint* numPtr3 = (uint*) renderhandlePtr;
|
||||
uint* numPtr4 = numPtr3 + renderhandleArray.Length;
|
||||
while (numPtr3 < numPtr4)
|
||||
*numPtr2++ = *numPtr3++;
|
||||
numPtr1 = (byte*) numPtr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte* numPtr2 = (byte*) renderhandlePtr;
|
||||
for (byte* numPtr3 = numPtr2 + ((IntPtr) renderhandleArray.Length * 4).ToInt64(); numPtr2 < numPtr3; numPtr2 += 4)
|
||||
{
|
||||
*numPtr1++ = numPtr2[3];
|
||||
*numPtr1++ = numPtr2[2];
|
||||
*numPtr1++ = numPtr2[1];
|
||||
*numPtr1++ = *numPtr2;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint cbData = param == null ? 0U : (uint)(param.Length * 4);
|
||||
return this.Add((object)param, cbData);
|
||||
}
|
||||
else if (obj == BlobInfo.s_msgBlobSentinal)
|
||||
|
||||
public BLOBREF Add(string param)
|
||||
{
|
||||
byte* pmsgBlob = (byte*) this.m_pmsgBlob;
|
||||
byte* numPtr2 = pmsgBlob + (int) this.m_pmsgBlob->cbSize;
|
||||
while (pmsgBlob < numPtr2)
|
||||
*numPtr1++ = *pmsgBlob++;
|
||||
if (param == null)
|
||||
param = "";
|
||||
uint cbData = (uint)((param.Length + 1) * 2);
|
||||
return this.Add((object)param, cbData);
|
||||
}
|
||||
|
||||
public unsafe BLOBREF Add(Message* pmsg)
|
||||
{
|
||||
uint cbData = 0;
|
||||
if ((IntPtr)pmsg != IntPtr.Zero)
|
||||
{
|
||||
this.m_pmsgBlob = pmsg;
|
||||
cbData = pmsg->cbSize;
|
||||
}
|
||||
return this.Add(BlobInfo.s_msgBlobSentinal, cbData);
|
||||
}
|
||||
|
||||
private BLOBREF Add(object param, uint cbData)
|
||||
{
|
||||
Debug2.Validate(cbData < (uint)ushort.MaxValue, typeof(ArgumentException), (object)"data blob too large", (object)nameof(param));
|
||||
BLOBREF blobref = BLOBREF.FromUInt32(this.m_totalSize | cbData << 16);
|
||||
if (cbData != 0U)
|
||||
{
|
||||
if (this.m_totalSize + cbData > (uint)ushort.MaxValue)
|
||||
throw new InvalidOperationException("insufficient space in message for data blob");
|
||||
this.m_totalSize += cbData;
|
||||
this.m_data.Add(param);
|
||||
}
|
||||
return blobref;
|
||||
}
|
||||
|
||||
public unsafe void Attach(Message* pMessage)
|
||||
{
|
||||
byte* numPtr1 = (byte*)((IntPtr)pMessage + (int)this.m_blobsOffset);
|
||||
foreach (object obj in this.m_data)
|
||||
{
|
||||
if (obj is string)
|
||||
{
|
||||
string str = (string)obj;
|
||||
fixed (char* chPtr1 = str)
|
||||
{
|
||||
if (!this.m_foreignByteOrder)
|
||||
{
|
||||
char* chPtr2 = (char*)numPtr1;
|
||||
char* chPtr3 = chPtr1;
|
||||
char* chPtr4 = chPtr1 + (str.Length + 1);
|
||||
while (chPtr3 < chPtr4)
|
||||
*chPtr2++ = *chPtr3++;
|
||||
numPtr1 = (byte*)chPtr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte* numPtr2 = (byte*)chPtr1;
|
||||
for (byte* numPtr3 = numPtr2 + ((IntPtr)(str.Length + 1) * 2).ToInt64(); numPtr2 < numPtr3; numPtr2 += 2)
|
||||
{
|
||||
*numPtr1++ = numPtr2[1];
|
||||
*numPtr1++ = *numPtr2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj is RENDERHANDLE[])
|
||||
{
|
||||
RENDERHANDLE[] renderhandleArray = (RENDERHANDLE[])obj;
|
||||
fixed (RENDERHANDLE* renderhandlePtr = renderhandleArray)
|
||||
{
|
||||
if (!this.m_foreignByteOrder)
|
||||
{
|
||||
uint* numPtr2 = (uint*)numPtr1;
|
||||
uint* numPtr3 = (uint*)renderhandlePtr;
|
||||
uint* numPtr4 = numPtr3 + renderhandleArray.Length;
|
||||
while (numPtr3 < numPtr4)
|
||||
*numPtr2++ = *numPtr3++;
|
||||
numPtr1 = (byte*)numPtr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte* numPtr2 = (byte*)renderhandlePtr;
|
||||
for (byte* numPtr3 = numPtr2 + ((IntPtr)renderhandleArray.Length * 4).ToInt64(); numPtr2 < numPtr3; numPtr2 += 4)
|
||||
{
|
||||
*numPtr1++ = numPtr2[3];
|
||||
*numPtr1++ = numPtr2[2];
|
||||
*numPtr1++ = numPtr2[1];
|
||||
*numPtr1++ = *numPtr2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj == BlobInfo.s_msgBlobSentinal)
|
||||
{
|
||||
byte* pmsgBlob = (byte*)this.m_pmsgBlob;
|
||||
byte* numPtr2 = pmsgBlob + (int)this.m_pmsgBlob->cbSize;
|
||||
while (pmsgBlob < numPtr2)
|
||||
*numPtr1++ = *pmsgBlob++;
|
||||
}
|
||||
else
|
||||
Debug2.Throw(false, "Unexpected type.");
|
||||
}
|
||||
this.m_data.Clear();
|
||||
BlobInfo.s_cache = this.m_data;
|
||||
this.m_data = (Vector)null;
|
||||
}
|
||||
else
|
||||
Debug2.Throw(false, "Unexpected type.");
|
||||
}
|
||||
this.m_data.Clear();
|
||||
BlobInfo.s_cache = this.m_data;
|
||||
this.m_data = (Vector) null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[ComVisible(false)]
|
||||
internal struct CallbackMessage
|
||||
{
|
||||
public uint cbSize;
|
||||
public uint nMsg;
|
||||
public RENDERHANDLE idObjectSubject;
|
||||
public RENDERHANDLE hTarget;
|
||||
}
|
||||
[ComVisible(false)]
|
||||
internal struct CallbackMessage
|
||||
{
|
||||
public uint cbSize;
|
||||
public uint nMsg;
|
||||
public RENDERHANDLE idObjectSubject;
|
||||
public RENDERHANDLE hTarget;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[Serializable]
|
||||
internal abstract class ConnectionInfo
|
||||
{
|
||||
public static readonly ConnectionInfo Default = (ConnectionInfo) new LocalConnectionInfo();
|
||||
}
|
||||
[Serializable]
|
||||
internal abstract class ConnectionInfo
|
||||
{
|
||||
public static readonly ConnectionInfo Default = (ConnectionInfo)new LocalConnectionInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[ComVisible(false)]
|
||||
[Serializable]
|
||||
internal struct ContextID
|
||||
{
|
||||
public static readonly ContextID NULL = new ContextID();
|
||||
public static readonly ContextID CURRENT = new ContextID(uint.MaxValue);
|
||||
private uint value;
|
||||
[ComVisible(false)]
|
||||
[Serializable]
|
||||
internal struct ContextID
|
||||
{
|
||||
public static readonly ContextID NULL = new ContextID();
|
||||
public static readonly ContextID CURRENT = new ContextID(uint.MaxValue);
|
||||
private uint value;
|
||||
|
||||
private ContextID(uint value) => this.value = value;
|
||||
private ContextID(uint value) => this.value = value;
|
||||
|
||||
public static bool operator ==(ContextID hl, ContextID hr) => (int) hl.value == (int) hr.value;
|
||||
public static bool operator ==(ContextID hl, ContextID hr) => (int)hl.value == (int)hr.value;
|
||||
|
||||
public static bool operator !=(ContextID hl, ContextID hr) => (int) hl.value != (int) hr.value;
|
||||
public static bool operator !=(ContextID hl, ContextID hr) => (int)hl.value != (int)hr.value;
|
||||
|
||||
public override bool Equals(object oCompare) => oCompare is ContextID contextId && (int) this.value == (int) contextId.value;
|
||||
public override bool Equals(object oCompare) => oCompare is ContextID contextId && (int)this.value == (int)contextId.value;
|
||||
|
||||
public override int GetHashCode() => (int) this.value;
|
||||
public override int GetHashCode() => (int)this.value;
|
||||
|
||||
public static ContextID FromUInt32(uint value) => new ContextID(value);
|
||||
public static ContextID FromUInt32(uint value) => new ContextID(value);
|
||||
|
||||
public static uint ToUInt32(ContextID handle) => handle.value;
|
||||
}
|
||||
public static uint ToUInt32(ContextID handle) => handle.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,97 +9,97 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal class DataBuffer : IDataBufferCallback, IRenderHandleOwner
|
||||
{
|
||||
private RenderPort m_port;
|
||||
private RemoteDataBuffer m_remoteBuffer;
|
||||
private unsafe void* m_pvData;
|
||||
private uint m_cbSize;
|
||||
|
||||
public unsafe DataBuffer(RenderPort port, void* pvData, uint cbSize)
|
||||
internal class DataBuffer : IDataBufferCallback, IRenderHandleOwner
|
||||
{
|
||||
this.m_port = port;
|
||||
this.m_remoteBuffer = (RemoteDataBuffer) null;
|
||||
this.m_pvData = pvData;
|
||||
this.m_cbSize = cbSize;
|
||||
}
|
||||
private RenderPort m_port;
|
||||
private RemoteDataBuffer m_remoteBuffer;
|
||||
private unsafe void* m_pvData;
|
||||
private uint m_cbSize;
|
||||
|
||||
~DataBuffer() => this.Dispose(false);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.m_port.Session.AssertOwningThread();
|
||||
GC.SuppressFinalize((object) this);
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool fInDispose)
|
||||
{
|
||||
if (fInDispose && this.m_remoteBuffer != null)
|
||||
this.m_remoteBuffer.Dispose();
|
||||
this.m_remoteBuffer = (RemoteDataBuffer) null;
|
||||
}
|
||||
|
||||
public RenderPort Port => this.m_port;
|
||||
|
||||
public uint DataSize => this.m_cbSize;
|
||||
|
||||
public unsafe void* Data => this.m_pvData;
|
||||
|
||||
public RemoteDataBuffer RemoteStub => this.m_remoteBuffer;
|
||||
|
||||
public unsafe void Commit()
|
||||
{
|
||||
RENDERHANDLE renderhandle = this.m_port.AllocHandle((IRenderHandleOwner) this);
|
||||
try
|
||||
{
|
||||
this.m_port.SendDataBuffer(this.m_pvData, this.m_cbSize, renderhandle);
|
||||
this.m_remoteBuffer = RemoteDataBuffer.CreateFromHandle(this.m_port, renderhandle);
|
||||
this.m_remoteBuffer.SendRegisterOwner(this.m_port.MessagingProtocol.LocalDataBufferCallbackHandle);
|
||||
renderhandle = RENDERHANDLE.NULL;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (renderhandle != RENDERHANDLE.NULL)
|
||||
public unsafe DataBuffer(RenderPort port, void* pvData, uint cbSize)
|
||||
{
|
||||
if (this.m_remoteBuffer != null)
|
||||
{
|
||||
this.m_remoteBuffer.Dispose();
|
||||
this.m_remoteBuffer = (RemoteDataBuffer) null;
|
||||
}
|
||||
else
|
||||
this.m_port.FreeHandle(renderhandle);
|
||||
this.m_port = port;
|
||||
this.m_remoteBuffer = (RemoteDataBuffer)null;
|
||||
this.m_pvData = pvData;
|
||||
this.m_cbSize = cbSize;
|
||||
}
|
||||
}
|
||||
|
||||
~DataBuffer() => this.Dispose(false);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.m_port.Session.AssertOwningThread();
|
||||
GC.SuppressFinalize((object)this);
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool fInDispose)
|
||||
{
|
||||
if (fInDispose && this.m_remoteBuffer != null)
|
||||
this.m_remoteBuffer.Dispose();
|
||||
this.m_remoteBuffer = (RemoteDataBuffer)null;
|
||||
}
|
||||
|
||||
public RenderPort Port => this.m_port;
|
||||
|
||||
public uint DataSize => this.m_cbSize;
|
||||
|
||||
public unsafe void* Data => this.m_pvData;
|
||||
|
||||
public RemoteDataBuffer RemoteStub => this.m_remoteBuffer;
|
||||
|
||||
public unsafe void Commit()
|
||||
{
|
||||
RENDERHANDLE renderhandle = this.m_port.AllocHandle((IRenderHandleOwner)this);
|
||||
try
|
||||
{
|
||||
this.m_port.SendDataBuffer(this.m_pvData, this.m_cbSize, renderhandle);
|
||||
this.m_remoteBuffer = RemoteDataBuffer.CreateFromHandle(this.m_port, renderhandle);
|
||||
this.m_remoteBuffer.SendRegisterOwner(this.m_port.MessagingProtocol.LocalDataBufferCallbackHandle);
|
||||
renderhandle = RENDERHANDLE.NULL;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (renderhandle != RENDERHANDLE.NULL)
|
||||
{
|
||||
if (this.m_remoteBuffer != null)
|
||||
{
|
||||
this.m_remoteBuffer.Dispose();
|
||||
this.m_remoteBuffer = (RemoteDataBuffer)null;
|
||||
}
|
||||
else
|
||||
this.m_port.FreeHandle(renderhandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler DataConsumed;
|
||||
|
||||
protected virtual void OnDataConsumed(object sender, EventArgs args)
|
||||
{
|
||||
this.OnReleaseLocalData();
|
||||
if (this.DataConsumed == null)
|
||||
return;
|
||||
this.DataConsumed(sender, args);
|
||||
}
|
||||
|
||||
protected void OnDataConsumed() => this.OnDataConsumed((object)this, EventArgs.Empty);
|
||||
|
||||
public event EventHandler ReleaseLocalData;
|
||||
|
||||
protected virtual void OnReleaseLocalData(object sender, EventArgs args)
|
||||
{
|
||||
if (this.ReleaseLocalData == null)
|
||||
return;
|
||||
this.ReleaseLocalData(sender, args);
|
||||
}
|
||||
|
||||
protected void OnReleaseLocalData() => this.OnReleaseLocalData((object)this, EventArgs.Empty);
|
||||
|
||||
RENDERHANDLE IRenderHandleOwner.RenderHandle => this.m_remoteBuffer.RenderHandle;
|
||||
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteBuffer = (RemoteDataBuffer)null;
|
||||
|
||||
void IDataBufferCallback.OnComplete(RENDERHANDLE target) => this.OnDataConsumed();
|
||||
}
|
||||
|
||||
public event EventHandler DataConsumed;
|
||||
|
||||
protected virtual void OnDataConsumed(object sender, EventArgs args)
|
||||
{
|
||||
this.OnReleaseLocalData();
|
||||
if (this.DataConsumed == null)
|
||||
return;
|
||||
this.DataConsumed(sender, args);
|
||||
}
|
||||
|
||||
protected void OnDataConsumed() => this.OnDataConsumed((object) this, EventArgs.Empty);
|
||||
|
||||
public event EventHandler ReleaseLocalData;
|
||||
|
||||
protected virtual void OnReleaseLocalData(object sender, EventArgs args)
|
||||
{
|
||||
if (this.ReleaseLocalData == null)
|
||||
return;
|
||||
this.ReleaseLocalData(sender, args);
|
||||
}
|
||||
|
||||
protected void OnReleaseLocalData() => this.OnReleaseLocalData((object) this, EventArgs.Empty);
|
||||
|
||||
RENDERHANDLE IRenderHandleOwner.RenderHandle => this.m_remoteBuffer.RenderHandle;
|
||||
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteBuffer = (RemoteDataBuffer) null;
|
||||
|
||||
void IDataBufferCallback.OnComplete(RENDERHANDLE target) => this.OnDataConsumed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,143 +9,143 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal class DataBufferTracker
|
||||
{
|
||||
private Vector m_alTracking;
|
||||
|
||||
internal DataBufferTracker(object objUser) => this.m_alTracking = new Vector();
|
||||
|
||||
~DataBufferTracker() => this.Dispose(false);
|
||||
|
||||
internal void Dispose()
|
||||
internal class DataBufferTracker
|
||||
{
|
||||
GC.SuppressFinalize((object) this);
|
||||
this.Dispose(true);
|
||||
}
|
||||
private Vector m_alTracking;
|
||||
|
||||
private void Dispose(bool fInDispose)
|
||||
{
|
||||
if (fInDispose && this.m_alTracking != null && this.m_alTracking.Count > 0)
|
||||
{
|
||||
foreach (DataBufferTracker.TrackingInfo trackingInfo in this.m_alTracking)
|
||||
trackingInfo.DataBuffer.Dispose();
|
||||
this.m_alTracking.Clear();
|
||||
}
|
||||
this.m_alTracking = (Vector) null;
|
||||
}
|
||||
internal DataBufferTracker(object objUser) => this.m_alTracking = new Vector();
|
||||
|
||||
internal int Count => this.m_alTracking.Count;
|
||||
~DataBufferTracker() => this.Dispose(false);
|
||||
|
||||
internal string DEBUG_Description => (string) null;
|
||||
|
||||
internal object DEBUG_User => (object) null;
|
||||
|
||||
internal event EventHandler TrackerEmpty;
|
||||
|
||||
protected virtual void OnTrackerEmpty(object sender, EventArgs args)
|
||||
{
|
||||
if (this.TrackerEmpty == null)
|
||||
return;
|
||||
this.TrackerEmpty(sender, args);
|
||||
}
|
||||
|
||||
internal void Track(DataBuffer dataBuffer) => this.Track(dataBuffer, (DataBufferTracker.CleanupEventHandler) null, (object) null);
|
||||
|
||||
internal void Track(
|
||||
DataBuffer dataBuffer,
|
||||
DataBufferTracker.CleanupEventHandler handler,
|
||||
object contextData)
|
||||
{
|
||||
DataBufferTracker.TrackingInfo trackingInfo = new DataBufferTracker.TrackingInfo(dataBuffer, DataBufferTracker.Users.Valid, handler, contextData);
|
||||
dataBuffer.DataConsumed += new EventHandler(this.OnDataConsumed);
|
||||
dataBuffer.ReleaseLocalData += new EventHandler(this.OnReleaseLocalData);
|
||||
this.m_alTracking.Add((object) trackingInfo);
|
||||
}
|
||||
|
||||
internal void Release(DataBuffer dataBuffer, DataBufferTracker.Users userFlags)
|
||||
{
|
||||
DataBufferTracker.TrackingInfo trackingInfo1 = (DataBufferTracker.TrackingInfo) null;
|
||||
foreach (DataBufferTracker.TrackingInfo trackingInfo2 in this.m_alTracking)
|
||||
{
|
||||
if (trackingInfo2.DataBuffer == dataBuffer)
|
||||
internal void Dispose()
|
||||
{
|
||||
trackingInfo1 = trackingInfo2;
|
||||
break;
|
||||
GC.SuppressFinalize((object)this);
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool fInDispose)
|
||||
{
|
||||
if (fInDispose && this.m_alTracking != null && this.m_alTracking.Count > 0)
|
||||
{
|
||||
foreach (DataBufferTracker.TrackingInfo trackingInfo in this.m_alTracking)
|
||||
trackingInfo.DataBuffer.Dispose();
|
||||
this.m_alTracking.Clear();
|
||||
}
|
||||
this.m_alTracking = (Vector)null;
|
||||
}
|
||||
|
||||
internal int Count => this.m_alTracking.Count;
|
||||
|
||||
internal string DEBUG_Description => (string)null;
|
||||
|
||||
internal object DEBUG_User => (object)null;
|
||||
|
||||
internal event EventHandler TrackerEmpty;
|
||||
|
||||
protected virtual void OnTrackerEmpty(object sender, EventArgs args)
|
||||
{
|
||||
if (this.TrackerEmpty == null)
|
||||
return;
|
||||
this.TrackerEmpty(sender, args);
|
||||
}
|
||||
|
||||
internal void Track(DataBuffer dataBuffer) => this.Track(dataBuffer, (DataBufferTracker.CleanupEventHandler)null, (object)null);
|
||||
|
||||
internal void Track(
|
||||
DataBuffer dataBuffer,
|
||||
DataBufferTracker.CleanupEventHandler handler,
|
||||
object contextData)
|
||||
{
|
||||
DataBufferTracker.TrackingInfo trackingInfo = new DataBufferTracker.TrackingInfo(dataBuffer, DataBufferTracker.Users.Valid, handler, contextData);
|
||||
dataBuffer.DataConsumed += new EventHandler(this.OnDataConsumed);
|
||||
dataBuffer.ReleaseLocalData += new EventHandler(this.OnReleaseLocalData);
|
||||
this.m_alTracking.Add((object)trackingInfo);
|
||||
}
|
||||
|
||||
internal void Release(DataBuffer dataBuffer, DataBufferTracker.Users userFlags)
|
||||
{
|
||||
DataBufferTracker.TrackingInfo trackingInfo1 = (DataBufferTracker.TrackingInfo)null;
|
||||
foreach (DataBufferTracker.TrackingInfo trackingInfo2 in this.m_alTracking)
|
||||
{
|
||||
if (trackingInfo2.DataBuffer == dataBuffer)
|
||||
{
|
||||
trackingInfo1 = trackingInfo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trackingInfo1 == null)
|
||||
return;
|
||||
uint userFlags1 = (uint)trackingInfo1.UserFlags;
|
||||
Bits.ClearFlag(ref userFlags1, (uint)userFlags);
|
||||
trackingInfo1.UserFlags = (DataBufferTracker.Users)userFlags1;
|
||||
if (userFlags1 != 0U)
|
||||
return;
|
||||
if (trackingInfo1.CleanupHandler != null)
|
||||
trackingInfo1.CleanupHandler((object)this, new DataBufferTracker.CleanupEventArgs(trackingInfo1.CleanupHandlerData));
|
||||
this.m_alTracking.Remove((object)trackingInfo1);
|
||||
trackingInfo1.DataBuffer.DataConsumed -= new EventHandler(this.OnDataConsumed);
|
||||
trackingInfo1.DataBuffer.ReleaseLocalData -= new EventHandler(this.OnReleaseLocalData);
|
||||
trackingInfo1.DataBuffer.Dispose();
|
||||
trackingInfo1.DataBuffer = (DataBuffer)null;
|
||||
trackingInfo1.CleanupHandler = (DataBufferTracker.CleanupEventHandler)null;
|
||||
trackingInfo1.CleanupHandlerData = (object)null;
|
||||
if (this.m_alTracking.Count != 0)
|
||||
return;
|
||||
this.OnTrackerEmpty((object)this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void OnDataConsumed(object oSender, EventArgs args) => this.Release(oSender as DataBuffer, DataBufferTracker.Users.Consumed);
|
||||
|
||||
private void OnReleaseLocalData(object oSender, EventArgs args) => this.Release(oSender as DataBuffer, DataBufferTracker.Users.LocalData);
|
||||
|
||||
internal void DEBUG_SetDescription(string stDescription)
|
||||
{
|
||||
}
|
||||
|
||||
internal void DEBUG_DumpTrackingList()
|
||||
{
|
||||
}
|
||||
|
||||
[System.Flags]
|
||||
internal enum Users : uint
|
||||
{
|
||||
Consumed = 1,
|
||||
LocalData = 2,
|
||||
Valid = LocalData | Consumed, // 0x00000003
|
||||
}
|
||||
|
||||
internal class CleanupEventArgs : EventArgs
|
||||
{
|
||||
public object ContextData;
|
||||
|
||||
internal CleanupEventArgs(object contextData) => this.ContextData = contextData;
|
||||
}
|
||||
|
||||
internal delegate void CleanupEventHandler(
|
||||
object sender,
|
||||
DataBufferTracker.CleanupEventArgs args);
|
||||
|
||||
private class TrackingInfo
|
||||
{
|
||||
private static uint s_idSeed;
|
||||
internal DataBuffer DataBuffer;
|
||||
internal DataBufferTracker.Users UserFlags;
|
||||
internal uint Id;
|
||||
internal DataBufferTracker.CleanupEventHandler CleanupHandler;
|
||||
internal object CleanupHandlerData;
|
||||
|
||||
internal TrackingInfo(
|
||||
DataBuffer dataBuffer,
|
||||
DataBufferTracker.Users userFlags,
|
||||
DataBufferTracker.CleanupEventHandler handler,
|
||||
object contextData)
|
||||
{
|
||||
this.DataBuffer = dataBuffer;
|
||||
this.UserFlags = userFlags;
|
||||
this.Id = DataBufferTracker.TrackingInfo.s_idSeed++;
|
||||
this.CleanupHandler = handler;
|
||||
this.CleanupHandlerData = contextData;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trackingInfo1 == null)
|
||||
return;
|
||||
uint userFlags1 = (uint) trackingInfo1.UserFlags;
|
||||
Bits.ClearFlag(ref userFlags1, (uint) userFlags);
|
||||
trackingInfo1.UserFlags = (DataBufferTracker.Users) userFlags1;
|
||||
if (userFlags1 != 0U)
|
||||
return;
|
||||
if (trackingInfo1.CleanupHandler != null)
|
||||
trackingInfo1.CleanupHandler((object) this, new DataBufferTracker.CleanupEventArgs(trackingInfo1.CleanupHandlerData));
|
||||
this.m_alTracking.Remove((object) trackingInfo1);
|
||||
trackingInfo1.DataBuffer.DataConsumed -= new EventHandler(this.OnDataConsumed);
|
||||
trackingInfo1.DataBuffer.ReleaseLocalData -= new EventHandler(this.OnReleaseLocalData);
|
||||
trackingInfo1.DataBuffer.Dispose();
|
||||
trackingInfo1.DataBuffer = (DataBuffer) null;
|
||||
trackingInfo1.CleanupHandler = (DataBufferTracker.CleanupEventHandler) null;
|
||||
trackingInfo1.CleanupHandlerData = (object) null;
|
||||
if (this.m_alTracking.Count != 0)
|
||||
return;
|
||||
this.OnTrackerEmpty((object) this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void OnDataConsumed(object oSender, EventArgs args) => this.Release(oSender as DataBuffer, DataBufferTracker.Users.Consumed);
|
||||
|
||||
private void OnReleaseLocalData(object oSender, EventArgs args) => this.Release(oSender as DataBuffer, DataBufferTracker.Users.LocalData);
|
||||
|
||||
internal void DEBUG_SetDescription(string stDescription)
|
||||
{
|
||||
}
|
||||
|
||||
internal void DEBUG_DumpTrackingList()
|
||||
{
|
||||
}
|
||||
|
||||
[System.Flags]
|
||||
internal enum Users : uint
|
||||
{
|
||||
Consumed = 1,
|
||||
LocalData = 2,
|
||||
Valid = LocalData | Consumed, // 0x00000003
|
||||
}
|
||||
|
||||
internal class CleanupEventArgs : EventArgs
|
||||
{
|
||||
public object ContextData;
|
||||
|
||||
internal CleanupEventArgs(object contextData) => this.ContextData = contextData;
|
||||
}
|
||||
|
||||
internal delegate void CleanupEventHandler(
|
||||
object sender,
|
||||
DataBufferTracker.CleanupEventArgs args);
|
||||
|
||||
private class TrackingInfo
|
||||
{
|
||||
private static uint s_idSeed;
|
||||
internal DataBuffer DataBuffer;
|
||||
internal DataBufferTracker.Users UserFlags;
|
||||
internal uint Id;
|
||||
internal DataBufferTracker.CleanupEventHandler CleanupHandler;
|
||||
internal object CleanupHandlerData;
|
||||
|
||||
internal TrackingInfo(
|
||||
DataBuffer dataBuffer,
|
||||
DataBufferTracker.Users userFlags,
|
||||
DataBufferTracker.CleanupEventHandler handler,
|
||||
object contextData)
|
||||
{
|
||||
this.DataBuffer = dataBuffer;
|
||||
this.UserFlags = userFlags;
|
||||
this.Id = DataBufferTracker.TrackingInfo.s_idSeed++;
|
||||
this.CleanupHandler = handler;
|
||||
this.CleanupHandlerData = contextData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,251 +13,251 @@ using System.Security;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal static class EngineApi
|
||||
{
|
||||
private const string s_stEhRenderDll = "UIXRender.dll";
|
||||
|
||||
public static void IFC(HRESULT hr)
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal static class EngineApi
|
||||
{
|
||||
if (hr.Int >= 0)
|
||||
return;
|
||||
RenderException.ErrorCode code = (RenderException.ErrorCode) hr.Int;
|
||||
switch (hr.Int)
|
||||
{
|
||||
case -2147221503:
|
||||
case -2147221502:
|
||||
throw new OutOfMemoryException();
|
||||
case -2147221494:
|
||||
throw new RenderException(code, "Generic failure.");
|
||||
case -2147221493:
|
||||
throw new RenderException(code, "The object is in a \"busy\" state and is not available to process the request.");
|
||||
case -2147221492:
|
||||
throw new RenderException(code, "The object is not in a usable state to process the request.");
|
||||
case -2147221484:
|
||||
throw new RenderException(code, "The Context has not been initialized.");
|
||||
case -2147221474:
|
||||
throw new RenderException(code, "The object was used in the incorrect context.");
|
||||
case -2147221473:
|
||||
throw new RenderException(code, "The Context has been marked to only allow read-only operations. For example, this may be in the middle of a read-only callback.");
|
||||
case -2147221472:
|
||||
throw new RenderException(code, "The threading model has already be determined by a previous call to SpInit() and can no longer be changed.");
|
||||
case -2147221471:
|
||||
throw new RenderException(code, "Unable to use the IGMM_STANDARD messaging model because it is either unsupported or cannot be installed.");
|
||||
case -2147221464:
|
||||
throw new RenderException(code, "Can not mix an invalid coordinate mapping, for example having a non-relative child of a relative parent.");
|
||||
case -2147221454:
|
||||
throw new RenderException(code, "Could not find a MSGID for one of the requested messages. This will be represented by a '0' in the MSGID field for that message.");
|
||||
case -2147221444:
|
||||
throw new RenderException(code, "The operation is not legal because the specified Gadget does not have a GS_BUFFERED style.");
|
||||
case -2147221434:
|
||||
throw new RenderException(code, "The specific Gadget has started the destruction and can not be be modified in this manner.");
|
||||
case -2147221433:
|
||||
throw new RenderException(code, "The specific object is locked and may not be modified.");
|
||||
case -2147221432:
|
||||
throw new InvalidOperationException("The operation is not supported.");
|
||||
case -2147221424:
|
||||
throw new RenderException(code, "The specified optional component has not yet been initialized with InitGadgetComponent().");
|
||||
case -2147221414:
|
||||
throw new RenderException(code, "The specified object was not found.");
|
||||
case -2147221413:
|
||||
throw new RenderException(code, "The ObjectID is already in use.");
|
||||
case -2147221412:
|
||||
throw new FileNotFoundException("The specified file could not be found");
|
||||
case -2147221411:
|
||||
throw new ArgumentOutOfRangeException("", "The argument is out of range");
|
||||
case -2147221404:
|
||||
throw new RenderException(code, "The specified parmeters are mismatched for the current object state.");
|
||||
case -2147221394:
|
||||
throw new RenderException(code, "GDI+ was unable to be loaded. It may not be installed on the system or may not be properly initialized.");
|
||||
case -2147221393:
|
||||
throw new RenderException(code, "Direct3D was unable to be loaded. It may not be installed on the system or may not be properly initialized.");
|
||||
case -2147221384:
|
||||
throw new RenderException(code, "The specified class was already registered.");
|
||||
case -2147221383:
|
||||
throw new RenderException(code, "The specified message was not found during class registration.");
|
||||
case -2147221382:
|
||||
throw new RenderException(code, "The specified message was not implemented during class registration.");
|
||||
case -2147221381:
|
||||
throw new RenderException(code, "The implementation of the specific class has not yet been registered.");
|
||||
case -2147221380:
|
||||
throw new RenderException(code, "Sending the message failed.");
|
||||
case -2147221379:
|
||||
throw new RenderException(code, "The message data is too large.");
|
||||
case -2147221374:
|
||||
throw new RenderException(code, "The specified object does not have any content.");
|
||||
case -2147221373:
|
||||
throw new RenderException(code, "The specified object is not properly setup to store the data.");
|
||||
case -2147221364:
|
||||
throw new RenderException(code, "Generic failure from Win32 that did not SetLastError().");
|
||||
case -2147221363:
|
||||
throw new RenderException(code, "Generic failure from GDI+.");
|
||||
case -2147221362:
|
||||
throw new RenderException(code, "Generic failure from driver or rendering.");
|
||||
case -2147221354:
|
||||
throw new RenderException(code, "Unable to connect to remote renderer.");
|
||||
default:
|
||||
Marshal.ThrowExceptionForHR(hr.Int);
|
||||
break;
|
||||
}
|
||||
private const string s_stEhRenderDll = "UIXRender.dll";
|
||||
|
||||
public static void IFC(HRESULT hr)
|
||||
{
|
||||
if (hr.Int >= 0)
|
||||
return;
|
||||
RenderException.ErrorCode code = (RenderException.ErrorCode)hr.Int;
|
||||
switch (hr.Int)
|
||||
{
|
||||
case -2147221503:
|
||||
case -2147221502:
|
||||
throw new OutOfMemoryException();
|
||||
case -2147221494:
|
||||
throw new RenderException(code, "Generic failure.");
|
||||
case -2147221493:
|
||||
throw new RenderException(code, "The object is in a \"busy\" state and is not available to process the request.");
|
||||
case -2147221492:
|
||||
throw new RenderException(code, "The object is not in a usable state to process the request.");
|
||||
case -2147221484:
|
||||
throw new RenderException(code, "The Context has not been initialized.");
|
||||
case -2147221474:
|
||||
throw new RenderException(code, "The object was used in the incorrect context.");
|
||||
case -2147221473:
|
||||
throw new RenderException(code, "The Context has been marked to only allow read-only operations. For example, this may be in the middle of a read-only callback.");
|
||||
case -2147221472:
|
||||
throw new RenderException(code, "The threading model has already be determined by a previous call to SpInit() and can no longer be changed.");
|
||||
case -2147221471:
|
||||
throw new RenderException(code, "Unable to use the IGMM_STANDARD messaging model because it is either unsupported or cannot be installed.");
|
||||
case -2147221464:
|
||||
throw new RenderException(code, "Can not mix an invalid coordinate mapping, for example having a non-relative child of a relative parent.");
|
||||
case -2147221454:
|
||||
throw new RenderException(code, "Could not find a MSGID for one of the requested messages. This will be represented by a '0' in the MSGID field for that message.");
|
||||
case -2147221444:
|
||||
throw new RenderException(code, "The operation is not legal because the specified Gadget does not have a GS_BUFFERED style.");
|
||||
case -2147221434:
|
||||
throw new RenderException(code, "The specific Gadget has started the destruction and can not be be modified in this manner.");
|
||||
case -2147221433:
|
||||
throw new RenderException(code, "The specific object is locked and may not be modified.");
|
||||
case -2147221432:
|
||||
throw new InvalidOperationException("The operation is not supported.");
|
||||
case -2147221424:
|
||||
throw new RenderException(code, "The specified optional component has not yet been initialized with InitGadgetComponent().");
|
||||
case -2147221414:
|
||||
throw new RenderException(code, "The specified object was not found.");
|
||||
case -2147221413:
|
||||
throw new RenderException(code, "The ObjectID is already in use.");
|
||||
case -2147221412:
|
||||
throw new FileNotFoundException("The specified file could not be found");
|
||||
case -2147221411:
|
||||
throw new ArgumentOutOfRangeException("", "The argument is out of range");
|
||||
case -2147221404:
|
||||
throw new RenderException(code, "The specified parmeters are mismatched for the current object state.");
|
||||
case -2147221394:
|
||||
throw new RenderException(code, "GDI+ was unable to be loaded. It may not be installed on the system or may not be properly initialized.");
|
||||
case -2147221393:
|
||||
throw new RenderException(code, "Direct3D was unable to be loaded. It may not be installed on the system or may not be properly initialized.");
|
||||
case -2147221384:
|
||||
throw new RenderException(code, "The specified class was already registered.");
|
||||
case -2147221383:
|
||||
throw new RenderException(code, "The specified message was not found during class registration.");
|
||||
case -2147221382:
|
||||
throw new RenderException(code, "The specified message was not implemented during class registration.");
|
||||
case -2147221381:
|
||||
throw new RenderException(code, "The implementation of the specific class has not yet been registered.");
|
||||
case -2147221380:
|
||||
throw new RenderException(code, "Sending the message failed.");
|
||||
case -2147221379:
|
||||
throw new RenderException(code, "The message data is too large.");
|
||||
case -2147221374:
|
||||
throw new RenderException(code, "The specified object does not have any content.");
|
||||
case -2147221373:
|
||||
throw new RenderException(code, "The specified object is not properly setup to store the data.");
|
||||
case -2147221364:
|
||||
throw new RenderException(code, "Generic failure from Win32 that did not SetLastError().");
|
||||
case -2147221363:
|
||||
throw new RenderException(code, "Generic failure from GDI+.");
|
||||
case -2147221362:
|
||||
throw new RenderException(code, "Generic failure from driver or rendering.");
|
||||
case -2147221354:
|
||||
throw new RenderException(code, "Unable to connect to remote renderer.");
|
||||
default:
|
||||
Marshal.ThrowExceptionForHR(hr.Int);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpInit(ref EngineApi.InitArgs args);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpUninit();
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern unsafe HRESULT SpBufferOpen(
|
||||
EngineApi.BufferInfo* phdrData,
|
||||
void* pvData);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern unsafe HRESULT SpWrapBufferProc(
|
||||
EngineApi.MessageBufferEventHandler pfnProcessBufferProc,
|
||||
IntPtr* ppNativeProc);
|
||||
|
||||
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
|
||||
public static extern HRESULT SpPeekMessage(
|
||||
out Win32Api.MSG msg,
|
||||
HWND hwnd,
|
||||
uint nMsgFilterMin,
|
||||
uint nMsgFilterMax,
|
||||
uint wRemoveMsg,
|
||||
out EngineApi.WorkResult nResult);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpWaitMessage(uint nTimeOutMs, IntPtr _unused);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpInvoke(
|
||||
ContextID idContext,
|
||||
IntPtr pfnInvoke,
|
||||
IntPtr pvArgs,
|
||||
bool synchronous);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRenderThreadInit(
|
||||
ref EngineApi.InitArgs argsRender,
|
||||
out IntPtr pThread);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRenderThreadUninit(IntPtr pThread);
|
||||
|
||||
[DllImport("UIXRender.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern HRESULT SpRemoteCreateServerStreams(
|
||||
string stSession,
|
||||
TransportProtocol nProtocol,
|
||||
out IntPtr pSendStream,
|
||||
out IntPtr pReceiveStream);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRemoteWaitServerStreamsConnected(
|
||||
TransportProtocol nProtocol,
|
||||
IntPtr pSendStream,
|
||||
IntPtr pReceiveStream);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRemoteServerInit(
|
||||
IntPtr pSendStream,
|
||||
IntPtr pReceiveStream,
|
||||
EngineApi.InitArgs argsSend,
|
||||
out IntPtr pSession);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRemoteServerUninit(
|
||||
IntPtr pSession,
|
||||
bool fForceShutdown,
|
||||
out ShutdownReason nShutdownReason);
|
||||
|
||||
[DllImport("UIXRender.dll", CharSet = CharSet.Ansi)]
|
||||
public static extern HRESULT SpDx9CompileEffect(
|
||||
string stEffect,
|
||||
string stDefines,
|
||||
out IntPtr pErrorString,
|
||||
out IntPtr pErrorBuffer,
|
||||
out IntPtr pEffectBlob,
|
||||
out uint EffectBlobSize,
|
||||
out IntPtr pEffectBlobBuffer);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern void SpObjectRelease(IntPtr pUnknown);
|
||||
|
||||
[System.Flags]
|
||||
public enum BufferFlags
|
||||
{
|
||||
IsBatch = 1,
|
||||
CopyData = 2,
|
||||
Valid = CopyData | IsBatch, // 0x00000003
|
||||
}
|
||||
|
||||
[ComVisible(false)]
|
||||
public struct BufferInfo
|
||||
{
|
||||
public ContextID idContextSrc;
|
||||
public ContextID idContextDest;
|
||||
public RENDERHANDLE idBuffer;
|
||||
public EngineApi.BufferFlags nFlags;
|
||||
public uint cbSizeBuffer;
|
||||
}
|
||||
|
||||
internal delegate void TimeoutEventHandler(IntPtr pData);
|
||||
|
||||
[ComVisible(false)]
|
||||
internal struct InitArgs
|
||||
{
|
||||
public uint cbSize;
|
||||
public ContextID idContext;
|
||||
public int cItemsPerGroupBits;
|
||||
public int cGroupBits;
|
||||
public IntPtr pfnProcessBuffer;
|
||||
public IntPtr pvProcessData;
|
||||
public RENDERHANDLE idObjectBrokerClass;
|
||||
public EngineApi.TimeoutEventHandler pfnTimeout;
|
||||
public IntPtr pvTimeoutData;
|
||||
public uint nTimeOutSec;
|
||||
|
||||
public InitArgs(MessageCookieLayout layout, ContextID idContextNew)
|
||||
{
|
||||
Debug2.Validate(idContextNew != ContextID.NULL, typeof(ArgumentNullException), nameof(idContextNew));
|
||||
this.cbSize = (uint)Marshal.SizeOf(typeof(EngineApi.InitArgs));
|
||||
this.idContext = idContextNew;
|
||||
this.cItemsPerGroupBits = (int)layout.numberOfObjectBits;
|
||||
this.cGroupBits = (int)layout.numberOfGroupBits;
|
||||
this.pfnProcessBuffer = IntPtr.Zero;
|
||||
this.pvProcessData = IntPtr.Zero;
|
||||
this.idObjectBrokerClass = RENDERHANDLE.FromUInt32(0U);
|
||||
this.pfnTimeout = (EngineApi.TimeoutEventHandler)null;
|
||||
this.pvTimeoutData = IntPtr.Zero;
|
||||
this.nTimeOutSec = 0U;
|
||||
}
|
||||
|
||||
public unsafe InitArgs(
|
||||
MessageCookieLayout layout,
|
||||
ContextID idContextNew,
|
||||
EngineApi.MessageBufferEventHandler pfnProcessBufferProc)
|
||||
: this(layout, idContextNew)
|
||||
{
|
||||
if (pfnProcessBufferProc == null)
|
||||
return;
|
||||
IntPtr num;
|
||||
EngineApi.IFC(EngineApi.SpWrapBufferProc(pfnProcessBufferProc, &num));
|
||||
this.pfnProcessBuffer = num;
|
||||
}
|
||||
}
|
||||
|
||||
internal unsafe delegate int MessageBufferEventHandler(
|
||||
IntPtr pData,
|
||||
uint hContext,
|
||||
EngineApi.BufferInfo* pBufferInfo,
|
||||
void* pvBufferData);
|
||||
|
||||
[System.Flags]
|
||||
public enum WorkResult : uint
|
||||
{
|
||||
ProcessedMessage = 1,
|
||||
NewUserMessage = 2,
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpInit(ref EngineApi.InitArgs args);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpUninit();
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern unsafe HRESULT SpBufferOpen(
|
||||
EngineApi.BufferInfo* phdrData,
|
||||
void* pvData);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern unsafe HRESULT SpWrapBufferProc(
|
||||
EngineApi.MessageBufferEventHandler pfnProcessBufferProc,
|
||||
IntPtr* ppNativeProc);
|
||||
|
||||
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
|
||||
public static extern HRESULT SpPeekMessage(
|
||||
out Win32Api.MSG msg,
|
||||
HWND hwnd,
|
||||
uint nMsgFilterMin,
|
||||
uint nMsgFilterMax,
|
||||
uint wRemoveMsg,
|
||||
out EngineApi.WorkResult nResult);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpWaitMessage(uint nTimeOutMs, IntPtr _unused);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpInvoke(
|
||||
ContextID idContext,
|
||||
IntPtr pfnInvoke,
|
||||
IntPtr pvArgs,
|
||||
bool synchronous);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRenderThreadInit(
|
||||
ref EngineApi.InitArgs argsRender,
|
||||
out IntPtr pThread);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRenderThreadUninit(IntPtr pThread);
|
||||
|
||||
[DllImport("UIXRender.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern HRESULT SpRemoteCreateServerStreams(
|
||||
string stSession,
|
||||
TransportProtocol nProtocol,
|
||||
out IntPtr pSendStream,
|
||||
out IntPtr pReceiveStream);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRemoteWaitServerStreamsConnected(
|
||||
TransportProtocol nProtocol,
|
||||
IntPtr pSendStream,
|
||||
IntPtr pReceiveStream);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRemoteServerInit(
|
||||
IntPtr pSendStream,
|
||||
IntPtr pReceiveStream,
|
||||
EngineApi.InitArgs argsSend,
|
||||
out IntPtr pSession);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern HRESULT SpRemoteServerUninit(
|
||||
IntPtr pSession,
|
||||
bool fForceShutdown,
|
||||
out ShutdownReason nShutdownReason);
|
||||
|
||||
[DllImport("UIXRender.dll", CharSet = CharSet.Ansi)]
|
||||
public static extern HRESULT SpDx9CompileEffect(
|
||||
string stEffect,
|
||||
string stDefines,
|
||||
out IntPtr pErrorString,
|
||||
out IntPtr pErrorBuffer,
|
||||
out IntPtr pEffectBlob,
|
||||
out uint EffectBlobSize,
|
||||
out IntPtr pEffectBlobBuffer);
|
||||
|
||||
[DllImport("UIXRender.dll")]
|
||||
public static extern void SpObjectRelease(IntPtr pUnknown);
|
||||
|
||||
[System.Flags]
|
||||
public enum BufferFlags
|
||||
{
|
||||
IsBatch = 1,
|
||||
CopyData = 2,
|
||||
Valid = CopyData | IsBatch, // 0x00000003
|
||||
}
|
||||
|
||||
[ComVisible(false)]
|
||||
public struct BufferInfo
|
||||
{
|
||||
public ContextID idContextSrc;
|
||||
public ContextID idContextDest;
|
||||
public RENDERHANDLE idBuffer;
|
||||
public EngineApi.BufferFlags nFlags;
|
||||
public uint cbSizeBuffer;
|
||||
}
|
||||
|
||||
internal delegate void TimeoutEventHandler(IntPtr pData);
|
||||
|
||||
[ComVisible(false)]
|
||||
internal struct InitArgs
|
||||
{
|
||||
public uint cbSize;
|
||||
public ContextID idContext;
|
||||
public int cItemsPerGroupBits;
|
||||
public int cGroupBits;
|
||||
public IntPtr pfnProcessBuffer;
|
||||
public IntPtr pvProcessData;
|
||||
public RENDERHANDLE idObjectBrokerClass;
|
||||
public EngineApi.TimeoutEventHandler pfnTimeout;
|
||||
public IntPtr pvTimeoutData;
|
||||
public uint nTimeOutSec;
|
||||
|
||||
public InitArgs(MessageCookieLayout layout, ContextID idContextNew)
|
||||
{
|
||||
Debug2.Validate(idContextNew != ContextID.NULL, typeof (ArgumentNullException), nameof (idContextNew));
|
||||
this.cbSize = (uint) Marshal.SizeOf(typeof (EngineApi.InitArgs));
|
||||
this.idContext = idContextNew;
|
||||
this.cItemsPerGroupBits = (int) layout.numberOfObjectBits;
|
||||
this.cGroupBits = (int) layout.numberOfGroupBits;
|
||||
this.pfnProcessBuffer = IntPtr.Zero;
|
||||
this.pvProcessData = IntPtr.Zero;
|
||||
this.idObjectBrokerClass = RENDERHANDLE.FromUInt32(0U);
|
||||
this.pfnTimeout = (EngineApi.TimeoutEventHandler) null;
|
||||
this.pvTimeoutData = IntPtr.Zero;
|
||||
this.nTimeOutSec = 0U;
|
||||
}
|
||||
|
||||
public unsafe InitArgs(
|
||||
MessageCookieLayout layout,
|
||||
ContextID idContextNew,
|
||||
EngineApi.MessageBufferEventHandler pfnProcessBufferProc)
|
||||
: this(layout, idContextNew)
|
||||
{
|
||||
if (pfnProcessBufferProc == null)
|
||||
return;
|
||||
IntPtr num;
|
||||
EngineApi.IFC(EngineApi.SpWrapBufferProc(pfnProcessBufferProc, &num));
|
||||
this.pfnProcessBuffer = num;
|
||||
}
|
||||
}
|
||||
|
||||
internal unsafe delegate int MessageBufferEventHandler(
|
||||
IntPtr pData,
|
||||
uint hContext,
|
||||
EngineApi.BufferInfo* pBufferInfo,
|
||||
void* pvBufferData);
|
||||
|
||||
[System.Flags]
|
||||
public enum WorkResult : uint
|
||||
{
|
||||
ProcessedMessage = 1,
|
||||
NewUserMessage = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,169 +11,169 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal class HandleTable : RenderObject, IComparer
|
||||
{
|
||||
private RenderPort m_portOwner;
|
||||
private HandleGroup m_groups;
|
||||
private uint m_MaxObjectsPerGroup;
|
||||
private int m_GroupShift;
|
||||
private int m_UniqueShift;
|
||||
private uint m_GroupMask;
|
||||
private uint m_ObjectMask;
|
||||
private uint m_UniqueMask;
|
||||
|
||||
public HandleTable(RenderPort portOwner, MessageCookieLayout layout)
|
||||
internal class HandleTable : RenderObject, IComparer
|
||||
{
|
||||
Debug2.Validate(portOwner != null, typeof (ArgumentNullException), nameof (portOwner));
|
||||
this.m_portOwner = portOwner;
|
||||
uint maxObjects = 1U << (int) layout.numberOfGroupBits;
|
||||
this.m_MaxObjectsPerGroup = 1U << (int) layout.numberOfObjectBits;
|
||||
this.m_GroupShift = (int) layout.numberOfObjectBits;
|
||||
this.m_UniqueShift = (int) layout.numberOfObjectBits + (int) layout.numberOfGroupBits;
|
||||
this.m_GroupMask = (uint) ((int) maxObjects - 1 << this.m_GroupShift);
|
||||
this.m_ObjectMask = this.m_MaxObjectsPerGroup - 1U;
|
||||
this.m_UniqueMask = (uint) ~((int) this.m_GroupMask | (int) this.m_ObjectMask);
|
||||
this.m_groups = new HandleGroup(GCHandleType.Normal, this.m_portOwner, maxObjects);
|
||||
}
|
||||
private RenderPort m_portOwner;
|
||||
private HandleGroup m_groups;
|
||||
private uint m_MaxObjectsPerGroup;
|
||||
private int m_GroupShift;
|
||||
private int m_UniqueShift;
|
||||
private uint m_GroupMask;
|
||||
private uint m_ObjectMask;
|
||||
private uint m_UniqueMask;
|
||||
|
||||
protected override void Dispose(bool inDispose)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!inDispose)
|
||||
return;
|
||||
foreach (HandleGroup group in this.m_groups)
|
||||
group?.Dispose();
|
||||
this.m_groups.Clear();
|
||||
this.m_groups = (HandleGroup) null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(inDispose);
|
||||
}
|
||||
}
|
||||
|
||||
public RENDERHANDLE Alloc(RENDERGROUP groupId, IRenderHandleOwner owner)
|
||||
{
|
||||
uint uint32 = RENDERGROUP.ToUInt32(groupId);
|
||||
HandleGroup group = this.m_groups[uint32] as HandleGroup;
|
||||
Debug2.Validate(group != null, typeof (ArgumentException), (object) "Group does not exist", (object) nameof (groupId));
|
||||
uint unique;
|
||||
uint num = group.Add(owner, out unique);
|
||||
return RENDERHANDLE.FromUInt32((uint) ((int) unique << this.m_UniqueShift | (int) uint32 << this.m_GroupShift) | num);
|
||||
}
|
||||
|
||||
public void AllocWithId(IRenderHandleOwner owner, RENDERHANDLE handle, bool fUpdateExisting)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, true, out unique, out group, out index);
|
||||
group.AddAtIndexWithKnownUniqueness(owner, index, unique, fUpdateExisting);
|
||||
}
|
||||
|
||||
public void Free(RENDERHANDLE handle)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index);
|
||||
group.Remove(index, unique);
|
||||
}
|
||||
|
||||
public IRenderHandleOwner GetOwner(RENDERHANDLE handle) => this.GetOwner(handle, false);
|
||||
|
||||
public IRenderHandleOwner GetOwner(RENDERHANDLE handle, bool fAllowInvalid)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index, fAllowInvalid);
|
||||
return group.Get(index, unique, fAllowInvalid);
|
||||
}
|
||||
|
||||
public void SetOwner(RENDERHANDLE handle, IRenderHandleOwner owner)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index);
|
||||
group.Set(index, unique, owner);
|
||||
}
|
||||
|
||||
public RENDERGROUP GetGroup(RENDERHANDLE handle) => RENDERGROUP.FromUInt32((RENDERHANDLE.ToUInt32(handle) & this.m_GroupMask) >> this.m_GroupShift);
|
||||
|
||||
public RENDERGROUP AllocGroup() => RENDERGROUP.FromUInt32(this.m_groups.Add((IRenderHandleOwner) this.CreateNewGroup()));
|
||||
|
||||
public void AllocGroupWithId(RENDERGROUP groupId)
|
||||
{
|
||||
uint uint32 = RENDERGROUP.ToUInt32(groupId);
|
||||
this.m_groups.AddAtIndex((IRenderHandleOwner) this.CreateNewGroup(), uint32);
|
||||
}
|
||||
|
||||
public void FreeGroup(RENDERGROUP groupId) => this.m_groups.Remove(RENDERGROUP.ToUInt32(groupId));
|
||||
|
||||
public void Validate(RENDERHANDLE handle)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index);
|
||||
Debug2.Validate((object) group.Get(index, unique) != null, typeof (ArgumentException), (object) "Must point to valid object", (object) nameof (handle));
|
||||
}
|
||||
|
||||
private HandleGroup CreateNewGroup() => new HandleGroup(GCHandleType.Weak, this.m_portOwner, true, this.m_MaxObjectsPerGroup);
|
||||
|
||||
private void MapHandle(
|
||||
RENDERHANDLE handle,
|
||||
bool fCreateGroup,
|
||||
out uint unique,
|
||||
out HandleGroup group,
|
||||
out uint index)
|
||||
{
|
||||
this.MapHandle(handle, fCreateGroup, out unique, out group, out index, false);
|
||||
}
|
||||
|
||||
private void MapHandle(
|
||||
RENDERHANDLE handle,
|
||||
bool fCreateGroup,
|
||||
out uint unique,
|
||||
out HandleGroup group,
|
||||
out uint index,
|
||||
bool fAllowInvalid)
|
||||
{
|
||||
uint uint32 = RENDERHANDLE.ToUInt32(handle);
|
||||
uint num1 = (uint32 & this.m_UniqueMask) >> this.m_UniqueShift;
|
||||
uint index1 = (uint32 & this.m_GroupMask) >> this.m_GroupShift;
|
||||
uint num2 = uint32 & this.m_ObjectMask;
|
||||
group = (HandleGroup) null;
|
||||
if (index1 <= this.m_groups.Count)
|
||||
group = this.m_groups[index1] as HandleGroup;
|
||||
if (group == null)
|
||||
{
|
||||
if (fCreateGroup)
|
||||
public HandleTable(RenderPort portOwner, MessageCookieLayout layout)
|
||||
{
|
||||
group = this.CreateNewGroup();
|
||||
this.m_groups.AddAtIndex((IRenderHandleOwner) group, index1);
|
||||
Debug2.Validate(portOwner != null, typeof(ArgumentNullException), nameof(portOwner));
|
||||
this.m_portOwner = portOwner;
|
||||
uint maxObjects = 1U << (int)layout.numberOfGroupBits;
|
||||
this.m_MaxObjectsPerGroup = 1U << (int)layout.numberOfObjectBits;
|
||||
this.m_GroupShift = (int)layout.numberOfObjectBits;
|
||||
this.m_UniqueShift = (int)layout.numberOfObjectBits + (int)layout.numberOfGroupBits;
|
||||
this.m_GroupMask = (uint)((int)maxObjects - 1 << this.m_GroupShift);
|
||||
this.m_ObjectMask = this.m_MaxObjectsPerGroup - 1U;
|
||||
this.m_UniqueMask = (uint)~((int)this.m_GroupMask | (int)this.m_ObjectMask);
|
||||
this.m_groups = new HandleGroup(GCHandleType.Normal, this.m_portOwner, maxObjects);
|
||||
}
|
||||
else
|
||||
Debug2.Throw(fAllowInvalid, "Group does not exist");
|
||||
}
|
||||
unique = num1;
|
||||
index = num2;
|
||||
}
|
||||
|
||||
int IComparer.Compare(object a, object b)
|
||||
{
|
||||
KeyValueEntry<string, uint> keyValueEntry1 = (KeyValueEntry<string, uint>) a;
|
||||
KeyValueEntry<string, uint> keyValueEntry2 = (KeyValueEntry<string, uint>) b;
|
||||
uint num1 = keyValueEntry1.Value;
|
||||
uint num2 = keyValueEntry2.Value;
|
||||
if (num1 > num2)
|
||||
return -1;
|
||||
return num1 < num2 ? 1 : string.Compare(keyValueEntry1.Key, keyValueEntry2.Key, StringComparison.Ordinal);
|
||||
}
|
||||
protected override void Dispose(bool inDispose)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!inDispose)
|
||||
return;
|
||||
foreach (HandleGroup group in this.m_groups)
|
||||
group?.Dispose();
|
||||
this.m_groups.Clear();
|
||||
this.m_groups = (HandleGroup)null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(inDispose);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Invariant() => Debug2.Validate(this.m_groups != null, typeof (InvalidOperationException), "HandleTable has no HandleGroups");
|
||||
}
|
||||
public RENDERHANDLE Alloc(RENDERGROUP groupId, IRenderHandleOwner owner)
|
||||
{
|
||||
uint uint32 = RENDERGROUP.ToUInt32(groupId);
|
||||
HandleGroup group = this.m_groups[uint32] as HandleGroup;
|
||||
Debug2.Validate(group != null, typeof(ArgumentException), (object)"Group does not exist", (object)nameof(groupId));
|
||||
uint unique;
|
||||
uint num = group.Add(owner, out unique);
|
||||
return RENDERHANDLE.FromUInt32((uint)((int)unique << this.m_UniqueShift | (int)uint32 << this.m_GroupShift) | num);
|
||||
}
|
||||
|
||||
public void AllocWithId(IRenderHandleOwner owner, RENDERHANDLE handle, bool fUpdateExisting)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, true, out unique, out group, out index);
|
||||
group.AddAtIndexWithKnownUniqueness(owner, index, unique, fUpdateExisting);
|
||||
}
|
||||
|
||||
public void Free(RENDERHANDLE handle)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index);
|
||||
group.Remove(index, unique);
|
||||
}
|
||||
|
||||
public IRenderHandleOwner GetOwner(RENDERHANDLE handle) => this.GetOwner(handle, false);
|
||||
|
||||
public IRenderHandleOwner GetOwner(RENDERHANDLE handle, bool fAllowInvalid)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index, fAllowInvalid);
|
||||
return group.Get(index, unique, fAllowInvalid);
|
||||
}
|
||||
|
||||
public void SetOwner(RENDERHANDLE handle, IRenderHandleOwner owner)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index);
|
||||
group.Set(index, unique, owner);
|
||||
}
|
||||
|
||||
public RENDERGROUP GetGroup(RENDERHANDLE handle) => RENDERGROUP.FromUInt32((RENDERHANDLE.ToUInt32(handle) & this.m_GroupMask) >> this.m_GroupShift);
|
||||
|
||||
public RENDERGROUP AllocGroup() => RENDERGROUP.FromUInt32(this.m_groups.Add((IRenderHandleOwner)this.CreateNewGroup()));
|
||||
|
||||
public void AllocGroupWithId(RENDERGROUP groupId)
|
||||
{
|
||||
uint uint32 = RENDERGROUP.ToUInt32(groupId);
|
||||
this.m_groups.AddAtIndex((IRenderHandleOwner)this.CreateNewGroup(), uint32);
|
||||
}
|
||||
|
||||
public void FreeGroup(RENDERGROUP groupId) => this.m_groups.Remove(RENDERGROUP.ToUInt32(groupId));
|
||||
|
||||
public void Validate(RENDERHANDLE handle)
|
||||
{
|
||||
uint unique;
|
||||
HandleGroup group;
|
||||
uint index;
|
||||
this.MapHandle(handle, false, out unique, out group, out index);
|
||||
Debug2.Validate((object)group.Get(index, unique) != null, typeof(ArgumentException), (object)"Must point to valid object", (object)nameof(handle));
|
||||
}
|
||||
|
||||
private HandleGroup CreateNewGroup() => new HandleGroup(GCHandleType.Weak, this.m_portOwner, true, this.m_MaxObjectsPerGroup);
|
||||
|
||||
private void MapHandle(
|
||||
RENDERHANDLE handle,
|
||||
bool fCreateGroup,
|
||||
out uint unique,
|
||||
out HandleGroup group,
|
||||
out uint index)
|
||||
{
|
||||
this.MapHandle(handle, fCreateGroup, out unique, out group, out index, false);
|
||||
}
|
||||
|
||||
private void MapHandle(
|
||||
RENDERHANDLE handle,
|
||||
bool fCreateGroup,
|
||||
out uint unique,
|
||||
out HandleGroup group,
|
||||
out uint index,
|
||||
bool fAllowInvalid)
|
||||
{
|
||||
uint uint32 = RENDERHANDLE.ToUInt32(handle);
|
||||
uint num1 = (uint32 & this.m_UniqueMask) >> this.m_UniqueShift;
|
||||
uint index1 = (uint32 & this.m_GroupMask) >> this.m_GroupShift;
|
||||
uint num2 = uint32 & this.m_ObjectMask;
|
||||
group = (HandleGroup)null;
|
||||
if (index1 <= this.m_groups.Count)
|
||||
group = this.m_groups[index1] as HandleGroup;
|
||||
if (group == null)
|
||||
{
|
||||
if (fCreateGroup)
|
||||
{
|
||||
group = this.CreateNewGroup();
|
||||
this.m_groups.AddAtIndex((IRenderHandleOwner)group, index1);
|
||||
}
|
||||
else
|
||||
Debug2.Throw(fAllowInvalid, "Group does not exist");
|
||||
}
|
||||
unique = num1;
|
||||
index = num2;
|
||||
}
|
||||
|
||||
int IComparer.Compare(object a, object b)
|
||||
{
|
||||
KeyValueEntry<string, uint> keyValueEntry1 = (KeyValueEntry<string, uint>)a;
|
||||
KeyValueEntry<string, uint> keyValueEntry2 = (KeyValueEntry<string, uint>)b;
|
||||
uint num1 = keyValueEntry1.Value;
|
||||
uint num2 = keyValueEntry2.Value;
|
||||
if (num1 > num2)
|
||||
return -1;
|
||||
return num1 < num2 ? 1 : string.Compare(keyValueEntry1.Key, keyValueEntry2.Key, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
protected override void Invariant() => Debug2.Validate(this.m_groups != null, typeof(InvalidOperationException), "HandleTable has no HandleGroups");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal interface IChannel
|
||||
{
|
||||
void Connect(ContextID idRemoteContext, RENDERHANDLE hBrokerClass, MessageCookieLayout layout);
|
||||
internal interface IChannel
|
||||
{
|
||||
void Connect(ContextID idRemoteContext, RENDERHANDLE hBrokerClass, MessageCookieLayout layout);
|
||||
|
||||
void Dispose();
|
||||
void Dispose();
|
||||
|
||||
bool IsConnected { get; }
|
||||
}
|
||||
bool IsConnected { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal interface IRenderHandleOwner
|
||||
{
|
||||
RENDERHANDLE RenderHandle { get; }
|
||||
internal interface IRenderHandleOwner
|
||||
{
|
||||
RENDERHANDLE RenderHandle { get; }
|
||||
|
||||
void OnDisconnect();
|
||||
}
|
||||
void OnDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,41 +9,41 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal class LocalChannel : RenderObject, IChannel
|
||||
{
|
||||
private IntPtr m_renderThread;
|
||||
|
||||
public LocalChannel(LocalConnectionInfo connectionInfo)
|
||||
internal class LocalChannel : RenderObject, IChannel
|
||||
{
|
||||
}
|
||||
private IntPtr m_renderThread;
|
||||
|
||||
public bool IsConnected => this.m_renderThread != IntPtr.Zero;
|
||||
public LocalChannel(LocalConnectionInfo connectionInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public void Connect(
|
||||
ContextID remoteContextId,
|
||||
RENDERHANDLE brokerClassHandle,
|
||||
MessageCookieLayout layout)
|
||||
{
|
||||
Debug2.Validate(remoteContextId != ContextID.NULL, typeof (ArgumentNullException), nameof (remoteContextId));
|
||||
EngineApi.IFC(EngineApi.SpRenderThreadInit(ref new EngineApi.InitArgs(layout, remoteContextId)
|
||||
{
|
||||
idObjectBrokerClass = brokerClassHandle
|
||||
}, out this.m_renderThread));
|
||||
}
|
||||
public bool IsConnected => this.m_renderThread != IntPtr.Zero;
|
||||
|
||||
protected override void Dispose(bool inDispose)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(this.m_renderThread != IntPtr.Zero))
|
||||
return;
|
||||
EngineApi.IFC(EngineApi.SpRenderThreadUninit(this.m_renderThread));
|
||||
this.m_renderThread = IntPtr.Zero;
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(inDispose);
|
||||
}
|
||||
public void Connect(
|
||||
ContextID remoteContextId,
|
||||
RENDERHANDLE brokerClassHandle,
|
||||
MessageCookieLayout layout)
|
||||
{
|
||||
Debug2.Validate(remoteContextId != ContextID.NULL, typeof(ArgumentNullException), nameof(remoteContextId));
|
||||
EngineApi.IFC(EngineApi.SpRenderThreadInit(ref new EngineApi.InitArgs(layout, remoteContextId)
|
||||
{
|
||||
idObjectBrokerClass = brokerClassHandle
|
||||
}, out this.m_renderThread));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool inDispose)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(this.m_renderThread != IntPtr.Zero))
|
||||
return;
|
||||
EngineApi.IFC(EngineApi.SpRenderThreadUninit(this.m_renderThread));
|
||||
this.m_renderThread = IntPtr.Zero;
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(inDispose);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[Serializable]
|
||||
internal sealed class LocalConnectionInfo : ConnectionInfo
|
||||
{
|
||||
}
|
||||
[Serializable]
|
||||
internal sealed class LocalConnectionInfo : ConnectionInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,166 +11,166 @@ using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal class MarshalHelper
|
||||
{
|
||||
private static RENDERHANDLE[] s_EmptyRenderHandleArray = new RENDERHANDLE[0];
|
||||
|
||||
public static unsafe void Decode(
|
||||
RenderPort port,
|
||||
Message* pmsg,
|
||||
BLOBREF refParam,
|
||||
out string param)
|
||||
internal class MarshalHelper
|
||||
{
|
||||
uint uint32 = BLOBREF.ToUInt32(refParam);
|
||||
uint num1 = uint32 & (uint) ushort.MaxValue;
|
||||
uint num2 = (uint32 & 4294901760U) >> 16;
|
||||
byte* numPtr = (byte*) ((IntPtr) pmsg + (int) num1);
|
||||
int length = (int) num2 - 2;
|
||||
byte[] numArray = new byte[length];
|
||||
Marshal.Copy(new IntPtr((void*) numPtr), numArray, 0, length);
|
||||
Encoding encoding = Encoding.Unicode;
|
||||
if (port.AlwaysBigEndian)
|
||||
encoding = Encoding.BigEndianUnicode;
|
||||
param = encoding.GetString(numArray);
|
||||
}
|
||||
private static RENDERHANDLE[] s_EmptyRenderHandleArray = new RENDERHANDLE[0];
|
||||
|
||||
public static unsafe void Decode(
|
||||
RenderPort port,
|
||||
Message* pmsgOuter,
|
||||
BLOBREF refMsgInner,
|
||||
out Message* pmsgInner)
|
||||
{
|
||||
byte* numPtr = (byte*) pmsgOuter;
|
||||
uint num = (uint) ushort.MaxValue & BLOBREF.ToUInt32(refMsgInner);
|
||||
pmsgInner = (Message*) (numPtr + (int) num);
|
||||
}
|
||||
|
||||
private static ushort[] ComputeByteOrderMap(Type targetType, bool fCompact)
|
||||
{
|
||||
ushort[] fieldMap = new ushort[10];
|
||||
MarshalHelper.ComputeByteOrderMapWorker(ref fieldMap, targetType, 0);
|
||||
if (fCompact)
|
||||
{
|
||||
int length = (int) fieldMap[0] + 1;
|
||||
if (fieldMap.Length > length)
|
||||
public static unsafe void Decode(
|
||||
RenderPort port,
|
||||
Message* pmsg,
|
||||
BLOBREF refParam,
|
||||
out string param)
|
||||
{
|
||||
ushort[] numArray = new ushort[length];
|
||||
Array.Copy((Array) fieldMap, (Array) numArray, length);
|
||||
fieldMap = numArray;
|
||||
uint uint32 = BLOBREF.ToUInt32(refParam);
|
||||
uint num1 = uint32 & (uint)ushort.MaxValue;
|
||||
uint num2 = (uint32 & 4294901760U) >> 16;
|
||||
byte* numPtr = (byte*)((IntPtr)pmsg + (int)num1);
|
||||
int length = (int)num2 - 2;
|
||||
byte[] numArray = new byte[length];
|
||||
Marshal.Copy(new IntPtr((void*)numPtr), numArray, 0, length);
|
||||
Encoding encoding = Encoding.Unicode;
|
||||
if (port.AlwaysBigEndian)
|
||||
encoding = Encoding.BigEndianUnicode;
|
||||
param = encoding.GetString(numArray);
|
||||
}
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
public static unsafe void SwapByteOrder(
|
||||
byte* pMem,
|
||||
ref ushort[] fieldMapByRef,
|
||||
Type type,
|
||||
int startOffset,
|
||||
int stopOffset)
|
||||
{
|
||||
if (fieldMapByRef == null)
|
||||
fieldMapByRef = MarshalHelper.ComputeByteOrderMap(type, true);
|
||||
ushort[] numArray = fieldMapByRef;
|
||||
if (stopOffset <= 0)
|
||||
stopOffset = int.MaxValue;
|
||||
int num1 = (int) numArray[0] + 1;
|
||||
for (int index1 = 1; index1 < num1; ++index1)
|
||||
{
|
||||
ushort num2 = numArray[index1];
|
||||
int num3 = (int) num2 >> 2;
|
||||
if (num3 >= startOffset)
|
||||
public static unsafe void Decode(
|
||||
RenderPort port,
|
||||
Message* pmsgOuter,
|
||||
BLOBREF refMsgInner,
|
||||
out Message* pmsgInner)
|
||||
{
|
||||
if (num3 >= stopOffset)
|
||||
break;
|
||||
int num4 = 1 << ((int) num2 & 3);
|
||||
byte* numPtr = pMem + num3;
|
||||
int num5 = num4 / 2;
|
||||
for (int index2 = 0; index2 < num5; ++index2)
|
||||
{
|
||||
int index3 = num4 - (index2 + 1);
|
||||
byte num6 = numPtr[index2];
|
||||
numPtr[index2] = numPtr[index3];
|
||||
numPtr[index3] = num6;
|
||||
}
|
||||
byte* numPtr = (byte*)pmsgOuter;
|
||||
uint num = (uint)ushort.MaxValue & BLOBREF.ToUInt32(refMsgInner);
|
||||
pmsgInner = (Message*)(numPtr + (int)num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static object MakeDumpable(string value) => (object) value;
|
||||
|
||||
public static object MakeDumpable(object value) => value;
|
||||
|
||||
public static unsafe object MakeDumpable(void* value) => (object) new IntPtr(value);
|
||||
|
||||
private static void ComputeByteOrderMapWorker(
|
||||
ref ushort[] fieldMap,
|
||||
Type targetType,
|
||||
int parentOffset)
|
||||
{
|
||||
if (targetType.IsPrimitive)
|
||||
return;
|
||||
int packingForType = MarshalHelper.GetPackingForType(targetType);
|
||||
int num1 = 0;
|
||||
foreach (FieldInfo field in targetType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
|
||||
{
|
||||
Type type = field.FieldType;
|
||||
if (type.IsEnum)
|
||||
type = Enum.GetUnderlyingType(type);
|
||||
int size = Marshal.SizeOf(type);
|
||||
int num2 = size;
|
||||
if (type.IsPrimitive)
|
||||
private static ushort[] ComputeByteOrderMap(Type targetType, bool fCompact)
|
||||
{
|
||||
if (num2 > packingForType)
|
||||
num2 = packingForType;
|
||||
ushort[] fieldMap = new ushort[10];
|
||||
MarshalHelper.ComputeByteOrderMapWorker(ref fieldMap, targetType, 0);
|
||||
if (fCompact)
|
||||
{
|
||||
int length = (int)fieldMap[0] + 1;
|
||||
if (fieldMap.Length > length)
|
||||
{
|
||||
ushort[] numArray = new ushort[length];
|
||||
Array.Copy((Array)fieldMap, (Array)numArray, length);
|
||||
fieldMap = numArray;
|
||||
}
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
else if (num2 > 4)
|
||||
num2 = 4;
|
||||
int num3 = num2 - 1;
|
||||
int num4 = num1 + num3 & ~num3;
|
||||
int num5 = num4 + parentOffset;
|
||||
if (type.IsPrimitive)
|
||||
MarshalHelper.AddByteOrderEntry(ref fieldMap, num5, size);
|
||||
else
|
||||
MarshalHelper.ComputeByteOrderMapWorker(ref fieldMap, type, num5);
|
||||
num1 = num4 + size;
|
||||
}
|
||||
|
||||
public static unsafe void SwapByteOrder(
|
||||
byte* pMem,
|
||||
ref ushort[] fieldMapByRef,
|
||||
Type type,
|
||||
int startOffset,
|
||||
int stopOffset)
|
||||
{
|
||||
if (fieldMapByRef == null)
|
||||
fieldMapByRef = MarshalHelper.ComputeByteOrderMap(type, true);
|
||||
ushort[] numArray = fieldMapByRef;
|
||||
if (stopOffset <= 0)
|
||||
stopOffset = int.MaxValue;
|
||||
int num1 = (int)numArray[0] + 1;
|
||||
for (int index1 = 1; index1 < num1; ++index1)
|
||||
{
|
||||
ushort num2 = numArray[index1];
|
||||
int num3 = (int)num2 >> 2;
|
||||
if (num3 >= startOffset)
|
||||
{
|
||||
if (num3 >= stopOffset)
|
||||
break;
|
||||
int num4 = 1 << ((int)num2 & 3);
|
||||
byte* numPtr = pMem + num3;
|
||||
int num5 = num4 / 2;
|
||||
for (int index2 = 0; index2 < num5; ++index2)
|
||||
{
|
||||
int index3 = num4 - (index2 + 1);
|
||||
byte num6 = numPtr[index2];
|
||||
numPtr[index2] = numPtr[index3];
|
||||
numPtr[index3] = num6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static object MakeDumpable(string value) => (object)value;
|
||||
|
||||
public static object MakeDumpable(object value) => value;
|
||||
|
||||
public static unsafe object MakeDumpable(void* value) => (object)new IntPtr(value);
|
||||
|
||||
private static void ComputeByteOrderMapWorker(
|
||||
ref ushort[] fieldMap,
|
||||
Type targetType,
|
||||
int parentOffset)
|
||||
{
|
||||
if (targetType.IsPrimitive)
|
||||
return;
|
||||
int packingForType = MarshalHelper.GetPackingForType(targetType);
|
||||
int num1 = 0;
|
||||
foreach (FieldInfo field in targetType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
|
||||
{
|
||||
Type type = field.FieldType;
|
||||
if (type.IsEnum)
|
||||
type = Enum.GetUnderlyingType(type);
|
||||
int size = Marshal.SizeOf(type);
|
||||
int num2 = size;
|
||||
if (type.IsPrimitive)
|
||||
{
|
||||
if (num2 > packingForType)
|
||||
num2 = packingForType;
|
||||
}
|
||||
else if (num2 > 4)
|
||||
num2 = 4;
|
||||
int num3 = num2 - 1;
|
||||
int num4 = num1 + num3 & ~num3;
|
||||
int num5 = num4 + parentOffset;
|
||||
if (type.IsPrimitive)
|
||||
MarshalHelper.AddByteOrderEntry(ref fieldMap, num5, size);
|
||||
else
|
||||
MarshalHelper.ComputeByteOrderMapWorker(ref fieldMap, type, num5);
|
||||
num1 = num4 + size;
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetPackingForType(Type t) => 8;
|
||||
|
||||
private static void AddByteOrderEntry(ref ushort[] fieldMap, int offset, int size)
|
||||
{
|
||||
ushort num;
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
return;
|
||||
case 2:
|
||||
num = (ushort)1;
|
||||
break;
|
||||
case 3:
|
||||
return;
|
||||
case 4:
|
||||
num = (ushort)2;
|
||||
break;
|
||||
case 8:
|
||||
num = (ushort)3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
int index = (int)fieldMap[0] + 1;
|
||||
if (index >= fieldMap.Length)
|
||||
{
|
||||
ushort[] numArray = new ushort[2 * fieldMap.Length];
|
||||
Array.Copy((Array)fieldMap, (Array)numArray, fieldMap.Length);
|
||||
fieldMap = numArray;
|
||||
}
|
||||
fieldMap[0] = (ushort)index;
|
||||
fieldMap[index] = (ushort)((uint)(offset << 2) | (uint)num);
|
||||
}
|
||||
|
||||
public static RENDERHANDLE[] CreateRenderHandleArray(int length) => length == 0 ? MarshalHelper.s_EmptyRenderHandleArray : new RENDERHANDLE[length];
|
||||
}
|
||||
|
||||
private static int GetPackingForType(Type t) => 8;
|
||||
|
||||
private static void AddByteOrderEntry(ref ushort[] fieldMap, int offset, int size)
|
||||
{
|
||||
ushort num;
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
return;
|
||||
case 2:
|
||||
num = (ushort) 1;
|
||||
break;
|
||||
case 3:
|
||||
return;
|
||||
case 4:
|
||||
num = (ushort) 2;
|
||||
break;
|
||||
case 8:
|
||||
num = (ushort) 3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
int index = (int) fieldMap[0] + 1;
|
||||
if (index >= fieldMap.Length)
|
||||
{
|
||||
ushort[] numArray = new ushort[2 * fieldMap.Length];
|
||||
Array.Copy((Array) fieldMap, (Array) numArray, fieldMap.Length);
|
||||
fieldMap = numArray;
|
||||
}
|
||||
fieldMap[0] = (ushort) index;
|
||||
fieldMap[index] = (ushort) ((uint) (offset << 2) | (uint) num);
|
||||
}
|
||||
|
||||
public static RENDERHANDLE[] CreateRenderHandleArray(int length) => length == 0 ? MarshalHelper.s_EmptyRenderHandleArray : new RENDERHANDLE[length];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,91 +9,91 @@ using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
internal static class Memory
|
||||
{
|
||||
public static unsafe bool IsOverlap(IntPtr pvA, int cbA, IntPtr pvB, int cbB)
|
||||
internal static class Memory
|
||||
{
|
||||
byte* pointer1 = (byte*) pvA.ToPointer();
|
||||
byte* pointer2 = (byte*) pvB.ToPointer();
|
||||
if (pointer1 >= pointer2 && pointer1 < pointer2 + cbB)
|
||||
return true;
|
||||
return pointer2 >= pointer1 && pointer2 < pointer1 + cbA;
|
||||
}
|
||||
public static unsafe bool IsOverlap(IntPtr pvA, int cbA, IntPtr pvB, int cbB)
|
||||
{
|
||||
byte* pointer1 = (byte*)pvA.ToPointer();
|
||||
byte* pointer2 = (byte*)pvB.ToPointer();
|
||||
if (pointer1 >= pointer2 && pointer1 < pointer2 + cbB)
|
||||
return true;
|
||||
return pointer2 >= pointer1 && pointer2 < pointer1 + cbA;
|
||||
}
|
||||
|
||||
public static unsafe void Zero(IntPtr pvDest, int cbZero)
|
||||
{
|
||||
uint* pointer = (uint*) pvDest.ToPointer();
|
||||
int num1 = cbZero / 4;
|
||||
int num2 = num1;
|
||||
while (num2-- > 0)
|
||||
*pointer++ = 0U;
|
||||
byte* numPtr = (byte*) pointer;
|
||||
int num3 = cbZero - num1 * 4;
|
||||
while (num3-- > 0)
|
||||
*numPtr++ = (byte) 0;
|
||||
}
|
||||
public static unsafe void Zero(IntPtr pvDest, int cbZero)
|
||||
{
|
||||
uint* pointer = (uint*)pvDest.ToPointer();
|
||||
int num1 = cbZero / 4;
|
||||
int num2 = num1;
|
||||
while (num2-- > 0)
|
||||
*pointer++ = 0U;
|
||||
byte* numPtr = (byte*)pointer;
|
||||
int num3 = cbZero - num1 * 4;
|
||||
while (num3-- > 0)
|
||||
*numPtr++ = (byte)0;
|
||||
}
|
||||
|
||||
public static unsafe void Copy(IntPtr pvDest, IntPtr pvSrc, int cbCopy)
|
||||
{
|
||||
uint* pointer1 = (uint*) pvDest.ToPointer();
|
||||
uint* pointer2 = (uint*) pvSrc.ToPointer();
|
||||
int num1 = cbCopy / 4;
|
||||
int num2 = num1;
|
||||
while (num2-- > 0)
|
||||
*pointer1++ = *pointer2++;
|
||||
byte* numPtr1 = (byte*) pointer1;
|
||||
byte* numPtr2 = (byte*) pointer2;
|
||||
int num3 = cbCopy - num1 * 4;
|
||||
while (num3-- > 0)
|
||||
*numPtr1++ = *numPtr2++;
|
||||
}
|
||||
public static unsafe void Copy(IntPtr pvDest, IntPtr pvSrc, int cbCopy)
|
||||
{
|
||||
uint* pointer1 = (uint*)pvDest.ToPointer();
|
||||
uint* pointer2 = (uint*)pvSrc.ToPointer();
|
||||
int num1 = cbCopy / 4;
|
||||
int num2 = num1;
|
||||
while (num2-- > 0)
|
||||
*pointer1++ = *pointer2++;
|
||||
byte* numPtr1 = (byte*)pointer1;
|
||||
byte* numPtr2 = (byte*)pointer2;
|
||||
int num3 = cbCopy - num1 * 4;
|
||||
while (num3-- > 0)
|
||||
*numPtr1++ = *numPtr2++;
|
||||
}
|
||||
|
||||
public static unsafe void ConvertEndian(
|
||||
IntPtr pvDest,
|
||||
IntPtr pvSrc,
|
||||
int cbConvert,
|
||||
int cUnitBits)
|
||||
{
|
||||
switch (cUnitBits)
|
||||
{
|
||||
case 8:
|
||||
break;
|
||||
case 16:
|
||||
uint* pointer1 = (uint*) pvDest.ToPointer();
|
||||
uint* pointer2 = (uint*) pvSrc.ToPointer();
|
||||
int num1 = cbConvert / 4;
|
||||
while (num1-- > 0)
|
||||
{
|
||||
uint num2 = *pointer2++;
|
||||
*pointer1++ = (uint) ((int) ((num2 & 4278190080U) >> 8) | ((int) num2 & 16711680) << 8 | (int) ((num2 & 65280U) >> 8) | ((int) num2 & (int) byte.MaxValue) << 8);
|
||||
}
|
||||
if (cbConvert % 4 == 0)
|
||||
break;
|
||||
ushort* numPtr1 = (ushort*) pointer1;
|
||||
ushort* numPtr2 = (ushort*) pointer1;
|
||||
ushort* numPtr3 = (ushort*) ((IntPtr) numPtr2 + new IntPtr(2));
|
||||
ushort num3 = *numPtr2;
|
||||
ushort* numPtr4 = numPtr1;
|
||||
ushort* numPtr5 = (ushort*) ((IntPtr) numPtr4 + new IntPtr(2));
|
||||
int num4 = (int) (ushort) (((int) num3 & 65280) >> 8 | ((int) num3 & (int) byte.MaxValue) << 8);
|
||||
*numPtr4 = (ushort) num4;
|
||||
break;
|
||||
case 32:
|
||||
uint* pointer3 = (uint*) pvDest.ToPointer();
|
||||
uint* pointer4 = (uint*) pvSrc.ToPointer();
|
||||
int num5 = cbConvert / 4;
|
||||
while (num5-- > 0)
|
||||
{
|
||||
uint num2 = *pointer4++;
|
||||
*pointer3++ = (uint) ((int) ((num2 & 4278190080U) >> 24) | (int) ((num2 & 16711680U) >> 8) | ((int) num2 & 65280) << 8 | ((int) num2 & (int) byte.MaxValue) << 24);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug2.Throw(false, "Unsupported data format");
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static unsafe void ConvertEndian(
|
||||
IntPtr pvDest,
|
||||
IntPtr pvSrc,
|
||||
int cbConvert,
|
||||
int cUnitBits)
|
||||
{
|
||||
switch (cUnitBits)
|
||||
{
|
||||
case 8:
|
||||
break;
|
||||
case 16:
|
||||
uint* pointer1 = (uint*)pvDest.ToPointer();
|
||||
uint* pointer2 = (uint*)pvSrc.ToPointer();
|
||||
int num1 = cbConvert / 4;
|
||||
while (num1-- > 0)
|
||||
{
|
||||
uint num2 = *pointer2++;
|
||||
*pointer1++ = (uint)((int)((num2 & 4278190080U) >> 8) | ((int)num2 & 16711680) << 8 | (int)((num2 & 65280U) >> 8) | ((int)num2 & (int)byte.MaxValue) << 8);
|
||||
}
|
||||
if (cbConvert % 4 == 0)
|
||||
break;
|
||||
ushort* numPtr1 = (ushort*)pointer1;
|
||||
ushort* numPtr2 = (ushort*)pointer1;
|
||||
ushort* numPtr3 = (ushort*)((IntPtr)numPtr2 + new IntPtr(2));
|
||||
ushort num3 = *numPtr2;
|
||||
ushort* numPtr4 = numPtr1;
|
||||
ushort* numPtr5 = (ushort*)((IntPtr)numPtr4 + new IntPtr(2));
|
||||
int num4 = (int)(ushort)(((int)num3 & 65280) >> 8 | ((int)num3 & (int)byte.MaxValue) << 8);
|
||||
*numPtr4 = (ushort)num4;
|
||||
break;
|
||||
case 32:
|
||||
uint* pointer3 = (uint*)pvDest.ToPointer();
|
||||
uint* pointer4 = (uint*)pvSrc.ToPointer();
|
||||
int num5 = cbConvert / 4;
|
||||
while (num5-- > 0)
|
||||
{
|
||||
uint num2 = *pointer4++;
|
||||
*pointer3++ = (uint)((int)((num2 & 4278190080U) >> 24) | (int)((num2 & 16711680U) >> 8) | ((int)num2 & 65280) << 8 | ((int)num2 & (int)byte.MaxValue) << 24);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug2.Throw(false, "Unsupported data format");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static uint ConvertEndian(uint src) => (uint) ((int) ((src & 4278190080U) >> 24) | (int) ((src & 16711680U) >> 8) | ((int) src & 65280) << 8 | ((int) src & (int) byte.MaxValue) << 24);
|
||||
}
|
||||
public static uint ConvertEndian(uint src) => (uint)((int)((src & 4278190080U) >> 24) | (int)((src & 16711680U) >> 8) | ((int)src & 65280) << 8 | ((int)src & (int)byte.MaxValue) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[ComVisible(false)]
|
||||
internal struct Message
|
||||
{
|
||||
public uint cbSize;
|
||||
public uint nMsg;
|
||||
public RENDERHANDLE idObjectSubject;
|
||||
}
|
||||
[ComVisible(false)]
|
||||
internal struct Message
|
||||
{
|
||||
public uint cbSize;
|
||||
public uint nMsg;
|
||||
public RENDERHANDLE idObjectSubject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[ComVisible(false)]
|
||||
internal struct MessageBatchEntry
|
||||
{
|
||||
public uint uOffsetNextEntry;
|
||||
}
|
||||
[ComVisible(false)]
|
||||
internal struct MessageBatchEntry
|
||||
{
|
||||
public uint uOffsetNextEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Iris.Render.Protocol
|
||||
{
|
||||
[ComVisible(false)]
|
||||
internal struct MessageBatchHeader
|
||||
{
|
||||
public RENDERHANDLE idPredicateBuffer;
|
||||
public uint uOffsetFirstEntry;
|
||||
}
|
||||
[ComVisible(false)]
|
||||
internal struct MessageBatchHeader
|
||||
{
|
||||
public RENDERHANDLE idPredicateBuffer;
|
||||
public uint uOffsetFirstEntry;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user