mirror of
https://github.com/DarthAffe/HPPH.git
synced 2025-12-13 05:48:57 +00:00
Fixed some code issues
This commit is contained in:
parent
3ccb62538d
commit
9c67e49293
@ -44,7 +44,7 @@ public class ColorSourceGenerator : IIncrementalGenerator
|
|||||||
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("ColorGeneratorAttribute.g.cs", SourceText.From(COLOR_GENERATOR_ATTRIBUTE_SOURCE, Encoding.UTF8)));
|
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("ColorGeneratorAttribute.g.cs", SourceText.From(COLOR_GENERATOR_ATTRIBUTE_SOURCE, Encoding.UTF8)));
|
||||||
|
|
||||||
IncrementalValueProvider<ImmutableArray<ColorFormatData>> classes = context.SyntaxProvider
|
IncrementalValueProvider<ImmutableArray<ColorFormatData>> classes = context.SyntaxProvider
|
||||||
.ForAttributeWithMetadataName("HPPH.ColorGeneratorAttribute", static (_, __) => true, Transform)
|
.ForAttributeWithMetadataName("HPPH.ColorGeneratorAttribute", static (_, _) => true, Transform)
|
||||||
.Where(type => type.HasValue)
|
.Where(type => type.HasValue)
|
||||||
.Select((data, _) => data!.Value)
|
.Select((data, _) => data!.Value)
|
||||||
.Collect();
|
.Collect();
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class ColorSortSourceGenerator : IIncrementalGenerator
|
|||||||
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("ColorSortGeneratorAttribute.g.cs", SourceText.From(SORT_GENERATOR_ATTRIBUTE_SOURCE, Encoding.UTF8)));
|
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("ColorSortGeneratorAttribute.g.cs", SourceText.From(SORT_GENERATOR_ATTRIBUTE_SOURCE, Encoding.UTF8)));
|
||||||
|
|
||||||
IncrementalValueProvider<ImmutableArray<ColorSortData>> classes = context.SyntaxProvider
|
IncrementalValueProvider<ImmutableArray<ColorSortData>> classes = context.SyntaxProvider
|
||||||
.ForAttributeWithMetadataName("HPPH.ColorSortGeneratorAttribute", static (_, __) => true, Transform)
|
.ForAttributeWithMetadataName("HPPH.ColorSortGeneratorAttribute", static (_, _) => true, Transform)
|
||||||
.Where(type => type.HasValue)
|
.Where(type => type.HasValue)
|
||||||
.Select((data, _) => data!.Value)
|
.Select((data, _) => data!.Value)
|
||||||
.Collect();
|
.Collect();
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
namespace HPPH.Reference;
|
|
||||||
|
|
||||||
internal static class HPPHExtensions
|
|
||||||
{
|
|
||||||
public static byte GetByteValueFromPercentage(this float percentage)
|
|
||||||
{
|
|
||||||
if (float.IsNaN(percentage) || (percentage < 0)) return 0;
|
|
||||||
|
|
||||||
return (byte)(percentage >= 1.0f ? 255 : percentage * 256.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float GetPercentageFromByteValue(this byte value)
|
|
||||||
=> value == 255 ? 1.0f : (value / 256.0f);
|
|
||||||
}
|
|
||||||
@ -145,7 +145,7 @@ public readonly ref struct RefImage<TColor>
|
|||||||
private int _position;
|
private int _position;
|
||||||
|
|
||||||
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
|
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
|
||||||
public TColor Current
|
public readonly TColor Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _pixels[_position];
|
get => _pixels[_position];
|
||||||
@ -194,7 +194,7 @@ public readonly ref struct RefImage<TColor>
|
|||||||
|
|
||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
public readonly ReadOnlyRefEnumerable<TColor> this[int row]
|
public ReadOnlyRefEnumerable<TColor> this[int row]
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
@ -212,6 +212,7 @@ public readonly ref struct RefImage<TColor>
|
|||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
|
// ReSharper disable once ConvertToPrimaryConstructor - Not possible with ref types
|
||||||
public ImageRows(ReadOnlySpan<TColor> pixels, int x, int y, int width, int height, int stride)
|
public ImageRows(ReadOnlySpan<TColor> pixels, int x, int y, int width, int height, int stride)
|
||||||
{
|
{
|
||||||
this._pixels = pixels;
|
this._pixels = pixels;
|
||||||
@ -240,7 +241,7 @@ public readonly ref struct RefImage<TColor>
|
|||||||
private int _position;
|
private int _position;
|
||||||
|
|
||||||
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
|
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
|
||||||
public ReadOnlyRefEnumerable<TColor> Current
|
public readonly ReadOnlyRefEnumerable<TColor> Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _rows[_position];
|
get => _rows[_position];
|
||||||
@ -306,6 +307,7 @@ public readonly ref struct RefImage<TColor>
|
|||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
|
// ReSharper disable once ConvertToPrimaryConstructor - Not possible with ref types
|
||||||
public ImageColumns(ReadOnlySpan<TColor> pixels, int x, int y, int width, int height, int stride)
|
public ImageColumns(ReadOnlySpan<TColor> pixels, int x, int y, int width, int height, int stride)
|
||||||
{
|
{
|
||||||
this._pixels = pixels;
|
this._pixels = pixels;
|
||||||
@ -334,7 +336,7 @@ public readonly ref struct RefImage<TColor>
|
|||||||
private int _position;
|
private int _position;
|
||||||
|
|
||||||
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
|
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
|
||||||
public ReadOnlyRefEnumerable<TColor> Current
|
public readonly ReadOnlyRefEnumerable<TColor> Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _columns[_position];
|
get => _columns[_position];
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
namespace HPPH;
|
namespace HPPH;
|
||||||
|
|
||||||
|
// ReSharper disable once RedundantUnsafeContext
|
||||||
public static unsafe partial class PixelHelper
|
public static unsafe partial class PixelHelper
|
||||||
{
|
{
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|||||||
@ -28,7 +28,7 @@ internal struct ColorCube<T>
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal Span<T> Slice(Span<T> fullColorList) => fullColorList.Slice(_offset, _length);
|
internal readonly Span<T> Slice(Span<T> fullColorList) => fullColorList.Slice(_offset, _length);
|
||||||
|
|
||||||
internal void Split(Span<T> fullColorList, out ColorCube<T> a, out ColorCube<T> b)
|
internal void Split(Span<T> fullColorList, out ColorCube<T> a, out ColorCube<T> b)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user