Browse Source

Trim back to test cause of slowness.

Former-commit-id: 467d987c47c6f4a97448a478aedba2b35d74b527
Former-commit-id: 38c2fb2764fc522bf2850bc8018f7303f51f56ed
Former-commit-id: caa43702a4f1aa90c87daf68a236d48a6ffcfe44
af/merge-core
James Jackson-South 10 years ago
parent
commit
5fd858b487
  1. 34
      src/ImageProcessorCore/PackedVector/Bgra32.cs
  2. 12
      src/ImageProcessorCore/PackedVector/IPackedVector.cs
  3. 29
      src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs

34
src/ImageProcessorCore/PackedVector/Bgra32.cs

@ -11,7 +11,7 @@ namespace ImageProcessorCore
/// <summary>
/// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 1.
/// </summary>
public struct Bgra32 : IPackedVector<uint>, IEquatable<Bgra32>
public struct Bgra32 : IPackedVector, IEquatable<Bgra32>
{
/// <summary>
/// Initializes a new instance of the <see cref="Bgra32"/> struct.
@ -41,6 +41,38 @@ namespace ImageProcessorCore
/// <inheritdoc/>
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)
{
}
/// <summary>
/// Compares two <see cref="Bgra32"/> objects for equality.
/// </summary>

12
src/ImageProcessorCore/PackedVector/IPackedVector.cs

@ -29,6 +29,18 @@ namespace ImageProcessorCore
/// </summary>
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);
/// <summary>
/// Sets the packed representation from a <see cref="Vector4"/>.
/// </summary>

29
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;
}
}

Loading…
Cancel
Save