-
-
Notifications
You must be signed in to change notification settings - Fork 888
Fix ARM Build for UWP Release #1391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,15 +106,23 @@ public GrayscaleLevelsRowOperation( | |
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| #if NETSTANDARD2_0 | ||
| // https://github.com/SixLabors/ImageSharp/issues/1204 | ||
| [MethodImpl(MethodImplOptions.NoOptimization)] | ||
| #else | ||
| [MethodImpl(InliningOptions.ShortMethod)] | ||
| #endif | ||
| public void Invoke(int y) | ||
| { | ||
| ref int histogramBase = ref MemoryMarshal.GetReference(this.histogramBuffer.GetSpan()); | ||
| ref TPixel pixelBase = ref MemoryMarshal.GetReference(this.source.GetPixelRowSpan(y)); | ||
| int levels = this.luminanceLevels; | ||
|
|
||
| for (int x = 0; x < this.bounds.Width; x++) | ||
| { | ||
| int luminance = GetLuminance(Unsafe.Add(ref pixelBase, x), this.luminanceLevels); | ||
| // TODO: We should bulk convert here. | ||
| var vector = Unsafe.Add(ref pixelBase, x).ToVector4(); | ||
| int luminance = ImageMaths.GetBT709Luminance(ref vector, levels); | ||
| Unsafe.Add(ref histogramBase, luminance)++; | ||
| } | ||
| } | ||
|
|
@@ -147,18 +155,27 @@ public CdfApplicationRowOperation( | |
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| #if NETSTANDARD2_0 | ||
| // https://github.com/SixLabors/ImageSharp/issues/1204 | ||
| [MethodImpl(MethodImplOptions.NoOptimization)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shame that we can't just target UWP specifically for this, but .NET Standard 2.0 as a whole should mostly be for back-compat anyway, so this seems absolutely fine to me. This whole processor is not one of the most used though, so this shouldn't affect most code paths and usages of the library anyway, which is great.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha! Just typed the same thing below 😝 |
||
| #else | ||
| [MethodImpl(InliningOptions.ShortMethod)] | ||
| #endif | ||
| public void Invoke(int y) | ||
| { | ||
| ref int cdfBase = ref MemoryMarshal.GetReference(this.cdfBuffer.GetSpan()); | ||
| ref TPixel pixelBase = ref MemoryMarshal.GetReference(this.source.GetPixelRowSpan(y)); | ||
| int levels = this.luminanceLevels; | ||
| float noOfPixelsMinusCdfMin = this.numberOfPixelsMinusCdfMin; | ||
|
|
||
| for (int x = 0; x < this.bounds.Width; x++) | ||
| { | ||
| // TODO: We should bulk convert here. | ||
| ref TPixel pixel = ref Unsafe.Add(ref pixelBase, x); | ||
| int luminance = GetLuminance(pixel, this.luminanceLevels); | ||
| float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / this.numberOfPixelsMinusCdfMin; | ||
| pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); | ||
| var vector = pixel.ToVector4(); | ||
| int luminance = ImageMaths.GetBT709Luminance(ref vector, levels); | ||
| float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / noOfPixelsMinusCdfMin; | ||
| pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some bonus loop hoisting, nice 🚀