Skip to content

Commit c578ab2

Browse files
committed
Remove ColorRGB32Half
* Related: #17
1 parent 699e437 commit c578ab2

File tree

10 files changed

+96
-448
lines changed

10 files changed

+96
-448
lines changed

AssetRipper.TextureDecoder.ColorGenerator/Program.cs

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using AssetRipper.Text.SourceGeneration;
2-
using AssetRipper.TextureDecoder.SourceGeneration.Common;
2+
using AssetRipper.TextureDecoder.SourceGeneration.Common;
33
using System.CodeDom.Compiler;
4-
using System.Text;
5-
4+
using System.Text;
5+
66
namespace AssetRipper.TextureDecoder.ColorGenerator;
77

88
internal static partial class Program
@@ -22,7 +22,6 @@ internal static partial class Program
2222
( "ColorRGB16", typeof(byte), true, true, true, false, false ),
2323
( "ColorRGB9e5", typeof(double), true, true, true, false, false ),
2424
( "ColorRGBA16", typeof(byte), true, true, true, true, false ),
25-
( "ColorRGB32Half", typeof(Half), true, true, true, false, false ),
2625
};
2726

2827
/// <summary>
@@ -97,43 +96,43 @@ private static void WriteToString(IndentedTextWriter writer, bool hasRed, bool h
9796
{
9897
writer.WriteLine("public override string ToString()");
9998
using (new CurlyBrackets(writer))
100-
{
101-
StringBuilder sb = new();
102-
sb.Append("return $\"{{ ");
103-
bool first = true;
104-
if (hasRed)
105-
{
106-
sb.Append("R: {R}");
107-
first = false;
108-
}
109-
if (hasGreen)
110-
{
111-
if (!first)
112-
{
113-
sb.Append(", ");
114-
}
115-
sb.Append("G: {G}");
116-
first = false;
117-
}
118-
if (hasBlue)
119-
{
120-
if (!first)
121-
{
122-
sb.Append(", ");
123-
}
124-
sb.Append("B: {B}");
125-
first = false;
126-
}
127-
if (hasAlpha)
128-
{
129-
if (!first)
130-
{
131-
sb.Append(", ");
132-
}
133-
sb.Append("A: {A}");
134-
}
135-
sb.Append(" }}\";");
136-
writer.WriteLine(sb.ToString());
99+
{
100+
StringBuilder sb = new();
101+
sb.Append("return $\"{{ ");
102+
bool first = true;
103+
if (hasRed)
104+
{
105+
sb.Append("R: {R}");
106+
first = false;
107+
}
108+
if (hasGreen)
109+
{
110+
if (!first)
111+
{
112+
sb.Append(", ");
113+
}
114+
sb.Append("G: {G}");
115+
first = false;
116+
}
117+
if (hasBlue)
118+
{
119+
if (!first)
120+
{
121+
sb.Append(", ");
122+
}
123+
sb.Append("B: {B}");
124+
first = false;
125+
}
126+
if (hasAlpha)
127+
{
128+
if (!first)
129+
{
130+
sb.Append(", ");
131+
}
132+
sb.Append("A: {A}");
133+
}
134+
sb.Append(" }}\";");
135+
writer.WriteLine(sb.ToString());
137136
}
138137
}
139138

@@ -180,8 +179,8 @@ private static void WriteGenericColor(IndentedTextWriter writer, string name, bo
180179
writer.WriteLineNoTabs();
181180
WriteSetChannels(writer, typeName, hasRed, hasGreen, hasBlue, hasAlpha);
182181
writer.WriteLineNoTabs();
183-
WriteHasChannelStaticProperties(writer, hasRed, hasGreen, hasBlue, hasAlpha, typeName);
184-
writer.WriteLineNoTabs();
182+
WriteHasChannelStaticProperties(writer, hasRed, hasGreen, hasBlue, hasAlpha, typeName);
183+
writer.WriteLineNoTabs();
185184
WriteToString(writer, hasRed, hasGreen, hasBlue, hasAlpha);
186185
}
187186
}

AssetRipper.TextureDecoder.ConsoleApp/Program.g.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, s
7373
Console.WriteLine(" 61 - ARGB32");
7474
Console.WriteLine(" 62 - BGRA32");
7575
Console.WriteLine(" 63 - RGB16");
76-
Console.WriteLine(" 64 - RGB32Half");
77-
Console.WriteLine(" 65 - RGB9e5");
78-
Console.WriteLine(" 66 - RGBA16");
76+
Console.WriteLine(" 64 - RGB9e5");
77+
Console.WriteLine(" 65 - RGBA16");
7978
int mode = int.Parse(modeString);
8079
switch(mode)
8180
{
@@ -272,12 +271,9 @@ private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, s
272271
RgbConverter.Convert<ColorRGB16, byte, ColorBGRA32, byte>(input, width, height, output);
273272
break;
274273
case 64:
275-
RgbConverter.Convert<ColorRGB32Half, Half, ColorBGRA32, byte>(input, width, height, output);
276-
break;
277-
case 65:
278274
RgbConverter.Convert<ColorRGB9e5, double, ColorBGRA32, byte>(input, width, height, output);
279275
break;
280-
case 66:
276+
case 65:
281277
RgbConverter.Convert<ColorRGBA16, byte, ColorBGRA32, byte>(input, width, height, output);
282278
break;
283279
default:

AssetRipper.TextureDecoder.SourceGeneration.Common/CSharpPrimitives.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
22
using System.Runtime.CompilerServices;
33

44
namespace AssetRipper.TextureDecoder.SourceGeneration.Common;

AssetRipper.TextureDecoder.TestGenerator/Program.cs

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using AssetRipper.Text.SourceGeneration;
22
using AssetRipper.TextureDecoder.Rgb;
33
using AssetRipper.TextureDecoder.Rgb.Formats;
4-
using AssetRipper.TextureDecoder.SourceGeneration.Common;
4+
using AssetRipper.TextureDecoder.SourceGeneration.Common;
55
using System.CodeDom.Compiler;
66

77
namespace AssetRipper.TextureDecoder.TestGenerator
@@ -14,7 +14,6 @@ internal static class Program
1414
new GenerationData(typeof(ColorARGB32), 4),
1515
new GenerationData(typeof(ColorBGRA32), 4),
1616
new GenerationData(typeof(ColorRGB16), 2),
17-
new GenerationData(typeof(ColorRGB32Half), 4),
1817
new GenerationData(typeof(ColorRGB9e5), 4),
1918
new GenerationData(typeof(ColorRGBA16), 2),
2019
};
@@ -39,57 +38,57 @@ private static void GenerateRgbConsoleMethod()
3938

4039
writer.WriteFileScopedNamespace("AssetRipper.TextureDecoder.ConsoleApp");
4140
writer.WriteLine("static partial class Program");
42-
using (new CurlyBrackets(writer))
43-
{
44-
writer.WriteLine("private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)");
45-
using (new CurlyBrackets(writer))
46-
{
47-
List<(string, string, string)> list = GetColorNames().ToList();
48-
writer.WriteLine("Console.WriteLine(\"Arg at index 5 : mode\");");
49-
for (int i = 0; i < list.Count; i++)
50-
{
51-
writer.WriteLine($"Console.WriteLine(\" {i} - {list[i].Item1.Substring(5)}\");");
52-
}
53-
writer.WriteLine("int mode = int.Parse(modeString);");
54-
writer.WriteLine("switch(mode)");
55-
using (new CurlyBrackets(writer))
56-
{
57-
for (int i = 0 ; i < list.Count; i++)
58-
{
59-
(string prettyName, string colorName, string channelName) = list[i];
60-
writer.WriteLine($"case {i}:");
61-
using (new IndentedBlock(writer))
62-
{
63-
writer.WriteLine($"RgbConverter.Convert<{colorName}, {channelName}, ColorBGRA32, byte>(input, width, height, output);");
64-
writer.WriteLine("break;");
65-
}
66-
}
67-
{
68-
writer.WriteLine("default:");
69-
using (new IndentedBlock(writer))
70-
{
71-
writer.WriteLine("throw new NotSupportedException(mode.ToString());");
72-
}
73-
}
74-
}
75-
}
41+
using (new CurlyBrackets(writer))
42+
{
43+
writer.WriteLine("private static void DecodeRgb(ReadOnlySpan<byte> input, int width, int height, string modeString, Span<byte> output)");
44+
using (new CurlyBrackets(writer))
45+
{
46+
List<(string, string, string)> list = GetColorNames().ToList();
47+
writer.WriteLine("Console.WriteLine(\"Arg at index 5 : mode\");");
48+
for (int i = 0; i < list.Count; i++)
49+
{
50+
writer.WriteLine($"Console.WriteLine(\" {i} - {list[i].Item1.Substring(5)}\");");
51+
}
52+
writer.WriteLine("int mode = int.Parse(modeString);");
53+
writer.WriteLine("switch(mode)");
54+
using (new CurlyBrackets(writer))
55+
{
56+
for (int i = 0 ; i < list.Count; i++)
57+
{
58+
(string prettyName, string colorName, string channelName) = list[i];
59+
writer.WriteLine($"case {i}:");
60+
using (new IndentedBlock(writer))
61+
{
62+
writer.WriteLine($"RgbConverter.Convert<{colorName}, {channelName}, ColorBGRA32, byte>(input, width, height, output);");
63+
writer.WriteLine("break;");
64+
}
65+
}
66+
{
67+
writer.WriteLine("default:");
68+
using (new IndentedBlock(writer))
69+
{
70+
writer.WriteLine("throw new NotSupportedException(mode.ToString());");
71+
}
72+
}
73+
}
74+
}
7675
}
7776

78-
static IEnumerable<(string, string, string)> GetColorNames()
79-
{
80-
foreach ((Type primitiveType, string primitiveName) in CSharpPrimitives.TypeNames)
81-
{
82-
int primitiveBitSize = CSharpPrimitives.Sizes[primitiveType] * 8;
83-
foreach (string genericColorName in TestClassGenerator.GetGenericColorNames())
84-
{
85-
string prettyName = $"{genericColorName}{primitiveBitSize}{primitiveType.Name}";
86-
yield return (prettyName, $"{genericColorName}<{primitiveName}>", primitiveName);
87-
}
88-
}
89-
foreach (GenerationData data in dataList)
90-
{
91-
yield return (data.ColorType.Name, data.ColorType.Name, data.ChannelTypeName);
92-
}
77+
static IEnumerable<(string, string, string)> GetColorNames()
78+
{
79+
foreach ((Type primitiveType, string primitiveName) in CSharpPrimitives.TypeNames)
80+
{
81+
int primitiveBitSize = CSharpPrimitives.Sizes[primitiveType] * 8;
82+
foreach (string genericColorName in TestClassGenerator.GetGenericColorNames())
83+
{
84+
string prettyName = $"{genericColorName}{primitiveBitSize}{primitiveType.Name}";
85+
yield return (prettyName, $"{genericColorName}<{primitiveName}>", primitiveName);
86+
}
87+
}
88+
foreach (GenerationData data in dataList)
89+
{
90+
yield return (data.ColorType.Name, data.ColorType.Name, data.ChannelTypeName);
91+
}
9392
}
9493
}
9594
}

AssetRipper.TextureDecoder.Tests/Formats/ColorRGB32HalfTests.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)