Remove Fody and ImageSharp hack.

They have a public method for this...
This commit is contained in:
Pieter-Jan Briers
2020-07-20 01:09:06 +02:00
parent 808bbeb71c
commit e68c5b47e7
4 changed files with 9 additions and 17 deletions

View File

@@ -1,3 +0,0 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<InlineIL />
</Weavers>

View File

@@ -26,8 +26,6 @@
<PackageReference Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" />
<PackageReference Include="OpenToolkit.OpenAL" Version="4.0.0-pre9.1" />
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" />
<PackageReference Include="Fody" Version="6.2.0" PrivateAssets="All" />
<PackageReference Include="InlineIL.Fody" Version="1.4.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(EnableClientScripting)' == 'True'">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="3.5.0" />

View File

@@ -1,9 +1,6 @@
using System;
using InlineIL;
using Robust.Shared.Maths;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using Color = Robust.Shared.Maths.Color;
@@ -65,13 +62,15 @@ namespace Robust.Client.Utility
/// Gets a <see cref="T:System.Span`1" /> to the backing data if the backing group consists of a single contiguous memory buffer.
/// </summary>
/// <returns>The <see cref="T:System.Span`1" /> referencing the memory area.</returns>
/// <exception cref="ArgumentException">Thrown if the image is not a single contiguous buffer.</exception>
public static Span<T> GetPixelSpan<T>(this Image<T> image) where T : unmanaged, IPixel<T>
{
IL.Push(image.Frames.RootFrame);
IL.Emit.Call(new MethodRef(typeof(ImageFrame<T>), "get_PixelBuffer"));
IL.Emit.Call(new MethodRef(typeof(Buffer2D<T>), "GetSingleSpan"));
IL.Emit.Ret();
throw IL.Unreachable();
if (!image.TryGetSinglePixelSpan(out var span))
{
throw new ArgumentException("Image is not backed by a single buffer, cannot fetch span.");
}
return span;
}
}
}

View File

@@ -1,7 +1,4 @@
using System.Runtime.CompilerServices;
[assembly: IgnoresAccessChecksTo("SixLabors.ImageSharp")]
// ReSharper disable once CheckNamespace
namespace System.Runtime.CompilerServices {
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
@@ -11,6 +8,7 @@ namespace System.Runtime.CompilerServices {
private readonly string assemblyName;
// ReSharper disable once ConvertToAutoProperty
// ReSharper disable once UnusedMember.Global
public string AssemblyName
=> assemblyName;