Skip to content

Commit 4a386d5

Browse files
committed
Change rgb SetConvertedChannels extension to use ColorRGB explicitly
1 parent d96d8e6 commit 4a386d5

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

AssetRipper.TextureDecoder/Dxt/DxtDecoder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static int DecompressDXT3<TOutputColor, TOutputChannel>(ReadOnlySpan<byte
245245
uint d = ToUInt32(input, offset + 12);
246246
for (int i = 0; i < 16; i++, d >>= 2)
247247
{
248-
buffer[i].SetConvertedChannels<TOutputColor, TOutputChannel, ColorRGB<byte>, byte>(colors[unchecked((int)(d & 3))], alphas[i]);
248+
buffer[i].SetConvertedChannels<TOutputColor, TOutputChannel, byte>(colors[unchecked((int)(d & 3))], alphas[i]);
249249
}
250250

251251
int clen = s < bcw - 1 ? 4 : clen_last;
@@ -348,8 +348,8 @@ public static int DecompressDXT5<TOutputColor, TOutputChannel>(ReadOnlySpan<byte
348348
for (int s = 0; s < bcw; s++, offset += 16)
349349
{
350350
byte a0 = input[offset + 0];
351-
byte a1 = input[offset + 1];
352-
alphas[0] = a0;
351+
byte a1 = input[offset + 1];
352+
alphas[0] = a0;
353353
alphas[1] = a1;
354354
if (a0 > a1)
355355
{
@@ -391,7 +391,7 @@ public static int DecompressDXT5<TOutputColor, TOutputChannel>(ReadOnlySpan<byte
391391
uint dc = ToUInt32(input, offset + 12);
392392
for (int i = 0; i < 16; i++, da >>= 3, dc >>= 2)
393393
{
394-
buffer[i].SetConvertedChannels<TOutputColor, TOutputChannel, ColorRGB<byte>, byte>(colors[unchecked((int)(dc & 3))], alphas[unchecked((int)(da & 7))]);
394+
buffer[i].SetConvertedChannels<TOutputColor, TOutputChannel, byte>(colors[unchecked((int)(dc & 3))], alphas[unchecked((int)(da & 7))]);
395395
}
396396

397397
int clen = s < bcw - 1 ? 4 : clen_last;

AssetRipper.TextureDecoder/Rgb/Color.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ internal static void SetConvertedChannels<TThis, TThisChannel, TSourceChannel>(t
5555
}
5656

5757
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
58-
internal static void SetConvertedChannels<TThis, TThisChannel, TSourceColor, TSourceChannel>(this ref TThis color, TSourceColor rgb, TSourceChannel a)
58+
internal static void SetConvertedChannels<TThis, TThisChannel, TSourceChannel>(this ref TThis color, ColorRGB<TSourceChannel> rgb, TSourceChannel a)
5959
where TThisChannel : unmanaged
60-
where TSourceChannel : unmanaged
60+
where TSourceChannel : unmanaged, INumberBase<TSourceChannel>, IMinMaxValue<TSourceChannel>
6161
where TThis : unmanaged, IColor<TThisChannel>
62-
where TSourceColor : unmanaged, IColor<TSourceChannel>
6362
{
6463
color.SetChannels(
6564
NumericConversion.Convert<TSourceChannel, TThisChannel>(rgb.R),

0 commit comments

Comments
 (0)