@@ -6,14 +6,14 @@ namespace AssetRipper.TextureDecoder.Tests;
66
77public sealed class EtcTests
88{
9- private static DecodingDelegate ETCDelegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressETC ( data , width , height , out decompressedData ) ;
10- private static DecodingDelegate ETC2Delegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressETC2 ( data , width , height , out decompressedData ) ;
11- private static DecodingDelegate ETC2A1Delegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressETC2A1 ( data , width , height , out decompressedData ) ;
12- private static DecodingDelegate ETC2A8Delegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressETC2A8 ( data , width , height , out decompressedData ) ;
13- private static DecodingDelegate EACRSignedDelegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressEACRSigned ( data , width , height , out decompressedData ) ;
14- private static DecodingDelegate EACRUnsignedDelegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressEACRUnsigned ( data , width , height , out decompressedData ) ;
15- private static DecodingDelegate EACRGSignedDelegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressEACRGSigned ( data , width , height , out decompressedData ) ;
16- private static DecodingDelegate EACRGUnsignedDelegate { get ; } = ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) => EtcDecoder . DecompressEACRGUnsigned ( data , width , height , out decompressedData ) ;
9+ private static DecodingDelegate ETCDelegate { get ; } = EtcDecoder . DecompressETC < ColorBGRA32 , byte > ;
10+ private static DecodingDelegate ETC2Delegate { get ; } = EtcDecoder . DecompressETC2 < ColorBGRA32 , byte > ;
11+ private static DecodingDelegate ETC2A1Delegate { get ; } = EtcDecoder . DecompressETC2A1 < ColorBGRA32 , byte > ;
12+ private static DecodingDelegate ETC2A8Delegate { get ; } = EtcDecoder . DecompressETC2A8 < ColorBGRA32 , byte > ;
13+ private static DecodingDelegate EACRSignedDelegate { get ; } = EtcDecoder . DecompressEACRSigned < ColorBGRA32 , byte > ;
14+ private static DecodingDelegate EACRUnsignedDelegate { get ; } = EtcDecoder . DecompressEACRUnsigned < ColorBGRA32 , byte > ;
15+ private static DecodingDelegate EACRGSignedDelegate { get ; } = EtcDecoder . DecompressEACRGSigned < ColorBGRA32 , byte > ;
16+ private static DecodingDelegate EACRGUnsignedDelegate { get ; } = EtcDecoder . DecompressEACRGUnsigned < ColorBGRA32 , byte > ;
1717
1818 [ Test ]
1919 public void DecompressETCTest ( ) => AssertCorrectByteCountReadFor256SquareWithMips ( TestFileFolders . EtcTestFiles + "test.etc" , ETCDelegate ) ;
@@ -57,15 +57,15 @@ public sealed class EtcTests
5757 [ Test ]
5858 public void CorrectnessEACRGUnsignedTest ( ) => AssertCorrectDecompression < AndroidTextures . Logo_15 , ColorRG < byte > > ( EACRGUnsignedDelegate , .1 , .6 ) ;
5959
60- private delegate int DecodingDelegate ( ArraySegment < byte > data , int width , int height , out byte [ ] decompressedData ) ;
60+ private delegate int DecodingDelegate ( ReadOnlySpan < byte > data , int width , int height , out byte [ ] decompressedData ) ;
6161
6262 private static void AssertCorrectByteCountReadFor256SquareWithMips ( string path , DecodingDelegate decoder )
6363 {
6464 byte [ ] data = File . ReadAllBytes ( path ) ;
6565 int totalBytesRead = 0 ;
6666 foreach ( int size in new int [ ] { 256 , 128 , 64 , 32 , 16 , 8 , 4 , 2 , 1 } ) //mip maps
6767 {
68- int bytesRead = decoder . Invoke ( new ArraySegment < byte > ( data , totalBytesRead , data . Length - totalBytesRead ) , size , size , out _ ) ;
68+ int bytesRead = decoder . Invoke ( new ReadOnlySpan < byte > ( data , totalBytesRead , data . Length - totalBytesRead ) , size , size , out _ ) ;
6969 totalBytesRead += bytesRead ;
7070 }
7171 Assert . That ( totalBytesRead , Is . EqualTo ( data . Length ) ) ;
@@ -79,7 +79,7 @@ private static void AssertCorrectDecompression<T>(DecodingDelegate decoder, doub
7979 private static void AssertCorrectDecompression < TTexture , TColor > ( DecodingDelegate decoder , double maxMeanDeviation , double maxStandardDeviation ) where TTexture : ITexture where TColor : unmanaged, IColor < TColor , byte >
8080 {
8181 byte [ ] data = TTexture . Data ;
82- int bytesRead = decoder . Invoke ( new ArraySegment < byte > ( data ) , TTexture . Width , TTexture . Height , out byte [ ] decompressedData ) ;
82+ int bytesRead = decoder . Invoke ( new ReadOnlySpan < byte > ( data ) , TTexture . Width , TTexture . Height , out byte [ ] decompressedData ) ;
8383 if ( ! TTexture . Mips )
8484 {
8585 Assert . That ( bytesRead , Is . EqualTo ( data . Length ) ) ;
0 commit comments