committed by
GitHub
13 changed files with 225 additions and 75 deletions
@ -1,6 +1,4 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" /> |
|||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,42 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.DotNet.PlatformAbstractions; |
|||
using Microsoft.Extensions.DependencyModel; |
|||
|
|||
namespace Avalonia.Shared.PlatformSupport |
|||
{ |
|||
internal partial class StandardRuntimePlatform |
|||
{ |
|||
private static readonly Lazy<Assembly[]> Assemblies = new Lazy<Assembly[]>(LoadAssemblies); |
|||
public Assembly[] GetLoadedAssemblies() => Assemblies.Value; |
|||
|
|||
static Assembly[] LoadAssemblies() |
|||
{ |
|||
var assemblies = new List<Assembly>(); |
|||
// Mostly copy-pasted from (MIT):
|
|||
// https://github.com/StefH/System.AppDomain.Core/blob/0b35e676c2721aa367b96e62eb52c97ee0b43a70/src/System.AppDomain.NetCoreApp/AppDomain.cs
|
|||
|
|||
foreach (var assemblyName in |
|||
DependencyContext.Default.GetRuntimeAssemblyNames(RuntimeEnvironment.GetRuntimeIdentifier())) |
|||
{ |
|||
try |
|||
{ |
|||
var assembly = Assembly.Load(assemblyName); |
|||
// just load all types and skip this assembly if one or more types cannot be resolved
|
|||
assembly.DefinedTypes.ToArray(); |
|||
assemblies.Add(assembly); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Debug.Write(ex.Message); |
|||
} |
|||
} |
|||
return assemblies.ToArray(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Gtk3.Interop |
|||
{ |
|||
class ManagedCairoSurface : IDisposable |
|||
{ |
|||
public IntPtr Buffer { get; private set; } |
|||
public CairoSurface Surface { get; private set; } |
|||
public int Stride { get; private set; } |
|||
private int _size; |
|||
private IRuntimePlatform _plat; |
|||
private IUnmanagedBlob _blob; |
|||
|
|||
public ManagedCairoSurface(int width, int height) |
|||
{ |
|||
_plat = AvaloniaLocator.Current.GetService<IRuntimePlatform>(); |
|||
Stride = width * 4; |
|||
_size = height * Stride; |
|||
_blob = _plat.AllocBlob(_size * 2); |
|||
Buffer = _blob.Address; |
|||
Surface = Native.CairoImageSurfaceCreateForData(Buffer, 1, width, height, Stride); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
|
|||
if (Buffer != IntPtr.Zero) |
|||
{ |
|||
Surface.Dispose(); |
|||
_blob.Dispose(); |
|||
Buffer = IntPtr.Zero; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue