mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Create GraphicsDevice on RenderWindowBase
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
using Microsoft.Iris.Render.Internal;
|
||||
using Microsoft.Iris.Render.Protocol;
|
||||
using Microsoft.Iris.Render.Protocols.Splash.Rendering;
|
||||
using Microsoft.Iris.Render.Protocols.Splash.Rendering.Nt;
|
||||
|
||||
namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
internal sealed class SkiaGraphicsDevice : GraphicsDevice, IRenderHandleOwner
|
||||
{
|
||||
private RemoteGdiDevice m_remoteDevice;
|
||||
private bool m_fAllowAlpha;
|
||||
private bool m_fAllowAnimations;
|
||||
private bool m_fEnableBackBuffer;
|
||||
private bool m_fSystemMemoryBitmaps;
|
||||
private ColorF m_clrBackground;
|
||||
private bool m_fEnableAlphaTracking;
|
||||
private VideoZoomMode m_vzmZoomMode;
|
||||
private bool m_fSecureDesktopMode;
|
||||
|
||||
internal SkiaGraphicsDevice(RenderSession session) : base(session, "Skia")
|
||||
{
|
||||
//this.m_remoteDevice = session.BuildRemoteGdiDevice(this);
|
||||
this.m_fAllowAlpha = true;
|
||||
this.m_fAllowAnimations = true;
|
||||
this.m_fEnableBackBuffer = true;
|
||||
this.m_fSystemMemoryBitmaps = false;
|
||||
this.m_clrBackground = new ColorF(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
this.m_deviceType = GraphicsDeviceType.Gdi;
|
||||
this.m_graphicsCaps = session.GetGraphicsCaps(this.m_deviceType);
|
||||
this.m_renderingQuality = GraphicsRenderingQuality.MinQuality;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool fInDispose)
|
||||
{
|
||||
if (fInDispose && this.m_remoteDevice != null)
|
||||
this.m_remoteDevice.Dispose();
|
||||
this.m_remoteDevice = null;
|
||||
base.Dispose(fInDispose);
|
||||
}
|
||||
|
||||
RENDERHANDLE IRenderHandleOwner.RenderHandle => this.m_remoteDevice.RenderHandle;
|
||||
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteDevice = null;
|
||||
|
||||
public override bool IsVideoComposited => false;
|
||||
|
||||
internal override RemoteDevice RemoteDevice => m_remoteDevice;
|
||||
|
||||
public override bool CanPlayAnimations => this.AllowAnimations;
|
||||
|
||||
public bool AllowAlpha
|
||||
{
|
||||
get => this.m_fAllowAlpha;
|
||||
set
|
||||
{
|
||||
if (this.m_fAllowAlpha == value)
|
||||
return;
|
||||
this.m_remoteDevice.SendSetAllowAlpha(value);
|
||||
this.m_fAllowAlpha = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowAnimations
|
||||
{
|
||||
get => this.m_fAllowAnimations;
|
||||
set
|
||||
{
|
||||
if (this.m_fAllowAnimations == value)
|
||||
return;
|
||||
this.m_remoteDevice.SendSetAllowAnimations(value);
|
||||
this.m_fAllowAnimations = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableBackBuffer
|
||||
{
|
||||
get => this.m_fEnableBackBuffer;
|
||||
set
|
||||
{
|
||||
if (value == this.m_fEnableBackBuffer)
|
||||
return;
|
||||
this.m_remoteDevice.SendSetEnableBackBuffer(value);
|
||||
this.m_fEnableBackBuffer = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableAlphaTracking
|
||||
{
|
||||
get => this.m_fEnableAlphaTracking;
|
||||
set
|
||||
{
|
||||
if (value == this.m_fEnableAlphaTracking)
|
||||
return;
|
||||
this.m_remoteDevice.SendSetEnableAlphaTracking(value);
|
||||
this.m_fEnableAlphaTracking = value;
|
||||
}
|
||||
}
|
||||
|
||||
public VideoZoomMode ZoomMode
|
||||
{
|
||||
get => this.m_vzmZoomMode;
|
||||
set
|
||||
{
|
||||
if (value == this.m_vzmZoomMode)
|
||||
return;
|
||||
this.m_remoteDevice.SendSetZoomMode(value);
|
||||
this.m_vzmZoomMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SystemMemoryBitmaps
|
||||
{
|
||||
get => this.m_fSystemMemoryBitmaps;
|
||||
set
|
||||
{
|
||||
if (value == this.m_fSystemMemoryBitmaps)
|
||||
return;
|
||||
this.m_remoteDevice.SendSetUseSystemMemoryBitmaps(value);
|
||||
this.m_fSystemMemoryBitmaps = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ColorF BackgroundColor
|
||||
{
|
||||
get => this.m_clrBackground;
|
||||
set
|
||||
{
|
||||
if (!(value != this.m_clrBackground))
|
||||
return;
|
||||
this.m_remoteDevice.SendSetBackgroundColor(value);
|
||||
this.m_clrBackground = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool SecureDesktopMode
|
||||
{
|
||||
get => this.m_fSecureDesktopMode;
|
||||
set
|
||||
{
|
||||
if (value == this.m_fSecureDesktopMode)
|
||||
return;
|
||||
this.m_remoteDevice.SendSecureDesktopMode(value);
|
||||
this.m_fSecureDesktopMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool IsSurfaceFormatSupported(SurfaceFormat nFormat)
|
||||
{
|
||||
switch (nFormat)
|
||||
{
|
||||
case SurfaceFormat.RGB24:
|
||||
case SurfaceFormat.RGB32:
|
||||
case SurfaceFormat.ARGB32:
|
||||
return true;
|
||||
case SurfaceFormat.External:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateSurfacePoolWorker(
|
||||
object oSurfacePool,
|
||||
object oHandle,
|
||||
SurfaceFormat nFormat)
|
||||
{
|
||||
this.m_remoteDevice.SendCreateSurfacePool((RENDERHANDLE)oHandle, nFormat);
|
||||
}
|
||||
|
||||
protected override void RestartRendering(uint nRenderGeneration) => this.m_remoteDevice.SendRestart(nRenderGeneration);
|
||||
|
||||
public override bool CanPlayAnimationType(AnimationInputType type) => false;
|
||||
|
||||
internal override EffectTemplate CreateEffectTemplate(string stName) => new GdiEffectTemplate(this.m_session, this, stName);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ namespace Microsoft.Iris.Render.Internal
|
||||
m_localContextId = AllocateContextId();
|
||||
m_primaryToken = new RenderToken(engineInfo, m_localContextId, m_engineContextId, RENDERGROUP.NULL);
|
||||
m_messagingSession = new MessagingSession(renderHost, this.m_primaryToken);
|
||||
m_renderWindow = engineInfo.Window;
|
||||
this.m_renderSession = new RenderSession(this);
|
||||
this.m_renderCaps = new RenderCaps(engineInfo.Surface);
|
||||
this.m_renderCaps.RequestCaps();
|
||||
@@ -91,6 +92,8 @@ namespace Microsoft.Iris.Render.Internal
|
||||
m_renderSession.Initialize();
|
||||
// TODO: Set up input system
|
||||
//m_inputSystem = new InputSystem(this.m_renderSession, this.m_renderWindow);
|
||||
|
||||
m_renderWindow.CreateGraphicsDevice(m_renderSession, m_typeGraphics, renderingQuality);
|
||||
}
|
||||
|
||||
IRenderSession IRenderEngine.Session => m_renderSession;//throw new NotSupportedException("Skia does not use render sessions"); m_renderSession;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Microsoft.Iris.Render.Internal
|
||||
}
|
||||
}
|
||||
|
||||
IGraphicsDevice IRenderSession.GraphicsDevice => null;// m_renderEngine.Window.GraphicsDevice;
|
||||
IGraphicsDevice IRenderSession.GraphicsDevice => m_renderEngine.Window.GraphicsDevice;
|
||||
|
||||
ISoundDevice IRenderSession.SoundDevice => m_renderEngine.SoundDevice;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Microsoft.Iris.Render.Internal
|
||||
|
||||
public override void Initialize() => BuildRootContainer();
|
||||
|
||||
private GraphicsDevice CreateGraphicsDevice(
|
||||
internal override GraphicsDevice CreateGraphicsDevice(
|
||||
RenderSession session,
|
||||
GraphicsDeviceType graphicsDeviceType,
|
||||
GraphicsRenderingQuality renderingQuality)
|
||||
|
||||
-3
@@ -33,19 +33,16 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Rendering
|
||||
|
||||
public unsafe void SendSetAnimationRate(int nFramesPerSecond)
|
||||
{
|
||||
Debug2.Throw(this.IsValid, "Non-static method call requires an instance");
|
||||
m_framesPerSecond = nFramesPerSecond;
|
||||
}
|
||||
|
||||
public unsafe void SendPulseTimeAdvance(int nPulseMs)
|
||||
{
|
||||
Debug2.Throw(this.IsValid, "Non-static method call requires an instance");
|
||||
m_pulseMs = nPulseMs;
|
||||
}
|
||||
|
||||
public unsafe void SendSetGlobalSpeedAdjustment(float flFactor)
|
||||
{
|
||||
Debug2.Throw(this.IsValid, "Non-static method call requires an instance");
|
||||
m_flFactor = flFactor;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@ namespace Microsoft.Iris.Render
|
||||
{
|
||||
public abstract class RenderWindowBase : IRenderWindow, ITreeOwner
|
||||
{
|
||||
internal abstract GraphicsDevice CreateGraphicsDevice(
|
||||
RenderSession session,
|
||||
GraphicsDeviceType graphicsDeviceType,
|
||||
GraphicsRenderingQuality renderingQuality);
|
||||
|
||||
public abstract int Left { get; }
|
||||
public abstract int Top { get; }
|
||||
public abstract int Right { get; }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Render.Graphics;
|
||||
using Microsoft.Iris.Render.Internal;
|
||||
using Microsoft.Iris.Library;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
@@ -16,6 +17,7 @@ namespace Microsoft.Iris.Render
|
||||
{
|
||||
private bool isDragging;
|
||||
private bool isFullscreen;
|
||||
private GraphicsDevice graphicsDevice;
|
||||
private Window WpfWindow { get; set; }
|
||||
private WindowInteropHelper InteropHelper { get; set; }
|
||||
|
||||
@@ -35,6 +37,16 @@ namespace Microsoft.Iris.Render
|
||||
WpfWindow.Loaded += WpfWindow_Loaded;
|
||||
}
|
||||
|
||||
internal override GraphicsDevice CreateGraphicsDevice(
|
||||
RenderSession session,
|
||||
GraphicsDeviceType graphicsDeviceType,
|
||||
GraphicsRenderingQuality renderingQuality)
|
||||
{
|
||||
if (graphicsDeviceType.FulfillsRequirement(GraphicsDeviceType.Skia))
|
||||
graphicsDevice = new SkiaGraphicsDevice(session);
|
||||
return GraphicsDevice;
|
||||
}
|
||||
|
||||
public override int Left => (int)WpfWindow.Left;
|
||||
|
||||
public override int Top => (int)WpfWindow.Top;
|
||||
@@ -190,7 +202,7 @@ namespace Microsoft.Iris.Render
|
||||
internal override ColorF OutlineAllColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
internal override ColorF OutlineMarkedColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
internal override GraphicsDevice GraphicsDevice => throw new NotImplementedException();
|
||||
internal override GraphicsDevice GraphicsDevice => graphicsDevice;
|
||||
|
||||
internal override RenderSession Session => throw new NotImplementedException();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#if UWP
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Render.Graphics;
|
||||
using Microsoft.Iris.Render.Internal;
|
||||
using System;
|
||||
@@ -17,6 +18,7 @@ namespace Microsoft.Iris.Render
|
||||
public sealed class XamlRenderWindow : RenderWindowBase
|
||||
{
|
||||
private bool isDragging = false;
|
||||
private GraphicsDevice graphicsDevice;
|
||||
private Window XamlWindow { get; set; }
|
||||
private ApplicationView CurrentView => ApplicationView.GetForCurrentView();
|
||||
private Rect VisibleBounds => CurrentView.VisibleBounds;
|
||||
@@ -38,6 +40,16 @@ namespace Microsoft.Iris.Render
|
||||
}
|
||||
}
|
||||
|
||||
internal override GraphicsDevice CreateGraphicsDevice(
|
||||
RenderSession session,
|
||||
GraphicsDeviceType graphicsDeviceType,
|
||||
GraphicsRenderingQuality renderingQuality)
|
||||
{
|
||||
if (graphicsDeviceType.FulfillsRequirement(GraphicsDeviceType.Skia))
|
||||
graphicsDevice = new SkiaGraphicsDevice(session);
|
||||
return GraphicsDevice;
|
||||
}
|
||||
|
||||
public override int Left => (int)VisibleBounds.Left;
|
||||
|
||||
public override int Top => (int)VisibleBounds.Top;
|
||||
@@ -177,7 +189,7 @@ namespace Microsoft.Iris.Render
|
||||
internal override ColorF OutlineAllColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
internal override ColorF OutlineMarkedColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
internal override GraphicsDevice GraphicsDevice => throw new NotImplementedException();
|
||||
internal override GraphicsDevice GraphicsDevice => graphicsDevice;
|
||||
|
||||
internal override RenderSession Session => throw new NotImplementedException();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user