mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-04-16 17:11:49 +00:00
* dotnet format style --severity info Some changes were manually reverted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0059 warnings * Address or silence dotnet format CA2208 warnings * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Address IDE0251 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Address review feedback * Update src/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.Intrinsics;
|
|
using System.Runtime.Intrinsics.X86;
|
|
|
|
namespace Ryujinx.Graphics.Texture.Utils
|
|
{
|
|
struct RgbaColor8 : IEquatable<RgbaColor8>
|
|
{
|
|
public byte R;
|
|
public byte G;
|
|
public byte B;
|
|
public byte A;
|
|
|
|
public RgbaColor8(byte r, byte g, byte b, byte a)
|
|
{
|
|
R = r;
|
|
G = g;
|
|
B = b;
|
|
A = a;
|
|
}
|
|
|
|
public static RgbaColor8 FromUInt32(uint color)
|
|
{
|
|
return Unsafe.As<uint, RgbaColor8>(ref color);
|
|
}
|
|
|
|
public static bool operator ==(RgbaColor8 x, RgbaColor8 y)
|
|
{
|
|
return x.Equals(y);
|
|
}
|
|
|
|
public static bool operator !=(RgbaColor8 x, RgbaColor8 y)
|
|
{
|
|
return !x.Equals(y);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public RgbaColor32 GetColor32()
|
|
{
|
|
if (Sse41.IsSupported)
|
|
{
|
|
Vector128<byte> color = Vector128.CreateScalarUnsafe(Unsafe.As<RgbaColor8, uint>(ref this)).AsByte();
|
|
return new RgbaColor32(Sse41.ConvertToVector128Int32(color));
|
|
}
|
|
else
|
|
{
|
|
return new RgbaColor32(R, G, B, A);
|
|
}
|
|
}
|
|
|
|
public uint ToUInt32()
|
|
{
|
|
return Unsafe.As<RgbaColor8, uint>(ref this);
|
|
}
|
|
|
|
public readonly override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(R, G, B, A);
|
|
}
|
|
|
|
public readonly override bool Equals(object obj)
|
|
{
|
|
return obj is RgbaColor8 other && Equals(other);
|
|
}
|
|
|
|
public readonly bool Equals(RgbaColor8 other)
|
|
{
|
|
return R == other.R && G == other.G && B == other.B && A == other.A;
|
|
}
|
|
|
|
public readonly byte GetComponent(int index)
|
|
{
|
|
return index switch
|
|
{
|
|
0 => R,
|
|
1 => G,
|
|
2 => B,
|
|
3 => A,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
|
};
|
|
}
|
|
}
|
|
}
|