Reimplemented basic RenderEngine for SK

This commit is contained in:
Yoshi Askharoun
2021-07-16 16:03:13 -05:00
parent a44a3ddc3f
commit cc8deff38a
15 changed files with 428 additions and 93 deletions
+26 -23
View File
@@ -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:
s_renderType = RenderingType.GDI;
break;
case GraphicsDeviceType.Direct3D9:
s_renderType = RenderingType.DX9;
break;
case GraphicsDeviceType.Ganesh:
case GraphicsDeviceType.Metal:
case GraphicsDeviceType.OpenGL:
case GraphicsDeviceType.Vulkan:
case GraphicsDeviceType.Dawn:
s_renderType = RenderingType.Skia;
break;
default:
throw new ArgumentException(InvariantString.Format("Unknown graphics type {0}", graphicsType));
}
if (graphicsType == GraphicsDeviceType.Gdi)
s_renderType = RenderingType.GDI;
else if (graphicsType == GraphicsDeviceType.Direct3D9)
s_renderType = RenderingType.DX9;
else if (graphicsType.FulfillsRequirement(GraphicsDeviceType.Skia))
s_renderType = RenderingType.Skia;
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));
+12 -9
View File
@@ -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,14 +46,15 @@ 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(
EventHandler rendererConnectedCallback,
TimeoutHandler handlerTimeout,
SKSurface skSurface,
EventHandler rendererConnectedCallback,
TimeoutHandler handlerTimeout,
uint timeoutSecValue)
{
_syncWindowHandler = new SimpleCallback(SyncWindowHandler);
@@ -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(
GraphicsDeviceType graphicsType,
GraphicsRenderingQuality renderingQuality,
SoundDeviceType soundType)
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);
+1
View File
@@ -10,5 +10,6 @@ namespace Microsoft.Iris
{
None,
DirectSound,
XAudio
}
}