committed by
GitHub
56 changed files with 910 additions and 287 deletions
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<startup> |
|||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
|||
</startup> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -0,0 +1,6 @@ |
|||
<Application xmlns="https://github.com/avaloniaui"> |
|||
<Application.Styles> |
|||
<StyleInclude Source="resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"/> |
|||
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/> |
|||
</Application.Styles> |
|||
</Application> |
|||
@ -0,0 +1,16 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace RenderTest |
|||
{ |
|||
public class App : Application |
|||
{ |
|||
public override void Initialize() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
Title="Avalonia Render Test"> |
|||
</Window> |
|||
@ -0,0 +1,82 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive.Linq; |
|||
using Avalonia; |
|||
using Avalonia.Animation; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Shapes; |
|||
using Avalonia.Data; |
|||
using Avalonia.Layout; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Media; |
|||
using Avalonia.Rendering; |
|||
|
|||
namespace RenderTest |
|||
{ |
|||
public class MainWindow : Window |
|||
{ |
|||
public MainWindow() |
|||
{ |
|||
this.InitializeComponent(); |
|||
this.CreateAnimations(); |
|||
this.AttachDevTools(); |
|||
RendererMixin.DrawFpsCounter = true; |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
private void CreateAnimations() |
|||
{ |
|||
const int Count = 100; |
|||
var panel = new WrapPanel(); |
|||
|
|||
for (var i = 0; i < Count; ++i) |
|||
{ |
|||
var element = new Panel |
|||
{ |
|||
Children = |
|||
{ |
|||
new Ellipse |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
Fill = Brushes.Blue, |
|||
}, |
|||
new Path |
|||
{ |
|||
Data = StreamGeometry.Parse( |
|||
"F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"), |
|||
Fill = Brushes.Green, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center, |
|||
RenderTransform = new ScaleTransform(2, 2), |
|||
} |
|||
}, |
|||
Margin = new Thickness(4), |
|||
RenderTransform = new ScaleTransform(), |
|||
}; |
|||
|
|||
var start = Animate.Stopwatch.Elapsed; |
|||
var index = i; |
|||
var degrees = Animate.Timer |
|||
.Select(x => (x - start).TotalSeconds) |
|||
.Where(x => (x % Count) >= index && (x % Count) < index + 1) |
|||
.Select(x => (x % 1) / 1); |
|||
|
|||
element.RenderTransform.Bind( |
|||
ScaleTransform.ScaleXProperty, |
|||
degrees, |
|||
BindingPriority.Animation); |
|||
|
|||
panel.Children.Add(element); |
|||
} |
|||
|
|||
Content = panel; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Logging.Serilog; |
|||
using Avalonia.Platform; |
|||
using Serilog; |
|||
|
|||
namespace RenderTest |
|||
{ |
|||
internal class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
InitializeLogging(); |
|||
|
|||
// TODO: Make this work with GTK/Skia/Cairo depending on command-line args
|
|||
// again.
|
|||
AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.Start<MainWindow>(); |
|||
} |
|||
|
|||
// This will be made into a runtime configuration extension soon!
|
|||
private static void InitializeLogging() |
|||
{ |
|||
#if DEBUG
|
|||
SerilogLogger.Initialize(new LoggerConfiguration() |
|||
.MinimumLevel.Warning() |
|||
.WriteTo.Trace(outputTemplate: "{Area}: {Message}") |
|||
.CreateLogger()); |
|||
#endif
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("RenderTest")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("RenderTest")] |
|||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("f1fdc5b0-4654-416f-ae69-e3e9bbd87801")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,192 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{F1FDC5B0-4654-416F-AE69-E3E9BBD87801}</ProjectGuid> |
|||
<OutputType>WinExe</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>RenderTest</RootNamespace> |
|||
<AssemblyName>RenderTest</AssemblyName> |
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
<TargetFrameworkProfile /> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<StartupObject /> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Serilog, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Serilog.1.5.14\lib\net45\Serilog.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="Serilog.FullNetFx, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Reactive.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\System.Reactive.Core.3.0.0\lib\net45\System.Reactive.Core.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.Interfaces, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\System.Reactive.Interfaces.3.0.0\lib\net45\System.Reactive.Interfaces.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.Linq, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\System.Reactive.Linq.3.0.0\lib\net45\System.Reactive.Linq.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.PlatformServices, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\System.Reactive.PlatformServices.3.0.0\lib\net45\System.Reactive.PlatformServices.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.Windows.Threading, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\System.Reactive.Windows.Threading.3.0.0\lib\net45\System.Reactive.Windows.Threading.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Net.Http" /> |
|||
<Reference Include="System.Xml" /> |
|||
<Reference Include="WindowsBase" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="App.xaml.cs"> |
|||
<DependentUpon>App.xaml</DependentUpon> |
|||
</Compile> |
|||
<Compile Include="Program.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="MainWindow.xaml.cs"> |
|||
<DependentUpon>MainWindow.xaml</DependentUpon> |
|||
</Compile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="App.config" /> |
|||
<None Include="packages.config" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<EmbeddedResource Include="App.xaml"> |
|||
<SubType>Designer</SubType> |
|||
</EmbeddedResource> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.DesignerSupport\Avalonia.DesignerSupport.csproj"> |
|||
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project> |
|||
<Name>Avalonia.DesignerSupport</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj"> |
|||
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project> |
|||
<Name>Avalonia.DotNetFrameworkRuntime</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Logging.Serilog\Avalonia.Logging.Serilog.csproj"> |
|||
<Project>{b61b66a3-b82d-4875-8001-89d3394fe0c9}</Project> |
|||
<Name>Avalonia.Logging.Serilog</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj"> |
|||
<Project>{6417b24e-49c2-4985-8db2-3ab9d898ec91}</Project> |
|||
<Name>Avalonia.ReactiveUI</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.SceneGraph\Avalonia.SceneGraph.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.SceneGraph</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Gtk\Avalonia.Cairo\Avalonia.Cairo.csproj"> |
|||
<Project>{fb05ac90-89ba-4f2f-a924-f37875fb547c}</Project> |
|||
<Name>Avalonia.Cairo</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Gtk\Avalonia.Gtk\Avalonia.Gtk.csproj"> |
|||
<Project>{54f237d5-a70a-4752-9656-0c70b1a7b047}</Project> |
|||
<Name>Avalonia.Gtk</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|||
<Name>Avalonia.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj"> |
|||
<Project>{3e908f67-5543-4879-a1dc-08eace79b3cd}</Project> |
|||
<Name>Avalonia.Direct2D1</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Windows\Avalonia.Win32\Avalonia.Win32.csproj"> |
|||
<Project>{811a76cf-1cf6-440f-963b-bbe31bd72a82}</Project> |
|||
<Name>Avalonia.Win32</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<EmbeddedResource Include="MainWindow.xaml"> |
|||
<SubType>Designer</SubType> |
|||
</EmbeddedResource> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
|||
@ -0,0 +1,26 @@ |
|||
<ProjectConfiguration> |
|||
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies> |
|||
<BuildPriority>1000</BuildPriority> |
|||
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace> |
|||
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing> |
|||
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies> |
|||
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking> |
|||
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking> |
|||
<AllowCodeAnalysis>false</AllowCodeAnalysis> |
|||
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely> |
|||
<RunPreBuildEvents>false</RunPreBuildEvents> |
|||
<RunPostBuildEvents>false</RunPostBuildEvents> |
|||
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully> |
|||
<InstrumentAssembly>true</InstrumentAssembly> |
|||
<PreventSigningOfAssembly>false</PreventSigningOfAssembly> |
|||
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> |
|||
<DetectStackOverflow>true</DetectStackOverflow> |
|||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> |
|||
<DefaultTestTimeout>60000</DefaultTestTimeout> |
|||
<UseBuildConfiguration /> |
|||
<UseBuildPlatform /> |
|||
<ProxyProcessPath /> |
|||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> |
|||
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState> |
|||
<BuildProcessArchitecture>x86</BuildProcessArchitecture> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<packages> |
|||
<package id="Serilog" version="1.5.14" targetFramework="net45" /> |
|||
<package id="System.Reactive" version="3.0.0" targetFramework="net45" /> |
|||
<package id="System.Reactive.Core" version="3.0.0" targetFramework="net45" /> |
|||
<package id="System.Reactive.Interfaces" version="3.0.0" targetFramework="net45" /> |
|||
<package id="System.Reactive.Linq" version="3.0.0" targetFramework="net45" /> |
|||
<package id="System.Reactive.PlatformServices" version="3.0.0" targetFramework="net45" /> |
|||
<package id="System.Reactive.Windows.Threading" version="3.0.0" targetFramework="net45" /> |
|||
</packages> |
|||
@ -1,59 +0,0 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Platform; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.Threading; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Avalonia.Android.CanvasRendering |
|||
{ |
|||
internal class AndroidTopLevelRenderer : ITopLevelRenderer |
|||
{ |
|||
public void Attach(TopLevel topLevel) |
|||
{ |
|||
var resources = new List<IDisposable>(); |
|||
var initialClientSize = topLevel.PlatformImpl.ClientSize; |
|||
|
|||
|
|||
var queueManager = ((IRenderRoot)topLevel).RenderQueueManager; |
|||
|
|||
if (queueManager == null) |
|||
return; |
|||
|
|||
|
|||
var viewport = PlatformManager.CreateRenderTarget(topLevel.PlatformImpl); |
|||
resources.Add(viewport); |
|||
//resources.Add(queueManager.RenderNeeded.Subscribe(_
|
|||
// =>
|
|||
// Dispatcher.UIThread.InvokeAsync(() => topLevel.PlatformImpl.Invalidate(new Rect(topLevel.ClientSize)))));
|
|||
Action pendingInvalidation = null; |
|||
resources.Add(queueManager.RenderNeeded.Subscribe(_ => |
|||
{ |
|||
if (pendingInvalidation == null) |
|||
{ |
|||
pendingInvalidation = () => |
|||
{ |
|||
topLevel.PlatformImpl.Invalidate(new Rect(topLevel.ClientSize)); |
|||
pendingInvalidation = null; |
|||
}; |
|||
Dispatcher.UIThread.InvokeAsync(pendingInvalidation); |
|||
} |
|||
} |
|||
)); |
|||
|
|||
topLevel.PlatformImpl.Paint = rect => |
|||
{ |
|||
viewport.Render(topLevel); |
|||
queueManager.RenderFinished(); |
|||
}; |
|||
|
|||
topLevel.Closed += delegate |
|||
{ |
|||
foreach (var disposable in resources) |
|||
disposable.Dispose(); |
|||
resources.Clear(); |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -1,66 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Controls.Platform |
|||
{ |
|||
public interface ITopLevelRenderer |
|||
{ |
|||
void Attach(TopLevel topLevel); |
|||
} |
|||
|
|||
|
|||
class DefaultTopLevelRenderer : ITopLevelRenderer |
|||
{ |
|||
|
|||
public void Attach(TopLevel topLevel) |
|||
{ |
|||
var resources = new List<IDisposable>(); |
|||
var initialClientSize = topLevel.PlatformImpl.ClientSize; |
|||
|
|||
|
|||
var queueManager = ((IRenderRoot)topLevel).RenderQueueManager; |
|||
|
|||
if (queueManager == null) |
|||
return; |
|||
|
|||
|
|||
var viewport = PlatformManager.CreateRenderTarget(topLevel.PlatformImpl); |
|||
resources.Add(viewport); |
|||
resources.Add(queueManager.RenderNeeded.Subscribe(_ |
|||
=> |
|||
Dispatcher.UIThread.InvokeAsync(() => topLevel.PlatformImpl.Invalidate(new Rect(topLevel.ClientSize))))); |
|||
|
|||
topLevel.PlatformImpl.Paint = rect => |
|||
{ |
|||
try |
|||
{ |
|||
viewport.Render(topLevel); |
|||
} |
|||
catch (RenderTargetCorruptedException ex) |
|||
{ |
|||
Logging.Logger.Error("Renderer", this, "Render target was corrupted. Exception: {0}", ex); |
|||
viewport.Dispose(); |
|||
resources.Remove(viewport); |
|||
viewport = PlatformManager.CreateRenderTarget(topLevel.PlatformImpl); |
|||
resources.Add(viewport); |
|||
topLevel.PlatformImpl.Paint(rect); // Retry painting
|
|||
} |
|||
queueManager.RenderFinished(); |
|||
}; |
|||
|
|||
topLevel.Closed += delegate |
|||
{ |
|||
foreach (var disposable in resources) |
|||
disposable.Dispose(); |
|||
resources.Clear(); |
|||
}; |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,103 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a default render loop that uses a standard timer.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// This class may be overridden by platform implementations to use a specialized timer
|
|||
/// implementation.
|
|||
/// </remarks>
|
|||
public class DefaultRenderLoop : IRenderLoop |
|||
{ |
|||
private IPlatformThreadingInterface _threading; |
|||
private int _subscriberCount; |
|||
private EventHandler<EventArgs> _tick; |
|||
private IDisposable _subscription; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="DefaultRenderLoop"/> class.
|
|||
/// </summary>
|
|||
/// <param name="framesPerSecond">
|
|||
/// The number of frames per second at which the loop should run.
|
|||
/// </param>
|
|||
public DefaultRenderLoop(int framesPerSecond) |
|||
{ |
|||
FramesPerSecond = framesPerSecond; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the number of frames per second at which the loop runs.
|
|||
/// </summary>
|
|||
public int FramesPerSecond { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public event EventHandler<EventArgs> Tick |
|||
{ |
|||
add |
|||
{ |
|||
if (_subscriberCount++ == 0) |
|||
{ |
|||
Start(); |
|||
} |
|||
|
|||
_tick += value; |
|||
} |
|||
|
|||
remove |
|||
{ |
|||
if (--_subscriberCount == 0) |
|||
{ |
|||
Stop(); |
|||
} |
|||
|
|||
_tick -= value; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Starts the timer.
|
|||
/// </summary>
|
|||
protected void Start() |
|||
{ |
|||
_subscription = StartCore(InternalTick); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Provides the implementation of starting the timer.
|
|||
/// </summary>
|
|||
/// <param name="tick">The method to call on each tick.</param>
|
|||
/// <remarks>
|
|||
/// This can be overridden by platform implementations to use a specialized timer
|
|||
/// implementation.
|
|||
/// </remarks>
|
|||
protected virtual IDisposable StartCore(Action tick) |
|||
{ |
|||
if (_threading == null) |
|||
{ |
|||
_threading = AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>(); |
|||
} |
|||
|
|||
return _threading.StartTimer(TimeSpan.FromSeconds(1.0 / FramesPerSecond), tick); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Stops the timer.
|
|||
/// </summary>
|
|||
protected void Stop() |
|||
{ |
|||
_subscription.Dispose(); |
|||
_subscription = null; |
|||
} |
|||
|
|||
private void InternalTick() |
|||
{ |
|||
_tick(this, EventArgs.Empty); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the interface implemented by an application render loop.
|
|||
/// </summary>
|
|||
public interface IRenderLoop |
|||
{ |
|||
/// <summary>
|
|||
/// Raised when the render loop ticks to signal a new frame should be drawn.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// This event can be raised on any thread; it is the responsibility of the subscriber to
|
|||
/// switch execution to the right thread.
|
|||
/// </remarks>
|
|||
event EventHandler<EventArgs> Tick; |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the interface for a <see cref="RenderQueueManager"/>.
|
|||
/// </summary>
|
|||
public interface IRenderQueueManager |
|||
{ |
|||
/// <summary>
|
|||
/// Gets an observable that is fired whenever a render is required.
|
|||
/// </summary>
|
|||
IObservable<Unit> RenderNeeded { get; } |
|||
|
|||
/// <summary>
|
|||
/// Invalidates the render for the specified visual and raises <see cref="RenderNeeded"/>.
|
|||
/// </summary>
|
|||
/// <param name="visual">The visual.</param>
|
|||
void InvalidateRender(IVisual visual); |
|||
|
|||
/// <summary>
|
|||
/// Called when rendering is finished.
|
|||
/// </summary>
|
|||
void RenderFinished(); |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
public interface IRenderer : IDisposable |
|||
{ |
|||
void AddDirty(IVisual visual); |
|||
|
|||
void Render(Rect rect); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a factory for creating <see cref="IRenderer"/> instances.
|
|||
/// </summary>
|
|||
public interface IRendererFactory |
|||
{ |
|||
/// <summary>
|
|||
/// Creates a new renderer for the specified render root.
|
|||
/// </summary>
|
|||
/// <param name="root">The render root.</param>
|
|||
/// <param name="renderLoop">The render loop.</param>
|
|||
/// <returns>An instance of an <see cref="IRenderer"/>.</returns>
|
|||
IRenderer CreateRenderer(IRenderRoot root, IRenderLoop renderLoop); |
|||
} |
|||
} |
|||
@ -1,51 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive; |
|||
using System.Reactive.Subjects; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
/// <summary>
|
|||
/// Schedules the rendering of a tree.
|
|||
/// </summary>
|
|||
public class RenderQueueManager : IRenderQueueManager |
|||
{ |
|||
private readonly Subject<Unit> _renderNeeded = new Subject<Unit>(); |
|||
|
|||
private bool _renderQueued; |
|||
|
|||
/// <summary>
|
|||
/// Gets an observable that is fired whenever a render is required.
|
|||
/// </summary>
|
|||
public IObservable<Unit> RenderNeeded => _renderNeeded; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether a render is queued.
|
|||
/// </summary>
|
|||
public bool RenderQueued => _renderQueued; |
|||
|
|||
/// <summary>
|
|||
/// Invalidates the render for the specified visual and raises <see cref="RenderNeeded"/>.
|
|||
/// </summary>
|
|||
/// <param name="visual">The visual.</param>
|
|||
public void InvalidateRender(IVisual visual) |
|||
{ |
|||
if (!_renderQueued) |
|||
{ |
|||
_renderQueued = true; |
|||
_renderNeeded.OnNext(Unit.Default); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Called when rendering is finished.
|
|||
/// </summary>
|
|||
public void RenderFinished() |
|||
{ |
|||
_renderQueued = false; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using Avalonia.Platform; |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
public class Renderer : IDisposable, IRenderer |
|||
{ |
|||
private readonly IRenderLoop _renderLoop; |
|||
private readonly IRenderRoot _root; |
|||
private IRenderTarget _renderTarget; |
|||
private bool _dirty; |
|||
|
|||
public Renderer(IRenderRoot root, IRenderLoop renderLoop) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(root != null); |
|||
|
|||
_root = root; |
|||
_renderLoop = renderLoop; |
|||
_renderLoop.Tick += OnRenderLoopTick; |
|||
} |
|||
|
|||
public void AddDirty(IVisual visual) |
|||
{ |
|||
_dirty = true; |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_renderLoop.Tick -= OnRenderLoopTick; |
|||
} |
|||
|
|||
public void Render(Rect rect) |
|||
{ |
|||
if (_renderTarget == null) |
|||
{ |
|||
_renderTarget = _root.CreateRenderTarget(); |
|||
} |
|||
|
|||
try |
|||
{ |
|||
_renderTarget.Render(_root); |
|||
} |
|||
catch (RenderTargetCorruptedException ex) |
|||
{ |
|||
Logging.Logger.Information("Renderer", this, "Render target was corrupted. Exception: {0}", ex); |
|||
_renderTarget.Dispose(); |
|||
_renderTarget = null; |
|||
} |
|||
finally |
|||
{ |
|||
_dirty = false; |
|||
} |
|||
} |
|||
|
|||
private void OnRenderLoopTick(object sender, EventArgs e) |
|||
{ |
|||
if (_dirty) |
|||
{ |
|||
_root.Invalidate(new Rect(_root.ClientSize)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.Reactive.Disposables; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.Win32.Interop; |
|||
|
|||
namespace Avalonia.Win32 |
|||
{ |
|||
internal class RenderLoop : DefaultRenderLoop |
|||
{ |
|||
private UnmanagedMethods.TimeCallback timerDelegate; |
|||
|
|||
public RenderLoop(int framesPerSecond) |
|||
: base(framesPerSecond) |
|||
{ |
|||
} |
|||
|
|||
protected override IDisposable StartCore(Action tick) |
|||
{ |
|||
timerDelegate = (id, uMsg, user, dw1, dw2) => tick(); |
|||
|
|||
var handle = UnmanagedMethods.timeSetEvent( |
|||
(uint)(1000 / FramesPerSecond), |
|||
0, |
|||
timerDelegate, |
|||
UIntPtr.Zero, |
|||
1); |
|||
|
|||
return Disposable.Create(() => |
|||
{ |
|||
timerDelegate = null; |
|||
UnmanagedMethods.timeKillEvent(handle); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue