Browse Source

Make PixelTypeInfo lazy

pull/1420/head
James Jackson-South 6 years ago
parent
commit
f23fd09669
  1. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/A8.PixelOperations.cs
  2. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Argb32.PixelOperations.cs
  3. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgr24.PixelOperations.cs
  4. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgr565.PixelOperations.cs
  5. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra32.PixelOperations.cs
  6. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra4444.PixelOperations.cs
  7. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra5551.PixelOperations.cs
  8. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Byte4.PixelOperations.cs
  9. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfSingle.PixelOperations.cs
  10. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector2.PixelOperations.cs
  11. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector4.PixelOperations.cs
  12. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/L16.PixelOperations.cs
  13. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/L8.PixelOperations.cs
  14. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/La16.PixelOperations.cs
  15. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/La32.PixelOperations.cs
  16. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte2.PixelOperations.cs
  17. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte4.PixelOperations.cs
  18. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort2.PixelOperations.cs
  19. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort4.PixelOperations.cs
  20. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rg32.PixelOperations.cs
  21. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgb24.PixelOperations.cs
  22. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgb48.PixelOperations.cs
  23. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba1010102.PixelOperations.cs
  24. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba32.PixelOperations.cs
  25. 7
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba64.PixelOperations.cs
  26. 5
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs
  27. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short2.PixelOperations.cs
  28. 6
      src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short4.PixelOperations.cs
  29. 4
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/A8.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<A8> internal class PixelOperations : PixelOperations<A8>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<A8>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<A8>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Argb32.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Argb32> internal partial class PixelOperations : PixelOperations<Argb32>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Argb32>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Argb32>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgr24.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Bgr24> internal partial class PixelOperations : PixelOperations<Bgr24>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Bgr24>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Bgr24>(PixelAlphaRepresentation.None);
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgr565.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Bgr565> internal class PixelOperations : PixelOperations<Bgr565>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Bgr565>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgr565>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra32.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Bgra32> internal partial class PixelOperations : PixelOperations<Bgra32>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Bgra32>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Bgra32>(PixelAlphaRepresentation.Unassociated);
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra4444.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Bgra4444> internal class PixelOperations : PixelOperations<Bgra4444>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Bgra4444>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra4444>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Bgra5551.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Bgra5551> internal partial class PixelOperations : PixelOperations<Bgra5551>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Bgra5551>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Bgra5551>(PixelAlphaRepresentation.Unassociated);
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Byte4.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Byte4> internal class PixelOperations : PixelOperations<Byte4>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Byte4>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Byte4>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfSingle.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<HalfSingle> internal class PixelOperations : PixelOperations<HalfSingle>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<HalfSingle>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<HalfSingle>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector2.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<HalfVector2> internal class PixelOperations : PixelOperations<HalfVector2>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<HalfVector2>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<HalfVector2>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/HalfVector4.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<HalfVector4> internal class PixelOperations : PixelOperations<HalfVector4>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<HalfVector4>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<HalfVector4>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/L16.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<L16> internal partial class PixelOperations : PixelOperations<L16>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<L16>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<L16>(PixelAlphaRepresentation.None);
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/L8.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<L8> internal partial class PixelOperations : PixelOperations<L8>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<L8>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<L8>(PixelAlphaRepresentation.None);
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/La16.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<La16> internal partial class PixelOperations : PixelOperations<La16>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<La16>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<La16>(PixelAlphaRepresentation.Unassociated);
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/La32.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<La32> internal partial class PixelOperations : PixelOperations<La32>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<La32>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<La32>(PixelAlphaRepresentation.Unassociated);
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte2.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<NormalizedByte2> internal class PixelOperations : PixelOperations<NormalizedByte2>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<NormalizedByte2>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedByte2>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedByte4.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<NormalizedByte4> internal class PixelOperations : PixelOperations<NormalizedByte4>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<NormalizedByte4>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedByte4>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort2.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<NormalizedShort2> internal class PixelOperations : PixelOperations<NormalizedShort2>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<NormalizedShort2>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedShort2>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/NormalizedShort4.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<NormalizedShort4> internal class PixelOperations : PixelOperations<NormalizedShort4>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<NormalizedShort4>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<NormalizedShort4>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rg32.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Rg32> internal class PixelOperations : PixelOperations<Rg32>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Rg32>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rg32>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgb24.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Rgb24> internal partial class PixelOperations : PixelOperations<Rgb24>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Rgb24>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Rgb24>(PixelAlphaRepresentation.None);
} }
} }
} }

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgb48.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Rgb48> internal partial class PixelOperations : PixelOperations<Rgb48>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Rgb48>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Rgb48>(PixelAlphaRepresentation.None);
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba1010102.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Rgba1010102> internal class PixelOperations : PixelOperations<Rgba1010102>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Rgba1010102>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Rgba1010102>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba32.PixelOperations.cs

@ -19,9 +19,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Rgba32> internal partial class PixelOperations : PixelOperations<Rgba32>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Rgba32>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Rgba32>(PixelAlphaRepresentation.Unassociated);
/// <inheritdoc /> /// <inheritdoc />
public override void ToVector4( public override void ToVector4(

7
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Rgba64.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,9 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal partial class PixelOperations : PixelOperations<Rgba64> internal partial class PixelOperations : PixelOperations<Rgba64>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Rgba64>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
=> PixelTypeInfo.Create<Rgba64>(PixelAlphaRepresentation.Unassociated);
} }
} }
} }

5
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs

@ -20,8 +20,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<RgbaVector> internal class PixelOperations : PixelOperations<RgbaVector>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<RgbaVector>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<RgbaVector>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
/// <inheritdoc /> /// <inheritdoc />
public override void FromVector4Destructive( public override void FromVector4Destructive(

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short2.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Short2> internal class PixelOperations : PixelOperations<Short2>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Short2>(PixelAlphaRepresentation.None), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Short2>(PixelAlphaRepresentation.None); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

6
src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Short4.PixelOperations.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
namespace SixLabors.ImageSharp.PixelFormats namespace SixLabors.ImageSharp.PixelFormats
@ -15,8 +16,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
internal class PixelOperations : PixelOperations<Short4> internal class PixelOperations : PixelOperations<Short4>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo =
new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<Short4>(PixelAlphaRepresentation.Unassociated), true);
/// <inheritdoc /> /// <inheritdoc />
public override PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Short4>(PixelAlphaRepresentation.Unassociated); public override PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
} }
} }
} }

4
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs

@ -17,6 +17,8 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial class PixelOperations<TPixel> public partial class PixelOperations<TPixel>
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
private static readonly Lazy<PixelTypeInfo> LazyInfo = new Lazy<PixelTypeInfo>(() => PixelTypeInfo.Create<TPixel>(), true);
/// <summary> /// <summary>
/// Gets the global <see cref="PixelOperations{TPixel}"/> instance for the pixel type <typeparamref name="TPixel"/> /// Gets the global <see cref="PixelOperations{TPixel}"/> instance for the pixel type <typeparamref name="TPixel"/>
/// </summary> /// </summary>
@ -26,7 +28,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Gets the pixel type info for the given <typeparamref name="TPixel"/>. /// Gets the pixel type info for the given <typeparamref name="TPixel"/>.
/// </summary> /// </summary>
/// <returns>The <see cref="PixelTypeInfo"/>.</returns> /// <returns>The <see cref="PixelTypeInfo"/>.</returns>
public virtual PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<TPixel>(); public virtual PixelTypeInfo GetPixelTypeInfo() => LazyInfo.Value;
/// <summary> /// <summary>
/// Bulk version of <see cref="IPixel.FromVector4"/> converting 'sourceVectors.Length' pixels into 'destinationColors'. /// Bulk version of <see cref="IPixel.FromVector4"/> converting 'sourceVectors.Length' pixels into 'destinationColors'.

Loading…
Cancel
Save