Skip to content

Commit d496a13

Browse files
committed
Rename type parameters
1 parent 850f7f3 commit d496a13

3 files changed

Lines changed: 57 additions & 57 deletions

File tree

AssetRipper.TextureDecoder/Rgb/IColor.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,24 @@ public interface IColor<T> where T : unmanaged
6969
public static class ColorExtensions
7070
{
7171
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
72-
internal static void SetConvertedChannels<TThis, TThisArg, TSourceArg>(this ref TThis color, TSourceArg r, TSourceArg g, TSourceArg b, TSourceArg a)
73-
where TThisArg : unmanaged
74-
where TSourceArg : unmanaged
75-
where TThis : unmanaged, IColor<TThisArg>
72+
internal static void SetConvertedChannels<TThis, TThisChannel, TSourceChannel>(this ref TThis color, TSourceChannel r, TSourceChannel g, TSourceChannel b, TSourceChannel a)
73+
where TThisChannel : unmanaged
74+
where TSourceChannel : unmanaged
75+
where TThis : unmanaged, IColor<TThisChannel>
7676
{
7777
color.SetChannels(
78-
NumericConversion.Convert<TSourceArg, TThisArg>(r),
79-
NumericConversion.Convert<TSourceArg, TThisArg>(g),
80-
NumericConversion.Convert<TSourceArg, TThisArg>(b),
81-
NumericConversion.Convert<TSourceArg, TThisArg>(a));
78+
NumericConversion.Convert<TSourceChannel, TThisChannel>(r),
79+
NumericConversion.Convert<TSourceChannel, TThisChannel>(g),
80+
NumericConversion.Convert<TSourceChannel, TThisChannel>(b),
81+
NumericConversion.Convert<TSourceChannel, TThisChannel>(a));
8282
}
8383

8484
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
85-
public static TTarget Convert<TThis, TThisArg, TTarget, TTargetArg>(this TThis color)
86-
where TThisArg : unmanaged
87-
where TTargetArg : unmanaged
88-
where TThis : unmanaged, IColor<TThisArg>
89-
where TTarget : unmanaged, IColor<TTargetArg>
85+
public static TTarget Convert<TThis, TThisChannel, TTarget, TTargetChannel>(this TThis color)
86+
where TThisChannel : unmanaged
87+
where TTargetChannel : unmanaged
88+
where TThis : unmanaged, IColor<TThisChannel>
89+
where TTarget : unmanaged, IColor<TTargetChannel>
9090
{
9191
if (typeof(TThis) == typeof(TTarget))
9292
{
@@ -95,8 +95,8 @@ public static TTarget Convert<TThis, TThisArg, TTarget, TTargetArg>(this TThis c
9595
else
9696
{
9797
TTarget destination = default;
98-
color.GetChannels(out TThisArg r, out TThisArg g, out TThisArg b, out TThisArg a);
99-
destination.SetConvertedChannels<TTarget, TTargetArg, TThisArg>(r, g, b, a);
98+
color.GetChannels(out TThisChannel r, out TThisChannel g, out TThisChannel b, out TThisChannel a);
99+
destination.SetConvertedChannels<TTarget, TTargetChannel, TThisChannel>(r, g, b, a);
100100
return destination;
101101
}
102102
}

AssetRipper.TextureDecoder/Rgb/RgbConverter.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -487,39 +487,39 @@ public static int RGBA64ToBGRA32(ReadOnlySpan<byte> input, int width, int height
487487
}
488488

489489
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
490-
public static int Convert<TSource, TSourceArg, TDestination, TDestinationArg>(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
491-
where TSourceArg : unmanaged
492-
where TSource : unmanaged, IColor<TSourceArg>
493-
where TDestinationArg : unmanaged
494-
where TDestination : unmanaged, IColor<TDestinationArg>
490+
public static int Convert<TSourceColor, TSourceChannel, TDestinationColor, TDestinationChannel>(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
491+
where TSourceChannel : unmanaged
492+
where TSourceColor : unmanaged, IColor<TSourceChannel>
493+
where TDestinationChannel : unmanaged
494+
where TDestinationColor : unmanaged, IColor<TDestinationChannel>
495495
{
496-
output = new byte[width * height * Unsafe.SizeOf<TDestination>()];
497-
return Convert<TSource, TSourceArg, TDestination, TDestinationArg>(input, width, height, output);
496+
output = new byte[width * height * Unsafe.SizeOf<TDestinationColor>()];
497+
return Convert<TSourceColor, TSourceChannel, TDestinationColor, TDestinationChannel>(input, width, height, output);
498498
}
499499

500500
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
501-
public static int Convert<TSource, TSourceArg, TDestination, TDestinationArg>(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
502-
where TSourceArg : unmanaged
503-
where TSource : unmanaged, IColor<TSourceArg>
504-
where TDestinationArg : unmanaged
505-
where TDestination : unmanaged, IColor<TDestinationArg>
501+
public static int Convert<TSourceColor, TSourceChannel, TDestinationColor, TDestinationChannel>(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
502+
where TSourceChannel : unmanaged
503+
where TSourceColor : unmanaged, IColor<TSourceChannel>
504+
where TDestinationChannel : unmanaged
505+
where TDestinationColor : unmanaged, IColor<TDestinationChannel>
506506
{
507-
ReadOnlySpan<TSource> sourceSpan = MemoryMarshal.Cast<byte, TSource>(input).Slice(0, width * height);
508-
Span<TDestination> destinationSpan = MemoryMarshal.Cast<byte, TDestination>(output).Slice(0, width * height);
509-
Convert<TSource, TSourceArg, TDestination, TDestinationArg>(sourceSpan, destinationSpan);
510-
return width * height * Unsafe.SizeOf<TSource>();
507+
ReadOnlySpan<TSourceColor> sourceSpan = MemoryMarshal.Cast<byte, TSourceColor>(input).Slice(0, width * height);
508+
Span<TDestinationColor> destinationSpan = MemoryMarshal.Cast<byte, TDestinationColor>(output).Slice(0, width * height);
509+
Convert<TSourceColor, TSourceChannel, TDestinationColor, TDestinationChannel>(sourceSpan, destinationSpan);
510+
return width * height * Unsafe.SizeOf<TSourceColor>();
511511
}
512512

513513
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
514-
public static void Convert<TSource, TSourceArg, TDestination, TDestinationArg>(ReadOnlySpan<TSource> sourceSpan, Span<TDestination> destinationSpan)
515-
where TSourceArg : unmanaged
516-
where TSource : unmanaged, IColor<TSourceArg>
517-
where TDestinationArg : unmanaged
518-
where TDestination : unmanaged, IColor<TDestinationArg>
514+
public static void Convert<TSourceColor, TSourceChannel, TDestinationColor, TDestinationChannel>(ReadOnlySpan<TSourceColor> sourceSpan, Span<TDestinationColor> destinationSpan)
515+
where TSourceChannel : unmanaged
516+
where TSourceColor : unmanaged, IColor<TSourceChannel>
517+
where TDestinationChannel : unmanaged
518+
where TDestinationColor : unmanaged, IColor<TDestinationChannel>
519519
{
520520
for (int i = 0; i < sourceSpan.Length; i++)
521521
{
522-
destinationSpan[i] = sourceSpan[i].Convert<TSource, TSourceArg, TDestination, TDestinationArg>();
522+
destinationSpan[i] = sourceSpan[i].Convert<TSourceColor, TSourceChannel, TDestinationColor, TDestinationChannel>();
523523
}
524524
}
525525

AssetRipper.TextureDecoder/Yuy2/Yuy2Decoder.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,54 +65,54 @@ public static int DecompressYUY2(ReadOnlySpan<byte> input, int width, int height
6565
/// <summary>
6666
/// Decompress a YUY2 image
6767
/// </summary>
68-
/// <typeparam name="TOutput"></typeparam>
69-
/// <typeparam name="TOutputArg"></typeparam>
68+
/// <typeparam name="TOutputColor"></typeparam>
69+
/// <typeparam name="TOutputChannel"></typeparam>
7070
/// <param name="input">Input buffer containing the compressed image.</param>
7171
/// <param name="width">Pixel width of the image.</param>
7272
/// <param name="height">Pixel height of the image.</param>
7373
/// <param name="output">An output buffer. Must be at least width * height * pixelSize.</param>
7474
/// <returns>Number of bytes read from <paramref name="input"/></returns>
7575
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
76-
public static int DecompressYUY2<TOutput, TOutputArg>(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
77-
where TOutputArg : unmanaged
78-
where TOutput : unmanaged, IColor<TOutputArg>
76+
public static int DecompressYUY2<TOutputColor, TOutputChannel>(ReadOnlySpan<byte> input, int width, int height, out byte[] output)
77+
where TOutputChannel : unmanaged
78+
where TOutputColor : unmanaged, IColor<TOutputChannel>
7979
{
80-
output = new byte[width * height * Unsafe.SizeOf<TOutput>()];
81-
return DecompressYUY2<TOutput, TOutputArg>(input, width, height, output);
80+
output = new byte[width * height * Unsafe.SizeOf<TOutputColor>()];
81+
return DecompressYUY2<TOutputColor, TOutputChannel>(input, width, height, output);
8282
}
8383

8484
/// <summary>
8585
/// Decompress a YUY2 image
8686
/// </summary>
87-
/// <typeparam name="TOutput"></typeparam>
88-
/// <typeparam name="TOutputArg"></typeparam>
87+
/// <typeparam name="TOutputColor"></typeparam>
88+
/// <typeparam name="TOutputChannel"></typeparam>
8989
/// <param name="input">Input buffer containing the compressed image.</param>
9090
/// <param name="width">Pixel width of the image.</param>
9191
/// <param name="height">Pixel height of the image.</param>
9292
/// <param name="output">An output buffer. Must be at least width * height * pixelSize.</param>
9393
/// <returns>Number of bytes read from <paramref name="input"/></returns>
9494
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
95-
public static int DecompressYUY2<TOutput, TOutputArg>(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
96-
where TOutputArg : unmanaged
97-
where TOutput : unmanaged, IColor<TOutputArg>
95+
public static int DecompressYUY2<TOutputColor, TOutputChannel>(ReadOnlySpan<byte> input, int width, int height, Span<byte> output)
96+
where TOutputChannel : unmanaged
97+
where TOutputColor : unmanaged, IColor<TOutputChannel>
9898
{
99-
return DecompressYUY2<TOutput, TOutputArg>(input, width, height, MemoryMarshal.Cast<byte, TOutput>(output));
99+
return DecompressYUY2<TOutputColor, TOutputChannel>(input, width, height, MemoryMarshal.Cast<byte, TOutputColor>(output));
100100
}
101101

102102
/// <summary>
103103
/// Decompress a YUY2 image
104104
/// </summary>
105-
/// <typeparam name="TOutput"></typeparam>
106-
/// <typeparam name="TOutputArg"></typeparam>
105+
/// <typeparam name="TOutputColor"></typeparam>
106+
/// <typeparam name="TOutputChannel"></typeparam>
107107
/// <param name="input">Input buffer containing the compressed image.</param>
108108
/// <param name="width">Pixel width of the image.</param>
109109
/// <param name="height">Pixel height of the image.</param>
110110
/// <param name="output">An output buffer. Must be at least width * height.</param>
111111
/// <returns>Number of bytes read from <paramref name="input"/></returns>
112112
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
113-
public static int DecompressYUY2<TOutput, TOutputArg>(ReadOnlySpan<byte> input, int width, int height, Span<TOutput> output)
114-
where TOutputArg : unmanaged
115-
where TOutput : unmanaged, IColor<TOutputArg>
113+
public static int DecompressYUY2<TOutputColor, TOutputChannel>(ReadOnlySpan<byte> input, int width, int height, Span<TOutputColor> output)
114+
where TOutputChannel : unmanaged
115+
where TOutputColor : unmanaged, IColor<TOutputChannel>
116116
{
117117
ThrowHelper.ThrowIfNotEnoughSpace(output.Length, width * height);
118118

@@ -133,12 +133,12 @@ public static int DecompressYUY2<TOutput, TOutputArg>(ReadOnlySpan<byte> input,
133133
byte b0 = ClampByte((298 * c + 516 * d + 128) >> 8); // blue
134134
byte g0 = ClampByte((298 * c - 100 * d - 208 * e + 128) >> 8); // green
135135
byte r0 = ClampByte((298 * c + 409 * e + 128) >> 8); // red
136-
output[o++].SetConvertedChannels<TOutput, TOutputArg, byte>(r0, g0, b0, byte.MaxValue);
136+
output[o++].SetConvertedChannels<TOutputColor, TOutputChannel, byte>(r0, g0, b0, byte.MaxValue);
137137
c = y1 - 16;
138138
byte b1 = ClampByte((298 * c + 516 * d + 128) >> 8); // blue
139139
byte g1 = ClampByte((298 * c - 100 * d - 208 * e + 128) >> 8); // green
140140
byte r1 = ClampByte((298 * c + 409 * e + 128) >> 8); // red
141-
output[o++].SetConvertedChannels<TOutput, TOutputArg, byte>(r1, g1, b1, byte.MaxValue);
141+
output[o++].SetConvertedChannels<TOutputColor, TOutputChannel, byte>(r1, g1, b1, byte.MaxValue);
142142
}
143143
}
144144

0 commit comments

Comments
 (0)