From 5b2d7c73971bee28c0d28e18347c4e618dac5efc Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 14:33:46 +0100 Subject: [PATCH] Update EuclideanPixelMap{TPixel}.cs --- .../Quantization/EuclideanPixelMap{TPixel}.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 6d9985ca07..422d84ac6c 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -116,11 +116,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// /// A cache for storing color distance matching results. - /// Not threadsafe but cache misses will be very rare and shouldn't - /// significantly negatively affect performance. /// /// /// The cache is limited to 646866 entries at 0.62MB. + /// TODO: How do we make this threadsafe? /// private struct ColorDistanceCache { @@ -169,13 +168,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization [MethodImpl(InliningOptions.ShortMethod)] private static int GetPaletteIndex(int r, int g, int b, int a) => (r << ((IndexBits * 2) + IndexAlphaBits)) - + (r << (IndexBits + IndexAlphaBits + 1)) - + (g << (IndexBits + IndexAlphaBits)) - + (r << (IndexBits * 2)) - + (r << (IndexBits + 1)) - + (g << IndexBits) - + ((r + g + b) << IndexAlphaBits) - + r + g + b + a; + + (r << (IndexBits + IndexAlphaBits + 1)) + + (g << (IndexBits + IndexAlphaBits)) + + (r << (IndexBits * 2)) + + (r << (IndexBits + 1)) + + (g << IndexBits) + + ((r + g + b) << IndexAlphaBits) + + r + g + b + a; } } }