Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GraphicsHelpers.cs
Go to the documentation of this file.
1using System;
3
5
6internal static class GraphicsHelpers
7{
8 public static void ThrowExceptionFromResult(uint result)
9 {
10 if (result == 0)
11 {
12 return;
13 }
14 throw GetExceptionFromResult(result);
15 }
16
17 [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
18 [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")]
19 [SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")]
20 public static Exception GetExceptionFromResult(uint result)
21 {
22 if (result == 0)
23 {
24 return null;
25 }
26 return result switch
27 {
29 2289436776u => new DeviceLostException(),
30 2289436777u => new DeviceNotResetException(),
31 2289436784u => new NotSupportedException(),
32 2289435004u => new OutOfMemoryException(),
34 _ => Helpers.GetExceptionFromResult(result),
35 };
36 }
37
38 internal static Blend AdjustAlphaBlend(Blend blend)
39 {
40 return blend switch
41 {
42 Blend.SourceColor => Blend.SourceAlpha,
43 Blend.InverseSourceColor => Blend.InverseSourceAlpha,
44 Blend.DestinationColor => Blend.DestinationAlpha,
45 Blend.InverseDestinationColor => Blend.InverseDestinationAlpha,
46 _ => blend,
47 };
48 }
49
50 internal static bool IsSeparateBlend(Blend colorBlend, Blend alphaBlend)
51 {
52 return AdjustAlphaBlend(colorBlend) != AdjustAlphaBlend(alphaBlend);
53 }
54}
static bool IsSeparateBlend(Blend colorBlend, Blend alphaBlend)
static Exception GetExceptionFromResult(uint result)
static Exception GetExceptionFromResult(uint result)
Definition Helpers.cs:115