Browse Source

DRY out PixelOperations generators

pull/744/head
Anton Firszov 7 years ago
parent
commit
0dedf86b0b
  1. 1
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
  2. 12
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt
  3. 32
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
  4. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt
  5. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
  6. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt
  7. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs
  8. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt
  9. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs
  10. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt
  11. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
  12. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt
  13. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
  14. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt
  15. 22
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
  16. 73
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt
  17. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
  18. 67
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt
  19. 15
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude

1
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs

@ -1,5 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;

12
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.tt

@ -1,4 +1,4 @@
<#@include file="RgbaCompatible.Common.ttinclude" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
namespace SixLabors.ImageSharp.PixelFormats
@ -14,15 +14,7 @@ namespace SixLabors.ImageSharp.PixelFormats
internal class PixelOperations : PixelOperations<Argb32>
{
<#
GenerateDefaultSelfConversionMethods("Argb32");
GenerateDefaultConvertToMethod("Argb32", "Bgr24");
GenerateDefaultConvertToMethod("Argb32", "Bgra32");
GenerateDefaultConvertToMethod("Argb32", "Gray8");
GenerateDefaultConvertToMethod("Argb32", "Gray16");
GenerateDefaultConvertToMethod("Argb32", "Rgb24");
GenerateDefaultConvertToMethod("Argb32", "Rgba32");
GenerateDefaultConvertToMethod("Argb32", "Rgb48");
GenerateDefaultConvertToMethod("Argb32", "Rgba64");
GenerateAllDefaultConversionMethods("Argb32");
#>
}

32
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Bgr24
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Bgr24>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromBgr24(ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destPixels, int count)
{
@ -43,7 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -60,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -77,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -94,7 +96,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -111,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -128,7 +130,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -145,7 +147,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
@ -162,7 +164,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Bgr24> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromBgr24(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Bgr24
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Bgr24>
{
/// <inheritdoc />
internal override void FromBgr24(ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToBgr24(ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgb48");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Bgr24");
#>
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Bgra32
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Bgra32>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromBgra32(ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels, int count)
{

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Bgra32> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromBgra32(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Bgra32
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Bgra32>
{
/// <inheritdoc />
internal override void FromBgra32(ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToBgra32(ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgb48");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Bgra32");
#>
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Gray16
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Gray16>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromGray16(ReadOnlySpan<Gray16> source, Span<Gray16> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Gray16> sourcePixels, Span<Argb32> destPixels, int count)
{

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Gray16> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Gray16
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Gray16>
{
/// <inheritdoc />
internal override void FromGray16(ReadOnlySpan<Gray16> source, Span<Gray16> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToGray16(ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgb48");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Gray16");
#>
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Gray8
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Gray8>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromGray8(ReadOnlySpan<Gray8> source, Span<Gray8> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Gray8> sourcePixels, Span<Argb32> destPixels, int count)
{

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Gray8> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray8(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Gray8
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Gray8>
{
/// <inheritdoc />
internal override void FromGray8(ReadOnlySpan<Gray8> source, Span<Gray8> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToGray8(ReadOnlySpan<Gray8> sourcePixels, Span<Gray8> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgb48");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Gray8");
#>
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgb24
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgb24>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromRgb24(ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destPixels, int count)
{

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Rgb24> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgb24(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgb24
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgb24>
{
/// <inheritdoc />
internal override void FromRgb24(ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToRgb24(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgb48");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Rgb24");
#>
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgb48
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgb48>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromRgb48(ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destPixels, int count)
{

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Rgb48> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgb48(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgb48
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgb48>
{
/// <inheritdoc />
internal override void FromRgb48(ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToRgb48(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Rgb48");
#>
}

22
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgba32
{
/// <content>
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </content>
internal partial class PixelOperations
/// </summary>
internal partial class PixelOperations : PixelOperations<Rgba32>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromRgba32(ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels, int count)
{

73
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Rgba32> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgba32(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgba32
{
/// <content>
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </content>
internal partial class PixelOperations
/// </summary>
internal partial class PixelOperations : PixelOperations<Rgba32>
{
/// <inheritdoc />
internal override void FromRgba32(ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToRgba32(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgb48");
GenerateConvertToMethod("Rgba64");
GenerateAllDefaultConversionMethods("Rgba32");
#>
}

16
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs

@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgba64
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgba64>
{
/// <inheritdoc />
/// <inheritdoc />
internal override void FromRgba64(ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
@ -35,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToArgb32(ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destPixels, int count)
{

67
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.tt

@ -1,83 +1,20 @@
<#
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#>
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@include file="_Common.ttinclude" #>
<#@ output extension=".cs" #>
<#
void GenerateConvertToMethod(string pixelType)
{
#>
/// <inheritdoc />
internal override void To<#=pixelType#>(ReadOnlySpan<Rgba64> sourcePixels, Span<<#=pixelType#>> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < count; i++)
{
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgba64(sp);
}
}
<#
}
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
namespace SixLabors.ImageSharp.PixelFormats
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Rgba64
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Rgba64>
{
/// <inheritdoc />
internal override void FromRgba64(ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels, int count)
{
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
source.Slice(0, count).CopyTo(destPixels);
}
/// <inheritdoc />
internal override void ToRgba64(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destPixels, int count)
{
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count);
sourcePixels.Slice(0, count).CopyTo(destPixels);
}
<#
GenerateConvertToMethod("Argb32");
GenerateConvertToMethod("Bgr24");
GenerateConvertToMethod("Bgra32");
GenerateConvertToMethod("Gray8");
GenerateConvertToMethod("Gray16");
GenerateConvertToMethod("Rgb24");
GenerateConvertToMethod("Rgba32");
GenerateConvertToMethod("Rgb48");
GenerateAllDefaultConversionMethods("Rgba64");
#>
}

15
src/ImageSharp/PixelFormats/PixelImplementations/Generated/RgbaCompatible.Common.ttinclude → src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude

@ -5,12 +5,15 @@
<#@ import namespace="System.Collections.Generic" #>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// <auto-generated />
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
<#+
static readonly string[] CommonPixelTypeNames = { "Argb32", "Bgr24", "Bgra32", "Gray8", "Gray16", "Rgb24", "Rgba32", "Rgb48", "Rgba64" };
void GenerateDefaultSelfConversionMethods(string pixelType)
{
#>
@ -56,4 +59,16 @@ using System.Runtime.InteropServices;
}
<#+
}
void GenerateAllDefaultConversionMethods(string pixelType)
{
GenerateDefaultSelfConversionMethods(pixelType);
var allOtherPixelTypes = CommonPixelTypeNames.Where(p => p != pixelType);
foreach (string destPixelType in allOtherPixelTypes)
{
GenerateDefaultConvertToMethod(pixelType, destPixelType);
}
}
#>
Loading…
Cancel
Save