|
|
|
@ -2,10 +2,8 @@ |
|
|
|
// Licensed under the Six Labors Split License.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Numerics; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using SixLabors.ImageSharp.Advanced; |
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
@ -182,19 +180,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void Invoke(in RowInterval rows, Span<Vector4> span) |
|
|
|
{ |
|
|
|
if (RuntimeEnvironment.IsOSPlatform(OSPlatform.OSX) |
|
|
|
&& RuntimeEnvironment.IsNetCore) |
|
|
|
{ |
|
|
|
// There's something wrong with the JIT in .NET Core 3.1 on certain
|
|
|
|
// macOS machines so we have to use different pipelines.
|
|
|
|
// It's:
|
|
|
|
// - Not reproducable locally
|
|
|
|
// - Doesn't seem to be triggered by the bulk Numerics.UnPremultiply method but by caller.
|
|
|
|
// https://github.com/SixLabors/ImageSharp/pull/1591
|
|
|
|
this.InvokeMacOS(in rows, span); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Matrix4x4 matrix = this.matrix; |
|
|
|
TResampler sampler = this.sampler; |
|
|
|
float yRadius = this.yRadius; |
|
|
|
@ -255,71 +240,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|
|
|
PixelConversionModifiers.Scale); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[ExcludeFromCodeCoverage] |
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public void InvokeMacOS(in RowInterval rows, Span<Vector4> span) |
|
|
|
{ |
|
|
|
Matrix4x4 matrix = this.matrix; |
|
|
|
TResampler sampler = this.sampler; |
|
|
|
float yRadius = this.yRadius; |
|
|
|
float xRadius = this.xRadius; |
|
|
|
int minY = this.bounds.Y; |
|
|
|
int maxY = this.bounds.Bottom - 1; |
|
|
|
int minX = this.bounds.X; |
|
|
|
int maxX = this.bounds.Right - 1; |
|
|
|
|
|
|
|
for (int y = rows.Min; y < rows.Max; y++) |
|
|
|
{ |
|
|
|
Span<TPixel> rowSpan = this.destination.DangerousGetRowSpan(y); |
|
|
|
PixelOperations<TPixel>.Instance.ToVector4( |
|
|
|
this.configuration, |
|
|
|
rowSpan, |
|
|
|
span, |
|
|
|
PixelConversionModifiers.Scale); |
|
|
|
|
|
|
|
for (int x = 0; x < span.Length; x++) |
|
|
|
{ |
|
|
|
Vector2 point = TransformUtils.ProjectiveTransform2D(x, y, matrix); |
|
|
|
float pY = point.Y; |
|
|
|
float pX = point.X; |
|
|
|
|
|
|
|
int top = LinearTransformUtility.GetRangeStart(yRadius, pY, minY, maxY); |
|
|
|
int bottom = LinearTransformUtility.GetRangeEnd(yRadius, pY, minY, maxY); |
|
|
|
int left = LinearTransformUtility.GetRangeStart(xRadius, pX, minX, maxX); |
|
|
|
int right = LinearTransformUtility.GetRangeEnd(xRadius, pX, minX, maxX); |
|
|
|
|
|
|
|
if (bottom <= top || right <= left) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Vector4 sum = Vector4.Zero; |
|
|
|
for (int yK = top; yK <= bottom; yK++) |
|
|
|
{ |
|
|
|
float yWeight = sampler.GetValue(yK - pY); |
|
|
|
|
|
|
|
for (int xK = left; xK <= right; xK++) |
|
|
|
{ |
|
|
|
float xWeight = sampler.GetValue(xK - pX); |
|
|
|
|
|
|
|
Vector4 current = this.source.GetElementUnsafe(xK, yK).ToScaledVector4(); |
|
|
|
Numerics.Premultiply(ref current); |
|
|
|
sum += current * xWeight * yWeight; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Numerics.UnPremultiply(ref sum); |
|
|
|
span[x] = sum; |
|
|
|
} |
|
|
|
|
|
|
|
PixelOperations<TPixel>.Instance.FromVector4Destructive( |
|
|
|
this.configuration, |
|
|
|
span, |
|
|
|
rowSpan, |
|
|
|
PixelConversionModifiers.Scale); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|