Modified UIX libs to allow use from UWP

This commit is contained in:
Yoshi Askharoun
2021-07-15 22:00:36 -05:00
parent dd63b8d273
commit c3d90fccbd
27 changed files with 326 additions and 173 deletions
@@ -11,5 +11,5 @@ namespace Microsoft.Iris.Render
public delegate void ContentNotifyHandler(
ContentNotification Notification,
IImage image,
IntPtr data);
byte[] data);
}
@@ -14,64 +14,77 @@ namespace Microsoft.Iris.Render.Extensions
[SuppressUnmanagedCodeSecurity]
public static class ExtensionsApi
{
private const string s_stExtensionsDll = "UIXRender.dll";
internal const ushort WAVE_FORMAT_PCM = 1;
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
internal static extern HRESULT SpBitmapLoadFile(
internal static HRESULT SpBitmapLoadFile(
string stFileName,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions,
BitmapOptions nOptions,
out HSpBitmap hBmp,
out ImageInformation info);
out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
internal static extern HRESULT SpBitmapLoadRaw(
internal static HRESULT SpBitmapLoadRaw(
Size sizeActualPxl,
int nStride,
SurfaceFormat nFormat,
IntPtr pvData,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions,
BitmapOptions nOptions,
out HSpBitmap hBmp,
out ImageInformation info);
out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
internal static extern HRESULT SpBitmapLoadResource(
internal static HRESULT SpBitmapLoadResource(
Win32Api.HINSTANCE hinst,
string stName,
int nType,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions,
BitmapOptions nOptions,
out HSpBitmap hBmp,
out ImageInformation info);
out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
internal static extern HRESULT SpBitmapLoadBuffer(
internal static HRESULT SpBitmapLoadBuffer(
IntPtr pvSrc,
uint cbSize,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions,
BitmapOptions nOptions,
out HSpBitmap hBmp,
out ImageInformation info);
out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
internal static extern HRESULT SpBitmapDelete(HSpBitmap hBmp);
internal static HRESULT SpBitmapDelete(HSpBitmap hBmp)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
internal static extern HRESULT SpSoundLoadBuffer(
internal static HRESULT SpSoundLoadBuffer(
IntPtr pBuffer,
int dwSize,
ExtensionsApi.SoundOptions options,
out ExtensionsApi.HSpSound hSound,
out ExtensionsApi.SoundInformation info);
SoundOptions options,
out HSpSound hSound,
out SoundInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
internal static extern HRESULT SpSoundDispose(
ExtensionsApi.HSpSound hSound,
ExtensionsApi.SoundInformation info);
internal static HRESULT SpSoundDispose(
HSpSound hSound,
SoundInformation info)
{
throw new NotImplementedException();
}
[System.Flags]
[Flags]
internal enum BitmapOptions
{
None = 0,
@@ -80,7 +93,7 @@ namespace Microsoft.Iris.Render.Extensions
Valid = Flip | Decode, // 0x00000003
}
[System.Flags]
[Flags]
internal enum SoundOptions
{
None = 0,
@@ -105,28 +118,28 @@ namespace Microsoft.Iris.Render.Extensions
[ComVisible(false)]
public struct SoundData
{
public IntPtr rgData;
public byte[] rgData;
}
[ComVisible(false)]
public struct SoundInformation
{
public ExtensionsApi.SoundHeader Header;
public ExtensionsApi.SoundData Data;
public static ExtensionsApi.SoundInformation NULL = new ExtensionsApi.SoundInformation();
public SoundHeader Header;
public SoundData Data;
public static SoundInformation NULL = new SoundInformation();
}
[ComVisible(false)]
public struct HSpSound
{
public IntPtr h;
public static readonly ExtensionsApi.HSpSound NULL = new ExtensionsApi.HSpSound();
public static readonly HSpSound NULL = new HSpSound();
public static bool operator ==(ExtensionsApi.HSpSound hA, ExtensionsApi.HSpSound hB) => hA.h == hB.h;
public static bool operator ==(HSpSound hA, HSpSound hB) => hA.h == hB.h;
public static bool operator !=(ExtensionsApi.HSpSound hA, ExtensionsApi.HSpSound hB) => hA.h != hB.h;
public static bool operator !=(HSpSound hA, HSpSound hB) => hA.h != hB.h;
public override bool Equals(object oCompare) => oCompare is ExtensionsApi.HSpSound hspSound && this.h == hspSound.h;
public override bool Equals(object oCompare) => oCompare is HSpSound hspSound && this.h == hspSound.h;
public override int GetHashCode() => (int)this.h.ToInt64();
}
@@ -9,16 +9,9 @@ using System.Runtime.InteropServices;
namespace Microsoft.Iris.Render.Extensions
{
public class GradientInformation : IDisposable
public class GradientInformation
{
public ImageInformation imageInfo;
internal GCHandle gcData;
void IDisposable.Dispose()
{
if (!this.gcData.IsAllocated)
return;
this.gcData.Free();
}
internal byte[] Data;
}
}
@@ -164,7 +164,7 @@ namespace Microsoft.Iris.Render.Extensions
protected void SetSize(Size size) => this.m_size = size;
internal void ReloadImage(ContentNotification notification, IImage image, IntPtr data)
internal void ReloadImage(ContentNotification notification, IImage image, byte[] data)
{
switch (notification)
{
@@ -12,6 +12,6 @@ namespace Microsoft.Iris.Render.Extensions
[ComVisible(false)]
public struct ImageData
{
public IntPtr rgData;
public byte[] rgData;
}
}
@@ -285,16 +285,16 @@ namespace Microsoft.Iris.Render.Extensions
GradientInformation gradientInformation = new GradientInformation()
{
imageInfo = {
Header = {
sizeActualPxl = sizeImage,
sizeOriginalPxl = sizeImage,
nStride = num2,
nFormat = nFormat
}
},
gcData = GCHandle.Alloc(numArray, GCHandleType.Pinned)
Header = {
sizeActualPxl = sizeImage,
sizeOriginalPxl = sizeImage,
nStride = num2,
nFormat = nFormat
}
},
Data = numArray
};
gradientInformation.imageInfo.Data.rgData = gradientInformation.gcData.AddrOfPinnedObject();
gradientInformation.imageInfo.Data.rgData = gradientInformation.Data;
bool flag = image.LoadContent(SurfaceFormatInfo.ToImageFormat(gradientInformation.imageInfo.Header.nFormat), gradientInformation.imageInfo.Header.sizeActualPxl, gradientInformation.imageInfo.Header.nStride, gradientInformation.imageInfo.Data.rgData);
if (flag)
{
@@ -54,7 +54,7 @@ namespace Microsoft.Iris.Render.Extensions
uint ISoundData.SampleCount => (uint)(m_soundInfo.Header.cbDataSize / (ulong)(m_soundInfo.Header.wBitsPerSample / 8));
IntPtr ISoundData.AcquireContent()
byte[] ISoundData.AcquireContent()
{
++this.m_usageCount;
return this.m_soundInfo.Data.rgData;
@@ -69,7 +69,7 @@ namespace Microsoft.Iris.Render.Extensions
ExtensionsApi.HSpSound soundDataHandle;
ExtensionsApi.SoundInformation soundDataInfo;
SoundLoader.FromResource(this.m_moduleName, this.m_resourceId, out soundDataHandle, out soundDataInfo);
Debug2.Validate(soundDataInfo.Data.rgData != IntPtr.Zero, typeof(InvalidOperationException), "Failed to load data and no exception was thrown");
Debug2.Validate(soundDataInfo.Data.rgData != null, typeof(InvalidOperationException), "Failed to load data and no exception was thrown");
Debug2.Validate(soundDataInfo.Header.wFormatTag == 1, typeof(ArgumentException), "Only PCM sound data is currently supported");
Debug2.Validate(soundDataInfo.Header.nChannels >= 1 && soundDataInfo.Header.nChannels <= 2, typeof(ArgumentException), "Only mono/stereo sound data is currently supported");
Debug2.Validate(soundDataInfo.Header.wBitsPerSample == 8 || soundDataInfo.Header.wBitsPerSample == 16, typeof(ArgumentException), "Only 8bps/16bps sound data is currently supported");
@@ -10,7 +10,7 @@ namespace Microsoft.Iris.Render.Graphics
{
internal class DataBufferCleanupInfo
{
public IntPtr rgConvertData;
public byte[] rgConvertData;
public ImageLoadInfo imageLoadInfo;
}
}
@@ -93,7 +93,8 @@ namespace Microsoft.Iris.Render.Graphics
++index;
}
}
this.RemoteEffect(effectBuilder, pEffectBlob, pBlobBuffer, nBlobSize);
// TODO: Re-implement
//this.RemoteEffect(effectBuilder, pEffectBlob.ToPointer(), pBlobBuffer, nBlobSize);
return true;
}
@@ -129,7 +130,7 @@ namespace Microsoft.Iris.Render.Graphics
private void RemoteEffect(
Dx9EffectBuilder effectBuilder,
IntPtr pEffectBlob,
byte[] pEffectBlob,
IntPtr pBlobBuffer,
uint nBlobSize)
{
@@ -107,7 +107,7 @@ namespace Microsoft.Iris.Render.Graphics
ImageFormat imageFormat,
Size sizeImage,
int nStride,
IntPtr rgData)
byte[] rgData)
{
this.m_session.AssertOwningThread();
bool flag1 = false;
@@ -131,18 +131,20 @@ namespace Microsoft.Iris.Render.Graphics
if (this.InUse)
this.m_surface.AddActiveUser(this);
}
IntPtr num1 = IntPtr.Zero;
byte[] num1 = null;
if (this.m_session.IsForeignByteOrderOnWindowing)
{
int bitsPerPixel = SurfaceFormatInfo.GetBitsPerPixel(nFormat);
int num2 = sizeImage.Height * nStride;
num1 = Marshal.AllocHGlobal(num2);
Memory.ConvertEndian(num1, rgData, num2, bitsPerPixel);
num1 = new byte[num2];
// TODO: Does this need to be re-implemented?
throw new NotImplementedException();
//Memory.ConvertEndian(num1, rgData, num2, bitsPerPixel);
}
this.m_imageFormat = imageFormat;
this.m_sizeImage = sizeImage;
uint cbSize = (uint)(nStride * this.m_sizeImage.Height);
buffer = this.m_session.BuildDataBuffer(num1 == IntPtr.Zero ? rgData : num1, cbSize);
buffer = this.m_session.BuildDataBuffer(num1 == null ? rgData : num1, cbSize);
this.Track(buffer, num1, rgData, nStride);
buffer.Commit();
++this.m_loadInfo.nLoadsInProgress;
@@ -182,7 +184,7 @@ namespace Microsoft.Iris.Render.Graphics
((IImage)this).LoadContent(this.m_imageFormat, this.m_sizeImage, this.m_loadInfo.nStride, this.m_loadInfo.rgAppData);
}
else
this.m_handlerContent(ContentNotification.Acquire, this, IntPtr.Zero);
this.m_handlerContent(ContentNotification.Acquire, this, null);
}
Surface surface = this.m_surface;
}
@@ -204,7 +206,7 @@ namespace Microsoft.Iris.Render.Graphics
}
}
private void Track(DataBuffer buffer, IntPtr rgConvertData, IntPtr rgAppData, int nStride)
private void Track(DataBuffer buffer, byte[] rgConvertData, byte[] rgAppData, int nStride)
{
ImageLoadInfo imageLoadInfo;
if (this.m_loadInfo != null && this.m_loadInfo.rgAppData == rgAppData && this.m_loadInfo.nStride == nStride)
@@ -259,14 +261,13 @@ namespace Microsoft.Iris.Render.Graphics
imageLoadInfo.handlerNotify(ContentNotification.Release, imageLoadInfo.imageOwner, imageLoadInfo.rgAppData);
imageLoadInfo.imageOwner.m_insideReleaseCallback = false;
}
imageLoadInfo.rgAppData = IntPtr.Zero;
imageLoadInfo.rgAppData = null;
imageLoadInfo.handlerNotify = null;
imageLoadInfo.imageOwner = null;
}
if (!(contextData.rgConvertData != IntPtr.Zero))
if (!(contextData.rgConvertData != null))
return;
Marshal.FreeHGlobal(contextData.rgConvertData);
contextData.rgConvertData = IntPtr.Zero;
contextData.rgConvertData = null;
}
internal delegate void ContentReloadedHandler(Image image);
@@ -11,7 +11,7 @@ namespace Microsoft.Iris.Render.Graphics
internal class ImageLoadInfo
{
public Image imageOwner;
public IntPtr rgAppData;
public byte[] rgAppData;
public int nStride;
public int nLoadsInProgress;
public int nSystemLoadRequests;
@@ -16,6 +16,6 @@ namespace Microsoft.Iris.Render
string Identifier { get; }
bool LoadContent(ImageFormat format, Size size, int Stride, IntPtr Data);
bool LoadContent(ImageFormat format, Size size, int Stride, byte[] Data);
}
}
@@ -20,7 +20,7 @@ namespace Microsoft.Iris.Render
uint SampleCount { get; }
IntPtr AcquireContent();
byte[] AcquireContent();
void ReleaseContent();
}
@@ -4,18 +4,21 @@
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.Render.Internal
{
internal static class FormApi
{
private const string s_stEhRenderDll = "UIXRender.dll";
public static HRESULT SpGdiplusInit()
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpGdiplusInit();
[DllImport("UIXRender.dll")]
public static extern HRESULT SpGdiplusUninit();
public static HRESULT SpGdiplusUninit()
{
throw new NotImplementedException();
}
}
}
@@ -34,5 +34,8 @@ namespace Microsoft.Iris.Render.Internal
}
public int Int => this.hr;
public static implicit operator HRESULT(int i) => new(i);
public static implicit operator int(HRESULT hr) => hr.Int;
}
}
@@ -292,7 +292,7 @@ namespace Microsoft.Iris.Render.Internal
return fUseSplitWindowingPort ? this.LocalRenderingProtocol.BuildRemoteNullDevice(device, this.LocalRenderingProtocol.LocalDeviceCallbackHandle) : this.RenderingProtocol.BuildRemoteNullDevice(device, this.RenderingProtocol.LocalDeviceCallbackHandle);
}
internal unsafe DataBuffer BuildDataBuffer(IntPtr pData, uint cbSize) => new DataBuffer(this.RenderingPort, pData.ToPointer(), cbSize);
internal unsafe DataBuffer BuildDataBuffer(byte[] pData, uint cbSize) => new DataBuffer(this.RenderingPort, pData, cbSize);
internal void LoadSurface(DataBuffer buffer, Surface surface, ImageHeader header) => RemoteRasterizer.SendLoadRawImage(this.RenderingProtocol, surface.RemoteStub, buffer.RemoteStub, header);
@@ -13,10 +13,10 @@ namespace Microsoft.Iris.Render.Protocol
{
private RenderPort m_port;
private RemoteDataBuffer m_remoteBuffer;
private unsafe void* m_pvData;
private byte[] m_pvData;
private uint m_cbSize;
public unsafe DataBuffer(RenderPort port, void* pvData, uint cbSize)
public unsafe DataBuffer(RenderPort port, byte[] pvData, uint cbSize)
{
this.m_port = port;
this.m_remoteBuffer = null;
@@ -44,7 +44,7 @@ namespace Microsoft.Iris.Render.Protocol
public uint DataSize => this.m_cbSize;
public unsafe void* Data => this.m_pvData;
public byte[] Data => this.m_pvData;
public RemoteDataBuffer RemoteStub => this.m_remoteBuffer;
@@ -10,14 +10,13 @@ using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
namespace Microsoft.Iris.Render.Protocol
{
[SuppressUnmanagedCodeSecurity]
internal static class EngineApi
{
private const string s_stEhRenderDll = "UIXRender.dll";
public static void IFC(HRESULT hr)
{
if (hr.Int >= 0)
@@ -102,89 +101,127 @@ namespace Microsoft.Iris.Render.Protocol
}
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpInit(ref EngineApi.InitArgs args);
public static HRESULT SpInit(ref InitArgs args)
{
return 0;
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpUninit();
public static HRESULT SpUninit()
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern unsafe HRESULT SpBufferOpen(
EngineApi.BufferInfo* phdrData,
void* pvData);
public static unsafe HRESULT SpBufferOpen(
BufferInfo* phdrData,
void* pvData)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern unsafe HRESULT SpWrapBufferProc(
EngineApi.MessageBufferEventHandler pfnProcessBufferProc,
IntPtr* ppNativeProc);
public static unsafe HRESULT SpWrapBufferProc(
MessageBufferEventHandler pfnProcessBufferProc,
IntPtr* ppNativeProc)
{
*ppNativeProc = Marshal.GetFunctionPointerForDelegate(pfnProcessBufferProc);
return 0;
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)]
public static extern HRESULT SpPeekMessage(
public static HRESULT SpPeekMessage(
out Win32Api.MSG msg,
HWND hwnd,
uint nMsgFilterMin,
uint nMsgFilterMax,
uint wRemoveMsg,
out EngineApi.WorkResult nResult);
out WorkResult nResult)
{
nResult = WorkResult.ProcessedMessage;
msg = new Win32Api.MSG
{
message = 1
};
return 0;
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpWaitMessage(uint nTimeOutMs, IntPtr _unused);
public static HRESULT SpWaitMessage(uint nTimeOutMs, IntPtr _unused)
{
return 0;
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpInvoke(
public static HRESULT SpInvoke(
ContextID idContext,
IntPtr pfnInvoke,
IntPtr pvArgs,
bool synchronous);
bool synchronous)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpRenderThreadInit(
ref EngineApi.InitArgs argsRender,
out IntPtr pThread);
public static HRESULT SpRenderThreadInit(
ref InitArgs argsRender,
out Thread pThread)
{
pThread = new Thread(new ThreadStart(() => Console.WriteLine("nan")));
pThread.Start();
return 0;
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpRenderThreadUninit(IntPtr pThread);
public static HRESULT SpRenderThreadUninit(Thread pThread)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Unicode)]
public static extern HRESULT SpRemoteCreateServerStreams(
public static HRESULT SpRemoteCreateServerStreams(
string stSession,
TransportProtocol nProtocol,
out IntPtr pSendStream,
out IntPtr pReceiveStream);
out IntPtr pReceiveStream)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpRemoteWaitServerStreamsConnected(
public static HRESULT SpRemoteWaitServerStreamsConnected(
TransportProtocol nProtocol,
IntPtr pSendStream,
IntPtr pReceiveStream);
IntPtr pReceiveStream)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpRemoteServerInit(
public static HRESULT SpRemoteServerInit(
IntPtr pSendStream,
IntPtr pReceiveStream,
EngineApi.InitArgs argsSend,
out IntPtr pSession);
InitArgs argsSend,
out IntPtr pSession)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern HRESULT SpRemoteServerUninit(
public static HRESULT SpRemoteServerUninit(
IntPtr pSession,
bool fForceShutdown,
out ShutdownReason nShutdownReason);
out ShutdownReason nShutdownReason)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Ansi)]
public static extern HRESULT SpDx9CompileEffect(
public static HRESULT SpDx9CompileEffect(
string stEffect,
string stDefines,
out IntPtr pErrorString,
out IntPtr pErrorBuffer,
out IntPtr pEffectBlob,
out uint EffectBlobSize,
out IntPtr pEffectBlobBuffer);
out IntPtr pEffectBlobBuffer)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")]
public static extern void SpObjectRelease(IntPtr pUnknown);
public static void SpObjectRelease(IntPtr pUnknown)
{
throw new NotImplementedException();
}
[System.Flags]
[Flags]
public enum BufferFlags
{
IsBatch = 1,
@@ -195,11 +232,11 @@ namespace Microsoft.Iris.Render.Protocol
[ComVisible(false)]
public struct BufferInfo
{
public ContextID idContextSrc;
public ContextID idContextDest;
public RENDERHANDLE idBuffer;
public EngineApi.BufferFlags nFlags;
public uint cbSizeBuffer;
public ContextID idContextSrc; // 0x00
public ContextID idContextDest; // 0x04
public RENDERHANDLE idBuffer; // 0x08
public BufferFlags nFlags; // 0x0C
public uint cbSizeBuffer; // 0x10
}
internal delegate void TimeoutEventHandler(IntPtr pData);
@@ -207,21 +244,21 @@ namespace Microsoft.Iris.Render.Protocol
[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 uint cbSize; // 0x00
public ContextID idContext; // 0x04
public int cItemsPerGroupBits; // 0x08
public int cGroupBits; // 0x0C
public IntPtr pfnProcessBuffer; // 0x10
public IntPtr pvProcessData; // 0x14
public RENDERHANDLE idObjectBrokerClass; // 0x18
public TimeoutEventHandler pfnTimeout; // 0x1C
public IntPtr pvTimeoutData; // 0x24
public uint nTimeOutSec; // 0x28
public InitArgs(MessageCookieLayout layout, ContextID idContextNew)
{
Debug2.Validate(idContextNew != ContextID.NULL, typeof(ArgumentNullException), nameof(idContextNew));
this.cbSize = (uint)Marshal.SizeOf(typeof(EngineApi.InitArgs));
this.cbSize = (uint)Marshal.SizeOf(typeof(InitArgs));
this.idContext = idContextNew;
this.cItemsPerGroupBits = layout.numberOfObjectBits;
this.cGroupBits = layout.numberOfGroupBits;
@@ -236,7 +273,7 @@ namespace Microsoft.Iris.Render.Protocol
public unsafe InitArgs(
MessageCookieLayout layout,
ContextID idContextNew,
EngineApi.MessageBufferEventHandler pfnProcessBufferProc)
MessageBufferEventHandler pfnProcessBufferProc)
: this(layout, idContextNew)
{
if (pfnProcessBufferProc == null)
@@ -250,10 +287,10 @@ namespace Microsoft.Iris.Render.Protocol
internal unsafe delegate int MessageBufferEventHandler(
IntPtr pData,
uint hContext,
EngineApi.BufferInfo* pBufferInfo,
BufferInfo* pBufferInfo,
void* pvBufferData);
[System.Flags]
[Flags]
public enum WorkResult : uint
{
ProcessedMessage = 1,
@@ -6,18 +6,19 @@
using Microsoft.Iris.Render.Common;
using System;
using System.Threading;
namespace Microsoft.Iris.Render.Protocol
{
internal class LocalChannel : RenderObject, IChannel
{
private IntPtr m_renderThread;
private Thread m_renderThread;
public LocalChannel(LocalConnectionInfo connectionInfo)
{
}
public bool IsConnected => this.m_renderThread != IntPtr.Zero;
public bool IsConnected => m_renderThread != null;
public void Connect(
ContextID remoteContextId,
@@ -29,17 +30,17 @@ namespace Microsoft.Iris.Render.Protocol
{
idObjectBrokerClass = brokerClassHandle
};
EngineApi.IFC(EngineApi.SpRenderThreadInit(ref args, out this.m_renderThread));
EngineApi.IFC(EngineApi.SpRenderThreadInit(ref args, out m_renderThread));
}
protected override void Dispose(bool inDispose)
{
try
{
if (!(this.m_renderThread != IntPtr.Zero))
if (m_renderThread == null)
return;
EngineApi.IFC(EngineApi.SpRenderThreadUninit(this.m_renderThread));
this.m_renderThread = IntPtr.Zero;
EngineApi.IFC(EngineApi.SpRenderThreadUninit(m_renderThread));
m_renderThread = null;
}
finally
{
@@ -94,6 +94,60 @@ namespace Microsoft.Iris.Render.Protocol
}
}
public static unsafe void ConvertEndian(
uint[] pvDest,
uint[] pvSrc,
int cbConvert,
int cUnitBits)
{
switch (cUnitBits)
{
case 8:
break;
case 16:
int count16 = cbConvert / 4;
int i16 = 0;
while (count16-- > 0)
{
i16++;
uint valSrc = pvSrc[i16];
pvDest[i16] = (uint)((int)((valSrc & 4278190080U) >> 8) | ((int)valSrc & 16711680) << 8 | (int)((valSrc & 65280U) >> 8) | ((int)valSrc & byte.MaxValue) << 8);
}
if (cbConvert % 4 == 0)
break;
// Convert uint to ushort array
ushort[] destUInt16 = new ushort[pvSrc.Length * (sizeof(uint) / sizeof(ushort))];
ushort lastVal = (ushort)pvDest[i16];
int lastValConv = (ushort)((lastVal & 65280) >> 8 | (lastVal & byte.MaxValue) << 8);
pvDest[i16] = (ushort)lastValConv;
break;
case 32:
int count32 = cbConvert / 4;
int i32 = 0;
while (count32-- > 0)
{
i32++;
pvDest[i32] = ConvertEndian(pvSrc[i32]);
}
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 & byte.MaxValue) << 24);
public static uint[] ReinterpretAsUInt16(byte[] src)
{
uint[] dest = new uint[src.Length * (sizeof(uint) / sizeof(byte))];
for (int s = 0; s < src.Length; s++)
{
}
return dest;
}
}
}

Some files were not shown because too many files have changed in this diff Show More