mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Moved CreateGraphcsDevice and InvokePaint implementations to RenderWindowBase
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.Iris.Input;
|
using Microsoft.Iris.Input;
|
||||||
|
using Microsoft.Iris.Library;
|
||||||
|
using Microsoft.Iris.Render.Common;
|
||||||
using Microsoft.Iris.Render.Graphics;
|
using Microsoft.Iris.Render.Graphics;
|
||||||
using Microsoft.Iris.Render.Internal;
|
using Microsoft.Iris.Render.Internal;
|
||||||
using System;
|
using System;
|
||||||
@@ -7,10 +9,24 @@ namespace Microsoft.Iris.Render
|
|||||||
{
|
{
|
||||||
public abstract class RenderWindowBase : IRenderWindow, ITreeOwner
|
public abstract class RenderWindowBase : IRenderWindow, ITreeOwner
|
||||||
{
|
{
|
||||||
internal abstract GraphicsDevice CreateGraphicsDevice(
|
private RenderSession m_session;
|
||||||
|
private GraphicsDevice m_graphicsDevice;
|
||||||
|
private IVisualContainer m_visualRoot;
|
||||||
|
|
||||||
|
internal virtual GraphicsDevice CreateGraphicsDevice(
|
||||||
RenderSession session,
|
RenderSession session,
|
||||||
GraphicsDeviceType graphicsDeviceType,
|
GraphicsDeviceType graphicsDeviceType,
|
||||||
GraphicsRenderingQuality renderingQuality);
|
GraphicsRenderingQuality renderingQuality)
|
||||||
|
{
|
||||||
|
m_session = session;
|
||||||
|
if (graphicsDeviceType.FulfillsRequirement(GraphicsDeviceType.Skia))
|
||||||
|
m_graphicsDevice = new SkiaGraphicsDevice(session);
|
||||||
|
|
||||||
|
m_visualRoot = new VisualContainer(true, session, this, new Object(), out var visual);
|
||||||
|
InvokePaint();
|
||||||
|
|
||||||
|
return GraphicsDevice;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract int Left { get; }
|
public abstract int Left { get; }
|
||||||
public abstract int Top { get; }
|
public abstract int Top { get; }
|
||||||
@@ -40,7 +56,7 @@ namespace Microsoft.Iris.Render
|
|||||||
public abstract WindowState WindowState { get; set; }
|
public abstract WindowState WindowState { get; set; }
|
||||||
public abstract FormStyleInfo Styles { get; set; }
|
public abstract FormStyleInfo Styles { get; set; }
|
||||||
public abstract HWND AppNotifyWindow { set; }
|
public abstract HWND AppNotifyWindow { set; }
|
||||||
public abstract IVisualContainer VisualRoot { get; }
|
public virtual IVisualContainer VisualRoot => m_visualRoot;
|
||||||
TreeNode ITreeOwner.Root { get; }
|
TreeNode ITreeOwner.Root { get; }
|
||||||
public bool CatchCloseRequests => CloseRequestEvent != null;
|
public bool CatchCloseRequests => CloseRequestEvent != null;
|
||||||
|
|
||||||
@@ -58,9 +74,9 @@ namespace Microsoft.Iris.Render
|
|||||||
|
|
||||||
internal abstract ColorF OutlineMarkedColor { get; set; }
|
internal abstract ColorF OutlineMarkedColor { get; set; }
|
||||||
|
|
||||||
internal abstract GraphicsDevice GraphicsDevice { get; }
|
internal virtual GraphicsDevice GraphicsDevice => m_graphicsDevice;
|
||||||
|
|
||||||
internal abstract RenderSession Session { get; }
|
internal virtual RenderSession Session => m_session;
|
||||||
|
|
||||||
internal abstract GraphicsDeviceType GraphicsDeviceType { get; }
|
internal abstract GraphicsDeviceType GraphicsDeviceType { get; }
|
||||||
|
|
||||||
@@ -119,5 +135,17 @@ namespace Microsoft.Iris.Render
|
|||||||
protected virtual void OnClose() => CloseEvent?.Invoke();
|
protected virtual void OnClose() => CloseEvent?.Invoke();
|
||||||
protected virtual void OnCloseRequest() => CloseRequestEvent?.Invoke();
|
protected virtual void OnCloseRequest() => CloseRequestEvent?.Invoke();
|
||||||
protected virtual void OnSetFocus(bool focused) => SetFocusEvent?.Invoke(focused);
|
protected virtual void OnSetFocus(bool focused) => SetFocusEvent?.Invoke(focused);
|
||||||
|
|
||||||
|
public virtual void InvokePaint()
|
||||||
|
{
|
||||||
|
Session?.DeferredInvoke(new DeferredHandler((obj) =>
|
||||||
|
{
|
||||||
|
Debug2.WriteLine(DebugCategory.FormWindow, 0, (string)obj);
|
||||||
|
}), "Howdy from dispatcher!", DeferredInvokePriority.VisualUpdate);
|
||||||
|
return;
|
||||||
|
|
||||||
|
var surface = Session.EngineInfo.Surface;
|
||||||
|
surface.Canvas.DrawText("Howdy from UIX in WPF!", 0, 0, new SkiaSharp.SKPaint(new SkiaSharp.SKFont(SkiaSharp.SKTypeface.Default)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace Microsoft.Iris.Render
|
|||||||
private GraphicsDevice graphicsDevice;
|
private GraphicsDevice graphicsDevice;
|
||||||
private HWND appNotifyWindow;
|
private HWND appNotifyWindow;
|
||||||
private IVisualContainer visualRoot;
|
private IVisualContainer visualRoot;
|
||||||
|
private RenderSession session;
|
||||||
|
|
||||||
private Window WpfWindow { get; set; }
|
private Window WpfWindow { get; set; }
|
||||||
private WindowInteropHelper InteropHelper { get; set; }
|
private WindowInteropHelper InteropHelper { get; set; }
|
||||||
@@ -42,19 +43,6 @@ namespace Microsoft.Iris.Render
|
|||||||
WpfWindow.Loaded += WpfWindow_Loaded;
|
WpfWindow.Loaded += WpfWindow_Loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override GraphicsDevice CreateGraphicsDevice(
|
|
||||||
RenderSession session,
|
|
||||||
GraphicsDeviceType graphicsDeviceType,
|
|
||||||
GraphicsRenderingQuality renderingQuality)
|
|
||||||
{
|
|
||||||
if (graphicsDeviceType.FulfillsRequirement(GraphicsDeviceType.Skia))
|
|
||||||
graphicsDevice = new SkiaGraphicsDevice(session);
|
|
||||||
|
|
||||||
visualRoot = new VisualContainer(true, session, this, new Object(), out var visual);
|
|
||||||
|
|
||||||
return GraphicsDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Left => (int)WpfWindow.Left;
|
public override int Left => (int)WpfWindow.Left;
|
||||||
|
|
||||||
public override int Top => (int)WpfWindow.Top;
|
public override int Top => (int)WpfWindow.Top;
|
||||||
@@ -201,15 +189,12 @@ namespace Microsoft.Iris.Render
|
|||||||
{
|
{
|
||||||
WpfWindow.Dispatcher.Invoke(() =>
|
WpfWindow.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (WpfWindow.Content is Control ctl)
|
WpfWindow.Background = new SolidColorBrush(Color.FromArgb(
|
||||||
{
|
(byte)(value.A * 255),
|
||||||
ctl.Background = new SolidColorBrush(Color.FromArgb(
|
(byte)(value.R * 255),
|
||||||
(byte)(value.A * 255),
|
(byte)(value.G * 255),
|
||||||
(byte)(value.R * 255),
|
(byte)(value.B * 255)
|
||||||
(byte)(value.G * 255),
|
));
|
||||||
(byte)(value.B * 255)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,8 +283,6 @@ namespace Microsoft.Iris.Render
|
|||||||
}
|
}
|
||||||
public override HWND AppNotifyWindow { set => appNotifyWindow = value; }
|
public override HWND AppNotifyWindow { set => appNotifyWindow = value; }
|
||||||
|
|
||||||
public override IVisualContainer VisualRoot => visualRoot;
|
|
||||||
|
|
||||||
TreeNode Root => throw new NotImplementedException();
|
TreeNode Root => throw new NotImplementedException();
|
||||||
|
|
||||||
private bool _IsClosing = false;
|
private bool _IsClosing = false;
|
||||||
@@ -316,10 +299,6 @@ namespace Microsoft.Iris.Render
|
|||||||
internal override ColorF OutlineAllColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
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 ColorF OutlineMarkedColor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
internal override GraphicsDevice GraphicsDevice => graphicsDevice;
|
|
||||||
|
|
||||||
internal override RenderSession Session => throw new NotImplementedException();
|
|
||||||
|
|
||||||
internal override GraphicsDeviceType GraphicsDeviceType => GraphicsDeviceType.Skia;
|
internal override GraphicsDeviceType GraphicsDeviceType => GraphicsDeviceType.Skia;
|
||||||
|
|
||||||
internal override bool IsRightToLeft => CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
|
internal override bool IsRightToLeft => CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ namespace Microsoft.Iris.Session
|
|||||||
|
|
||||||
private PriorityQueue.HookProc GetQueueDrainHook(DispatchPriority priority) => _masterQueue.GetDrainHook((int)priority);
|
private PriorityQueue.HookProc GetQueueDrainHook(DispatchPriority priority) => _masterQueue.GetDrainHook((int)priority);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="MessageLoop"/> and starts handling items in <paramref name="queue"/>.
|
||||||
|
/// </summary>
|
||||||
private void MainLoop(Queue queue, LoopCondition condition)
|
private void MainLoop(Queue queue, LoopCondition condition)
|
||||||
{
|
{
|
||||||
using (new UIDispatcher.MessageLoop(this, condition))
|
using (new UIDispatcher.MessageLoop(this, condition))
|
||||||
|
|||||||
@@ -51,12 +51,7 @@ namespace Microsoft.Iris.Session
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public UISession(
|
public UISession(SKSurface skSurface, RenderWindowBase renderWindow, EventHandler rendererConnectedCallback, TimeoutHandler handlerTimeout, uint timeoutSecValue)
|
||||||
SKSurface skSurface,
|
|
||||||
RenderWindowBase renderWindow,
|
|
||||||
EventHandler rendererConnectedCallback,
|
|
||||||
TimeoutHandler handlerTimeout,
|
|
||||||
uint timeoutSecValue)
|
|
||||||
{
|
{
|
||||||
_syncWindowHandler = new SimpleCallback(SyncWindowHandler);
|
_syncWindowHandler = new SimpleCallback(SyncWindowHandler);
|
||||||
_queueSyncLayoutComplete = new SimpleQueue();
|
_queueSyncLayoutComplete = new SimpleQueue();
|
||||||
|
|||||||
Reference in New Issue
Block a user