From 5fd858b487ef4ab0da1a275bcd8a802a293eac0c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 9 Jul 2016 20:06:02 +1000 Subject: [PATCH] Trim back to test cause of slowness. Former-commit-id: 467d987c47c6f4a97448a478aedba2b35d74b527 Former-commit-id: 38c2fb2764fc522bf2850bc8018f7303f51f56ed Former-commit-id: caa43702a4f1aa90c87daf68a236d48a6ffcfe44 --- src/ImageProcessorCore/PackedVector/Bgra32.cs | 34 ++++++++++++++++++- .../PackedVector/IPackedVector.cs | 12 +++++++ .../Samplers/Processors/ResizeProcessor.cs | 29 +++++++++------- 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/src/ImageProcessorCore/PackedVector/Bgra32.cs b/src/ImageProcessorCore/PackedVector/Bgra32.cs index fc6a788b0..5fdf24e17 100644 --- a/src/ImageProcessorCore/PackedVector/Bgra32.cs +++ b/src/ImageProcessorCore/PackedVector/Bgra32.cs @@ -11,7 +11,7 @@ namespace ImageProcessorCore /// /// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 1. /// - public struct Bgra32 : IPackedVector, IEquatable + public struct Bgra32 : IPackedVector, IEquatable { /// /// Initializes a new instance of the struct. @@ -41,6 +41,38 @@ namespace ImageProcessorCore /// public uint PackedValue { get; set; } + // The maths are wrong here I just wanted to test the performance to see if the + // issues are caused by the Vector transform or something else. + public void Add(IPackedVector value) + { + + } + + public void Subtract(IPackedVector value) + { + + } + + public void Multiply(IPackedVector value) + { + + } + + public void Multiply(float value) + { + + } + + public void Divide(IPackedVector value) + { + + } + + public void Divide(float value) + { + + } + /// /// Compares two objects for equality. /// diff --git a/src/ImageProcessorCore/PackedVector/IPackedVector.cs b/src/ImageProcessorCore/PackedVector/IPackedVector.cs index 7022e4d9d..e7533a0dd 100644 --- a/src/ImageProcessorCore/PackedVector/IPackedVector.cs +++ b/src/ImageProcessorCore/PackedVector/IPackedVector.cs @@ -29,6 +29,18 @@ namespace ImageProcessorCore /// public interface IPackedVector { + void Add(IPackedVector value); + + void Subtract(IPackedVector value); + + void Multiply(IPackedVector value); + + void Multiply(float value); + + void Divide(IPackedVector value); + + void Divide(float value); + /// /// Sets the packed representation from a . /// diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs index 67d20a564..15d202ef4 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs @@ -153,27 +153,29 @@ namespace ImageProcessorCore.Processors //} //firstPassPixels[x, y] = destination; - Vector4 destination = new Vector4(); + T destination = new T(); for (int i = 0; i < sum; i++) { Weight xw = horizontalValues[i]; int originX = xw.Index; - Vector4 sourceColor = sourcePixels[originX, y].ToVector4(); + T sourceColor = sourcePixels[originX, y]; //Color sourceColor = compand // ? Color.Expand(sourcePixels[originX, y]) // : sourcePixels[originX, y]; - destination += sourceColor * xw.Value; + //sourceColor.Multiply(xw.Value); + //destination.Add(sourceColor); + //destination += sourceColor * xw.Value; } //if (compand) //{ // destination = Color.Compress(destination); //} - T packed = new T(); - packed.PackVector(destination); + //T packed = new T(); + //packed.PackVector(destination); - firstPassPixels[x, y] = packed; + firstPassPixels[x, y] = destination; } } }); @@ -194,7 +196,7 @@ namespace ImageProcessorCore.Processors for (int x = 0; x < width; x++) { // Destination color components - Vector4 destination = new Vector4(); + T destination = new T(); for (int i = 0; i < sum; i++) { @@ -203,8 +205,11 @@ namespace ImageProcessorCore.Processors //Color sourceColor = compand // ? Color.Expand(firstPassPixels[x, originY]) // : firstPassPixels[x, originY]; - Vector4 sourceColor = firstPassPixels[x, originY].ToVector4(); - destination += sourceColor * yw.Value; + //Vector4 sourceColor = firstPassPixels[x, originY].ToVector4(); + //destination += sourceColor * yw.Value; + T sourceColor = firstPassPixels[x, originY]; + //sourceColor.Multiply(yw.Value); + //destination.Add(sourceColor); } //if (compand) @@ -212,10 +217,10 @@ namespace ImageProcessorCore.Processors // destination = Color.Compress(destination); //} - T packed = new T(); - packed.PackVector(destination); + //T packed = new T(); + //packed.PackVector(destination); - targetPixels[x, y] = packed; + targetPixels[x, y] = destination; } }