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( public delegate void ContentNotifyHandler(
ContentNotification Notification, ContentNotification Notification,
IImage image, IImage image,
IntPtr data); byte[] data);
} }
@@ -14,64 +14,77 @@ namespace Microsoft.Iris.Render.Extensions
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
public static class ExtensionsApi public static class ExtensionsApi
{ {
private const string s_stExtensionsDll = "UIXRender.dll";
internal const ushort WAVE_FORMAT_PCM = 1; internal const ushort WAVE_FORMAT_PCM = 1;
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)] internal static HRESULT SpBitmapLoadFile(
internal static extern HRESULT SpBitmapLoadFile(
string stFileName, string stFileName,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req, [MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions, BitmapOptions nOptions,
out HSpBitmap hBmp, out HSpBitmap hBmp,
out ImageInformation info); out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)] internal static HRESULT SpBitmapLoadRaw(
internal static extern HRESULT SpBitmapLoadRaw(
Size sizeActualPxl, Size sizeActualPxl,
int nStride, int nStride,
SurfaceFormat nFormat, SurfaceFormat nFormat,
IntPtr pvData, IntPtr pvData,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req, [MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions, BitmapOptions nOptions,
out HSpBitmap hBmp, out HSpBitmap hBmp,
out ImageInformation info); out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)] internal static HRESULT SpBitmapLoadResource(
internal static extern HRESULT SpBitmapLoadResource(
Win32Api.HINSTANCE hinst, Win32Api.HINSTANCE hinst,
string stName, string stName,
int nType, int nType,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req, [MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions, BitmapOptions nOptions,
out HSpBitmap hBmp, out HSpBitmap hBmp,
out ImageInformation info); out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)] internal static HRESULT SpBitmapLoadBuffer(
internal static extern HRESULT SpBitmapLoadBuffer(
IntPtr pvSrc, IntPtr pvSrc,
uint cbSize, uint cbSize,
[MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req, [MarshalAs(UnmanagedType.LPStruct), In] ImageRequirements req,
ExtensionsApi.BitmapOptions nOptions, BitmapOptions nOptions,
out HSpBitmap hBmp, out HSpBitmap hBmp,
out ImageInformation info); out ImageInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] internal static HRESULT SpBitmapDelete(HSpBitmap hBmp)
internal static extern HRESULT SpBitmapDelete(HSpBitmap hBmp); {
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)] internal static HRESULT SpSoundLoadBuffer(
internal static extern HRESULT SpSoundLoadBuffer(
IntPtr pBuffer, IntPtr pBuffer,
int dwSize, int dwSize,
ExtensionsApi.SoundOptions options, SoundOptions options,
out ExtensionsApi.HSpSound hSound, out HSpSound hSound,
out ExtensionsApi.SoundInformation info); out SoundInformation info)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] internal static HRESULT SpSoundDispose(
internal static extern HRESULT SpSoundDispose( HSpSound hSound,
ExtensionsApi.HSpSound hSound, SoundInformation info)
ExtensionsApi.SoundInformation info); {
throw new NotImplementedException();
}
[System.Flags] [Flags]
internal enum BitmapOptions internal enum BitmapOptions
{ {
None = 0, None = 0,
@@ -80,7 +93,7 @@ namespace Microsoft.Iris.Render.Extensions
Valid = Flip | Decode, // 0x00000003 Valid = Flip | Decode, // 0x00000003
} }
[System.Flags] [Flags]
internal enum SoundOptions internal enum SoundOptions
{ {
None = 0, None = 0,
@@ -105,28 +118,28 @@ namespace Microsoft.Iris.Render.Extensions
[ComVisible(false)] [ComVisible(false)]
public struct SoundData public struct SoundData
{ {
public IntPtr rgData; public byte[] rgData;
} }
[ComVisible(false)] [ComVisible(false)]
public struct SoundInformation public struct SoundInformation
{ {
public ExtensionsApi.SoundHeader Header; public SoundHeader Header;
public ExtensionsApi.SoundData Data; public SoundData Data;
public static ExtensionsApi.SoundInformation NULL = new ExtensionsApi.SoundInformation(); public static SoundInformation NULL = new SoundInformation();
} }
[ComVisible(false)] [ComVisible(false)]
public struct HSpSound public struct HSpSound
{ {
public IntPtr h; 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(); public override int GetHashCode() => (int)this.h.ToInt64();
} }
@@ -9,16 +9,9 @@ using System.Runtime.InteropServices;
namespace Microsoft.Iris.Render.Extensions namespace Microsoft.Iris.Render.Extensions
{ {
public class GradientInformation : IDisposable public class GradientInformation
{ {
public ImageInformation imageInfo; public ImageInformation imageInfo;
internal GCHandle gcData; internal byte[] Data;
void IDisposable.Dispose()
{
if (!this.gcData.IsAllocated)
return;
this.gcData.Free();
}
} }
} }
@@ -164,7 +164,7 @@ namespace Microsoft.Iris.Render.Extensions
protected void SetSize(Size size) => this.m_size = size; 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) switch (notification)
{ {
@@ -12,6 +12,6 @@ namespace Microsoft.Iris.Render.Extensions
[ComVisible(false)] [ComVisible(false)]
public struct ImageData public struct ImageData
{ {
public IntPtr rgData; public byte[] rgData;
} }
} }
@@ -285,16 +285,16 @@ namespace Microsoft.Iris.Render.Extensions
GradientInformation gradientInformation = new GradientInformation() GradientInformation gradientInformation = new GradientInformation()
{ {
imageInfo = { imageInfo = {
Header = { Header = {
sizeActualPxl = sizeImage, sizeActualPxl = sizeImage,
sizeOriginalPxl = sizeImage, sizeOriginalPxl = sizeImage,
nStride = num2, nStride = num2,
nFormat = nFormat nFormat = nFormat
} }
}, },
gcData = GCHandle.Alloc(numArray, GCHandleType.Pinned) 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); bool flag = image.LoadContent(SurfaceFormatInfo.ToImageFormat(gradientInformation.imageInfo.Header.nFormat), gradientInformation.imageInfo.Header.sizeActualPxl, gradientInformation.imageInfo.Header.nStride, gradientInformation.imageInfo.Data.rgData);
if (flag) 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)); uint ISoundData.SampleCount => (uint)(m_soundInfo.Header.cbDataSize / (ulong)(m_soundInfo.Header.wBitsPerSample / 8));
IntPtr ISoundData.AcquireContent() byte[] ISoundData.AcquireContent()
{ {
++this.m_usageCount; ++this.m_usageCount;
return this.m_soundInfo.Data.rgData; return this.m_soundInfo.Data.rgData;
@@ -69,7 +69,7 @@ namespace Microsoft.Iris.Render.Extensions
ExtensionsApi.HSpSound soundDataHandle; ExtensionsApi.HSpSound soundDataHandle;
ExtensionsApi.SoundInformation soundDataInfo; ExtensionsApi.SoundInformation soundDataInfo;
SoundLoader.FromResource(this.m_moduleName, this.m_resourceId, out soundDataHandle, out 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.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.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"); 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 internal class DataBufferCleanupInfo
{ {
public IntPtr rgConvertData; public byte[] rgConvertData;
public ImageLoadInfo imageLoadInfo; public ImageLoadInfo imageLoadInfo;
} }
} }
@@ -93,7 +93,8 @@ namespace Microsoft.Iris.Render.Graphics
++index; ++index;
} }
} }
this.RemoteEffect(effectBuilder, pEffectBlob, pBlobBuffer, nBlobSize); // TODO: Re-implement
//this.RemoteEffect(effectBuilder, pEffectBlob.ToPointer(), pBlobBuffer, nBlobSize);
return true; return true;
} }
@@ -129,7 +130,7 @@ namespace Microsoft.Iris.Render.Graphics
private void RemoteEffect( private void RemoteEffect(
Dx9EffectBuilder effectBuilder, Dx9EffectBuilder effectBuilder,
IntPtr pEffectBlob, byte[] pEffectBlob,
IntPtr pBlobBuffer, IntPtr pBlobBuffer,
uint nBlobSize) uint nBlobSize)
{ {
@@ -107,7 +107,7 @@ namespace Microsoft.Iris.Render.Graphics
ImageFormat imageFormat, ImageFormat imageFormat,
Size sizeImage, Size sizeImage,
int nStride, int nStride,
IntPtr rgData) byte[] rgData)
{ {
this.m_session.AssertOwningThread(); this.m_session.AssertOwningThread();
bool flag1 = false; bool flag1 = false;
@@ -131,18 +131,20 @@ namespace Microsoft.Iris.Render.Graphics
if (this.InUse) if (this.InUse)
this.m_surface.AddActiveUser(this); this.m_surface.AddActiveUser(this);
} }
IntPtr num1 = IntPtr.Zero; byte[] num1 = null;
if (this.m_session.IsForeignByteOrderOnWindowing) if (this.m_session.IsForeignByteOrderOnWindowing)
{ {
int bitsPerPixel = SurfaceFormatInfo.GetBitsPerPixel(nFormat); int bitsPerPixel = SurfaceFormatInfo.GetBitsPerPixel(nFormat);
int num2 = sizeImage.Height * nStride; int num2 = sizeImage.Height * nStride;
num1 = Marshal.AllocHGlobal(num2); num1 = new byte[num2];
Memory.ConvertEndian(num1, rgData, num2, bitsPerPixel); // TODO: Does this need to be re-implemented?
throw new NotImplementedException();
//Memory.ConvertEndian(num1, rgData, num2, bitsPerPixel);
} }
this.m_imageFormat = imageFormat; this.m_imageFormat = imageFormat;
this.m_sizeImage = sizeImage; this.m_sizeImage = sizeImage;
uint cbSize = (uint)(nStride * this.m_sizeImage.Height); 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); this.Track(buffer, num1, rgData, nStride);
buffer.Commit(); buffer.Commit();
++this.m_loadInfo.nLoadsInProgress; ++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); ((IImage)this).LoadContent(this.m_imageFormat, this.m_sizeImage, this.m_loadInfo.nStride, this.m_loadInfo.rgAppData);
} }
else else
this.m_handlerContent(ContentNotification.Acquire, this, IntPtr.Zero); this.m_handlerContent(ContentNotification.Acquire, this, null);
} }
Surface surface = this.m_surface; 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; ImageLoadInfo imageLoadInfo;
if (this.m_loadInfo != null && this.m_loadInfo.rgAppData == rgAppData && this.m_loadInfo.nStride == nStride) 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.handlerNotify(ContentNotification.Release, imageLoadInfo.imageOwner, imageLoadInfo.rgAppData);
imageLoadInfo.imageOwner.m_insideReleaseCallback = false; imageLoadInfo.imageOwner.m_insideReleaseCallback = false;
} }
imageLoadInfo.rgAppData = IntPtr.Zero; imageLoadInfo.rgAppData = null;
imageLoadInfo.handlerNotify = null; imageLoadInfo.handlerNotify = null;
imageLoadInfo.imageOwner = null; imageLoadInfo.imageOwner = null;
} }
if (!(contextData.rgConvertData != IntPtr.Zero)) if (!(contextData.rgConvertData != null))
return; return;
Marshal.FreeHGlobal(contextData.rgConvertData); contextData.rgConvertData = null;
contextData.rgConvertData = IntPtr.Zero;
} }
internal delegate void ContentReloadedHandler(Image image); internal delegate void ContentReloadedHandler(Image image);
@@ -11,7 +11,7 @@ namespace Microsoft.Iris.Render.Graphics
internal class ImageLoadInfo internal class ImageLoadInfo
{ {
public Image imageOwner; public Image imageOwner;
public IntPtr rgAppData; public byte[] rgAppData;
public int nStride; public int nStride;
public int nLoadsInProgress; public int nLoadsInProgress;
public int nSystemLoadRequests; public int nSystemLoadRequests;
@@ -16,6 +16,6 @@ namespace Microsoft.Iris.Render
string Identifier { get; } 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; } uint SampleCount { get; }
IntPtr AcquireContent(); byte[] AcquireContent();
void ReleaseContent(); void ReleaseContent();
} }
@@ -4,18 +4,21 @@
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1 // MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll // Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Microsoft.Iris.Render.Internal namespace Microsoft.Iris.Render.Internal
{ {
internal static class FormApi internal static class FormApi
{ {
private const string s_stEhRenderDll = "UIXRender.dll"; public static HRESULT SpGdiplusInit()
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static HRESULT SpGdiplusUninit()
public static extern HRESULT SpGdiplusInit(); {
throw new NotImplementedException();
[DllImport("UIXRender.dll")] }
public static extern HRESULT SpGdiplusUninit();
} }
} }
@@ -34,5 +34,8 @@ namespace Microsoft.Iris.Render.Internal
} }
public int Int => this.hr; 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); 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); 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 RenderPort m_port;
private RemoteDataBuffer m_remoteBuffer; private RemoteDataBuffer m_remoteBuffer;
private unsafe void* m_pvData; private byte[] m_pvData;
private uint m_cbSize; 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_port = port;
this.m_remoteBuffer = null; this.m_remoteBuffer = null;
@@ -44,7 +44,7 @@ namespace Microsoft.Iris.Render.Protocol
public uint DataSize => this.m_cbSize; 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; public RemoteDataBuffer RemoteStub => this.m_remoteBuffer;
@@ -10,14 +10,13 @@ using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Threading;
namespace Microsoft.Iris.Render.Protocol namespace Microsoft.Iris.Render.Protocol
{ {
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
internal static class EngineApi internal static class EngineApi
{ {
private const string s_stEhRenderDll = "UIXRender.dll";
public static void IFC(HRESULT hr) public static void IFC(HRESULT hr)
{ {
if (hr.Int >= 0) if (hr.Int >= 0)
@@ -102,89 +101,127 @@ namespace Microsoft.Iris.Render.Protocol
} }
} }
[DllImport("UIXRender.dll")] public static HRESULT SpInit(ref InitArgs args)
public static extern HRESULT SpInit(ref EngineApi.InitArgs args); {
return 0;
}
[DllImport("UIXRender.dll")] public static HRESULT SpUninit()
public static extern HRESULT SpUninit(); {
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static unsafe HRESULT SpBufferOpen(
public static extern unsafe HRESULT SpBufferOpen( BufferInfo* phdrData,
EngineApi.BufferInfo* phdrData, void* pvData)
void* pvData); {
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static unsafe HRESULT SpWrapBufferProc(
public static extern unsafe HRESULT SpWrapBufferProc( MessageBufferEventHandler pfnProcessBufferProc,
EngineApi.MessageBufferEventHandler pfnProcessBufferProc, IntPtr* ppNativeProc)
IntPtr* ppNativeProc); {
*ppNativeProc = Marshal.GetFunctionPointerForDelegate(pfnProcessBufferProc);
return 0;
}
[DllImport("UIXRender.dll", CharSet = CharSet.Auto)] public static HRESULT SpPeekMessage(
public static extern HRESULT SpPeekMessage(
out Win32Api.MSG msg, out Win32Api.MSG msg,
HWND hwnd, HWND hwnd,
uint nMsgFilterMin, uint nMsgFilterMin,
uint nMsgFilterMax, uint nMsgFilterMax,
uint wRemoveMsg, 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 HRESULT SpWaitMessage(uint nTimeOutMs, IntPtr _unused)
public static extern HRESULT SpWaitMessage(uint nTimeOutMs, IntPtr _unused); {
return 0;
}
[DllImport("UIXRender.dll")] public static HRESULT SpInvoke(
public static extern HRESULT SpInvoke(
ContextID idContext, ContextID idContext,
IntPtr pfnInvoke, IntPtr pfnInvoke,
IntPtr pvArgs, IntPtr pvArgs,
bool synchronous); bool synchronous)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static HRESULT SpRenderThreadInit(
public static extern HRESULT SpRenderThreadInit( ref InitArgs argsRender,
ref EngineApi.InitArgs argsRender, out Thread pThread)
out IntPtr pThread); {
pThread = new Thread(new ThreadStart(() => Console.WriteLine("nan")));
pThread.Start();
return 0;
}
[DllImport("UIXRender.dll")] public static HRESULT SpRenderThreadUninit(Thread pThread)
public static extern HRESULT SpRenderThreadUninit(IntPtr pThread); {
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Unicode)] public static HRESULT SpRemoteCreateServerStreams(
public static extern HRESULT SpRemoteCreateServerStreams(
string stSession, string stSession,
TransportProtocol nProtocol, TransportProtocol nProtocol,
out IntPtr pSendStream, out IntPtr pSendStream,
out IntPtr pReceiveStream); out IntPtr pReceiveStream)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static HRESULT SpRemoteWaitServerStreamsConnected(
public static extern HRESULT SpRemoteWaitServerStreamsConnected(
TransportProtocol nProtocol, TransportProtocol nProtocol,
IntPtr pSendStream, IntPtr pSendStream,
IntPtr pReceiveStream); IntPtr pReceiveStream)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static HRESULT SpRemoteServerInit(
public static extern HRESULT SpRemoteServerInit(
IntPtr pSendStream, IntPtr pSendStream,
IntPtr pReceiveStream, IntPtr pReceiveStream,
EngineApi.InitArgs argsSend, InitArgs argsSend,
out IntPtr pSession); out IntPtr pSession)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static HRESULT SpRemoteServerUninit(
public static extern HRESULT SpRemoteServerUninit(
IntPtr pSession, IntPtr pSession,
bool fForceShutdown, bool fForceShutdown,
out ShutdownReason nShutdownReason); out ShutdownReason nShutdownReason)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll", CharSet = CharSet.Ansi)] public static HRESULT SpDx9CompileEffect(
public static extern HRESULT SpDx9CompileEffect(
string stEffect, string stEffect,
string stDefines, string stDefines,
out IntPtr pErrorString, out IntPtr pErrorString,
out IntPtr pErrorBuffer, out IntPtr pErrorBuffer,
out IntPtr pEffectBlob, out IntPtr pEffectBlob,
out uint EffectBlobSize, out uint EffectBlobSize,
out IntPtr pEffectBlobBuffer); out IntPtr pEffectBlobBuffer)
{
throw new NotImplementedException();
}
[DllImport("UIXRender.dll")] public static void SpObjectRelease(IntPtr pUnknown)
public static extern void SpObjectRelease(IntPtr pUnknown); {
throw new NotImplementedException();
}
[System.Flags] [Flags]
public enum BufferFlags public enum BufferFlags
{ {
IsBatch = 1, IsBatch = 1,
@@ -195,11 +232,11 @@ namespace Microsoft.Iris.Render.Protocol
[ComVisible(false)] [ComVisible(false)]
public struct BufferInfo public struct BufferInfo
{ {
public ContextID idContextSrc; public ContextID idContextSrc; // 0x00
public ContextID idContextDest; public ContextID idContextDest; // 0x04
public RENDERHANDLE idBuffer; public RENDERHANDLE idBuffer; // 0x08
public EngineApi.BufferFlags nFlags; public BufferFlags nFlags; // 0x0C
public uint cbSizeBuffer; public uint cbSizeBuffer; // 0x10
} }
internal delegate void TimeoutEventHandler(IntPtr pData); internal delegate void TimeoutEventHandler(IntPtr pData);
@@ -207,21 +244,21 @@ namespace Microsoft.Iris.Render.Protocol
[ComVisible(false)] [ComVisible(false)]
internal struct InitArgs internal struct InitArgs
{ {
public uint cbSize; public uint cbSize; // 0x00
public ContextID idContext; public ContextID idContext; // 0x04
public int cItemsPerGroupBits; public int cItemsPerGroupBits; // 0x08
public int cGroupBits; public int cGroupBits; // 0x0C
public IntPtr pfnProcessBuffer; public IntPtr pfnProcessBuffer; // 0x10
public IntPtr pvProcessData; public IntPtr pvProcessData; // 0x14
public RENDERHANDLE idObjectBrokerClass; public RENDERHANDLE idObjectBrokerClass; // 0x18
public EngineApi.TimeoutEventHandler pfnTimeout; public TimeoutEventHandler pfnTimeout; // 0x1C
public IntPtr pvTimeoutData; public IntPtr pvTimeoutData; // 0x24
public uint nTimeOutSec; public uint nTimeOutSec; // 0x28
public InitArgs(MessageCookieLayout layout, ContextID idContextNew) public InitArgs(MessageCookieLayout layout, ContextID idContextNew)
{ {
Debug2.Validate(idContextNew != ContextID.NULL, typeof(ArgumentNullException), nameof(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.idContext = idContextNew;
this.cItemsPerGroupBits = layout.numberOfObjectBits; this.cItemsPerGroupBits = layout.numberOfObjectBits;
this.cGroupBits = layout.numberOfGroupBits; this.cGroupBits = layout.numberOfGroupBits;
@@ -236,7 +273,7 @@ namespace Microsoft.Iris.Render.Protocol
public unsafe InitArgs( public unsafe InitArgs(
MessageCookieLayout layout, MessageCookieLayout layout,
ContextID idContextNew, ContextID idContextNew,
EngineApi.MessageBufferEventHandler pfnProcessBufferProc) MessageBufferEventHandler pfnProcessBufferProc)
: this(layout, idContextNew) : this(layout, idContextNew)
{ {
if (pfnProcessBufferProc == null) if (pfnProcessBufferProc == null)
@@ -250,10 +287,10 @@ namespace Microsoft.Iris.Render.Protocol
internal unsafe delegate int MessageBufferEventHandler( internal unsafe delegate int MessageBufferEventHandler(
IntPtr pData, IntPtr pData,
uint hContext, uint hContext,
EngineApi.BufferInfo* pBufferInfo, BufferInfo* pBufferInfo,
void* pvBufferData); void* pvBufferData);
[System.Flags] [Flags]
public enum WorkResult : uint public enum WorkResult : uint
{ {
ProcessedMessage = 1, ProcessedMessage = 1,
@@ -6,18 +6,19 @@
using Microsoft.Iris.Render.Common; using Microsoft.Iris.Render.Common;
using System; using System;
using System.Threading;
namespace Microsoft.Iris.Render.Protocol namespace Microsoft.Iris.Render.Protocol
{ {
internal class LocalChannel : RenderObject, IChannel internal class LocalChannel : RenderObject, IChannel
{ {
private IntPtr m_renderThread; private Thread m_renderThread;
public LocalChannel(LocalConnectionInfo connectionInfo) public LocalChannel(LocalConnectionInfo connectionInfo)
{ {
} }
public bool IsConnected => this.m_renderThread != IntPtr.Zero; public bool IsConnected => m_renderThread != null;
public void Connect( public void Connect(
ContextID remoteContextId, ContextID remoteContextId,
@@ -29,17 +30,17 @@ namespace Microsoft.Iris.Render.Protocol
{ {
idObjectBrokerClass = brokerClassHandle 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) protected override void Dispose(bool inDispose)
{ {
try try
{ {
if (!(this.m_renderThread != IntPtr.Zero)) if (m_renderThread == null)
return; return;
EngineApi.IFC(EngineApi.SpRenderThreadUninit(this.m_renderThread)); EngineApi.IFC(EngineApi.SpRenderThreadUninit(m_renderThread));
this.m_renderThread = IntPtr.Zero; m_renderThread = null;
} }
finally 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 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