mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.0 KiB
71 lines
2.0 KiB
using System.Numerics;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion
|
|
{
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
struct TestRgba : ITestPixel<TestRgba>
|
|
{
|
|
public byte R, G, B, A;
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public void FromRgba32(Rgba32 source)
|
|
{
|
|
this = Unsafe.As<Rgba32, TestRgba>(ref source);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public void FromRgba32(ref Rgba32 source)
|
|
{
|
|
this = Unsafe.As<Rgba32, TestRgba>(ref source);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public void FromBytes(byte r, byte g, byte b, byte a)
|
|
{
|
|
this.R = r;
|
|
this.G = g;
|
|
this.B = b;
|
|
this.A = a;
|
|
}
|
|
|
|
public void FromVector4(Vector4 source)
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
public void FromVector4(ref Vector4 source)
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public Rgba32 ToRgba32()
|
|
{
|
|
return Unsafe.As<TestRgba, Rgba32>(ref this);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public void CopyToRgba32(ref Rgba32 dest)
|
|
{
|
|
dest = Unsafe.As<TestRgba, Rgba32>(ref this);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public Vector4 ToVector4()
|
|
{
|
|
return new Vector4(this.R, this.G, this.B, this.A) * new Vector4(1f / 255f);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public void CopyToVector4(ref Vector4 dest)
|
|
{
|
|
var tmp = new Vector4(this.R, this.G, this.B, this.A);
|
|
tmp *= new Vector4(1f / 255f);
|
|
dest = tmp;
|
|
}
|
|
}
|
|
}
|