diff --git a/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject b/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject new file mode 100644 index 00000000000..6800b4a3fec --- /dev/null +++ b/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject b/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject new file mode 100644 index 00000000000..6800b4a3fec --- /dev/null +++ b/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject b/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject new file mode 100644 index 00000000000..6800b4a3fec --- /dev/null +++ b/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index c7c61e2b4ea..413794dfa2a 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -10,6 +10,7 @@ public MainWindow() { this.InitializeComponent(); this.AttachDevTools(); + Renderer.DrawDirtyRects = Renderer.DrawFps = true; } private void InitializeComponent() diff --git a/samples/interop/Direct3DInteropSample/Program.cs b/samples/interop/Direct3DInteropSample/Program.cs index 7fb650a7a8b..d5de5ccb4ed 100644 --- a/samples/interop/Direct3DInteropSample/Program.cs +++ b/samples/interop/Direct3DInteropSample/Program.cs @@ -11,7 +11,7 @@ class Program { static void Main(string[] args) { - AppBuilder.Configure().UseWin32().UseDirect2D1().Start(); + AppBuilder.Configure().UseWin32(deferredRendering: false).UseDirect2D1().Start(); } } } diff --git a/src/Android/Avalonia.Android/AndroidPlatform.cs b/src/Android/Avalonia.Android/AndroidPlatform.cs index e9b4ad0a6d2..7134e7d1b42 100644 --- a/src/Android/Avalonia.Android/AndroidPlatform.cs +++ b/src/Android/Avalonia.Android/AndroidPlatform.cs @@ -52,13 +52,11 @@ public static void Initialize(Avalonia.Application app) .Bind().ToTransient() .Bind().ToSingleton() .Bind().ToConstant(Instance) - .Bind().ToConstant(ImmediateRenderer.Factory) .Bind().ToConstant(new AndroidThreadingInterface()) .Bind().ToTransient() .Bind().ToConstant(Instance) .Bind().ToSingleton() .Bind().ToConstant(new DefaultRenderLoop(60)) - .Bind().ToConstant(new AssetLoader(app.GetType().Assembly)); SkiaPlatform.Initialize(); diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index 0c62eb90602..6c8db17c71d 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -13,6 +13,7 @@ using Avalonia.Android.Platform.Input; using Avalonia.Controls; using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Rendering; namespace Avalonia.Android.Platform.SkiaPlatform { @@ -85,7 +86,12 @@ public virtual Size ClientSize public IPlatformHandle Handle => _view; public IEnumerable Surfaces => new object[] {this}; - + + public IRenderer CreateRenderer(IRenderRoot root) + { + return new ImmediateRenderer(root); + } + public virtual void Hide() { _view.Visibility = ViewStates.Invisible; diff --git a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs index ba3ecb99c56..60e25d2be65 100644 --- a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs +++ b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using Avalonia.Input; using Avalonia.Input.Raw; +using Avalonia.Rendering; using JetBrains.Annotations; namespace Avalonia.Platform @@ -60,6 +61,12 @@ public interface ITopLevelImpl : IDisposable /// Action ScalingChanged { get; set; } + /// + /// Creates a new renderer for the toplevel. + /// + /// The toplevel. + IRenderer CreateRenderer(IRenderRoot root); + /// /// Invalidates a rect on the toplevel. /// diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index a0a8f6b27eb..f8db0e2a5be 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -90,8 +90,7 @@ public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver dependencyResolv _renderInterface = TryGetService(dependencyResolver); var renderLoop = TryGetService(dependencyResolver); - var rendererFactory = TryGetService(dependencyResolver); - Renderer = rendererFactory?.CreateRenderer(this, renderLoop); + Renderer = impl.CreateRenderer(this); impl.SetInputRoot(this); @@ -181,6 +180,9 @@ bool IInputRoot.ShowAccessKeys /// double ILayoutRoot.LayoutScaling => PlatformImpl?.Scaling ?? 1; + /// + double IRenderRoot.RenderScaling => PlatformImpl?.Scaling ?? 1; + IStyleHost IStyleHost.StylingParent { get { return AvaloniaLocator.Current.GetService(); } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 3802f2b6eaf..46c625cc4cb 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -225,8 +225,14 @@ public void Close(object dialogResult) /// public override void Hide() { + if (!IsVisible) + { + return; + } + using (BeginAutoSizing()) { + Renderer?.Stop(); PlatformImpl?.Hide(); } @@ -252,6 +258,7 @@ public override void Show() using (BeginAutoSizing()) { PlatformImpl?.Show(); + Renderer?.Start(); } } @@ -297,6 +304,8 @@ public Task ShowDialog() var modal = PlatformImpl?.ShowDialog(); var result = new TaskCompletionSource(); + Renderer?.Start(); + Observable.FromEventPattern( x => this.Closed += x, x => this.Closed -= x) diff --git a/src/Avalonia.Controls/WindowBase.cs b/src/Avalonia.Controls/WindowBase.cs index fbdf64b14af..bcc09936ba1 100644 --- a/src/Avalonia.Controls/WindowBase.cs +++ b/src/Avalonia.Controls/WindowBase.cs @@ -117,6 +117,7 @@ public virtual void Hide() try { + Renderer?.Stop(); PlatformImpl?.Hide(); IsVisible = false; } @@ -145,6 +146,7 @@ public virtual void Show() } PlatformImpl?.Show(); + Renderer?.Start(); } finally { diff --git a/src/Avalonia.Themes.Default/CheckBox.xaml b/src/Avalonia.Themes.Default/CheckBox.xaml index e88e93eac68..2fc19b2679c 100644 --- a/src/Avalonia.Themes.Default/CheckBox.xaml +++ b/src/Avalonia.Themes.Default/CheckBox.xaml @@ -1,10 +1,11 @@