More spans

This commit is contained in:
VaDiM
2025-08-08 19:00:08 +03:00
parent 35324083e1
commit 054906a426
6 changed files with 120 additions and 110 deletions

View File

@ -8,6 +8,10 @@
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AssetStudio.PInvoke\AssetStudio.PInvoke.csproj" />
</ItemGroup>

View File

@ -16,7 +16,7 @@ namespace Texture2DDecoder
}
#endif
public static bool DecodeDXT1(byte[] data, int width, int height, byte[] image)
public static bool DecodeDXT1(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -27,7 +27,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeDXT5(byte[] data, int width, int height, byte[] image)
public static bool DecodeDXT5(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -38,7 +38,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodePVRTC(byte[] data, int width, int height, byte[] image, bool is2bpp)
public static bool DecodePVRTC(ReadOnlySpan<byte> data, int width, int height, Span<byte> image, bool is2bpp)
{
fixed (byte* pData = data)
{
@ -49,7 +49,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeETC1(byte[] data, int width, int height, byte[] image)
public static bool DecodeETC1(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -60,7 +60,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeETC2(byte[] data, int width, int height, byte[] image)
public static bool DecodeETC2(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -71,7 +71,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeETC2A1(byte[] data, int width, int height, byte[] image)
public static bool DecodeETC2A1(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -82,7 +82,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeETC2A8(byte[] data, int width, int height, byte[] image)
public static bool DecodeETC2A8(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -93,7 +93,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeEACR(byte[] data, int width, int height, byte[] image)
public static bool DecodeEACR(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -104,7 +104,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeEACRSigned(byte[] data, int width, int height, byte[] image)
public static bool DecodeEACRSigned(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -115,7 +115,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeEACRG(byte[] data, int width, int height, byte[] image)
public static bool DecodeEACRG(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -126,7 +126,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeEACRGSigned(byte[] data, int width, int height, byte[] image)
public static bool DecodeEACRGSigned(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -137,7 +137,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeBC4(byte[] data, int width, int height, byte[] image)
public static bool DecodeBC4(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -148,7 +148,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeBC5(byte[] data, int width, int height, byte[] image)
public static bool DecodeBC5(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -159,7 +159,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeBC6(byte[] data, int width, int height, byte[] image)
public static bool DecodeBC6(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -170,7 +170,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeBC7(byte[] data, int width, int height, byte[] image)
public static bool DecodeBC7(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -181,7 +181,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeATCRGB4(byte[] data, int width, int height, byte[] image)
public static bool DecodeATCRGB4(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -192,7 +192,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeATCRGBA8(byte[] data, int width, int height, byte[] image)
public static bool DecodeATCRGBA8(ReadOnlySpan<byte> data, int width, int height, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -203,7 +203,7 @@ namespace Texture2DDecoder
}
}
public static bool DecodeASTC(byte[] data, int width, int height, int blockWidth, int blockHeight, byte[] image)
public static bool DecodeASTC(ReadOnlySpan<byte> data, int width, int height, int blockWidth, int blockHeight, Span<byte> image)
{
fixed (byte* pData = data)
{
@ -214,7 +214,7 @@ namespace Texture2DDecoder
}
}
public static byte[] UnpackCrunch(byte[] data)
public static byte[] UnpackCrunch(ReadOnlySpan<byte> data)
{
void* pBuffer;
uint bufferSize;
@ -238,7 +238,7 @@ namespace Texture2DDecoder
return result;
}
public static byte[] UnpackUnityCrunch(byte[] data)
public static byte[] UnpackUnityCrunch(ReadOnlySpan<byte> data)
{
void* pBuffer;
uint bufferSize;
@ -261,6 +261,5 @@ namespace Texture2DDecoder
return result;
}
}
}