diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 39aa3bac1b..683a144bb7 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -27,22 +27,25 @@ namespace Avalonia.Direct2D1 { private static readonly Direct2D1Platform s_instance = new Direct2D1Platform(); - private static readonly SharpDX.Direct2D1.Factory s_d2D1Factory = + private static readonly SharpDX.Direct2D1.Factory1 s_d2D1Factory = #if DEBUG - new SharpDX.Direct2D1.Factory(SharpDX.Direct2D1.FactoryType.MultiThreaded, SharpDX.Direct2D1.DebugLevel.Error); + new SharpDX.Direct2D1.Factory1(SharpDX.Direct2D1.FactoryType.MultiThreaded, SharpDX.Direct2D1.DebugLevel.Error); #else - new SharpDX.Direct2D1.Factory(SharpDX.Direct2D1.FactoryType.MultiThreaded, SharpDX.Direct2D1.DebugLevel.None); + new SharpDX.Direct2D1.Factory1(SharpDX.Direct2D1.FactoryType.MultiThreaded, SharpDX.Direct2D1.DebugLevel.None); #endif private static readonly SharpDX.DirectWrite.Factory s_dwfactory = new SharpDX.DirectWrite.Factory(); private static readonly SharpDX.WIC.ImagingFactory s_imagingFactory = new SharpDX.WIC.ImagingFactory(); + public static bool UseImmediateRenderer { get; set; } + public static void Initialize() { AvaloniaLocator.CurrentMutable .Bind().ToConstant(s_instance) .Bind().ToConstant(s_instance) - .BindToSelf(s_d2D1Factory) + .Bind().ToConstant(s_d2D1Factory) + .Bind().ToConstant(s_d2D1Factory) .BindToSelf(s_dwfactory) .BindToSelf(s_imagingFactory); SharpDX.Configuration.EnableReleaseOnFinalizer = true; @@ -76,7 +79,14 @@ namespace Avalonia.Direct2D1 public IRenderer CreateRenderer(IRenderRoot root, IRenderLoop renderLoop) { - return new DeferredRenderer(root, renderLoop); + if (UseImmediateRenderer) + { + return new ImmediateRenderer(root, renderLoop); + } + else + { + return new DeferredRenderer(root, renderLoop); + } } public IRenderTarget CreateRenderTarget(IPlatformHandle handle) diff --git a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs index d5f298cf3b..06eda82206 100644 --- a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs @@ -27,9 +27,11 @@ namespace Avalonia.Direct2D1 public HwndRenderTarget(IntPtr hwnd) { _hwnd = hwnd; - Direct2DFactory = AvaloniaLocator.Current.GetService(); + Direct2DFactory = AvaloniaLocator.Current.GetService(); DirectWriteFactory = AvaloniaLocator.Current.GetService(); + System.Diagnostics.Debug.WriteLine("Created HwndRenderTarget"); + var featureLevels = new[] { SharpDX.Direct3D.FeatureLevel.Level_12_1, @@ -56,7 +58,7 @@ namespace Avalonia.Direct2D1 /// /// Gets the Direct2D factory. /// - public Factory Direct2DFactory + public Factory1 Direct2DFactory { get; } @@ -99,7 +101,7 @@ namespace Avalonia.Direct2D1 _dpi = dpi; using (var dxgiDevice = _d3dDevice.QueryInterface()) - using (var d2dDevice = new Device(dxgiDevice)) + using (var d2dDevice = new Device(Direct2DFactory, dxgiDevice)) using (var dxgiAdaptor = dxgiDevice.Adapter) using (var dxgiFactory = dxgiAdaptor.GetParent()) {