Browse Source

Update source generators to use ReadOnlySpan

pull/495/head
Jason Nelson 9 years ago
parent
commit
5c35f4392f
  1. 36
      src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
  2. 4
      src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt

36
src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs

@ -34,8 +34,8 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="PackFromRgba32(Span{Rgba32}, Span{TPixel}, int)"/> that expects a byte span. /// A helper for <see cref="PackFromRgba32(ReadOnlySpan{byte}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgba32"/> layout. /// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgba32"/> layout.
/// </summary> /// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param> /// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
@ -69,14 +69,14 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="ToRgba32(Span{TPixel}, Span{Rgba32}, int)"/> that expects a byte span as destination. /// A helper for <see cref="ToRgba32(ReadOnlySpan{TPixel}, Span{Rgba32}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgba32"/> layout. /// The layout of the data in 'destBytes' must be compatible with <see cref="Rgba32"/> layout.
/// </summary> /// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param> /// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param> /// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param> /// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba32Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count) internal void ToRgba32Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count)
{ {
this.ToRgba32(sourceColors, destBytes.NonPortableCast<byte, Rgba32>(), count); this.ToRgba32(sourceColors, destBytes.NonPortableCast<byte, Rgba32>(), count);
@ -105,8 +105,8 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="PackFromBgra32(Span{Bgra32}, Span{TPixel}, int)"/> that expects a byte span. /// A helper for <see cref="PackFromBgra32(ReadOnlySpan{Bgra32}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Bgra32"/> layout. /// The layout of the data in 'sourceBytes' must be compatible with <see cref="Bgra32"/> layout.
/// </summary> /// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param> /// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
@ -140,14 +140,14 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="ToBgra32(Span{TPixel}, Span{Bgra32}, int)"/> that expects a byte span as destination. /// A helper for <see cref="ToBgra32(ReadOnlySpan{TPixel}, Span{Bgra32}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Bgra32"/> layout. /// The layout of the data in 'destBytes' must be compatible with <see cref="Bgra32"/> layout.
/// </summary> /// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param> /// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param> /// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param> /// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra32Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count) internal void ToBgra32Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count)
{ {
this.ToBgra32(sourceColors, destBytes.NonPortableCast<byte, Bgra32>(), count); this.ToBgra32(sourceColors, destBytes.NonPortableCast<byte, Bgra32>(), count);
@ -176,8 +176,8 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="PackFromRgb24(Span{Rgb24}, Span{TPixel}, int)"/> that expects a byte span. /// A helper for <see cref="PackFromRgb24(ReadOnlySpan{Rgb24}, Span{TPixel}, int)"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgb24"/> layout. /// The layout of the data in 'sourceBytes' must be compatible with <see cref="Rgb24"/> layout.
/// </summary> /// </summary>
/// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param> /// <param name="sourceBytes">The <see cref="Span{T}"/> to the source bytes.</param>
@ -211,14 +211,14 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="ToRgb24(Span{TPixel}, Span{Rgb24}, int)"/> that expects a byte span as destination. /// A helper for <see cref="ToRgb24(ReadOnlySpan{TPixel}, Span{Rgb24}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Rgb24"/> layout. /// The layout of the data in 'destBytes' must be compatible with <see cref="Rgb24"/> layout.
/// </summary> /// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param> /// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param> /// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param> /// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb24Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count) internal void ToRgb24Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count)
{ {
this.ToRgb24(sourceColors, destBytes.NonPortableCast<byte, Rgb24>(), count); this.ToRgb24(sourceColors, destBytes.NonPortableCast<byte, Rgb24>(), count);
@ -282,14 +282,14 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary> /// <summary>
/// A helper for <see cref="ToBgr24(Span{TPixel}, Span{Bgr24}, int)"/> that expects a byte span as destination. /// A helper for <see cref="ToBgr24(ReadOnlySpan{TPixel}, Span{Bgr24}, int)"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Bgr24"/> layout. /// The layout of the data in 'destBytes' must be compatible with <see cref="Bgr24"/> layout.
/// </summary> /// </summary>
/// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param> /// <param name="sourceColors">The <see cref="Span{T}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param> /// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param> /// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgr24Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count) internal void ToBgr24Bytes(ReadOnlySpan<TPixel> sourceColors, Span<byte> destBytes, int count)
{ {
this.ToBgr24(sourceColors, destBytes.NonPortableCast<byte, Bgr24>(), count); this.ToBgr24(sourceColors, destBytes.NonPortableCast<byte, Bgr24>(), count);

4
src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt

@ -14,7 +14,7 @@
#> #>
/// <inheritdoc /> /// <inheritdoc />
internal override void PackFrom<#=pixelType#>(Span<<#=pixelType#>> source, Span<Rgba32> destPixels, int count) internal override void PackFrom<#=pixelType#>(ReadOnlySpan<<#=pixelType#>> source, Span<Rgba32> destPixels, int count)
{ {
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -36,7 +36,7 @@
#> #>
/// <inheritdoc /> /// <inheritdoc />
internal override void To<#=pixelType#>(Span<Rgba32> sourcePixels, Span<<#=pixelType#>> dest, int count) internal override void To<#=pixelType#>(ReadOnlySpan<Rgba32> sourcePixels, Span<<#=pixelType#>> dest, int count)
{ {
GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count); GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);

Loading…
Cancel
Save