Browse Source

Update based on Tanner's investigationl.

pull/1152/head
James Jackson-South 6 years ago
parent
commit
f36930dcc0
  1. 3
      src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs
  2. 2
      src/ImageSharp/Common/Helpers/Vector4Utilities.cs

3
src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs

@ -125,8 +125,7 @@ namespace SixLabors.ImageSharp
Vector4 s = Unsafe.Add(ref sBase, i);
s *= maxBytes;
s += half;
s = Vector4.Max(Vector4.Zero, s);
s = Vector4.Min(maxBytes, s);
s = Vector4Utilities.FastClamp(s, Vector4.Zero, maxBytes);
ref ByteVector4 d = ref Unsafe.Add(ref dBase, i);
d.X = (byte)s.X;

2
src/ImageSharp/Common/Helpers/Vector4Utilities.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Vector4"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static Vector4 FastClamp(Vector4 x, Vector4 min, Vector4 max)
=> Vector4.Min(Vector4.Max(min, x), max);
=> Vector4.Min(Vector4.Max(x, min), max);
/// <summary>
/// Pre-multiplies the "x", "y", "z" components of a vector by its "w" component leaving the "w" component intact.

Loading…
Cancel
Save