Skip to content

Commit d6b38c1

Browse files
Utils FTW
1 parent 6eb53e9 commit d6b38c1

11 files changed

Lines changed: 37 additions & 37 deletions

File tree

src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void Convolve2D3<TPixel>(
5959
ref Vector4 target = ref Unsafe.Add(ref targetRowRef, column);
6060
vector.W = target.W;
6161

62-
Vector4Utilities.UnPremultiply(ref vector);
62+
Vector4Utils.UnPremultiply(ref vector);
6363
target = vector;
6464
}
6565

@@ -105,7 +105,7 @@ public static void Convolve2D4<TPixel>(
105105
out Vector4 vector);
106106

107107
ref Vector4 target = ref Unsafe.Add(ref targetRowRef, column);
108-
Vector4Utilities.UnPremultiply(ref vector);
108+
Vector4Utils.UnPremultiply(ref vector);
109109
target = vector;
110110
}
111111

@@ -140,7 +140,7 @@ public static void Convolve2DImpl<TPixel>(
140140
{
141141
int offsetX = Numerics.Clamp(sourceOffsetColumnBase + x - radiusX, minColumn, maxColumn);
142142
var currentColor = sourceRowSpan[offsetX].ToVector4();
143-
Vector4Utilities.Premultiply(ref currentColor);
143+
Vector4Utils.Premultiply(ref currentColor);
144144

145145
vectorX += matrixX[y, x] * currentColor;
146146
vectorY += matrixY[y, x] * currentColor;
@@ -193,7 +193,7 @@ public static void Convolve3<TPixel>(
193193
ref Vector4 target = ref Unsafe.Add(ref targetRowRef, column);
194194
vector.W = target.W;
195195

196-
Vector4Utilities.UnPremultiply(ref vector);
196+
Vector4Utils.UnPremultiply(ref vector);
197197
target = vector;
198198
}
199199

@@ -238,7 +238,7 @@ public static void Convolve4<TPixel>(
238238
ref vector);
239239

240240
ref Vector4 target = ref Unsafe.Add(ref targetRowRef, column);
241-
Vector4Utilities.UnPremultiply(ref vector);
241+
Vector4Utils.UnPremultiply(ref vector);
242242
target = vector;
243243
}
244244

@@ -270,7 +270,7 @@ private static void ConvolveImpl<TPixel>(
270270
{
271271
int offsetX = Numerics.Clamp(sourceOffsetColumnBase + x - radiusX, minColumn, maxColumn);
272272
var currentColor = sourceRowSpan[offsetX].ToVector4();
273-
Vector4Utilities.Premultiply(ref currentColor);
273+
Vector4Utils.Premultiply(ref currentColor);
274274
vector += matrix[y, x] * currentColor;
275275
}
276276
}

src/ImageSharp/Common/Helpers/Vector4Utilities.cs renamed to src/ImageSharp/Common/Helpers/Vector4Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp
1515
/// <summary>
1616
/// Utility methods for the <see cref="Vector4"/> struct.
1717
/// </summary>
18-
internal static class Vector4Utilities
18+
internal static class Vector4Utils
1919
{
2020
private const int BlendAlphaControl = 0b_10_00_10_00;
2121
private const int ShuffleAlphaControl = 0b_11_11_11_11;

src/ImageSharp/PixelFormats/Utils/Vector4Converters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal static void ApplyForwardConversionModifiers(Span<Vector4> vectors, Pixe
2424

2525
if (modifiers.IsDefined(PixelConversionModifiers.Premultiply))
2626
{
27-
Vector4Utilities.Premultiply(vectors);
27+
Vector4Utils.Premultiply(vectors);
2828
}
2929
}
3030

@@ -36,7 +36,7 @@ internal static void ApplyBackwardConversionModifiers(Span<Vector4> vectors, Pix
3636
{
3737
if (modifiers.IsDefined(PixelConversionModifiers.Premultiply))
3838
{
39-
Vector4Utilities.UnPremultiply(vectors);
39+
Vector4Utils.UnPremultiply(vectors);
4040
}
4141

4242
if (modifiers.IsDefined(PixelConversionModifiers.SRgbCompand))

src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void Invoke(int y, Span<Vector4> span)
7474
Span<TPixel> rowSpan = this.source.GetPixelRowSpan(y).Slice(this.startX, span.Length);
7575
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, rowSpan, span);
7676

77-
Vector4Utilities.Transform(span, ref Unsafe.AsRef(this.matrix));
77+
Vector4Utils.Transform(span, ref Unsafe.AsRef(this.matrix));
7878

7979
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, span, rowSpan);
8080
}

src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public void ApplyTransform<TResampler>(in TResampler sampler)
8080
return;
8181
}
8282

83-
int yRadius = LinearTransformUtilities.GetSamplingRadius(in sampler, source.Height, destination.Height);
84-
int xRadius = LinearTransformUtilities.GetSamplingRadius(in sampler, source.Width, destination.Width);
83+
int yRadius = LinearTransformUtils.GetSamplingRadius(in sampler, source.Height, destination.Height);
84+
int xRadius = LinearTransformUtils.GetSamplingRadius(in sampler, source.Width, destination.Width);
8585
var radialExtents = new Vector2(xRadius, yRadius);
8686
int yLength = (yRadius * 2) + 1;
8787
int xLength = (xRadius * 2) + 1;
@@ -207,7 +207,7 @@ public void Invoke(int y, Span<Vector4> span)
207207
// Use the single precision position to calculate correct bounding pixels
208208
// otherwise we get rogue pixels outside of the bounds.
209209
var point = Vector2.Transform(new Vector2(x, y), this.matrix);
210-
LinearTransformUtilities.Convolve(
210+
LinearTransformUtils.Convolve(
211211
in this.sampler,
212212
point,
213213
sourceBuffer,

src/ImageSharp/Processing/Processors/Transforms/Linear/LinearTransformUtilities.cs renamed to src/ImageSharp/Processing/Processors/Transforms/Linear/LinearTransformUtils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
1212
/// <summary>
1313
/// Utility methods for affine and projective transforms.
1414
/// </summary>
15-
internal static class LinearTransformUtilities
15+
internal static class LinearTransformUtils
1616
{
1717
[MethodImpl(InliningOptions.ShortMethod)]
1818
internal static int GetSamplingRadius<TResampler>(in TResampler sampler, int sourceSize, int destinationSize)
@@ -78,13 +78,13 @@ internal static void Convolve<TResampler, TPixel>(
7878

7979
// Values are first premultiplied to prevent darkening of edge pixels.
8080
var current = sourcePixels[x, y].ToVector4();
81-
Vector4Utilities.Premultiply(ref current);
81+
Vector4Utils.Premultiply(ref current);
8282
sum += current * xWeight * yWeight;
8383
}
8484
}
8585

8686
// Reverse the premultiplication
87-
Vector4Utilities.UnPremultiply(ref sum);
87+
Vector4Utils.UnPremultiply(ref sum);
8888
targetRow[column] = sum;
8989
}
9090

src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public void ApplyTransform<TResampler>(in TResampler sampler)
8080
return;
8181
}
8282

83-
int yRadius = LinearTransformUtilities.GetSamplingRadius(in sampler, source.Height, destination.Height);
84-
int xRadius = LinearTransformUtilities.GetSamplingRadius(in sampler, source.Width, destination.Width);
83+
int yRadius = LinearTransformUtils.GetSamplingRadius(in sampler, source.Height, destination.Height);
84+
int xRadius = LinearTransformUtils.GetSamplingRadius(in sampler, source.Width, destination.Width);
8585
var radialExtents = new Vector2(xRadius, yRadius);
8686
int yLength = (yRadius * 2) + 1;
8787
int xLength = (xRadius * 2) + 1;
@@ -207,7 +207,7 @@ public void Invoke(int y, Span<Vector4> span)
207207
// Use the single precision position to calculate correct bounding pixels
208208
// otherwise we get rogue pixels outside of the bounds.
209209
Vector2 point = TransformUtilities.ProjectiveTransform2D(x, y, this.matrix);
210-
LinearTransformUtilities.Convolve(
210+
LinearTransformUtils.Convolve(
211211
in this.sampler,
212212
point,
213213
sourceBuffer,

tests/ImageSharp.Benchmarks/Color/Bulk/PremultiplyVector4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void PremultiplyBaseline()
2929
[Benchmark]
3030
public void Premultiply()
3131
{
32-
Vector4Utilities.Premultiply(Vectors);
32+
Vector4Utils.Premultiply(Vectors);
3333
}
3434

3535
[MethodImpl(InliningOptions.ShortMethod)]

tests/ImageSharp.Benchmarks/Color/Bulk/UnPremultiplyVector4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void UnPremultiplyBaseline()
2929
[Benchmark]
3030
public void UnPremultiply()
3131
{
32-
Vector4Utilities.UnPremultiply(Vectors);
32+
Vector4Utils.UnPremultiply(Vectors);
3333
}
3434

3535
[MethodImpl(InliningOptions.ShortMethod)]

tests/ImageSharp.Tests/Helpers/Vector4UtilsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public void Premultiply_VectorSpan(int length)
2424
Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1);
2525
Vector4[] expected = source.Select(v =>
2626
{
27-
Vector4Utilities.Premultiply(ref v);
27+
Vector4Utils.Premultiply(ref v);
2828
return v;
2929
}).ToArray();
3030

31-
Vector4Utilities.Premultiply(source);
31+
Vector4Utils.Premultiply(source);
3232

3333
Assert.Equal(expected, source, this.approximateFloatComparer);
3434
}
@@ -44,11 +44,11 @@ public void UnPremultiply_VectorSpan(int length)
4444
Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1);
4545
Vector4[] expected = source.Select(v =>
4646
{
47-
Vector4Utilities.UnPremultiply(ref v);
47+
Vector4Utils.UnPremultiply(ref v);
4848
return v;
4949
}).ToArray();
5050

51-
Vector4Utilities.UnPremultiply(source);
51+
Vector4Utils.UnPremultiply(source);
5252

5353
Assert.Equal(expected, source, this.approximateFloatComparer);
5454
}

0 commit comments

Comments
 (0)