mirror of https://github.com/SixLabors/ImageSharp
25 changed files with 381 additions and 9 deletions
@ -0,0 +1,56 @@ |
|||||
|
namespace ImageSharp |
||||
|
{ |
||||
|
using System.Numerics; |
||||
|
|
||||
|
public unsafe class BulkPixelOperations<TColor> |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
public static BulkPixelOperations<TColor> Instance { get; } = default(TColor).BulkOperations; |
||||
|
|
||||
|
internal virtual void PackFromVector4( |
||||
|
ArrayPointer<Vector4> sourceVectors, |
||||
|
ArrayPointer<TColor> destColors, |
||||
|
int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackToVector4( |
||||
|
ArrayPointer<TColor> sourceColors, |
||||
|
ArrayPointer<Vector4> destVectors, |
||||
|
int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackToXyzBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackFromXyzBytes(ArrayPointer<byte> sourceBytes, ArrayPointer<TColor> destColors, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackToXyzwBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackFromXyzwBytes(ArrayPointer<byte> sourceBytes, ArrayPointer<TColor> destColors, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackToZyxBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackFromZyxBytes(ArrayPointer<byte> sourceBytes, ArrayPointer<TColor> destColors, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackToZyxwBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal virtual void PackFromZyxwBytes(ArrayPointer<byte> sourceBytes, ArrayPointer<TColor> destColors, int count) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
namespace ImageSharp |
||||
|
{ |
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Utility methods to <see cref="ArrayPointer{T}"/>
|
||||
|
/// </summary>
|
||||
|
internal static class ArrayPointer |
||||
|
{ |
||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
||||
|
public static unsafe void Copy<T>(ArrayPointer<T> source, ArrayPointer<T> destination, int count) |
||||
|
where T : struct |
||||
|
{ |
||||
|
Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf<T>(count)); |
||||
|
} |
||||
|
|
||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
||||
|
public static unsafe void Copy<T>(ArrayPointer<T> source, ArrayPointer<byte> destination, int countInSource) |
||||
|
where T : struct |
||||
|
{ |
||||
|
Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf<T>(countInSource)); |
||||
|
} |
||||
|
|
||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
||||
|
public static unsafe void Copy<T>(ArrayPointer<byte> source, ArrayPointer<T> destination, int countInDest) |
||||
|
where T : struct |
||||
|
{ |
||||
|
Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf<T>(countInDest)); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the size of `count` elements in bytes.
|
||||
|
/// </summary>
|
||||
|
/// <param name="count">The count of the elements</param>
|
||||
|
/// <returns>The size in bytes as int</returns>
|
||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
||||
|
public static int SizeOf<T>(int count) |
||||
|
where T : struct => Unsafe.SizeOf<T>() * count; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the size of `count` elements in bytes as UInt32
|
||||
|
/// </summary>
|
||||
|
/// <param name="count">The count of the elements</param>
|
||||
|
/// <returns>The size in bytes as UInt32</returns>
|
||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
||||
|
public static uint USizeOf<T>(int count) |
||||
|
where T : struct |
||||
|
=> (uint)SizeOf<T>(count); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,104 @@ |
|||||
|
namespace ImageSharp.Tests.Colors |
||||
|
{ |
||||
|
using System; |
||||
|
|
||||
|
using Xunit; |
||||
|
|
||||
|
public class BulkPixelOperationsTests |
||||
|
{ |
||||
|
public class TypeParam<TColor> |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackFromVector4<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackToVector4<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackToXyzBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackFromXyzBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackToXyzwBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackFromXyzwBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackToZyxBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackFromZyxBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackToZyxwBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(default(TypeParam<Color>))] |
||||
|
[InlineData(default(TypeParam<Argb>))] |
||||
|
public virtual void PackFromZyxwBytes<TColor>(TypeParam<TColor> dummy) |
||||
|
where TColor : struct, IPixel<TColor> |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue