mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Reimplemented basic RenderEngine for SK
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Render.Common;
|
||||
|
||||
namespace Microsoft.Iris.Library
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static bool FulfillsRequirement(this GraphicsDeviceType cur, GraphicsDeviceType requirement)
|
||||
{
|
||||
Debug2.Assert(requirement != GraphicsDeviceType.Unknown, nameof(requirement));
|
||||
|
||||
if (cur == requirement || requirement == GraphicsDeviceType.None)
|
||||
return true;
|
||||
else if (cur == GraphicsDeviceType.Unknown)
|
||||
return false;
|
||||
|
||||
if (requirement == GraphicsDeviceType.Skia)
|
||||
return ((int)cur >> 4) == 1;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,23 +10,15 @@ namespace Microsoft.Iris.Render
|
||||
{
|
||||
Unknown = -1,
|
||||
|
||||
None,
|
||||
Gdi,
|
||||
Direct3D9,
|
||||
XeDirectX9,
|
||||
None = 0b0000_0000_0000_0000,
|
||||
Gdi = 0b0000_0000_0000_0001,
|
||||
Direct3D9 = 0b0000_0000_0000_0010,
|
||||
XeDirectX9 = 0b0000_0000_0000_0011,
|
||||
|
||||
Metal,
|
||||
OpenGL,
|
||||
Vulkan,
|
||||
Dawn,
|
||||
|
||||
/// <summary>
|
||||
/// Skia's GPU backend
|
||||
/// </summary>
|
||||
Ganesh,
|
||||
/// <summary>
|
||||
/// Skia's GPU backend
|
||||
/// </summary>
|
||||
SKGanesh = Ganesh,
|
||||
Skia = 0b0000_0000_0001_0000,
|
||||
Metal = 0b0000_0000_0001_0001,
|
||||
OpenGL = 0b0000_0000_0001_0010,
|
||||
Vulkan = 0b0000_0000_0001_0011,
|
||||
Dawn = 0b0000_0000_0001_0100,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Microsoft.Iris.Render
|
||||
public interface IRenderEngine : IRenderObject, IDisposable
|
||||
{
|
||||
void Initialize(
|
||||
SkiaSharp.SKSurface skSurface,
|
||||
GraphicsDeviceType typeGraphics,
|
||||
GraphicsRenderingQuality renderingQuality,
|
||||
SoundDeviceType typeSound);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Microsoft.Iris.Render.Internal
|
||||
[Serializable]
|
||||
internal struct GraphicsCaps
|
||||
{
|
||||
internal uint DeviceType;
|
||||
internal GraphicsDeviceType DeviceType;
|
||||
internal int MaxSimultaneousTextures;
|
||||
internal int MaxTextureWidth;
|
||||
internal int MaxTextureHeight;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
|
||||
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
|
||||
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Render.Common;
|
||||
using Microsoft.Iris.Render.Protocol;
|
||||
using Microsoft.Iris.Render.Sound;
|
||||
@@ -92,6 +93,7 @@ namespace Microsoft.Iris.Render.Internal
|
||||
}
|
||||
|
||||
void IRenderEngine.Initialize(
|
||||
SkiaSharp.SKSurface skSurface,
|
||||
GraphicsDeviceType typeGraphics,
|
||||
GraphicsRenderingQuality renderingQuality,
|
||||
SoundDeviceType typeSound)
|
||||
@@ -128,9 +130,9 @@ namespace Microsoft.Iris.Render.Internal
|
||||
|
||||
internal SoundDevice SoundDevice => this.m_soundDevice;
|
||||
|
||||
internal Vector<Microsoft.Iris.Render.Internal.GraphicsCaps> GraphicsCaps => this.m_renderCaps.Graphics;
|
||||
internal Vector<GraphicsCaps> GraphicsCaps => this.m_renderCaps.Graphics;
|
||||
|
||||
internal Vector<Microsoft.Iris.Render.Internal.SoundCaps> SoundCaps => this.m_renderCaps.Sound;
|
||||
internal Vector<SoundCaps> SoundCaps => this.m_renderCaps.Sound;
|
||||
|
||||
private void DoEvents(uint nTimeoutInMsecs)
|
||||
{
|
||||
@@ -178,9 +180,9 @@ namespace Microsoft.Iris.Render.Internal
|
||||
|
||||
private bool IsGraphicsDeviceAvailable(GraphicsDeviceType type, bool fFilterRecommended)
|
||||
{
|
||||
foreach (Microsoft.Iris.Render.Internal.GraphicsCaps graphic in this.m_renderCaps.Graphics)
|
||||
foreach (GraphicsCaps graphic in this.m_renderCaps.Graphics)
|
||||
{
|
||||
if ((GraphicsDeviceType)graphic.DeviceType == type)
|
||||
if (graphic.DeviceType.FulfillsRequirement(type))
|
||||
return !fFilterRecommended || graphic.DriverWarning == 0;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.Render.Internal.RenderCaps
|
||||
// Assembly: UIX.RenderApi, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
|
||||
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
|
||||
|
||||
using Microsoft.Iris.Render.Common;
|
||||
using Microsoft.Iris.Render.Protocol;
|
||||
using Microsoft.Iris.Render.Protocols.Splash.Rendering;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Render.Internal
|
||||
{
|
||||
internal class SkiaRenderCaps : RenderObject, IRenderCapsCallback
|
||||
{
|
||||
private SKSurface m_remoteObject;
|
||||
private Vector<GraphicsCaps> m_graphicsCapsList;
|
||||
private Vector<SoundCaps> m_soundCapsList;
|
||||
private bool m_hasValidCaps;
|
||||
private bool m_capsPending;
|
||||
private uint m_currentRequestId;
|
||||
|
||||
internal SkiaRenderCaps(SKSurface skSurface)
|
||||
{
|
||||
this.m_hasValidCaps = false;
|
||||
this.m_capsPending = false;
|
||||
this.m_currentRequestId = 0U;
|
||||
this.m_graphicsCapsList = new Vector<GraphicsCaps>();
|
||||
this.m_soundCapsList = new Vector<SoundCaps>();
|
||||
this.m_remoteObject = skSurface;
|
||||
}
|
||||
|
||||
internal bool HasValidCaps => this.m_hasValidCaps;
|
||||
|
||||
internal Vector<GraphicsCaps> Graphics => this.m_graphicsCapsList;
|
||||
|
||||
internal Vector<SoundCaps> Sound => this.m_soundCapsList;
|
||||
|
||||
internal void RequestCaps()
|
||||
{
|
||||
if (this.m_capsPending)
|
||||
return;
|
||||
++this.m_currentRequestId;
|
||||
this.m_capsPending = true;
|
||||
|
||||
// TODO: Is there any way to get the graphics capabilities from an SKSurface?
|
||||
Graphics.Add(new GraphicsCaps
|
||||
{
|
||||
DeviceType = GraphicsDeviceType.Skia
|
||||
});
|
||||
|
||||
((IRenderCapsCallback)this).OnEndCapsCheck(default, 0);
|
||||
}
|
||||
|
||||
internal event EventHandler CapsAvailable;
|
||||
|
||||
protected void NotifyCapsAvailable()
|
||||
{
|
||||
if (this.CapsAvailable == null)
|
||||
return;
|
||||
this.CapsAvailable(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
void IRenderCapsCallback.OnBeginCapsCheck(RENDERHANDLE target, uint cookie)
|
||||
{
|
||||
this.m_graphicsCapsList.Clear();
|
||||
this.m_soundCapsList.Clear();
|
||||
this.m_hasValidCaps = false;
|
||||
}
|
||||
|
||||
void IRenderCapsCallback.OnEndCapsCheck(RENDERHANDLE target, uint cookie)
|
||||
{
|
||||
this.m_hasValidCaps = true;
|
||||
this.m_capsPending = false;
|
||||
this.NotifyCapsAvailable();
|
||||
}
|
||||
|
||||
void IRenderCapsCallback.OnGraphicsCaps(
|
||||
RENDERHANDLE target,
|
||||
uint cookie,
|
||||
GraphicsCaps caps)
|
||||
{
|
||||
if ((int)this.m_currentRequestId != (int)cookie)
|
||||
return;
|
||||
this.m_graphicsCapsList.Add(caps);
|
||||
}
|
||||
|
||||
void IRenderCapsCallback.OnSoundCaps(
|
||||
RENDERHANDLE target,
|
||||
uint cookie,
|
||||
SoundCaps caps)
|
||||
{
|
||||
if ((int)this.m_currentRequestId != (int)cookie)
|
||||
return;
|
||||
this.m_soundCapsList.Add(caps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Render.Common;
|
||||
using Microsoft.Iris.Render.Protocol;
|
||||
using Microsoft.Iris.Render.Sound;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Microsoft.Iris.Render.Internal
|
||||
{
|
||||
internal class SkiaRenderEngine : RenderObject, IRenderEngine, IRenderObject, IDisposable
|
||||
{
|
||||
private static BitArray s_contexts;
|
||||
private static uint s_contextIdSeed = 1;
|
||||
private static uint s_maxContextId = 254;
|
||||
private IrisEngineInfo m_engineInfo;
|
||||
private RenderToken m_primaryToken;
|
||||
private MessagingSession m_messagingSession;
|
||||
private SkiaRenderCaps m_renderCaps;
|
||||
private GraphicsDeviceType m_typeGraphics;
|
||||
private SoundDeviceType m_typeSound;
|
||||
private InputSystem m_inputSystem;
|
||||
private SoundDevice m_soundDevice;
|
||||
private ContextID m_localContextId;
|
||||
private ContextID m_engineContextId;
|
||||
|
||||
static SkiaRenderEngine() => s_contexts = new BitArray((int)s_maxContextId + 1);
|
||||
|
||||
internal SkiaRenderEngine(IrisEngineInfo engineInfo, IRenderHost renderHost)
|
||||
{
|
||||
Debug2.Validate(engineInfo != null, typeof(ArgumentNullException), nameof(engineInfo));
|
||||
Debug2.Validate(renderHost != null, typeof(ArgumentNullException), nameof(renderHost));
|
||||
m_engineInfo = engineInfo;
|
||||
m_engineContextId = AllocateContextId();
|
||||
m_localContextId = AllocateContextId();
|
||||
m_primaryToken = new RenderToken(engineInfo, m_localContextId, m_engineContextId, RENDERGROUP.NULL);
|
||||
m_messagingSession = new MessagingSession(renderHost, this.m_primaryToken);
|
||||
this.m_renderCaps = new SkiaRenderCaps(engineInfo.Surface);
|
||||
this.m_renderCaps.RequestCaps();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool fInDispose)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fInDispose)
|
||||
{
|
||||
//this.m_renderSession.ReleaseSharedResources();
|
||||
//if (this.m_renderWindow != null)
|
||||
// this.m_renderWindow.WindowCreatedEvent -= new EventHandler(OnRenderWindowCreated);
|
||||
if (m_soundDevice != null)
|
||||
m_soundDevice.Dispose();
|
||||
//if (this.m_renderWindow != null)
|
||||
// this.m_renderWindow.Dispose();
|
||||
if (m_inputSystem != null)
|
||||
m_inputSystem.Dispose();
|
||||
//if (this.m_displayManager != null)
|
||||
// this.m_displayManager.Dispose();
|
||||
//if (this.m_renderSession != null)
|
||||
// this.m_renderSession.Dispose();
|
||||
if (this.m_messagingSession != null)
|
||||
{
|
||||
if (this.m_messagingSession.IsConnected)
|
||||
this.m_messagingSession.Disconnect();
|
||||
this.m_messagingSession.Dispose();
|
||||
}
|
||||
FreeContextId(m_localContextId);
|
||||
FreeContextId(m_engineContextId);
|
||||
}
|
||||
m_soundDevice = null;
|
||||
//this.m_displayManager = null;
|
||||
//this.m_renderWindow = null;
|
||||
//this.m_renderSession = null;
|
||||
this.m_messagingSession = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(fInDispose);
|
||||
}
|
||||
}
|
||||
|
||||
void IRenderEngine.Initialize(
|
||||
SkiaSharp.SKSurface skSurface,
|
||||
GraphicsDeviceType typeGraphics,
|
||||
GraphicsRenderingQuality renderingQuality,
|
||||
SoundDeviceType typeSound)
|
||||
{
|
||||
Debug2.Validate(IsGraphicsDeviceAvailable(typeGraphics, false), typeof(InvalidOperationException), "Graphics device type not available");
|
||||
Debug2.Validate(IsSoundDeviceAvailable(typeSound), typeof(InvalidOperationException), "Sound device type not available");
|
||||
m_typeGraphics = typeGraphics;
|
||||
m_typeSound = typeSound;
|
||||
// TODO: Set up input system
|
||||
//m_inputSystem = new InputSystem(this.m_renderSession, this.m_renderWindow);
|
||||
}
|
||||
|
||||
IRenderSession IRenderEngine.Session => null;//throw new NotSupportedException("Skia does not use render sessions"); m_renderSession;
|
||||
|
||||
internal RenderSession Session => null;
|
||||
|
||||
IRenderWindow IRenderEngine.Window => null;
|
||||
|
||||
IDisplayManager IRenderEngine.DisplayManager => null;
|
||||
|
||||
public InputSystem InputSystem => throw new NotImplementedException("Skia does not support input yet");// m_inputSystem;
|
||||
|
||||
internal SoundDevice SoundDevice => m_soundDevice;
|
||||
|
||||
internal Vector<GraphicsCaps> GraphicsCaps => this.m_renderCaps.Graphics;
|
||||
|
||||
internal Vector<SoundCaps> SoundCaps => this.m_renderCaps.Sound;
|
||||
|
||||
private void DoEvents(uint nTimeoutInMsecs)
|
||||
{
|
||||
MessagingSession.DoEvents(nTimeoutInMsecs);
|
||||
}
|
||||
|
||||
void IRenderEngine.WaitForWork(uint nTimeoutInMsecs)
|
||||
{
|
||||
EngineApi.SpWaitMessage(nTimeoutInMsecs, IntPtr.Zero);
|
||||
}
|
||||
|
||||
void IRenderEngine.FlushBatch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool IRenderEngine.IsGraphicsDeviceAvailable(
|
||||
GraphicsDeviceType type,
|
||||
bool fFilterRecommended)
|
||||
{
|
||||
return IsGraphicsDeviceAvailable(type, fFilterRecommended);
|
||||
}
|
||||
|
||||
private bool IsGraphicsDeviceAvailable(GraphicsDeviceType type, bool fFilterRecommended)
|
||||
{
|
||||
foreach (GraphicsCaps graphic in this.m_renderCaps.Graphics)
|
||||
{
|
||||
if (graphic.DeviceType.FulfillsRequirement(type))
|
||||
return !fFilterRecommended || graphic.DriverWarning == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IRenderEngine.IsSoundDeviceAvailable(SoundDeviceType type) => IsSoundDeviceAvailable(type);
|
||||
|
||||
private bool IsSoundDeviceAvailable(SoundDeviceType type)
|
||||
{
|
||||
if (type == SoundDeviceType.None)
|
||||
return true;
|
||||
foreach (SoundCaps soundCaps in this.m_renderCaps.Sound)
|
||||
{
|
||||
if ((SoundDeviceType)soundCaps.DeviceType == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnRenderWindowCreated(object sender, EventArgs args)
|
||||
{
|
||||
SoundDevice soundDevice = null;
|
||||
switch (m_typeSound)
|
||||
{
|
||||
case SoundDeviceType.None:
|
||||
m_soundDevice = soundDevice;
|
||||
break;
|
||||
case SoundDeviceType.DirectSound8:
|
||||
//soundDevice = new Ds8SoundDevice(this.m_renderSession, m_renderWindow);
|
||||
//goto case SoundDeviceType.None;
|
||||
case SoundDeviceType.WaveAudio:
|
||||
case SoundDeviceType.XAudio:
|
||||
case SoundDeviceType.XAudio2:
|
||||
Debug2.Validate(false, typeof(NotImplementedException), "{0} is not yet supported");
|
||||
break;
|
||||
default:
|
||||
Debug2.Validate(false, typeof(ArgumentException), "typeSound");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal static ContextID AllocateContextId()
|
||||
{
|
||||
uint num1 = 0;
|
||||
lock (s_contexts)
|
||||
{
|
||||
for (int index = 0; index < s_maxContextId; ++index)
|
||||
{
|
||||
uint num2 = s_contextIdSeed++;
|
||||
if (s_contextIdSeed > s_maxContextId)
|
||||
s_contextIdSeed = 1U;
|
||||
if (!s_contexts[(int)num2])
|
||||
{
|
||||
num1 = num2;
|
||||
s_contexts[(int)num1] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Debug2.Validate(num1 != 0U, typeof(InvalidOperationException), "Failed to allocate a context ID");
|
||||
return ContextID.FromUInt32(num1);
|
||||
}
|
||||
|
||||
private static void FreeContextId(ContextID contextId)
|
||||
{
|
||||
uint uint32 = ContextID.ToUInt32(contextId);
|
||||
Debug2.Validate(s_contexts[(int)uint32], typeof(InvalidOperationException), "ContextID is not in use");
|
||||
lock (s_contexts)
|
||||
s_contexts[(int)uint32] = false;
|
||||
}
|
||||
|
||||
protected override void Invariant()
|
||||
{
|
||||
Debug2.Validate(m_localContextId != ContextID.NULL, typeof(InvalidOperationException), "local ContextId should not be NULL while running");
|
||||
Debug2.Validate(m_engineContextId != ContextID.NULL, typeof(InvalidOperationException), "engine ContextId should not be NULL while running");
|
||||
}
|
||||
|
||||
bool IRenderEngine.ProcessNativeEvents() => true;
|
||||
|
||||
void IRenderEngine.InterThreadWake()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,30 @@
|
||||
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
|
||||
|
||||
using Microsoft.Iris.Render.Protocol;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Render
|
||||
{
|
||||
public sealed class IrisEngineInfo : EngineInfo
|
||||
{
|
||||
private SKSurface m_skSurface;
|
||||
private ConnectionInfo m_connectionInfo;
|
||||
|
||||
public static EngineInfo CreateLocal() => new IrisEngineInfo(true);
|
||||
public static EngineInfo CreateLocal(SKSurface skSurface) => new IrisEngineInfo(skSurface, true);
|
||||
|
||||
public static EngineInfo CreateRemote() => new IrisEngineInfo(true, TransportProtocol.TCP, "127.0.0.1", false);
|
||||
public static EngineInfo CreateRemote(SKSurface skSurface) => new IrisEngineInfo(skSurface, true, TransportProtocol.TCP, "127.0.0.1", false);
|
||||
|
||||
internal IrisEngineInfo(bool isPrimary)
|
||||
: base(EngineType.Iris)
|
||||
internal IrisEngineInfo(SKSurface skSurface, bool isPrimary) : base(EngineType.Iris)
|
||||
{
|
||||
if (!isPrimary)
|
||||
throw new NotImplementedException("Local connections to an existing engine are not supported yet");
|
||||
this.m_connectionInfo = new LocalConnectionInfo();
|
||||
this.m_skSurface = skSurface;
|
||||
}
|
||||
|
||||
internal IrisEngineInfo(
|
||||
SKSurface skSurface,
|
||||
bool isPrimary,
|
||||
TransportProtocol protocol,
|
||||
string sessionName,
|
||||
@@ -35,8 +38,10 @@ namespace Microsoft.Iris.Render
|
||||
if (!isPrimary)
|
||||
throw new NotImplementedException("Local connections to an existing engine are not supported yet");
|
||||
this.m_connectionInfo = new RemoteConnectionInfo(protocol, sessionName, swapByteOrder);
|
||||
this.m_skSurface = skSurface;
|
||||
}
|
||||
|
||||
internal ConnectionInfo ConnectionInfo => this.m_connectionInfo;
|
||||
internal SKSurface Surface => this.m_skSurface;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,8 +240,6 @@ namespace Microsoft.Iris.Render.Protocol
|
||||
}
|
||||
if (this.m_isBatchingMessages)
|
||||
this.FlushBatch();
|
||||
return;
|
||||
// TODO: What does this do?
|
||||
while (this.m_pingRequestCount > 0)
|
||||
DoEvents(uint.MaxValue);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Microsoft.Iris.Render
|
||||
Debug2.Validate(renderHost != null, typeof(ArgumentNullException), nameof(renderHost));
|
||||
IRenderEngine renderEngine = null;
|
||||
if (engineInfo.Type == EngineType.Iris)
|
||||
renderEngine = new RenderEngine(engineInfo as IrisEngineInfo, renderHost);
|
||||
renderEngine = new SkiaRenderEngine(engineInfo as IrisEngineInfo, renderHost);
|
||||
return renderEngine;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,5 +12,6 @@ namespace Microsoft.Iris.Render
|
||||
DirectSound8,
|
||||
WaveAudio,
|
||||
XAudio,
|
||||
XAudio2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,9 @@ namespace Microsoft.Iris
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsInitialized => s_initializationState != InitializationState.NotInitialized;
|
||||
public static bool IsInitialized => s_initializationState != InitializationState.NotInitialized;
|
||||
|
||||
public static bool IsInitializing { get; private set; }
|
||||
|
||||
public static bool StaticDllResourcesOnly
|
||||
{
|
||||
@@ -135,33 +137,26 @@ namespace Microsoft.Iris
|
||||
|
||||
public static bool IsDebug { get; set; }
|
||||
|
||||
public static void Initialize()
|
||||
public static void Initialize(SkiaSharp.SKSurface skSurface)
|
||||
{
|
||||
if (IsInitialized)
|
||||
throw new InvalidOperationException("Application already initialized");
|
||||
IsInitializing = true;
|
||||
Debug.Assert.IsNotNull(skSurface, nameof(skSurface));
|
||||
VerifyTrustedEnvironment();
|
||||
s_session = new UISession();
|
||||
|
||||
s_session = new UISession(skSurface);
|
||||
s_session.IsRtl = s_IsRTL;
|
||||
s_session.InputManager.KeyCoalescePolicy = new KeyCoalesceFilter(QueryKeyCoalesce);
|
||||
GraphicsDeviceType graphicsType = ChooseRenderingGraphicsDevice(s_renderType);
|
||||
switch (graphicsType)
|
||||
{
|
||||
case GraphicsDeviceType.Gdi:
|
||||
if (graphicsType == GraphicsDeviceType.Gdi)
|
||||
s_renderType = RenderingType.GDI;
|
||||
break;
|
||||
case GraphicsDeviceType.Direct3D9:
|
||||
else if (graphicsType == GraphicsDeviceType.Direct3D9)
|
||||
s_renderType = RenderingType.DX9;
|
||||
break;
|
||||
case GraphicsDeviceType.Ganesh:
|
||||
case GraphicsDeviceType.Metal:
|
||||
case GraphicsDeviceType.OpenGL:
|
||||
case GraphicsDeviceType.Vulkan:
|
||||
case GraphicsDeviceType.Dawn:
|
||||
else if (graphicsType.FulfillsRequirement(GraphicsDeviceType.Skia))
|
||||
s_renderType = RenderingType.Skia;
|
||||
break;
|
||||
default:
|
||||
else
|
||||
throw new ArgumentException(InvariantString.Format("Unknown graphics type {0}", graphicsType));
|
||||
}
|
||||
if (graphicsType == GraphicsDeviceType.Gdi)
|
||||
s_EnableAnimations = false;
|
||||
SoundDeviceType soundType = ChooseRendererSoundDevice(s_soundType);
|
||||
@@ -173,16 +168,21 @@ namespace Microsoft.Iris
|
||||
case SoundDeviceType.DirectSound8:
|
||||
s_soundType = SoundType.DirectSound;
|
||||
break;
|
||||
case SoundDeviceType.XAudio:
|
||||
case SoundDeviceType.XAudio2:
|
||||
s_soundType = SoundType.XAudio;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException(InvariantString.Format("Unknown sound type {0}", soundType));
|
||||
}
|
||||
s_session.InitializeRenderingDevices(graphicsType, (GraphicsRenderingQuality)s_renderingQuality, soundType);
|
||||
s_session.InitializeRenderingDevices(skSurface, graphicsType, (GraphicsRenderingQuality)s_renderingQuality, soundType);
|
||||
s_renderingQuality = (RenderingQuality)s_session.RenderSession.GraphicsDevice.RenderingQuality;
|
||||
InitializeCommon(true);
|
||||
if (!s_EnableAnimations)
|
||||
AnimationSystem.OverrideAnimationState(true);
|
||||
UIForm uiForm = new UIForm(s_session);
|
||||
s_initializationState = InitializationState.FullyInitialized;
|
||||
IsInitializing = false;
|
||||
}
|
||||
|
||||
private static void InitializeCommon(bool fullInitialization)
|
||||
@@ -469,9 +469,12 @@ namespace Microsoft.Iris
|
||||
graphicsType = GraphicsDeviceType.Gdi;
|
||||
break;
|
||||
case RenderingType.DX9:
|
||||
case RenderingType.Default:
|
||||
graphicsType = GraphicsDeviceType.Direct3D9;
|
||||
break;
|
||||
case RenderingType.Skia:
|
||||
case RenderingType.Default:
|
||||
graphicsType = GraphicsDeviceType.Skia;
|
||||
break;
|
||||
default:
|
||||
graphicsType = GraphicsDeviceType.Unknown;
|
||||
throw new ArgumentException(InvariantString.Format("Unknown rendering type {0}", type));
|
||||
|
||||
@@ -14,6 +14,7 @@ using Microsoft.Iris.Queues;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.RenderAPI.Audio;
|
||||
using Microsoft.Iris.UI;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Session
|
||||
@@ -45,12 +46,13 @@ namespace Microsoft.Iris.Session
|
||||
private static readonly DeferredHandler s_deferredPlaySound = new DeferredHandler(DeferredPlaySound);
|
||||
private static readonly DeferredHandler s_deferredPlaySystemSound = new DeferredHandler(DeferredPlaySystemSound);
|
||||
|
||||
public UISession()
|
||||
: this(null, null, 0U)
|
||||
public UISession(SKSurface skSurface)
|
||||
: this(skSurface, null, null, 0U)
|
||||
{
|
||||
}
|
||||
|
||||
public UISession(
|
||||
SKSurface skSurface,
|
||||
EventHandler rendererConnectedCallback,
|
||||
TimeoutHandler handlerTimeout,
|
||||
uint timeoutSecValue)
|
||||
@@ -67,18 +69,19 @@ namespace Microsoft.Iris.Session
|
||||
int pdwDefaultLayout;
|
||||
Win32Api.IFWIN32(Win32Api.GetProcessDefaultLayout(out pdwDefaultLayout));
|
||||
_rtl = pdwDefaultLayout == 1;
|
||||
_engine = RenderApi.CreateEngine(IrisEngineInfo.CreateLocal(), Dispatcher);
|
||||
_engine = RenderApi.CreateEngine(IrisEngineInfo.CreateLocal(skSurface), Dispatcher);
|
||||
_session = _engine.Session;
|
||||
TextImageCache.Initialize(this);
|
||||
ScavengeImageCache.Initialize(this);
|
||||
}
|
||||
|
||||
internal void InitializeRenderingDevices(
|
||||
SKSurface skSurface,
|
||||
GraphicsDeviceType graphicsType,
|
||||
GraphicsRenderingQuality renderingQuality,
|
||||
SoundDeviceType soundType)
|
||||
{
|
||||
_engine.Initialize(graphicsType, renderingQuality, soundType);
|
||||
_engine.Initialize(skSurface, graphicsType, renderingQuality, soundType);
|
||||
_effectManager = new EffectManager(_session);
|
||||
_soundManager = new SoundManager(this, _session);
|
||||
_animationManager = new AnimationManager(_session);
|
||||
|
||||
@@ -10,5 +10,6 @@ namespace Microsoft.Iris
|
||||
{
|
||||
None,
|
||||
DirectSound,
|
||||
XAudio
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,35 +27,20 @@ namespace Xune.Uno
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
readonly Random rand = new Random();
|
||||
DispatcherTimer timer = new DispatcherTimer();
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Microsoft.Iris.Application.Initialize();
|
||||
|
||||
Canvas.PaintSurface += Canvas_PaintSurface;
|
||||
timer.Interval = new TimeSpan(17000);
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, object e)
|
||||
{
|
||||
Canvas.Invalidate();
|
||||
}
|
||||
|
||||
ulong t = 0;
|
||||
private void Canvas_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
|
||||
{
|
||||
if (t == ulong.MaxValue)
|
||||
t = 0;
|
||||
byte r = (byte)rand.Next(0, byte.MaxValue);
|
||||
byte g = (byte)rand.Next(0, byte.MaxValue);
|
||||
byte b = (byte)rand.Next(0, byte.MaxValue);
|
||||
e.Surface.Canvas.DrawColor(new SKColor(100, 50, (byte)(t % byte.MaxValue)));
|
||||
t++;
|
||||
// Initialize UI framework
|
||||
if (Microsoft.Iris.Application.IsInitialized || Microsoft.Iris.Application.IsInitializing)
|
||||
return;
|
||||
|
||||
Microsoft.Iris.Application.Initialize(e.Surface);
|
||||
}
|
||||
|
||||
//private unsafe void nothing()
|
||||
|
||||
Reference in New Issue
Block a user