Browse Source

Merge branch 'master' into moreKeys

pull/2019/head
danwalmsley 8 years ago
committed by GitHub
parent
commit
347c976be9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      azure-pipelines.yml
  2. 6
      readme.md
  3. 3
      src/Avalonia.Base/Platform/IRuntimePlatform.cs
  4. 2
      src/Avalonia.Controls/AppBuilderBase.cs
  5. 4
      src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs
  6. 2
      src/Avalonia.Native/AvaloniaNativePlatform.cs
  7. 2
      src/Linux/Avalonia.LinuxFramebuffer/Mice.cs
  8. 4
      src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaRuntimeTypeProvider.cs
  9. 2
      src/Shared/PlatformSupport/AssetLoader.cs
  10. 4
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs
  11. 17
      src/Skia/Avalonia.Skia/TypefaceCache.cs
  12. 3
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
  13. 6
      src/Windows/Avalonia.Win32/Win32Platform.cs

6
azure-pipelines.yml

@ -57,10 +57,13 @@ jobs:
inputs: inputs:
pathToPublish: '$(Build.SourcesDirectory)/Build/Products/Release/' pathToPublish: '$(Build.SourcesDirectory)/Build/Products/Release/'
artifactName: 'Avalonia.Native.OSX' artifactName: 'Avalonia.Native.OSX'
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
inputs: inputs:
pathToPublish: '$(Build.SourcesDirectory)/artifacts/bin' pathToPublish: '$(Build.SourcesDirectory)/artifacts/bin'
artifactName: 'BinariesOSX' artifactName: 'BinariesOSX'
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
- job: Windows - job: Windows
pool: pool:
@ -79,11 +82,14 @@ jobs:
inputs: inputs:
pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget' pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget'
artifactName: 'NuGet' artifactName: 'NuGet'
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
inputs: inputs:
pathToPublish: '$(Build.SourcesDirectory)/artifacts/zip' pathToPublish: '$(Build.SourcesDirectory)/artifacts/zip'
artifactName: 'Samples' artifactName: 'Samples'
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
inputs: inputs:
pathToPublish: '$(Build.SourcesDirectory)/artifacts/bin' pathToPublish: '$(Build.SourcesDirectory)/artifacts/bin'
artifactName: 'BinariesWindows' artifactName: 'BinariesWindows'
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))

6
readme.md

@ -2,9 +2,9 @@
# Avalonia # Avalonia
| Gitter Chat | Build Status | Windows Build Status | Linux/Mac Build Status | Open Collective | | Gitter Chat | Build Status (Win, Linux, OSX) | Appveyor Build Status | Open Collective |
|---|---|---|---|---| |---|---|---|---|
| [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/AvaloniaUI/Avalonia?utm_campaign=pr-badge&utm_content=badge&utm_medium=badge&utm_source=badge) | [![Build Status](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_apis/build/status/AvaloniaUI.Avalonia)](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_build/latest?definitionId=4) | [![Build status](https://ci.appveyor.com/api/projects/status/hubk3k0w9idyibfg/branch/master?svg=true)](https://ci.appveyor.com/project/AvaloniaUI/Avalonia/branch/master) | [![Build Status](https://travis-ci.org/AvaloniaUI/Avalonia.svg?branch=master)](https://travis-ci.org/AvaloniaUI/Avalonia) | [![Backers on Open Collective](https://opencollective.com/Avalonia/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/Avalonia/sponsors/badge.svg)](#sponsors) | | [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/AvaloniaUI/Avalonia?utm_campaign=pr-badge&utm_content=badge&utm_medium=badge&utm_source=badge) | [![Build Status](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_apis/build/status/AvaloniaUI.Avalonia)](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_build/latest?definitionId=4) | [![Build status](https://ci.appveyor.com/api/projects/status/hubk3k0w9idyibfg/branch/master?svg=true)](https://ci.appveyor.com/project/AvaloniaUI/Avalonia/branch/master) | [![Backers on Open Collective](https://opencollective.com/Avalonia/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/Avalonia/sponsors/badge.svg)](#sponsors) |
## About ## About

3
src/Avalonia.Base/Platform/IRuntimePlatform.cs

@ -5,10 +5,7 @@ namespace Avalonia.Platform
{ {
public interface IRuntimePlatform public interface IRuntimePlatform
{ {
Assembly[] GetLoadedAssemblies();
void PostThreadPoolItem(Action cb);
IDisposable StartSystemTimer(TimeSpan interval, Action tick); IDisposable StartSystemTimer(TimeSpan interval, Action tick);
string GetStackTrace();
RuntimePlatformInfo GetRuntimeInfo(); RuntimePlatformInfo GetRuntimeInfo();
IUnmanagedBlob AllocBlob(int size); IUnmanagedBlob AllocBlob(int size);
} }

2
src/Avalonia.Controls/AppBuilderBase.cs

@ -222,7 +222,7 @@ namespace Avalonia.Controls
private void SetupAvaloniaModules() private void SetupAvaloniaModules()
{ {
var moduleInitializers = from assembly in AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetLoadedAssemblies() var moduleInitializers = from assembly in AppDomain.CurrentDomain.GetAssemblies()
from attribute in assembly.GetCustomAttributes<ExportAvaloniaModuleAttribute>() from attribute in assembly.GetCustomAttributes<ExportAvaloniaModuleAttribute>()
where attribute.ForWindowingSubsystem == "" where attribute.ForWindowingSubsystem == ""
|| attribute.ForWindowingSubsystem == WindowingSubsystemName || attribute.ForWindowingSubsystem == WindowingSubsystemName

4
src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

@ -55,7 +55,7 @@ namespace Avalonia
LoadAssembliesInDirectory(); LoadAssembliesInDirectory();
var windowingSubsystemAttribute = (from assembly in RuntimePlatform.GetLoadedAssemblies() var windowingSubsystemAttribute = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
from attribute in assembly.GetCustomAttributes<ExportWindowingSubsystemAttribute>() from attribute in assembly.GetCustomAttributes<ExportWindowingSubsystemAttribute>()
where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker) where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker)
orderby attribute.Priority ascending orderby attribute.Priority ascending
@ -65,7 +65,7 @@ namespace Avalonia
throw new InvalidOperationException("No windowing subsystem found. Are you missing assembly references?"); throw new InvalidOperationException("No windowing subsystem found. Are you missing assembly references?");
} }
var renderingSubsystemAttribute = (from assembly in RuntimePlatform.GetLoadedAssemblies() var renderingSubsystemAttribute = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
from attribute in assembly.GetCustomAttributes<ExportRenderingSubsystemAttribute>() from attribute in assembly.GetCustomAttributes<ExportRenderingSubsystemAttribute>()
where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker) where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker)
where attribute.RequiresWindowingSubsystem == null where attribute.RequiresWindowingSubsystem == null

2
src/Avalonia.Native/AvaloniaNativePlatform.cs

@ -120,7 +120,7 @@ namespace Avalonia.Native
{ {
public AvaloniaNativeMacOptions MacOptions { get; set; } public AvaloniaNativeMacOptions MacOptions { get; set; }
public bool UseDeferredRendering { get; set; } = true; public bool UseDeferredRendering { get; set; } = true;
public bool UseGpu { get; set; } = false; public bool UseGpu { get; set; } = true;
internal AvaloniaNativeOptions(IAvaloniaNativeFactory factory) internal AvaloniaNativeOptions(IAvaloniaNativeFactory factory)
{ {
var mac = factory.GetMacOptions(); var mac = factory.GetMacOptions();

2
src/Linux/Avalonia.LinuxFramebuffer/Mice.cs

@ -22,7 +22,7 @@ namespace Avalonia.LinuxFramebuffer
_height = height; _height = height;
} }
public void Start() => AvaloniaLocator.Current.GetService<IRuntimePlatform>().PostThreadPoolItem(Worker); public void Start() => ThreadPool.UnsafeQueueUserWorkItem(_ => Worker(), null);
private void Worker() private void Worker()
{ {

4
src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaRuntimeTypeProvider.cs

@ -91,9 +91,7 @@ namespace Avalonia.Markup.Xaml.Context
private void ScanNewAssemblies() private void ScanNewAssemblies()
{ {
IEnumerable<Assembly> assemblies = AvaloniaLocator.Current IEnumerable<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies();
.GetService<IRuntimePlatform>()
?.GetLoadedAssemblies();
if (assemblies != null) if (assemblies != null)
{ {

2
src/Shared/PlatformSupport/AssetLoader.cs

@ -157,7 +157,7 @@ namespace Avalonia.Shared.PlatformSupport
AssemblyDescriptor rv; AssemblyDescriptor rv;
if (!AssemblyNameCache.TryGetValue(name, out rv)) if (!AssemblyNameCache.TryGetValue(name, out rv))
{ {
var loadedAssemblies = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetLoadedAssemblies(); var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
var match = loadedAssemblies.FirstOrDefault(a => a.GetName().Name == name); var match = loadedAssemblies.FirstOrDefault(a => a.GetName().Name == name);
if (match != null) if (match != null)
{ {

4
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -13,15 +13,11 @@ namespace Avalonia.Shared.PlatformSupport
{ {
internal partial class StandardRuntimePlatform : IRuntimePlatform internal partial class StandardRuntimePlatform : IRuntimePlatform
{ {
public void PostThreadPoolItem(Action cb) => ThreadPool.UnsafeQueueUserWorkItem(_ => cb(), null);
public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies();
public IDisposable StartSystemTimer(TimeSpan interval, Action tick) public IDisposable StartSystemTimer(TimeSpan interval, Action tick)
{ {
return new Timer(_ => tick(), null, interval, interval); return new Timer(_ => tick(), null, interval, interval);
} }
public string GetStackTrace() => Environment.StackTrace;
public IUnmanagedBlob AllocBlob(int size) => new UnmanagedBlob(this, size); public IUnmanagedBlob AllocBlob(int size) => new UnmanagedBlob(this, size);
class UnmanagedBlob : IUnmanagedBlob class UnmanagedBlob : IUnmanagedBlob

17
src/Skia/Avalonia.Skia/TypefaceCache.cs

@ -12,7 +12,7 @@ namespace Avalonia.Skia
/// </summary> /// </summary>
internal static class TypefaceCache internal static class TypefaceCache
{ {
public static SKTypeface Default = SKTypeface.FromFamilyName(FontFamily.Default.Name); public static SKTypeface Default = CreateDefaultTypeface();
static readonly Dictionary<string, Dictionary<FontKey, SKTypeface>> Cache = new Dictionary<string, Dictionary<FontKey, SKTypeface>>(); static readonly Dictionary<string, Dictionary<FontKey, SKTypeface>> Cache = new Dictionary<string, Dictionary<FontKey, SKTypeface>>();
struct FontKey struct FontKey
@ -49,6 +49,13 @@ namespace Avalonia.Skia
// Equals and GetHashCode ommitted // Equals and GetHashCode ommitted
} }
private static SKTypeface CreateDefaultTypeface()
{
var defaultTypeface = SKTypeface.FromFamilyName(FontFamily.Default.Name) ?? SKTypeface.FromFamilyName(null);
return defaultTypeface;
}
private static SKTypeface GetTypeface(string name, FontKey key) private static SKTypeface GetTypeface(string name, FontKey key)
{ {
var familyKey = name; var familyKey = name;
@ -60,12 +67,8 @@ namespace Avalonia.Skia
if (!entry.TryGetValue(key, out var typeface)) if (!entry.TryGetValue(key, out var typeface))
{ {
typeface = SKTypeface.FromFamilyName(familyKey, key.Weight, SKFontStyleWidth.Normal, key.Slant); typeface = SKTypeface.FromFamilyName(familyKey, key.Weight, SKFontStyleWidth.Normal, key.Slant)
?? Default;
if (typeface.FamilyName != name)
{
typeface = Default;
}
entry[key] = typeface; entry[key] = typeface;
} }

3
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

@ -756,9 +756,6 @@ namespace Avalonia.Win32.Interop
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
public static extern IntPtr GetModuleHandle(string lpModuleName); public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32.dll")]
public static extern uint GetCurrentThreadId();
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern int GetSystemMetrics(SystemMetric smIndex); public static extern int GetSystemMetrics(SystemMetric smIndex);

6
src/Windows/Avalonia.Win32/Win32Platform.cs

@ -42,7 +42,7 @@ namespace Avalonia.Win32
class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader
{ {
private static readonly Win32Platform s_instance = new Win32Platform(); private static readonly Win32Platform s_instance = new Win32Platform();
private static uint _uiThread; private static Thread _uiThread;
private UnmanagedMethods.WndProc _wndProcDelegate; private UnmanagedMethods.WndProc _wndProcDelegate;
private IntPtr _hwnd; private IntPtr _hwnd;
private readonly List<Delegate> _delegates = new List<Delegate>(); private readonly List<Delegate> _delegates = new List<Delegate>();
@ -82,7 +82,7 @@ namespace Avalonia.Win32
.Bind<IPlatformIconLoader>().ToConstant(s_instance); .Bind<IPlatformIconLoader>().ToConstant(s_instance);
Win32GlManager.Initialize(); Win32GlManager.Initialize();
UseDeferredRendering = deferredRendering; UseDeferredRendering = deferredRendering;
_uiThread = UnmanagedMethods.GetCurrentThreadId(); _uiThread = Thread.CurrentThread;
if (OleContext.Current != null) if (OleContext.Current != null)
AvaloniaLocator.CurrentMutable.Bind<IPlatformDragSource>().ToSingleton<DragSource>(); AvaloniaLocator.CurrentMutable.Bind<IPlatformDragSource>().ToSingleton<DragSource>();
@ -146,7 +146,7 @@ namespace Avalonia.Win32
new IntPtr(SignalL)); new IntPtr(SignalL));
} }
public bool CurrentThreadIsLoopThread => _uiThread == UnmanagedMethods.GetCurrentThreadId(); public bool CurrentThreadIsLoopThread => _uiThread == Thread.CurrentThread;
public event Action<DispatcherPriority?> Signaled; public event Action<DispatcherPriority?> Signaled;

Loading…
Cancel
Save