From be1e555a604ca5c3e8afdf4fd5a963e51bade47b Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 27 Jun 2018 13:44:56 +0200 Subject: [PATCH 01/40] Changed Pixel Blender/Composer generators to generate all combinations of ColorBlenders and AlphaComposers --- .../GradientBrushBase{TPixel}.cs | 2 +- .../DefaultPixelBlenders.Generated.cs | 3679 ++++++++++++++++- .../DefaultPixelBlenders.Generated.tt | 50 +- .../PorterDuffFunctions.Generated.cs | 2827 ++++++++++++- .../PorterDuffFunctions.Generated.tt | 150 +- .../PixelBlenders/PorterDuffFunctions.cs | 371 +- .../PixelOperations{TPixel}.PixelBenders.cs | 42 +- .../PixelBlenders/PorterDuffBulkVsPixel.cs | 4 +- .../PixelBlenders/PorterDuffFunctionsTests.cs | 18 +- .../PorterDuffFunctionsTests_TPixel.cs | 54 +- .../PixelOperationsTests.Blender.cs | 84 +- 11 files changed, 6706 insertions(+), 575 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/GradientBrushes/GradientBrushBase{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/GradientBrushes/GradientBrushBase{TPixel}.cs index d0a1ef1c24..061023428b 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/GradientBrushes/GradientBrushBase{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/GradientBrushes/GradientBrushBase{TPixel}.cs @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes.GradientBrushes float onLocalGradient = (positionOnCompleteGradient - from.Ratio) / to.Ratio; // TODO: this should be changeble for different gradienting functions - Vector4 result = PorterDuffFunctions.Normal( + Vector4 result = PorterDuffFunctions.Normal_SrcOver( fromAsVector, toAsVector, onLocalGradient); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 6828f11dcc..c5bed2b270 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -1,4 +1,11 @@ -// Copyright (c) Six Labors and contributors. + + + + + + + +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // @@ -24,17 +31,258 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders where TPixel : struct, IPixel { - internal class Normal : PixelBlender + + internal class Normal_Src : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_Src Instance { get; } = new Normal_Src(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_Src(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_Src : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_Src Instance { get; } = new Multiply_Src(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_Src(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_Src : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_Src Instance { get; } = new Add_Src(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_Src(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_Src : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_Src Instance { get; } = new Subtract_Src(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_Src(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_Src : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_Src Instance { get; } = new Screen_Src(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_Src(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_Src : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_Src Instance { get; } = new Darken_Src(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_Src(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_Src : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal Instance { get; } = new Normal(); + public static Lighten_Src Instance { get; } = new Lighten_Src(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal(background, source, amount); + return PorterDuffFunctions.Lighten_Src(background, source, amount); } /// @@ -55,7 +303,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Lighten_Src(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -63,17 +311,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply : PixelBlender + + internal class Overlay_Src : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply Instance { get; } = new Multiply(); + public static Overlay_Src Instance { get; } = new Overlay_Src(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply(background, source, amount); + return PorterDuffFunctions.Overlay_Src(background, source, amount); } /// @@ -94,7 +343,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Overlay_Src(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -102,17 +351,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add : PixelBlender + + internal class HardLight_Src : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add Instance { get; } = new Add(); + public static HardLight_Src Instance { get; } = new HardLight_Src(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add(background, source, amount); + return PorterDuffFunctions.HardLight_Src(background, source, amount); } /// @@ -133,7 +383,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLight_Src(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -141,17 +391,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract : PixelBlender + + internal class Normal_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract Instance { get; } = new Subtract(); + public static Normal_SrcAtop Instance { get; } = new Normal_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract(background, source, amount); + return PorterDuffFunctions.Normal_SrcAtop(background, source, amount); } /// @@ -172,7 +423,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Normal_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -180,17 +431,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen : PixelBlender + + internal class Multiply_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen Instance { get; } = new Screen(); + public static Multiply_SrcAtop Instance { get; } = new Multiply_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen(background, source, amount); + return PorterDuffFunctions.Multiply_SrcAtop(background, source, amount); } /// @@ -211,7 +463,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Multiply_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -219,17 +471,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken : PixelBlender + + internal class Add_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken Instance { get; } = new Darken(); + public static Add_SrcAtop Instance { get; } = new Add_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken(background, source, amount); + return PorterDuffFunctions.Add_SrcAtop(background, source, amount); } /// @@ -250,7 +503,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Add_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -258,17 +511,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten : PixelBlender + + internal class Subtract_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten Instance { get; } = new Lighten(); + public static Subtract_SrcAtop Instance { get; } = new Subtract_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten(background, source, amount); + return PorterDuffFunctions.Subtract_SrcAtop(background, source, amount); } /// @@ -289,7 +543,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Subtract_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -297,17 +551,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay : PixelBlender + + internal class Screen_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay Instance { get; } = new Overlay(); + public static Screen_SrcAtop Instance { get; } = new Screen_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay(background, source, amount); + return PorterDuffFunctions.Screen_SrcAtop(background, source, amount); } /// @@ -328,7 +583,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Screen_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -336,17 +591,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight : PixelBlender + + internal class Darken_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight Instance { get; } = new HardLight(); + public static Darken_SrcAtop Instance { get; } = new Darken_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight(background, source, amount); + return PorterDuffFunctions.Darken_SrcAtop(background, source, amount); } /// @@ -367,7 +623,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Darken_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -375,17 +631,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Src : PixelBlender + + internal class Lighten_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Src Instance { get; } = new Src(); + public static Lighten_SrcAtop Instance { get; } = new Lighten_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Src(background, source, amount); + return PorterDuffFunctions.Lighten_SrcAtop(background, source, amount); } /// @@ -406,7 +663,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Lighten_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -414,17 +671,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Atop : PixelBlender + + internal class Overlay_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Atop Instance { get; } = new Atop(); + public static Overlay_SrcAtop Instance { get; } = new Overlay_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Atop(background, source, amount); + return PorterDuffFunctions.Overlay_SrcAtop(background, source, amount); } /// @@ -445,7 +703,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Atop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Overlay_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -453,17 +711,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Over : PixelBlender + + internal class HardLight_SrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Over Instance { get; } = new Over(); + public static HardLight_SrcAtop Instance { get; } = new HardLight_SrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Over(background, source, amount); + return PorterDuffFunctions.HardLight_SrcAtop(background, source, amount); } /// @@ -484,7 +743,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Over(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLight_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -492,17 +751,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class In : PixelBlender + + internal class Normal_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static In Instance { get; } = new In(); + public static Normal_SrcOver Instance { get; } = new Normal_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.In(background, source, amount); + return PorterDuffFunctions.Normal_SrcOver(background, source, amount); } /// @@ -523,7 +783,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.In(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Normal_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -531,17 +791,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Out : PixelBlender + + internal class Multiply_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Out Instance { get; } = new Out(); + public static Multiply_SrcOver Instance { get; } = new Multiply_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Out(background, source, amount); + return PorterDuffFunctions.Multiply_SrcOver(background, source, amount); } /// @@ -562,7 +823,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Out(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Multiply_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -570,17 +831,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Dest : PixelBlender + + internal class Add_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Dest Instance { get; } = new Dest(); + public static Add_SrcOver Instance { get; } = new Add_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Dest(background, source, amount); + return PorterDuffFunctions.Add_SrcOver(background, source, amount); } /// @@ -601,7 +863,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Add_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -609,17 +871,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class DestAtop : PixelBlender + + internal class Subtract_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static DestAtop Instance { get; } = new DestAtop(); + public static Subtract_SrcOver Instance { get; } = new Subtract_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.DestAtop(background, source, amount); + return PorterDuffFunctions.Subtract_SrcOver(background, source, amount); } /// @@ -640,7 +903,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Subtract_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -648,17 +911,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class DestOver : PixelBlender + + internal class Screen_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static DestOver Instance { get; } = new DestOver(); + public static Screen_SrcOver Instance { get; } = new Screen_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.DestOver(background, source, amount); + return PorterDuffFunctions.Screen_SrcOver(background, source, amount); } /// @@ -679,7 +943,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Screen_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -687,17 +951,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class DestIn : PixelBlender + + internal class Darken_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static DestIn Instance { get; } = new DestIn(); + public static Darken_SrcOver Instance { get; } = new Darken_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.DestIn(background, source, amount); + return PorterDuffFunctions.Darken_SrcOver(background, source, amount); } /// @@ -718,7 +983,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Darken_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -726,17 +991,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class DestOut : PixelBlender + + internal class Lighten_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static DestOut Instance { get; } = new DestOut(); + public static Lighten_SrcOver Instance { get; } = new Lighten_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.DestOut(background, source, amount); + return PorterDuffFunctions.Lighten_SrcOver(background, source, amount); } /// @@ -757,7 +1023,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Lighten_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -765,17 +1031,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Clear : PixelBlender + + internal class Overlay_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Clear Instance { get; } = new Clear(); + public static Overlay_SrcOver Instance { get; } = new Overlay_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Clear(background, source, amount); + return PorterDuffFunctions.Overlay_SrcOver(background, source, amount); } /// @@ -796,7 +1063,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Overlay_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -804,17 +1071,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Xor : PixelBlender + + internal class HardLight_SrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Xor Instance { get; } = new Xor(); + public static HardLight_SrcOver Instance { get; } = new HardLight_SrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Xor(background, source, amount); + return PorterDuffFunctions.HardLight_SrcOver(background, source, amount); } /// @@ -835,7 +1103,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLight_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -843,5 +1111,3246 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } + + internal class Normal_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_SrcIn Instance { get; } = new Normal_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_SrcIn Instance { get; } = new Multiply_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_SrcIn Instance { get; } = new Add_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_SrcIn Instance { get; } = new Subtract_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_SrcIn Instance { get; } = new Screen_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_SrcIn Instance { get; } = new Darken_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_SrcIn Instance { get; } = new Lighten_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_SrcIn Instance { get; } = new Overlay_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_SrcIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_SrcIn Instance { get; } = new HardLight_SrcIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_SrcIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_SrcOut Instance { get; } = new Normal_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_SrcOut Instance { get; } = new Multiply_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_SrcOut Instance { get; } = new Add_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_SrcOut Instance { get; } = new Subtract_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_SrcOut Instance { get; } = new Screen_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_SrcOut Instance { get; } = new Darken_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_SrcOut Instance { get; } = new Lighten_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_SrcOut Instance { get; } = new Overlay_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_SrcOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_SrcOut Instance { get; } = new HardLight_SrcOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_SrcOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_Dest Instance { get; } = new Normal_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_Dest Instance { get; } = new Multiply_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_Dest Instance { get; } = new Add_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_Dest Instance { get; } = new Subtract_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_Dest Instance { get; } = new Screen_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_Dest Instance { get; } = new Darken_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_Dest Instance { get; } = new Lighten_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_Dest Instance { get; } = new Overlay_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_Dest : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_Dest Instance { get; } = new HardLight_Dest(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_Dest(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_DestAtop Instance { get; } = new Normal_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_DestAtop Instance { get; } = new Multiply_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_DestAtop Instance { get; } = new Add_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_DestAtop Instance { get; } = new Subtract_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_DestAtop Instance { get; } = new Screen_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_DestAtop Instance { get; } = new Darken_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_DestAtop Instance { get; } = new Lighten_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_DestAtop Instance { get; } = new Overlay_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_DestAtop : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_DestAtop Instance { get; } = new HardLight_DestAtop(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_DestAtop(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_DestOver Instance { get; } = new Normal_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_DestOver Instance { get; } = new Multiply_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_DestOver Instance { get; } = new Add_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_DestOver Instance { get; } = new Subtract_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_DestOver Instance { get; } = new Screen_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_DestOver Instance { get; } = new Darken_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_DestOver Instance { get; } = new Lighten_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_DestOver Instance { get; } = new Overlay_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_DestOver : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_DestOver Instance { get; } = new HardLight_DestOver(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_DestOver(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_DestIn Instance { get; } = new Normal_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_DestIn Instance { get; } = new Multiply_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_DestIn Instance { get; } = new Add_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_DestIn Instance { get; } = new Subtract_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_DestIn Instance { get; } = new Screen_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_DestIn Instance { get; } = new Darken_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_DestIn Instance { get; } = new Lighten_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_DestIn Instance { get; } = new Overlay_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_DestIn : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_DestIn Instance { get; } = new HardLight_DestIn(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_DestIn(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_DestOut Instance { get; } = new Normal_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_DestOut Instance { get; } = new Multiply_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_DestOut Instance { get; } = new Add_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_DestOut Instance { get; } = new Subtract_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_DestOut Instance { get; } = new Screen_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_DestOut Instance { get; } = new Darken_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_DestOut Instance { get; } = new Lighten_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_DestOut Instance { get; } = new Overlay_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_DestOut : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_DestOut Instance { get; } = new HardLight_DestOut(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_DestOut(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_Clear Instance { get; } = new Normal_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_Clear Instance { get; } = new Multiply_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_Clear Instance { get; } = new Add_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_Clear Instance { get; } = new Subtract_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_Clear Instance { get; } = new Screen_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_Clear Instance { get; } = new Darken_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_Clear Instance { get; } = new Lighten_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_Clear Instance { get; } = new Overlay_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_Clear : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_Clear Instance { get; } = new HardLight_Clear(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_Clear(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Normal_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Normal_Xor Instance { get; } = new Normal_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Normal_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Normal_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Multiply_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Multiply_Xor Instance { get; } = new Multiply_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Multiply_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Multiply_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Add_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Add_Xor Instance { get; } = new Add_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Add_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Add_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Subtract_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Subtract_Xor Instance { get; } = new Subtract_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Subtract_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Subtract_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Screen_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Screen_Xor Instance { get; } = new Screen_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Screen_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Screen_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Darken_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Darken_Xor Instance { get; } = new Darken_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Darken_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Darken_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Lighten_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Lighten_Xor Instance { get; } = new Lighten_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Lighten_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Lighten_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class Overlay_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static Overlay_Xor Instance { get; } = new Overlay_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.Overlay_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.Overlay_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + + internal class HardLight_Xor : PixelBlender + { + /// + /// Gets the static instance of this blender. + /// + public static HardLight_Xor Instance { get; } = new HardLight_Xor(); + + /// + public override TPixel Blend(TPixel background, TPixel source, float amount) + { + return PorterDuffFunctions.HardLight_Xor(background, source, amount); + } + + /// + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) + { + Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); + Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); + Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); + + using (IBuffer buffer = memoryManager.Allocate(destination.Length * 3, false)) + { + Span destinationSpan = buffer.Slice(0, destination.Length); + Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); + Span sourceSpan = buffer.Slice(destination.Length * 2, destination.Length); + + PixelOperations.Instance.ToVector4(background, backgroundSpan, destination.Length); + PixelOperations.Instance.ToVector4(source, sourceSpan, destination.Length); + + for (int i = 0; i < destination.Length; i++) + { + destinationSpan[i] = PorterDuffFunctions.HardLight_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + } + + PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); + } + } + } + + } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index 07888a756d..c2afc6cf67 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { using System; using System.Numerics; - using SixLabors.ImageSharp.Memory; + using SixLabors.Memory; /// @@ -35,24 +35,12 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { <# - - - - string[] blenders = new []{ - "Normal", - "Multiply", - "Add", - "Subtract", - "Screen", - "Darken", - "Lighten", - "Overlay", - "HardLight", + string[] composers = new []{ "Src" , - "Atop" , - "Over" , - "In" , - "Out" , + "SrcAtop" , + "SrcOver" , + "SrcIn" , + "SrcOut" , "Dest" , "DestAtop" , "DestOver" , @@ -62,21 +50,37 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders "Xor" , }; + string[] blenders = new []{ + "Normal" , + "Multiply" , + "Add" , + "Subtract" , + "Screen" , + "Darken" , + "Lighten" , + "Overlay" , + "HardLight" + }; + + foreach(var composer in composers) { foreach(var blender in blenders) { + + string blender_composer= $"{blender}_{composer}"; + #> - internal class <#=blender#> : PixelBlender + internal class <#= blender_composer#> : PixelBlender { /// /// Gets the static instance of this blender. /// - public static <#=blender#> Instance { get; } = new <#=blender#>(); + public static <#= blender_composer#> Instance { get; } = new <#= blender_composer#>(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.<#=blender#>(background, source, amount); + return PorterDuffFunctions.<#= blender_composer#>(background, source, amount); } /// @@ -97,7 +101,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.<#=blender#>(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.<#= blender_composer#>(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -106,7 +110,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } <# - + } } #> diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index 66cc427deb..25c22bd502 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -1,4 +1,11 @@ -// Copyright (c) Six Labors and contributors. + + + + + + + +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. // @@ -11,12 +18,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { internal static partial class PorterDuffFunctions { + + + #region Compositors + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Src(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -26,17 +35,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 1) + (bw * 0) + (xw * 1); // calculate final value - Vector4 xform = ((source * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Atop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SrcAtop(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -46,18 +53,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 0) + (bw * 1) + (xw * 1); // calculate final value - Vector4 xform = ((source * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((xform * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Over(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SrcOver(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -67,17 +71,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 1) + (bw * 1) + (xw * 1); // calculate final value - Vector4 xform = ((source * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 In(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SrcIn(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -87,18 +89,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 0) + (bw * 0) + (xw * 1); // calculate final value - Vector4 xform = ((source * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((xform * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Out(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SrcOut(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -108,17 +107,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 1) + (bw * 0) + (xw * 0); // calculate final value - Vector4 xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Dest(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -128,18 +125,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 0) + (bw * 1) + (xw * 1); // calculate final value - Vector4 xform = ((backdrop * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((backdrop * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DestAtop(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -149,18 +143,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 1) + (bw * 0) + (xw * 1); // calculate final value - Vector4 xform = ((backdrop * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((backdrop * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DestOver(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -170,17 +161,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 1) + (bw * 1) + (xw * 1); // calculate final value - Vector4 xform = ((backdrop * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((backdrop * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DestIn(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -190,17 +179,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 0) + (bw * 0) + (xw * 1); // calculate final value - Vector4 xform = ((backdrop * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((backdrop * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DestOut(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -210,17 +197,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 0) + (bw * 1) + (xw * 0); // calculate final value - Vector4 xform = ((Vector4.Zero * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((Vector4.Zero * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Clear(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -230,18 +215,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 0) + (bw * 0) + (xw * 0); // calculate final value - Vector4 xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Xor(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -251,200 +233,2827 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * 1) + (bw * 1) + (xw * 0); // calculate final value - Vector4 xform = ((Vector4.Zero * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((Vector4.Zero * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; + } + + + #endregion + + #region Blenders + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Src(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Src(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Src(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Src(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Src(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal(TPixel backdrop, TPixel source, float amount) + public static TPixel Darken_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Normal(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(Src(backdropV,sourceV, Darken(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply(TPixel backdrop, TPixel source, float amount) + public static TPixel Lighten_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Multiply(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(Src(backdropV,sourceV, Lighten(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, Overlay(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add(TPixel backdrop, TPixel source, float amount) + public static TPixel Overlay_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Add(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(Src(backdropV,sourceV, Overlay(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop,source, HardLight(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract(TPixel backdrop, TPixel source, float amount) + public static TPixel HardLight_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Subtract(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(Src(backdropV,sourceV, HardLight(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen(TPixel backdrop, TPixel source, float amount) + public static TPixel Normal_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Screen(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Normal(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Multiply(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken(TPixel backdrop, TPixel source, float amount) + public static TPixel Multiply_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Darken(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Multiply(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Add(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten(TPixel backdrop, TPixel source, float amount) + public static TPixel Add_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Lighten(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Add(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Subtract(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay(TPixel backdrop, TPixel source, float amount) + public static TPixel Subtract_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Overlay(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Subtract(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Screen(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight(TPixel backdrop, TPixel source, float amount) + public static TPixel Screen_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(HardLight(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Screen(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Src(TPixel backdrop, TPixel source, float amount) + public static TPixel Darken_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Src(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Darken(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Atop(TPixel backdrop, TPixel source, float amount) + public static TPixel Lighten_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Atop(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Lighten(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, Overlay(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Over(TPixel backdrop, TPixel source, float amount) + public static TPixel Overlay_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Over(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, Overlay(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop,source, HardLight(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel In(TPixel backdrop, TPixel source, float amount) + public static TPixel HardLight_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(In(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcAtop(backdropV,sourceV, HardLight(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Out(TPixel backdrop, TPixel source, float amount) + public static TPixel Normal_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Out(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Normal(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Multiply(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Dest(TPixel backdrop, TPixel source, float amount) + public static TPixel Multiply_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Dest(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Multiply(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Add(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel DestAtop(TPixel backdrop, TPixel source, float amount) + public static TPixel Add_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(DestAtop(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Add(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Subtract(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel DestOver(TPixel backdrop, TPixel source, float amount) + public static TPixel Subtract_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(DestOver(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Subtract(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Screen(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel DestIn(TPixel backdrop, TPixel source, float amount) + public static TPixel Screen_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(DestIn(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Screen(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel DestOut(TPixel backdrop, TPixel source, float amount) + public static TPixel Darken_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(DestOut(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Darken(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Clear(TPixel backdrop, TPixel source, float amount) + public static TPixel Lighten_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Clear(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Lighten(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, Overlay(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Xor(TPixel backdrop, TPixel source, float amount) + public static TPixel Overlay_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + TPixel dest = default; - dest.PackFromVector4(Xor(backdrop.ToVector4(), source.ToVector4(), amount)); + dest.PackFromVector4(SrcOver(backdropV,sourceV, Overlay(backdropV, sourceV))); return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop,source, HardLight(backdrop, source)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOver(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcIn(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(SrcOut(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Dest(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestAtop(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOver(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestIn(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(DestOut(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Clear(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Normal(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Multiply(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Add(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Subtract(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Screen(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Darken(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Lighten(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, Overlay(backdropV, sourceV))); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop,source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(Xor(backdropV,sourceV, HardLight(backdropV, sourceV))); + return dest; + } + + + + #endregion } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index 4cbc068618..25f1e76487 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -21,37 +21,15 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { internal static partial class PorterDuffFunctions { -<# - - void GeneratePixelBlender (string blender) - { -#> - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel <#=blender#>(TPixel backdrop, TPixel source, float amount) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(<#=blender#>(backdrop.ToVector4(), source.ToVector4(), amount)); - return dest; - } - -<# - } - - void GenerateVectorCompositor(string name, string sourceVar, string destVar, string blendVar) +<# void GenerateVectorCompositor(string name, string sourceVar, string destVar, string blendVar) { int a_s = sourceVar == "Vector4.Zero" ? 0 : 1; int a_b = destVar == "Vector4.Zero" ? 0 : 1; int a_x = blendVar == "Vector4.Zero" ? 0 : 1; #> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=name#>(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=name#>(Vector4 backdrop, Vector4 source, Vector4 xform) { - opacity = opacity.Clamp(0, 1); -<# if(sourceVar != "Vector4.Zero" ) { #> - source.W *= opacity; -<# } #> - // calculate weights float xw = backdrop.W * source.W; float bw = backdrop.W - xw; @@ -61,52 +39,98 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float fw = (sw * <#=a_s#>) + (bw * <#=a_b#>) + (xw * <#=a_x#>); // calculate final value - Vector4 xform = ((<#=blendVar#> * xw) + (<#=destVar#> * bw) + (<#=sourceVar#> * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((<#=blendVar#> * xw) + (<#=destVar#> * bw) + (<#=sourceVar#> * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; - return Vector4.Lerp(backdrop, xform, opacity); + return xform; + } +<# } #> +<# void GeneratePixelBlender(string blender, string compositor) { #> + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_<#=compositor#>(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return <#=compositor#>(backdrop,source, <#=blender#>(backdrop, source)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel <#=blender#>_<#=compositor#>(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + opacity = opacity.Clamp(0, 1); + + Vector4 backdropV = backdrop.ToVector4(); + Vector4 sourceV = source.ToVector4(); + sourceV.W *= opacity; + + TPixel dest = default; + dest.PackFromVector4(<#=compositor#>(backdropV,sourceV, <#=blender#>(backdropV, sourceV))); + return dest; + } + +<# } #> + #region Compositors + <# - } - GenerateVectorCompositor("Src", "source", "Vector4.Zero", "source"); - GenerateVectorCompositor("Atop", "Vector4.Zero", "backdrop", "source"); - GenerateVectorCompositor("Over", "source", "backdrop", "source"); - GenerateVectorCompositor("In", "Vector4.Zero", "Vector4.Zero", "source"); - GenerateVectorCompositor("Out", "source", "Vector4.Zero", "Vector4.Zero"); - GenerateVectorCompositor("Dest", "Vector4.Zero", "backdrop", "backdrop"); - GenerateVectorCompositor("DestAtop", "source", "Vector4.Zero", "backdrop"); - GenerateVectorCompositor("DestOver", "source", "backdrop", "backdrop"); - GenerateVectorCompositor("DestIn", "Vector4.Zero", "Vector4.Zero", "backdrop"); - GenerateVectorCompositor("DestOut", "Vector4.Zero", "backdrop", "Vector4.Zero"); - GenerateVectorCompositor("Clear", "Vector4.Zero", "Vector4.Zero", "Vector4.Zero"); - GenerateVectorCompositor("Xor", "source", "backdrop", "Vector4.Zero"); - - - GeneratePixelBlender("Normal"); - GeneratePixelBlender("Multiply"); - GeneratePixelBlender("Add"); - GeneratePixelBlender("Subtract"); - GeneratePixelBlender("Screen"); - GeneratePixelBlender("Darken"); - GeneratePixelBlender("Lighten"); - GeneratePixelBlender("Overlay"); - GeneratePixelBlender("HardLight"); - - GeneratePixelBlender("Src"); - GeneratePixelBlender("Atop"); - GeneratePixelBlender("Over"); - GeneratePixelBlender("In"); - GeneratePixelBlender("Out"); - GeneratePixelBlender("Dest"); - GeneratePixelBlender("DestAtop"); - GeneratePixelBlender("DestOver"); - GeneratePixelBlender("DestIn"); - GeneratePixelBlender("DestOut"); - GeneratePixelBlender("Clear"); - GeneratePixelBlender("Xor"); +GenerateVectorCompositor("Src", "source", "Vector4.Zero", "xform"); +GenerateVectorCompositor("SrcAtop", "Vector4.Zero", "backdrop", "xform"); +GenerateVectorCompositor("SrcOver", "source", "backdrop", "xform"); +GenerateVectorCompositor("SrcIn", "Vector4.Zero", "Vector4.Zero", "xform"); +GenerateVectorCompositor("SrcOut", "source", "Vector4.Zero", "Vector4.Zero"); +GenerateVectorCompositor("Dest", "Vector4.Zero", "backdrop", "backdrop"); +GenerateVectorCompositor("DestAtop", "source", "Vector4.Zero", "backdrop"); +GenerateVectorCompositor("DestOver", "source", "backdrop", "backdrop"); +GenerateVectorCompositor("DestIn", "Vector4.Zero", "Vector4.Zero", "backdrop"); +GenerateVectorCompositor("DestOut", "Vector4.Zero", "backdrop", "Vector4.Zero"); +GenerateVectorCompositor("Clear", "Vector4.Zero", "Vector4.Zero", "Vector4.Zero"); +GenerateVectorCompositor("Xor", "source", "backdrop", "Vector4.Zero"); +#> + + #endregion + + #region Blenders + +<# +string[] composers = new []{ + "Src" , + "SrcAtop" , + "SrcOver" , + "SrcIn" , + "SrcOut" , + "Dest" , + "DestAtop" , + "DestOver" , + "DestIn" , + "DestOut" , + "Clear" , + "Xor" , +}; +string[] blenders = new []{ + "Normal" , + "Multiply" , + "Add" , + "Subtract" , + "Screen" , + "Darken" , + "Lighten" , + "Overlay" , + "HardLight" +}; +foreach(var composer in composers) +{ + foreach(var blender in blenders) + { + GeneratePixelBlender(blender,composer); + + } +} #> + + #endregion } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index c47ef35a3d..b5e89dbec8 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -1,194 +1,179 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders -{ - /// - /// Collection of Porter Duff alpha blending functions applying an the 'Over' composition model. - /// - /// - /// These functions are designed to be a general solution for all color cases, - /// that is, they take in account the alpha value of both the backdrop - /// and source, and there's no need to alpha-premultiply neither the backdrop - /// nor the source. - /// Note there are faster functions for when the backdrop color is known - /// to be opaque - /// - internal static partial class PorterDuffFunctions - { - /// - /// Source over backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, source); - } - - /// - /// Source multiplied by backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, backdrop * source); - } - - /// - /// Source added to backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, Vector4.Min(Vector4.One, backdrop + source)); - } - - /// - /// Source subtracted from backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, Vector4.Max(Vector4.Zero, backdrop - source)); - } - - /// - /// Complement of source multiplied by the complement of backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, Vector4.One - ((Vector4.One - backdrop) * (Vector4.One - source))); - } - - /// - /// Per element, chooses the smallest value of source and backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, Vector4.Min(backdrop, source)); - } - - /// - /// Per element, chooses the largest value of source and backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - return Compose(backdrop, source, Vector4.Max(backdrop, source)); - } - - /// - /// Overlays source over backdrop - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - float cr = OverlayValueFunction(backdrop.X, source.X); - float cg = OverlayValueFunction(backdrop.Y, source.Y); - float cb = OverlayValueFunction(backdrop.Z, source.Z); - - return Compose(backdrop, source, Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0))); - } - - /// - /// Hard light effect - /// - /// Backdrop color - /// Source color - /// Opacity applied to Source Alpha - /// Output color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight(Vector4 backdrop, Vector4 source, float opacity) - { - source.W *= opacity; - float cr = OverlayValueFunction(source.X, backdrop.X); - float cg = OverlayValueFunction(source.Y, backdrop.Y); - float cb = OverlayValueFunction(source.Z, backdrop.Z); - - return Compose(backdrop, source, Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0))); - } - - /// - /// Helper function for Overlay andHardLight modes - /// - /// Backdrop color element - /// Source color element - /// Overlay value - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static float OverlayValueFunction(float backdrop, float source) - { - return backdrop <= 0.5f ? (2 * backdrop * source) : 1 - ((2 * (1 - source)) * (1 - backdrop)); - } - - /// - /// General composition function for all modes, with a general solution for alpha channel - /// - /// Original Backdrop color - /// Original source color - /// Desired transformed color, without taking Alpha channel in account - /// The final color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Vector4 Compose(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float a = xw + bw + sw; - - // calculate final value - xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon); - xform.W = a; - - return xform; - } - } +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Numerics; +using System.Runtime.CompilerServices; + +namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders +{ + /// + /// Collection of Porter Duff alpha blending functions applying an the 'Over' composition model. + /// + /// + /// These functions are designed to be a general solution for all color cases, + /// that is, they take in account the alpha value of both the backdrop + /// and source, and there's no need to alpha-premultiply neither the backdrop + /// nor the source. + /// Note there are faster functions for when the backdrop color is known + /// to be opaque + /// + internal static partial class PorterDuffFunctions + { + /// + /// Source over backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal(Vector4 backdrop, Vector4 source) + { + return source; + } + + /// + /// Source multiplied by backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply(Vector4 backdrop, Vector4 source) + { + return backdrop * source; + } + + /// + /// Source added to backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add(Vector4 backdrop, Vector4 source) + { + return Vector4.Min(Vector4.One, backdrop + source); + } + + /// + /// Source subtracted from backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract(Vector4 backdrop, Vector4 source) + { + return Vector4.Max(Vector4.Zero, backdrop - source); + } + + /// + /// Complement of source multiplied by the complement of backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen(Vector4 backdrop, Vector4 source) + { + return Vector4.One - ((Vector4.One - backdrop) * (Vector4.One - source)); + } + + /// + /// Per element, chooses the smallest value of source and backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken(Vector4 backdrop, Vector4 source) + { + return Vector4.Min(backdrop, source); + } + + /// + /// Per element, chooses the largest value of source and backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten(Vector4 backdrop, Vector4 source) + { + return Vector4.Max(backdrop, source); + } + + /// + /// Overlays source over backdrop + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay(Vector4 backdrop, Vector4 source) + { + float cr = OverlayValueFunction(backdrop.X, source.X); + float cg = OverlayValueFunction(backdrop.Y, source.Y); + float cb = OverlayValueFunction(backdrop.Z, source.Z); + + return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + } + + /// + /// Hard light effect + /// + /// Backdrop color + /// Source color + /// Output color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight(Vector4 backdrop, Vector4 source) + { + float cr = OverlayValueFunction(source.X, backdrop.X); + float cg = OverlayValueFunction(source.Y, backdrop.Y); + float cb = OverlayValueFunction(source.Z, backdrop.Z); + + return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + } + + /// + /// Helper function for Overlay andHardLight modes + /// + /// Backdrop color element + /// Source color element + /// Overlay value + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static float OverlayValueFunction(float backdrop, float source) + { + return backdrop <= 0.5f ? (2 * backdrop * source) : 1 - ((2 * (1 - source)) * (1 - backdrop)); + } + + /// + /// General composition function for all modes, with a general solution for alpha channel + /// + /// Original Backdrop color + /// Original source color + /// Desired transformed color, without taking Alpha channel in account + /// The final color + /// + /// This is the default compositor for "normal" alpha blending, which matches the generated SrcOver compositor. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static Vector4 Compose(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + float bw = backdrop.W - xw; + float sw = source.W - xw; + + // calculate final alpha + float a = xw + bw + sw; + + // calculate final value + xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon); + xform.W = a; + + return xform; + } + } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs index 2c225ba4c4..ad9366bc52 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs @@ -20,30 +20,30 @@ namespace SixLabors.ImageSharp.PixelFormats { switch (mode) { - case PixelBlenderMode.Multiply: return DefaultPixelBlenders.Multiply.Instance; - case PixelBlenderMode.Add: return DefaultPixelBlenders.Add.Instance; - case PixelBlenderMode.Subtract: return DefaultPixelBlenders.Subtract.Instance; - case PixelBlenderMode.Screen: return DefaultPixelBlenders.Screen.Instance; - case PixelBlenderMode.Darken: return DefaultPixelBlenders.Darken.Instance; - case PixelBlenderMode.Lighten: return DefaultPixelBlenders.Lighten.Instance; - case PixelBlenderMode.Overlay: return DefaultPixelBlenders.Overlay.Instance; - case PixelBlenderMode.HardLight: return DefaultPixelBlenders.HardLight.Instance; - case PixelBlenderMode.Src: return DefaultPixelBlenders.Src.Instance; - case PixelBlenderMode.Atop: return DefaultPixelBlenders.Atop.Instance; - case PixelBlenderMode.Over: return DefaultPixelBlenders.Over.Instance; - case PixelBlenderMode.In: return DefaultPixelBlenders.In.Instance; - case PixelBlenderMode.Out: return DefaultPixelBlenders.Out.Instance; - case PixelBlenderMode.Dest: return DefaultPixelBlenders.Dest.Instance; - case PixelBlenderMode.DestAtop: return DefaultPixelBlenders.DestAtop.Instance; - case PixelBlenderMode.DestOver: return DefaultPixelBlenders.DestOver.Instance; - case PixelBlenderMode.DestIn: return DefaultPixelBlenders.DestIn.Instance; - case PixelBlenderMode.DestOut: return DefaultPixelBlenders.DestOut.Instance; - case PixelBlenderMode.Clear: return DefaultPixelBlenders.Clear.Instance; - case PixelBlenderMode.Xor: return DefaultPixelBlenders.Xor.Instance; + case PixelBlenderMode.Multiply: return DefaultPixelBlenders.Multiply_SrcOver.Instance; + case PixelBlenderMode.Add: return DefaultPixelBlenders.Add_SrcOver.Instance; + case PixelBlenderMode.Subtract: return DefaultPixelBlenders.Subtract_SrcOver.Instance; + case PixelBlenderMode.Screen: return DefaultPixelBlenders.Screen_SrcOver.Instance; + case PixelBlenderMode.Darken: return DefaultPixelBlenders.Darken_SrcOver.Instance; + case PixelBlenderMode.Lighten: return DefaultPixelBlenders.Lighten_SrcOver.Instance; + case PixelBlenderMode.Overlay: return DefaultPixelBlenders.Overlay_SrcOver.Instance; + case PixelBlenderMode.HardLight: return DefaultPixelBlenders.HardLight_SrcOver.Instance; + case PixelBlenderMode.Src: return DefaultPixelBlenders.Normal_Src.Instance; + case PixelBlenderMode.Atop: return DefaultPixelBlenders.Normal_SrcAtop.Instance; + case PixelBlenderMode.Over: return DefaultPixelBlenders.Normal_SrcOver.Instance; + case PixelBlenderMode.In: return DefaultPixelBlenders.Normal_SrcIn.Instance; + case PixelBlenderMode.Out: return DefaultPixelBlenders.Normal_SrcOut.Instance; + case PixelBlenderMode.Dest: return DefaultPixelBlenders.Normal_Dest.Instance; + case PixelBlenderMode.DestAtop: return DefaultPixelBlenders.Normal_DestAtop.Instance; + case PixelBlenderMode.DestOver: return DefaultPixelBlenders.Normal_DestOver.Instance; + case PixelBlenderMode.DestIn: return DefaultPixelBlenders.Normal_DestIn.Instance; + case PixelBlenderMode.DestOut: return DefaultPixelBlenders.Normal_DestOut.Instance; + case PixelBlenderMode.Clear: return DefaultPixelBlenders.Normal_Clear.Instance; + case PixelBlenderMode.Xor: return DefaultPixelBlenders.Normal_Xor.Instance; case PixelBlenderMode.Normal: default: - return DefaultPixelBlenders.Normal.Instance; + return DefaultPixelBlenders.Normal_SrcOver.Instance; } } } diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index 5fe8b2785d..df7e5b4135 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Benchmarks for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.Normal_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Benchmarks for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.Normal(destination[i], source[i], amount[i]); + destination[i] = PorterDuffFunctions.Normal_SrcOver(destination[i], source[i], amount[i]); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index c5910e13a3..c34bdc56e4 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(NormalBlendFunctionData))] public void NormalBlendFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Normal((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Normal_SrcOver((Vector4)back, source, amount); Assert.Equal(expected, actual); } @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(MultiplyFunctionData))] public void MultiplyFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Multiply((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Multiply_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(AddFunctionData))] public void AddFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Multiply((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Multiply_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(SubstractFunctionData))] public void SubstractFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Subtract((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Subtract_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(ScreenFunctionData))] public void ScreenFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Screen((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Screen_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(DarkenFunctionData))] public void DarkenFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Darken((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Darken_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(LightenFunctionData))] public void LightenFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Lighten((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Lighten_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(OverlayFunctionData))] public void OverlayFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Overlay((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.Overlay_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -174,7 +174,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(HardLightFunctionData))] public void HardLightFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.HardLight((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.HardLight_SrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs index 1273a453ea..a53591dbc2 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void NormalBlendFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Normal((TPixel)(TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Normal_SrcOver((TPixel)(TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void NormalBlendFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Normal().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Normal_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Normal().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Normal_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void MultiplyFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Multiply((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Multiply_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void MultiplyFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Multiply().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Multiply_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Multiply().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Multiply_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void AddFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Add((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Add_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void AddFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Add().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Add_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Add().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Add_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void SubstractFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Subtract((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Subtract_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void SubstractFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Subtract().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Subtract_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Subtract().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Subtract_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void ScreenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Screen((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Screen_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void ScreenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Screen().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Screen_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Screen().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Screen_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -229,7 +229,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void DarkenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Darken((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Darken_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void DarkenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Darken().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Darken_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -248,7 +248,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Darken().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Darken_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -268,7 +268,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void LightenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Lighten((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Lighten_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -277,7 +277,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void LightenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Lighten().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Lighten_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -287,7 +287,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Lighten().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Lighten_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -307,7 +307,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void OverlayFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Overlay((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.Overlay_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -316,7 +316,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void OverlayFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Overlay().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.Overlay_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -326,7 +326,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Overlay().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Overlay_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -346,7 +346,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void HardLightFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.HardLight((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.HardLight_SrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -355,7 +355,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void HardLightFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.HardLight().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.HardLight_SrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -365,7 +365,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.HardLight().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.HardLight_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs index d3956ecd5d..1a4121c974 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs @@ -17,50 +17,50 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public static TheoryData BlenderMappings = new TheoryData() { - { new TestPixel(), typeof(DefaultPixelBlenders.Normal), PixelBlenderMode.Normal }, - { new TestPixel(), typeof(DefaultPixelBlenders.Screen), PixelBlenderMode.Screen }, - { new TestPixel(), typeof(DefaultPixelBlenders.HardLight), PixelBlenderMode.HardLight }, - { new TestPixel(), typeof(DefaultPixelBlenders.Overlay), PixelBlenderMode.Overlay }, - { new TestPixel(), typeof(DefaultPixelBlenders.Darken), PixelBlenderMode.Darken }, - { new TestPixel(), typeof(DefaultPixelBlenders.Lighten), PixelBlenderMode.Lighten }, - { new TestPixel(), typeof(DefaultPixelBlenders.Add), PixelBlenderMode.Add }, - { new TestPixel(), typeof(DefaultPixelBlenders.Subtract), PixelBlenderMode.Subtract }, - { new TestPixel(), typeof(DefaultPixelBlenders.Multiply), PixelBlenderMode.Multiply }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Normal }, + { new TestPixel(), typeof(DefaultPixelBlenders.Screen_SrcOver), PixelBlenderMode.Screen }, + { new TestPixel(), typeof(DefaultPixelBlenders.HardLight_SrcOver), PixelBlenderMode.HardLight }, + { new TestPixel(), typeof(DefaultPixelBlenders.Overlay_SrcOver), PixelBlenderMode.Overlay }, + { new TestPixel(), typeof(DefaultPixelBlenders.Darken_SrcOver), PixelBlenderMode.Darken }, + { new TestPixel(), typeof(DefaultPixelBlenders.Lighten_SrcOver), PixelBlenderMode.Lighten }, + { new TestPixel(), typeof(DefaultPixelBlenders.Add_SrcOver), PixelBlenderMode.Add }, + { new TestPixel(), typeof(DefaultPixelBlenders.Subtract_SrcOver), PixelBlenderMode.Subtract }, + { new TestPixel(), typeof(DefaultPixelBlenders.Multiply_SrcOver), PixelBlenderMode.Multiply }, - { new TestPixel(), typeof(DefaultPixelBlenders.Src), PixelBlenderMode.Src }, - { new TestPixel(), typeof(DefaultPixelBlenders.Atop), PixelBlenderMode.Atop }, - { new TestPixel(), typeof(DefaultPixelBlenders.Over), PixelBlenderMode.Over }, - { new TestPixel(), typeof(DefaultPixelBlenders.In), PixelBlenderMode.In }, - { new TestPixel(), typeof(DefaultPixelBlenders.Out), PixelBlenderMode.Out }, - { new TestPixel(), typeof(DefaultPixelBlenders.Dest), PixelBlenderMode.Dest }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestAtop), PixelBlenderMode.DestAtop }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestOver), PixelBlenderMode.DestOver }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestIn), PixelBlenderMode.DestIn }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestOut), PixelBlenderMode.DestOut }, - { new TestPixel(), typeof(DefaultPixelBlenders.Clear), PixelBlenderMode.Clear }, - { new TestPixel(), typeof(DefaultPixelBlenders.Xor), PixelBlenderMode.Xor }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Src), PixelBlenderMode.Src }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcAtop), PixelBlenderMode.Atop }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Over }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcIn), PixelBlenderMode.In }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOut), PixelBlenderMode.Out }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Dest), PixelBlenderMode.Dest }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestAtop), PixelBlenderMode.DestAtop }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOver), PixelBlenderMode.DestOver }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestIn), PixelBlenderMode.DestIn }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOut), PixelBlenderMode.DestOut }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Clear), PixelBlenderMode.Clear }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Xor), PixelBlenderMode.Xor }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal), PixelBlenderMode.Normal }, - { new TestPixel(), typeof(DefaultPixelBlenders.Screen), PixelBlenderMode.Screen }, - { new TestPixel(), typeof(DefaultPixelBlenders.HardLight), PixelBlenderMode.HardLight }, - { new TestPixel(), typeof(DefaultPixelBlenders.Overlay), PixelBlenderMode.Overlay }, - { new TestPixel(), typeof(DefaultPixelBlenders.Darken), PixelBlenderMode.Darken }, - { new TestPixel(), typeof(DefaultPixelBlenders.Lighten), PixelBlenderMode.Lighten }, - { new TestPixel(), typeof(DefaultPixelBlenders.Add), PixelBlenderMode.Add }, - { new TestPixel(), typeof(DefaultPixelBlenders.Subtract), PixelBlenderMode.Subtract }, - { new TestPixel(), typeof(DefaultPixelBlenders.Multiply), PixelBlenderMode.Multiply }, - { new TestPixel(), typeof(DefaultPixelBlenders.Src), PixelBlenderMode.Src }, - { new TestPixel(), typeof(DefaultPixelBlenders.Atop), PixelBlenderMode.Atop }, - { new TestPixel(), typeof(DefaultPixelBlenders.Over), PixelBlenderMode.Over }, - { new TestPixel(), typeof(DefaultPixelBlenders.In), PixelBlenderMode.In }, - { new TestPixel(), typeof(DefaultPixelBlenders.Out), PixelBlenderMode.Out }, - { new TestPixel(), typeof(DefaultPixelBlenders.Dest), PixelBlenderMode.Dest }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestAtop), PixelBlenderMode.DestAtop }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestOver), PixelBlenderMode.DestOver }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestIn), PixelBlenderMode.DestIn }, - { new TestPixel(), typeof(DefaultPixelBlenders.DestOut), PixelBlenderMode.DestOut }, - { new TestPixel(), typeof(DefaultPixelBlenders.Clear), PixelBlenderMode.Clear }, - { new TestPixel(), typeof(DefaultPixelBlenders.Xor), PixelBlenderMode.Xor }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Normal }, + { new TestPixel(), typeof(DefaultPixelBlenders.Screen_SrcOver), PixelBlenderMode.Screen }, + { new TestPixel(), typeof(DefaultPixelBlenders.HardLight_SrcOver), PixelBlenderMode.HardLight }, + { new TestPixel(), typeof(DefaultPixelBlenders.Overlay_SrcOver), PixelBlenderMode.Overlay }, + { new TestPixel(), typeof(DefaultPixelBlenders.Darken_SrcOver), PixelBlenderMode.Darken }, + { new TestPixel(), typeof(DefaultPixelBlenders.Lighten_SrcOver), PixelBlenderMode.Lighten }, + { new TestPixel(), typeof(DefaultPixelBlenders.Add_SrcOver), PixelBlenderMode.Add }, + { new TestPixel(), typeof(DefaultPixelBlenders.Subtract_SrcOver), PixelBlenderMode.Subtract }, + { new TestPixel(), typeof(DefaultPixelBlenders.Multiply_SrcOver), PixelBlenderMode.Multiply }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Src), PixelBlenderMode.Src }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcAtop), PixelBlenderMode.Atop }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Over }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcIn), PixelBlenderMode.In }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOut), PixelBlenderMode.Out }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Dest), PixelBlenderMode.Dest }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestAtop), PixelBlenderMode.DestAtop }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOver), PixelBlenderMode.DestOver }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestIn), PixelBlenderMode.DestIn }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOut), PixelBlenderMode.DestOut }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Clear), PixelBlenderMode.Clear }, + { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Xor), PixelBlenderMode.Xor }, }; From a720778807551ee13c0e66e8d02da5cc6fa45f00 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 27 Jun 2018 16:23:11 +0200 Subject: [PATCH 02/40] removed trailing spaces --- .../PixelBlenders/PorterDuffFunctions.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index b5e89dbec8..0719b834c6 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source over backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Normal(Vector4 backdrop, Vector4 source) @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source multiplied by backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Multiply(Vector4 backdrop, Vector4 source) @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source added to backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Add(Vector4 backdrop, Vector4 source) @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source subtracted from backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Subtract(Vector4 backdrop, Vector4 source) @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Complement of source multiplied by the complement of backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Screen(Vector4 backdrop, Vector4 source) @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Per element, chooses the smallest value of source and backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Darken(Vector4 backdrop, Vector4 source) @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Per element, chooses the largest value of source and backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Lighten(Vector4 backdrop, Vector4 source) @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Overlays source over backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Overlay(Vector4 backdrop, Vector4 source) @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Hard light effect /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 HardLight(Vector4 backdrop, Vector4 source) From 4836450c22ea4e9500f3223d1b83e6a757fd9e79 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Thu, 28 Jun 2018 17:59:10 +0200 Subject: [PATCH 03/40] exploring an alternative way of generating methods --- .../PorterDuffFunctions.Generated.cs | 3077 +++++++---------- .../PorterDuffFunctions.Generated.tt | 177 +- .../PixelBlenders/PorterDuffFunctions.cs | 157 +- 3 files changed, 1441 insertions(+), 1970 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index 25c22bd502..73e1c7f024 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -20,26 +20,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { - #region Compositors - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Src(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - // calculate final alpha - float fw = (sw * 1) + (bw * 0) + (xw * 1); - // calculate final value - xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - return xform; - } + + + + + + + #region Blenders [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 SrcAtop(Vector4 backdrop, Vector4 source, Vector4 xform) @@ -78,7 +70,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 SrcIn(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Dest(Vector4 backdrop, Vector4 source, Vector4 xform) { // calculate weights float xw = backdrop.W * source.W; @@ -86,17 +78,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float sw = source.W - xw; // calculate final alpha - float fw = (sw * 0) + (bw * 0) + (xw * 1); + float fw = (sw * 0) + (bw * 1) + (xw * 1); // calculate final value - xform = ((xform * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((backdrop * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 SrcOut(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 DestOut(Vector4 backdrop, Vector4 source, Vector4 xform) { // calculate weights float xw = backdrop.W * source.W; @@ -104,17 +96,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float sw = source.W - xw; // calculate final alpha - float fw = (sw * 1) + (bw * 0) + (xw * 0); + float fw = (sw * 0) + (bw * 1) + (xw * 0); // calculate final value - xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((Vector4.Zero * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; return xform; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Dest(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Xor(Vector4 backdrop, Vector4 source, Vector4 xform) { // calculate weights float xw = backdrop.W * source.W; @@ -122,2935 +114,2182 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float sw = source.W - xw; // calculate final alpha - float fw = (sw * 0) + (bw * 1) + (xw * 1); + float fw = (sw * 1) + (bw * 1) + (xw * 0); // calculate final value - xform = ((backdrop * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform = ((Vector4.Zero * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); xform.W = fw; return xform; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestAtop(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Normal_Src(Vector4 backdrop, Vector4 source, float opacity) { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 0) + (xw * 1); - - // calculate final value - xform = ((backdrop * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - return xform; + return Src(backdrop, source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestOver(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Normal_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 1) + (xw * 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - // calculate final value - xform = ((backdrop * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; + return SrcAtop(backdrop, source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestIn(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Normal_SrcOver(Vector4 backdrop, Vector4 source, float opacity) { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - // calculate final alpha - float fw = (sw * 0) + (bw * 0) + (xw * 1); + return SrcOver(backdrop, source, Normal(backdrop, source)); + } - // calculate final value - xform = ((backdrop * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - return xform; + return SrcIn(backdrop, source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestOut(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Normal_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - // calculate final alpha - float fw = (sw * 0) + (bw * 1) + (xw * 0); + return SrcOut(backdrop, source, Normal(backdrop, source)); + } - // calculate final value - xform = ((Vector4.Zero * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - return xform; + return Dest(backdrop, source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Clear(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Normal_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - // calculate final alpha - float fw = (sw * 0) + (bw * 0) + (xw * 0); + return DestAtop(backdrop, source, Normal(backdrop, source)); + } - // calculate final value - xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - return xform; + return DestOver(backdrop, source, Normal(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Xor(Vector4 backdrop, Vector4 source, Vector4 xform) + public static Vector4 Normal_DestIn(Vector4 backdrop, Vector4 source, float opacity) { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - // calculate final alpha - float fw = (sw * 1) + (bw * 1) + (xw * 0); + return DestIn(backdrop, source, Normal(backdrop, source)); + } - // calculate final value - xform = ((Vector4.Zero * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - return xform; + return DestOut(backdrop, source, Normal(backdrop, source)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Clear(backdrop, source, source); + } - #endregion - - #region Blenders + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Xor(backdrop, source, source); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Src(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Normal_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Normal(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Normal_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel Normal_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Normal(backdropV, sourceV))); + dest.PackFromVector4(Normal_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Src(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Normal_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Multiply(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Normal_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel Normal_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Multiply(backdropV, sourceV))); + dest.PackFromVector4(Normal_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Src(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Normal_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Add(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Normal_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel Normal_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Normal_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Src(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Normal_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Normal_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel Normal_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Normal_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Src(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Normal_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Normal_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel Normal_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Normal_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Src(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Normal_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Normal_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel Normal_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Normal_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Multiply_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Lighten(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Multiply(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Multiply_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Lighten(backdropV, sourceV))); - return dest; - } + return SrcAtop(backdrop, source, Multiply(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return SrcOver(backdrop, source, Multiply(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Multiply_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, Overlay(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, Multiply(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Multiply_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, Overlay(backdropV, sourceV))); - return dest; - } + return SrcOut(backdrop, source, Multiply(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Dest(backdrop, source, Multiply(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Multiply_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop,source, HardLight(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, Multiply(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Multiply_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Src(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } + return DestOver(backdrop, source, Multiply(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Multiply(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Multiply_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Normal(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, Multiply(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Multiply_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return Clear(backdrop, source, source); + } - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Xor(backdrop, source, source); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Multiply_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Multiply(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Multiply_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel Multiply_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Multiply(backdropV, sourceV))); + dest.PackFromVector4(Multiply_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Multiply_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Add(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Multiply_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Multiply_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Multiply_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Multiply_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Multiply_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Multiply_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Multiply_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Multiply_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Multiply_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Multiply_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Multiply_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Multiply_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Multiply_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Multiply_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Multiply_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Multiply_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Lighten(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Multiply_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Multiply_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Multiply_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Add_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, Overlay(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Add(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Add_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, Overlay(backdropV, sourceV))); - return dest; - } + return SrcAtop(backdrop, source, Add(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return SrcOver(backdrop, source, Add(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Add_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop,source, HardLight(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, Add(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Add_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(SrcAtop(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } + return SrcOut(backdrop, source, Add(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Dest(backdrop, source, Add(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Add_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Normal(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, Add(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Add_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } + return DestOver(backdrop, source, Add(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Add(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Add_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Multiply(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, Add(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Add_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return Clear(backdrop, source, source); + } - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Xor(backdrop, source, source); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Add_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Add(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Add_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Add_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Add_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Add_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Add_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Add_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Add_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Add_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Add_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Add_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Add_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Add_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Add_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Add_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Add_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Add_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Lighten(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Add_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Add_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Add_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Add_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, Overlay(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Add_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Add_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(Add_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Subtract_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop,source, HardLight(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Subtract(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Subtract_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(SrcOver(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } + return SrcAtop(backdrop, source, Subtract(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return SrcOver(backdrop, source, Subtract(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Subtract_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Normal(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, Subtract(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Subtract_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } + return SrcOut(backdrop, source, Subtract(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Dest(backdrop, source, Subtract(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Subtract_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Multiply(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, Subtract(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Subtract_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } + return DestOver(backdrop, source, Subtract(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Subtract(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Subtract_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Add(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, Subtract(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Subtract_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return Clear(backdrop, source, source); + } - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Add(backdropV, sourceV))); - return dest; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Xor(backdrop, source, source); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Subtract_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Subtract_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Subtract_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Subtract_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Subtract_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Subtract_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Subtract_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Subtract_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Subtract_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Subtract_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Subtract_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Subtract_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Subtract_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Lighten(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Subtract_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Subtract_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Subtract_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Subtract_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, Overlay(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Subtract_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Subtract_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(Subtract_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Subtract_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop,source, HardLight(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Subtract_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Subtract_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcIn(backdropV,sourceV, HardLight(backdropV, sourceV))); + dest.PackFromVector4(Subtract_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Screen_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Normal(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Screen(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Screen_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } + return SrcAtop(backdrop, source, Screen(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return SrcOver(backdrop, source, Screen(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Screen_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Multiply(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, Screen(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Screen_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } + return SrcOut(backdrop, source, Screen(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Dest(backdrop, source, Screen(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Screen_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Add(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, Screen(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Screen_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Add(backdropV, sourceV))); - return dest; - } + return DestOver(backdrop, source, Screen(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Screen(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Screen_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Subtract(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop, source, Screen(backdrop, source)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source, source); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Screen_Xor(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return Xor(backdrop, source, source); + } - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Subtract(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Screen(backdrop, source)); - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Screen_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Darken(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Screen_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Lighten(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Screen_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, Overlay(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(Screen_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop,source, HardLight(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_SrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(SrcOut(backdropV,sourceV, HardLight(backdropV, sourceV))); + dest.PackFromVector4(Screen_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Normal(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Normal(backdropV, sourceV))); + dest.PackFromVector4(Screen_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Multiply(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_DestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Multiply(backdropV, sourceV))); + dest.PackFromVector4(Screen_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Add(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Screen_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Subtract(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_DestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Screen_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Screen(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Screen_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Darken(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_Clear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Screen_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Lighten(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel Screen_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Screen_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Darken_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, Overlay(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, Overlay(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop,source, HardLight(backdrop, source)); + return SrcAtop(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_SrcOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(Dest(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Normal(backdrop, source)); + return SrcOver(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Multiply(backdrop, source)); + return SrcIn(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Add(backdrop, source)); + return SrcOut(backdrop, source, Darken(backdrop, source)); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Dest(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Add(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Subtract(backdrop, source)); + return Dest(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Subtract(backdropV, sourceV))); - return dest; - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Screen(backdrop, source)); + return DestAtop(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Screen(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Darken(backdrop, source)); + return DestOver(backdrop, source, Darken(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_DestIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Darken(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Darken(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Darken_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Lighten(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, Darken(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Darken_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Lighten(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Clear(backdrop, source, source); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Darken_Xor(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, Overlay(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(Darken_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop,source, HardLight(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestAtop(backdropV,sourceV, HardLight(backdropV, sourceV))); + dest.PackFromVector4(Darken_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Normal(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_SrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Normal(backdropV, sourceV))); + dest.PackFromVector4(Darken_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Multiply(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Multiply(backdropV, sourceV))); + dest.PackFromVector4(Darken_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Add(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_SrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Darken_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Subtract(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Darken_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Screen(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_DestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Darken_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Darken(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel Darken_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Darken_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Lighten(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_DestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Darken_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, Overlay(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(Darken_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop,source, HardLight(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_Clear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOver(backdropV,sourceV, HardLight(backdropV, sourceV))); + dest.PackFromVector4(Darken_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Normal(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel Darken_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Normal(backdropV, sourceV))); + dest.PackFromVector4(Darken_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Lighten_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Multiply(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Add(backdrop, source)); + return SrcAtop(backdrop, source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_SrcOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Add(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Subtract(backdrop, source)); + return SrcOver(backdrop, source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Subtract(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Screen(backdrop, source)); + return SrcIn(backdrop, source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Screen(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Darken(backdrop, source)); + return SrcOut(backdrop, source, Lighten(backdrop, source)); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Dest(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Darken(backdropV, sourceV))); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Lighten(backdrop, source)); + return Dest(backdrop, source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Lighten(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestAtop(backdrop, source, Lighten(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Lighten_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, Overlay(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOver(backdrop, source, Lighten(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_DestIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, Overlay(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Lighten(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Lighten_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop,source, HardLight(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, Lighten(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Lighten_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(DestIn(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } - + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Clear(backdrop, source, source); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Lighten_Xor(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Normal(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_Src(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Normal(backdropV, sourceV))); + dest.PackFromVector4(Lighten_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Multiply(backdrop, source)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Multiply(backdropV, sourceV))); + dest.PackFromVector4(Lighten_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Lighten_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Add(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Lighten_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Lighten_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Lighten_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Lighten_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Lighten_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Lighten_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Lighten_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Lighten_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Lighten_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Lighten_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Lighten_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Lighten_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Lighten(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Lighten_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel Lighten_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Lighten_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Overlay_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, Overlay(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, Overlay(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Overlay_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, Overlay(backdropV, sourceV))); - return dest; - } + return SrcAtop(backdrop, source, Overlay(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return SrcOver(backdrop, source, Overlay(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Overlay_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop,source, HardLight(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, Overlay(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Overlay_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(DestOut(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } + return SrcOut(backdrop, source, Overlay(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Dest(backdrop, source, Overlay(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Overlay_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Normal(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, Overlay(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Overlay_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } + return DestOver(backdrop, source, Overlay(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, Overlay(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 Overlay_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Multiply(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, Overlay(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 Overlay_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return Clear(backdrop, source, source); + } - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Xor(backdrop, source, source); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Overlay_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Add(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Overlay_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel Overlay_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Add(backdropV, sourceV))); + dest.PackFromVector4(Overlay_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Overlay_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Overlay_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel Overlay_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(Overlay_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Overlay_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Overlay_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel Overlay_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(Overlay_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Overlay_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Overlay_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel Overlay_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(Overlay_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Overlay_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Lighten(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Overlay_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel Overlay_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(Overlay_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel Overlay_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, Overlay(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(Overlay_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel Overlay_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(Overlay_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLight_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop,source, HardLight(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, HardLight(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 HardLight_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Clear(backdropV,sourceV, HardLight(backdropV, sourceV))); - return dest; - } + return SrcAtop(backdrop, source, HardLight(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return SrcOver(backdrop, source, HardLight(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLight_SrcIn(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Normal(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, HardLight(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 HardLight_SrcOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Normal(backdropV, sourceV))); - return dest; - } + return SrcOut(backdrop, source, HardLight(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Dest(backdrop, source, HardLight(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLight_DestAtop(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Multiply(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, HardLight(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 HardLight_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Multiply(backdropV, sourceV))); - return dest; - } + return DestOver(backdrop, source, HardLight(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestIn(backdrop, source, HardLight(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLight_DestOut(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Add(backdrop, source)); - } + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return DestOut(backdrop, source, HardLight(backdrop, source)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 HardLight_Clear(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return Clear(backdrop, source, source); + } - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Add(backdropV, sourceV))); - return dest; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + return Xor(backdrop, source, source); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel HardLight_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Subtract(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(HardLight_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLight_SrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Subtract(backdropV, sourceV))); + dest.PackFromVector4(HardLight_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel HardLight_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Screen(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(HardLight_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLight_SrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Screen(backdropV, sourceV))); + dest.PackFromVector4(HardLight_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel HardLight_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Darken(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(HardLight_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLight_Dest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Darken(backdropV, sourceV))); + dest.PackFromVector4(HardLight_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel HardLight_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Lighten(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(HardLight_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLight_DestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Lighten(backdropV, sourceV))); + dest.PackFromVector4(HardLight_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel HardLight_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, Overlay(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(HardLight_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLight_DestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, Overlay(backdropV, sourceV))); + dest.PackFromVector4(HardLight_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } - + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static TPixel HardLight_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop,source, HardLight(backdrop, source)); + TPixel dest = default; + dest.PackFromVector4(HardLight_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TPixel HardLight_Xor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { - opacity = opacity.Clamp(0, 1); - - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; - TPixel dest = default; - dest.PackFromVector4(Xor(backdropV,sourceV, HardLight(backdropV, sourceV))); + dest.PackFromVector4(HardLight_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index 25f1e76487..64608fcfac 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -21,6 +21,8 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { internal static partial class PorterDuffFunctions { + + <# void GenerateVectorCompositor(string name, string sourceVar, string destVar, string blendVar) { int a_s = sourceVar == "Vector4.Zero" ? 0 : 1; @@ -45,55 +47,152 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return xform; } <# } #> -<# void GeneratePixelBlender(string blender, string compositor) { #> + + + + + +<# void GeneratePixelBlenders(string blender) { #> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_<#=compositor#>(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>_Src(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return <#=compositor#>(backdrop,source, <#=blender#>(backdrop, source)); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Src(backdrop, source, <#=blender#>(backdrop, source)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel <#=blender#>_<#=compositor#>(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel + public static Vector4 <#=blender#>_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcAtop(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOver(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcIn(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return SrcOut(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Dest(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestAtop(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestOver(Vector4 backdrop, Vector4 source, float opacity) { - opacity = opacity.Clamp(0, 1); + opacity = opacity.Clamp(0, 1); + source.W *= opacity; - Vector4 backdropV = backdrop.ToVector4(); - Vector4 sourceV = source.ToVector4(); - sourceV.W *= opacity; + return DestOver(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestIn(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return DestOut(backdrop, source, <#=blender#>(backdrop, source)); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source, source); + } + +<# } #> + + +<# void GenerateGenericPixelBlender(string blender, string composer) { #> + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel <#=blender#>_<#=composer#>(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { TPixel dest = default; - dest.PackFromVector4(<#=compositor#>(backdropV,sourceV, <#=blender#>(backdropV, sourceV))); + dest.PackFromVector4(<#=blender#>_<#=composer#>(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; - } + } <# } #> - #region Compositors + #region Blenders <# -GenerateVectorCompositor("Src", "source", "Vector4.Zero", "xform"); -GenerateVectorCompositor("SrcAtop", "Vector4.Zero", "backdrop", "xform"); -GenerateVectorCompositor("SrcOver", "source", "backdrop", "xform"); -GenerateVectorCompositor("SrcIn", "Vector4.Zero", "Vector4.Zero", "xform"); -GenerateVectorCompositor("SrcOut", "source", "Vector4.Zero", "Vector4.Zero"); -GenerateVectorCompositor("Dest", "Vector4.Zero", "backdrop", "backdrop"); -GenerateVectorCompositor("DestAtop", "source", "Vector4.Zero", "backdrop"); -GenerateVectorCompositor("DestOver", "source", "backdrop", "backdrop"); -GenerateVectorCompositor("DestIn", "Vector4.Zero", "Vector4.Zero", "backdrop"); -GenerateVectorCompositor("DestOut", "Vector4.Zero", "backdrop", "Vector4.Zero"); -GenerateVectorCompositor("Clear", "Vector4.Zero", "Vector4.Zero", "Vector4.Zero"); -GenerateVectorCompositor("Xor", "source", "backdrop", "Vector4.Zero"); -#> - #endregion +// GenerateVectorCompositor("Src", "source", "Vector4.Zero", "xform"); +GenerateVectorCompositor("SrcAtop", "Vector4.Zero", "backdrop", "xform"); +GenerateVectorCompositor("SrcOver", "source", "backdrop", "xform"); +// GenerateVectorCompositor("SrcIn", "Vector4.Zero", "Vector4.Zero", "xform"); +// GenerateVectorCompositor("SrcOut", "source", "Vector4.Zero", "Vector4.Zero"); +GenerateVectorCompositor("Dest", "Vector4.Zero", "backdrop", "backdrop"); +// GenerateVectorCompositor("DestAtop", "source", "Vector4.Zero", "backdrop"); +// GenerateVectorCompositor("DestOver", "source", "backdrop", "backdrop"); +// GenerateVectorCompositor("DestIn", "Vector4.Zero", "Vector4.Zero", "backdrop"); +GenerateVectorCompositor("DestOut", "Vector4.Zero", "backdrop", "Vector4.Zero"); +// GenerateVectorCompositor("Clear", "Vector4.Zero", "Vector4.Zero", "Vector4.Zero"); +GenerateVectorCompositor("Xor", "source", "backdrop", "Vector4.Zero"); - #region Blenders - -<# string[] composers = new []{ "Src" , "SrcAtop" , @@ -121,14 +220,16 @@ string[] blenders = new []{ "HardLight" }; -foreach(var composer in composers) -{ foreach(var blender in blenders) - { - GeneratePixelBlender(blender,composer); - + { + GeneratePixelBlenders(blender); + + foreach(var composer in composers) + { + GenerateGenericPixelBlender(blender,composer); + } } -} + #> #endregion diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index 0719b834c6..5738238568 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -20,11 +20,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// internal static partial class PorterDuffFunctions { + #region color blenders + /// /// Source over backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Normal(Vector4 backdrop, Vector4 source) @@ -36,7 +38,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source multiplied by backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Multiply(Vector4 backdrop, Vector4 source) @@ -48,7 +50,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source added to backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Add(Vector4 backdrop, Vector4 source) @@ -60,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source subtracted from backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Subtract(Vector4 backdrop, Vector4 source) @@ -72,7 +74,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Complement of source multiplied by the complement of backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Screen(Vector4 backdrop, Vector4 source) @@ -84,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Per element, chooses the smallest value of source and backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Darken(Vector4 backdrop, Vector4 source) @@ -96,7 +98,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Per element, chooses the largest value of source and backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Lighten(Vector4 backdrop, Vector4 source) @@ -108,7 +110,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Overlays source over backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Overlay(Vector4 backdrop, Vector4 source) @@ -124,7 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Hard light effect /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 HardLight(Vector4 backdrop, Vector4 source) @@ -148,6 +150,10 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return backdrop <= 0.5f ? (2 * backdrop * source) : 1 - ((2 * (1 - source)) * (1 - backdrop)); } + #endregion + + #region alpha composers + /// /// General composition function for all modes, with a general solution for alpha channel /// @@ -155,11 +161,8 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Original source color /// Desired transformed color, without taking Alpha channel in account /// The final color - /// - /// This is the default compositor for "normal" alpha blending, which matches the generated SrcOver compositor. - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Vector4 Compose(Vector4 backdrop, Vector4 source, Vector4 xform) + private static Vector4 SrcOver_Reference(Vector4 backdrop, Vector4 source, Vector4 xform) { // calculate weights float xw = backdrop.W * source.W; @@ -175,5 +178,133 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return xform; } + + + + + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Src(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + float bw = backdrop.W - xw; + float sw = source.W - xw; + + // calculate final alpha + float fw = (sw * 1) + (bw * 0) + (xw * 1); + + // calculate final value + xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform.W = fw; + + return Vector4.Lerp(backdrop, xform, source.W); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 SrcIn(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + + // calculate final value + xform.W = xw; + + return Vector4.Lerp(backdrop, xform, source.W); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 SrcOut(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + float bw = backdrop.W - xw; + float sw = source.W - xw; + + // calculate final alpha + float fw = sw; + + // calculate final value + xform = source; + xform.W = fw; + + return Vector4.Lerp(backdrop, xform, source.W); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 DestAtop(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + float bw = backdrop.W - xw; + float sw = source.W - xw; + + // calculate final alpha + float fw = (sw * 1) + (bw * 0) + (xw * 1); + + // calculate final value + xform = ((backdrop * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform.W = fw; + + return Vector4.Lerp(backdrop, xform, source.W); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 DestOver(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + float bw = backdrop.W - xw; + float sw = source.W - xw; + + // calculate final alpha + float fw = (sw * 1) + (bw * 1) + (xw * 1); + + // calculate final value + xform = ((backdrop * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); + xform.W = fw; + + return Vector4.Lerp(backdrop, xform, source.W); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 DestIn(Vector4 backdrop, Vector4 source, Vector4 xform) + { + // calculate weights + float xw = backdrop.W * source.W; + float bw = backdrop.W - xw; + float sw = source.W - xw; + + // calculate final alpha + float fw = (sw * 0) + (bw * 0) + (xw * 1); + + // calculate final value + xform = ((backdrop * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); + xform.W = fw; + + return Vector4.Lerp(backdrop, xform, source.W); + } + + /// + /// General composition function for all modes, with a general solution for alpha channel + /// + /// Original Backdrop color + /// Original source color + /// Desired transformed color, without taking Alpha channel in account + /// The final color + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static Vector4 Clear(Vector4 backdrop, Vector4 source, Vector4 xform) + { + return Vector4.Lerp(backdrop, Vector4.Zero, xform.W); + } + + #endregion + + + + + } } \ No newline at end of file From 4bb5f9f45e3074d117b37da641909b2ee5efe498 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Mon, 2 Jul 2018 16:10:51 +0200 Subject: [PATCH 04/40] progress on pixel conposer/blender combinations --- .../PorterDuffFunctions.Generated.cs | 4451 ++++++++--------- .../PorterDuffFunctions.Generated.tt | 426 +- .../PixelBlenders/PorterDuffFunctions.cs | 159 +- .../Drawing/SolidFillBlendedShapesTests.cs | 23 +- 4 files changed, 2414 insertions(+), 2645 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index 73e1c7f024..b8c3faf4f5 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -1,2298 +1,2155 @@ - - - - - - - -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -// - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders -{ - internal static partial class PorterDuffFunctions - { - - - - - - - - - - - - - - #region Blenders - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 SrcAtop(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 0) + (bw * 1) + (xw * 1); - - // calculate final value - xform = ((xform * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 SrcOver(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 1) + (xw * 1); - - // calculate final value - xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Dest(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 0) + (bw * 1) + (xw * 1); - - // calculate final value - xform = ((backdrop * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestOut(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 0) + (bw * 1) + (xw * 0); - - // calculate final value - xform = ((Vector4.Zero * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Xor(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 1) + (xw * 0); - - // calculate final value - xform = ((Vector4.Zero * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; - } - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Normal(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Normal(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Normal_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Multiply(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Multiply(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Multiply_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Add(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Add(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Add_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Subtract(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Subtract(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Subtract_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Screen(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Screen(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Screen_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Darken(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Darken(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Darken_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Lighten(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Lighten(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Lighten_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, Overlay(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, Overlay(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(Overlay_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, HardLight(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, HardLight(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Src(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Dest(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestAtop(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestOver(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestIn(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestOut(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Clear(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Xor(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(HardLight_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - - - - #endregion - } +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +// + +using System; +using System.Numerics; +using System.Runtime.CompilerServices; + +namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders +{ + internal static partial class PorterDuffFunctions + { + + + + + #region Blenders + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Normal(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Normal(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Normal(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Normal(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Normal_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Normal_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Normal_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Multiply(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Multiply(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Multiply(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Multiply(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Multiply_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Multiply_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Multiply_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Add(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Add(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Add(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Add(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Add_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Add_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Add_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Subtract(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Subtract(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Subtract(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Subtract(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Subtract_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Subtract_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Subtract_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Screen(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Screen(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Screen(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Screen(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Screen_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Screen_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Screen_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Darken(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Darken(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Darken(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Darken(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Darken_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Darken_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Darken_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Lighten(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Lighten(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Lighten(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Lighten(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Lighten_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Lighten_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Lighten_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, Overlay(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, Overlay(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, Overlay(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, Overlay(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 Overlay_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel Overlay_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(Overlay_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, HardLight(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, HardLight(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, HardLight(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, HardLight(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 HardLight_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Src(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_SrcOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Dest(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestAtop(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestOver(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestIn(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_DestOut(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Clear(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel HardLight_Xor(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(HardLight_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + + + #endregion + } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index 64608fcfac..3045b1e81c 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -1,237 +1,191 @@ -<# -// 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" #> -<#@ output extension=".cs" #> -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -// - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders -{ - internal static partial class PorterDuffFunctions - { - - -<# void GenerateVectorCompositor(string name, string sourceVar, string destVar, string blendVar) - { - int a_s = sourceVar == "Vector4.Zero" ? 0 : 1; - int a_b = destVar == "Vector4.Zero" ? 0 : 1; - int a_x = blendVar == "Vector4.Zero" ? 0 : 1; -#> - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=name#>(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * <#=a_s#>) + (bw * <#=a_b#>) + (xw * <#=a_x#>); - - // calculate final value - xform = ((<#=blendVar#> * xw) + (<#=destVar#> * bw) + (<#=sourceVar#> * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return xform; - } -<# } #> - - - - - -<# void GeneratePixelBlenders(string blender) { #> - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Src(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Src(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcAtop(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOver(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcIn(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return SrcOut(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Dest(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Dest(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestAtop(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestAtop(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestOver(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOver(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestIn(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestIn(backdrop, source, <#=blender#>(backdrop, source)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestOut(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return DestOut(backdrop, source, <#=blender#>(backdrop, source)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Clear(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Clear(backdrop, source, source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Xor(Vector4 backdrop, Vector4 source, float opacity) - { - opacity = opacity.Clamp(0, 1); - source.W *= opacity; - - return Xor(backdrop, source, source); - } - -<# } #> - - -<# void GenerateGenericPixelBlender(string blender, string composer) { #> - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel <#=blender#>_<#=composer#>(TPixel backdrop, TPixel source, float opacity) - where TPixel : struct, IPixel - { - TPixel dest = default; - dest.PackFromVector4(<#=blender#>_<#=composer#>(backdrop.ToVector4(),source.ToVector4(),opacity)); - return dest; - } - -<# } #> - - #region Blenders -<# - -// GenerateVectorCompositor("Src", "source", "Vector4.Zero", "xform"); -GenerateVectorCompositor("SrcAtop", "Vector4.Zero", "backdrop", "xform"); -GenerateVectorCompositor("SrcOver", "source", "backdrop", "xform"); -// GenerateVectorCompositor("SrcIn", "Vector4.Zero", "Vector4.Zero", "xform"); -// GenerateVectorCompositor("SrcOut", "source", "Vector4.Zero", "Vector4.Zero"); -GenerateVectorCompositor("Dest", "Vector4.Zero", "backdrop", "backdrop"); -// GenerateVectorCompositor("DestAtop", "source", "Vector4.Zero", "backdrop"); -// GenerateVectorCompositor("DestOver", "source", "backdrop", "backdrop"); -// GenerateVectorCompositor("DestIn", "Vector4.Zero", "Vector4.Zero", "backdrop"); -GenerateVectorCompositor("DestOut", "Vector4.Zero", "backdrop", "Vector4.Zero"); -// GenerateVectorCompositor("Clear", "Vector4.Zero", "Vector4.Zero", "Vector4.Zero"); -GenerateVectorCompositor("Xor", "source", "backdrop", "Vector4.Zero"); - -string[] composers = new []{ - "Src" , - "SrcAtop" , - "SrcOver" , - "SrcIn" , - "SrcOut" , - "Dest" , - "DestAtop" , - "DestOver" , - "DestIn" , - "DestOut" , - "Clear" , - "Xor" , -}; - -string[] blenders = new []{ - "Normal" , - "Multiply" , - "Add" , - "Subtract" , - "Screen" , - "Darken" , - "Lighten" , - "Overlay" , - "HardLight" -}; - - foreach(var blender in blenders) - { - GeneratePixelBlenders(blender); - - foreach(var composer in composers) - { - GenerateGenericPixelBlender(blender,composer); - } - } - -#> - - #endregion - } +<# +// 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" #> +<#@ output extension=".cs" #> +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +// + +using System; +using System.Numerics; +using System.Runtime.CompilerServices; + +namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders +{ + internal static partial class PorterDuffFunctions + { + +<# void GeneratePixelBlenders(string blender) { #> + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Src(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return source; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(backdrop, source, <#=blender#>(backdrop, source)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Dest(Vector4 backdrop, Vector4 source, float opacity) + { + return backdrop; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Atop(source, backdrop, <#=blender#>(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestOver(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Over(source, backdrop, <#=blender#>(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestIn(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return In(source, backdrop, <#=blender#>(source, backdrop)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_DestOut(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Out(source, backdrop); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Xor(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Xor(backdrop, source); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vector4 <#=blender#>_Clear(Vector4 backdrop, Vector4 source, float opacity) + { + opacity = opacity.Clamp(0, 1); + source.W *= opacity; + + return Clear(backdrop, source); + } +<# } #> + + +<# void GenerateGenericPixelBlender(string blender, string composer) { #> + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPixel <#=blender#>_<#=composer#>(TPixel backdrop, TPixel source, float opacity) + where TPixel : struct, IPixel + { + TPixel dest = default; + dest.PackFromVector4(<#=blender#>_<#=composer#>(backdrop.ToVector4(),source.ToVector4(),opacity)); + return dest; + } + +<# } #> + + #region Blenders +<# + +string[] composers = new []{ + "Src" , + "SrcAtop" , + "SrcOver" , + "SrcIn" , + "SrcOut" , + "Dest" , + "DestAtop" , + "DestOver" , + "DestIn" , + "DestOut" , + "Clear" , + "Xor" , +}; + +string[] blenders = new []{ + "Normal" , + "Multiply" , + "Add" , + "Subtract" , + "Screen" , + "Darken" , + "Lighten" , + "Overlay" , + "HardLight" +}; + + foreach(var blender in blenders) + { + GeneratePixelBlenders(blender); + + foreach(var composer in composers) + { + GenerateGenericPixelBlender(blender,composer); + } + } + +#> + + #endregion + } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index 5738238568..e2c0c85db9 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -179,125 +179,78 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return xform; } + public static Vector4 Over(Vector4 dst, Vector4 src, Vector4 blend) + { + // calculate weights + float blendW = dst.W * src.W; + float dstW = dst.W - blendW; + float srcW = src.W - blendW; + // calculate final alpha + float alpha = dstW + srcW + blendW; + // calculate final color + Vector4 color = dst * dstW + src * srcW + blend * blendW; + // unpremultiply + color /= MathF.Max(alpha, Constants.Epsilon); + color.W = alpha; + return color; + } + public static Vector4 Atop(Vector4 dst, Vector4 src, Vector4 blend) + { + // calculate weights + float blendW = dst.W * src.W; + float dstW = dst.W - blendW; - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Src(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 0) + (xw * 1); - - // calculate final value - xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return Vector4.Lerp(backdrop, xform, source.W); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 SrcIn(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - - // calculate final value - xform.W = xw; - - return Vector4.Lerp(backdrop, xform, source.W); - } + // calculate final alpha + float alpha = dstW + blendW; + + // calculate final color + Vector4 color = dst * dstW + blend * blendW; + + // unpremultiply + color /= MathF.Max(alpha, Constants.Epsilon); + color.W = alpha; - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 SrcOut(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = sw; - - // calculate final value - xform = source; - xform.W = fw; - - return Vector4.Lerp(backdrop, xform, source.W); + return color; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestAtop(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 0) + (xw * 1); - - // calculate final value - xform = ((backdrop * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return Vector4.Lerp(backdrop, xform, source.W); + public static Vector4 In(Vector4 dst, Vector4 src, Vector4 blend) + { + blend.W = dst.W * src.W; + + return blend; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestOver(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 1) + (bw * 1) + (xw * 1); - - // calculate final value - xform = ((backdrop * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return Vector4.Lerp(backdrop, xform, source.W); + public static Vector4 Out(Vector4 dst, Vector4 src) + { + // calculate final alpha + src.W = (1 - dst.W) * src.W; + + return src; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 DestIn(Vector4 backdrop, Vector4 source, Vector4 xform) - { - // calculate weights - float xw = backdrop.W * source.W; - float bw = backdrop.W - xw; - float sw = source.W - xw; - - // calculate final alpha - float fw = (sw * 0) + (bw * 0) + (xw * 1); - - // calculate final value - xform = ((backdrop * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon); - xform.W = fw; - - return Vector4.Lerp(backdrop, xform, source.W); + public static Vector4 Xor(Vector4 dst, Vector4 src) + { + float srcW = 1 - dst.W; + float dstW = 1 - src.W; + + float alpha = src.W * srcW + dst.W * dstW; + Vector4 color = src.W * src * srcW + dst.W * dst * dstW; + + // unpremultiply + color /= MathF.Max(alpha, Constants.Epsilon); + color.W = alpha; + + return color; } - /// - /// General composition function for all modes, with a general solution for alpha channel - /// - /// Original Backdrop color - /// Original source color - /// Desired transformed color, without taking Alpha channel in account - /// The final color - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Vector4 Clear(Vector4 backdrop, Vector4 source, Vector4 xform) + private static Vector4 Clear(Vector4 backdrop, Vector4 source) { - return Vector4.Lerp(backdrop, Vector4.Zero, xform.W); + return Vector4.Lerp(backdrop, Vector4.Zero, source.W); } #endregion diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index 7d73d1b650..f43428d492 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -116,21 +116,26 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void _1DarkBlueRect_2BlendBlackEllipse(TestImageProvider provider, PixelBlenderMode mode) where TPixel : struct, IPixel { - using (Image img = provider.GetImage()) + using(Image dstImg = provider.GetImage(), srcImg = provider.GetImage()) { - int scaleX = (img.Width / 100); - int scaleY = (img.Height / 100); - img.Mutate( + int scaleX = (dstImg.Width / 100); + int scaleY = (dstImg.Height / 100); + + dstImg.Mutate( x => x.Fill( NamedColors.DarkBlue, - new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); - img.Mutate( + new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); + + srcImg.Mutate( x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, NamedColors.Black, - new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); + new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); + + dstImg.Mutate( + x => x.DrawImage(new GraphicsOptions(true) { BlenderMode = mode }, srcImg) + ); - VerifyImage(provider, mode, img); + VerifyImage(provider, mode, dstImg); } } From 8368f1efc9eaa22e3562d9c97fc5c57952666719 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Mon, 2 Jul 2018 16:39:41 +0200 Subject: [PATCH 05/40] removed trailing spaces --- .../PixelBlenders/PorterDuffFunctions.cs | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index e2c0c85db9..200b185fad 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source over backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Normal(Vector4 backdrop, Vector4 source) @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source multiplied by backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Multiply(Vector4 backdrop, Vector4 source) @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source added to backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Add(Vector4 backdrop, Vector4 source) @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Source subtracted from backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Subtract(Vector4 backdrop, Vector4 source) @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Complement of source multiplied by the complement of backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Screen(Vector4 backdrop, Vector4 source) @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Per element, chooses the smallest value of source and backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Darken(Vector4 backdrop, Vector4 source) @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Per element, chooses the largest value of source and backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Lighten(Vector4 backdrop, Vector4 source) @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Overlays source over backdrop /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Overlay(Vector4 backdrop, Vector4 source) @@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Hard light effect /// /// Backdrop color - /// Source color + /// Source color /// Output color [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 HardLight(Vector4 backdrop, Vector4 source) @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float alpha = dstW + srcW + blendW; // calculate final color - Vector4 color = dst * dstW + src * srcW + blend * blendW; + Vector4 color = (dst * dstW) + (src * srcW) + (blend * blendW); // unpremultiply color /= MathF.Max(alpha, Constants.Epsilon); @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float alpha = dstW + blendW; // calculate final color - Vector4 color = dst * dstW + blend * blendW; + Vector4 color = (dst * dstW) + (blend * blendW); // unpremultiply color /= MathF.Max(alpha, Constants.Epsilon); @@ -238,8 +238,8 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders float srcW = 1 - dst.W; float dstW = 1 - src.W; - float alpha = src.W * srcW + dst.W * dstW; - Vector4 color = src.W * src * srcW + dst.W * dst * dstW; + float alpha = (src.W * srcW) + (dst.W * dstW); + Vector4 color = (src.W * src * srcW) + (dst.W * dst * dstW); // unpremultiply color /= MathF.Max(alpha, Constants.Epsilon); @@ -255,9 +255,5 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders #endregion - - - - } } \ No newline at end of file From a9a8ded37fbd52e21ed8f99f38257992b8aacb69 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Mon, 2 Jul 2018 16:43:17 +0200 Subject: [PATCH 06/40] removed trailing spaces, regions & cleared code --- .../PixelFormats/PixelBlenders/PorterDuffFunctions.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index 200b185fad..1a4fd15d3d 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -20,8 +20,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// internal static partial class PorterDuffFunctions { - #region color blenders - /// /// Source over backdrop /// @@ -150,10 +148,6 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders return backdrop <= 0.5f ? (2 * backdrop * source) : 1 - ((2 * (1 - source)) * (1 - backdrop)); } - #endregion - - #region alpha composers - /// /// General composition function for all modes, with a general solution for alpha channel /// @@ -252,8 +246,5 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders { return Vector4.Lerp(backdrop, Vector4.Zero, source.W); } - - #endregion - } } \ No newline at end of file From 8a59bf7f38fd121697c27b26fc747779c1f3933f Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Tue, 3 Jul 2018 18:53:13 +0200 Subject: [PATCH 07/40] fixed Clear composition, it essentially returns fully transparent --- .../PixelFormats/PixelBlenders/PorterDuffFunctions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index 1a4fd15d3d..8b6fbcfb90 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -244,7 +244,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders private static Vector4 Clear(Vector4 backdrop, Vector4 source) { - return Vector4.Lerp(backdrop, Vector4.Zero, source.W); + return Vector4.Zero; } } } \ No newline at end of file From c3a4b673309ed821e94c99090a8420494b942155 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Thu, 5 Jul 2018 13:41:28 +0200 Subject: [PATCH 08/40] changed In and Out composition functions to always produce "transparent black" --- .../PixelBlenders/PorterDuffFunctions.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index 8b6fbcfb90..c84cd9a7b1 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -214,17 +214,24 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders public static Vector4 In(Vector4 dst, Vector4 src, Vector4 blend) { - blend.W = dst.W * src.W; + float alpha = dst.W * src.W; - return blend; + Vector4 color = src * alpha; // premultiply + color /= MathF.Max(alpha, Constants.Epsilon); // unpremultiply + color.W = alpha; + + return color; } public static Vector4 Out(Vector4 dst, Vector4 src) { - // calculate final alpha - src.W = (1 - dst.W) * src.W; + float alpha = (1 - dst.W) * src.W; - return src; + Vector4 color = src * alpha; // premultiply + color /= MathF.Max(alpha, Constants.Epsilon); // unpremultiply + color.W = alpha; + + return color; } public static Vector4 Xor(Vector4 dst, Vector4 src) From 29c01dab6cc4546751efae3374af254ca2d55820 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 4 Aug 2018 12:35:31 +0100 Subject: [PATCH 09/40] No underscores! --- .../Processing/GradientBrushBase{TPixel}.cs | 8 +- .../DefaultPixelBlenders.Generated.cs | 864 +++++++++--------- .../DefaultPixelBlenders.Generated.tt | 52 +- .../PorterDuffFunctions.Generated.cs | 651 +++++++------ .../PorterDuffFunctions.Generated.tt | 71 +- .../PixelBlenders/PorterDuffFunctions.cs | 2 +- .../PixelOperations{TPixel}.PixelBenders.cs | 42 +- .../PixelBlenders/PorterDuffBulkVsPixel.cs | 4 +- .../PixelBlenders/PorterDuffFunctionsTests.cs | 21 +- .../PorterDuffFunctionsTests_TPixel.cs | 113 ++- .../PixelOperationsTests.Blender.cs | 84 +- 11 files changed, 949 insertions(+), 963 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/GradientBrushBase{TPixel}.cs b/src/ImageSharp.Drawing/Processing/GradientBrushBase{TPixel}.cs index fe997ed7f1..897b3f384f 100644 --- a/src/ImageSharp.Drawing/Processing/GradientBrushBase{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/GradientBrushBase{TPixel}.cs @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Processing throw new ArgumentOutOfRangeException(); } - var (from, to) = this.GetGradientSegment(positionOnCompleteGradient); + (ColorStop from, ColorStop to) = this.GetGradientSegment(positionOnCompleteGradient); if (from.Color.Equals(to.Color)) { @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Processing float onLocalGradient = (positionOnCompleteGradient - from.Ratio) / to.Ratio; // TODO: this should be changeble for different gradienting functions - Vector4 result = PorterDuffFunctions.Normal_SrcOver( + Vector4 result = PorterDuffFunctions.NormalSrcOver( fromAsVector, toAsVector, onLocalGradient); @@ -153,11 +153,11 @@ namespace SixLabors.ImageSharp.Processing private (ColorStop from, ColorStop to) GetGradientSegment( float positionOnCompleteGradient) { - var localGradientFrom = this.colorStops[0]; + ColorStop localGradientFrom = this.colorStops[0]; ColorStop localGradientTo = default; // TODO: ensure colorStops has at least 2 items (technically 1 would be okay, but that's no gradient) - foreach (var colorStop in this.colorStops) + foreach (ColorStop colorStop in this.colorStops) { localGradientTo = colorStop; diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 1ee9848d63..b454349d78 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -24,17 +24,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders where TPixel : struct, IPixel { - internal class Normal_Src : PixelBlender + internal class NormalSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_Src Instance { get; } = new Normal_Src(); + public static NormalSrc Instance { get; } = new NormalSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_Src(background, source, amount); + return PorterDuffFunctions.NormalSrc(background, source, amount); } /// @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -63,17 +63,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_Src : PixelBlender + internal class MultiplySrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_Src Instance { get; } = new Multiply_Src(); + public static MultiplySrc Instance { get; } = new MultiplySrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_Src(background, source, amount); + return PorterDuffFunctions.MultiplySrc(background, source, amount); } /// @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplySrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -102,17 +102,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_Src : PixelBlender + internal class AddSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_Src Instance { get; } = new Add_Src(); + public static AddSrc Instance { get; } = new AddSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_Src(background, source, amount); + return PorterDuffFunctions.AddSrc(background, source, amount); } /// @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -141,17 +141,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_Src : PixelBlender + internal class SubtractSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_Src Instance { get; } = new Subtract_Src(); + public static SubtractSrc Instance { get; } = new SubtractSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_Src(background, source, amount); + return PorterDuffFunctions.SubtractSrc(background, source, amount); } /// @@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -180,17 +180,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_Src : PixelBlender + internal class ScreenSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_Src Instance { get; } = new Screen_Src(); + public static ScreenSrc Instance { get; } = new ScreenSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_Src(background, source, amount); + return PorterDuffFunctions.ScreenSrc(background, source, amount); } /// @@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -219,17 +219,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_Src : PixelBlender + internal class DarkenSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_Src Instance { get; } = new Darken_Src(); + public static DarkenSrc Instance { get; } = new DarkenSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_Src(background, source, amount); + return PorterDuffFunctions.DarkenSrc(background, source, amount); } /// @@ -250,7 +250,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -258,17 +258,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_Src : PixelBlender + internal class LightenSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_Src Instance { get; } = new Lighten_Src(); + public static LightenSrc Instance { get; } = new LightenSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_Src(background, source, amount); + return PorterDuffFunctions.LightenSrc(background, source, amount); } /// @@ -289,7 +289,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -297,17 +297,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_Src : PixelBlender + internal class OverlaySrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_Src Instance { get; } = new Overlay_Src(); + public static OverlaySrc Instance { get; } = new OverlaySrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_Src(background, source, amount); + return PorterDuffFunctions.OverlaySrc(background, source, amount); } /// @@ -328,7 +328,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlaySrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -336,17 +336,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_Src : PixelBlender + internal class HardLightSrc : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_Src Instance { get; } = new HardLight_Src(); + public static HardLightSrc Instance { get; } = new HardLightSrc(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_Src(background, source, amount); + return PorterDuffFunctions.HardLightSrc(background, source, amount); } /// @@ -367,7 +367,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_Src(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightSrc(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -375,17 +375,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_SrcAtop : PixelBlender + internal class NormalSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_SrcAtop Instance { get; } = new Normal_SrcAtop(); + public static NormalSrcAtop Instance { get; } = new NormalSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_SrcAtop(background, source, amount); + return PorterDuffFunctions.NormalSrcAtop(background, source, amount); } /// @@ -406,7 +406,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -414,17 +414,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_SrcAtop : PixelBlender + internal class MultiplySrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_SrcAtop Instance { get; } = new Multiply_SrcAtop(); + public static MultiplySrcAtop Instance { get; } = new MultiplySrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_SrcAtop(background, source, amount); + return PorterDuffFunctions.MultiplySrcAtop(background, source, amount); } /// @@ -445,7 +445,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplySrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -453,17 +453,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_SrcAtop : PixelBlender + internal class AddSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_SrcAtop Instance { get; } = new Add_SrcAtop(); + public static AddSrcAtop Instance { get; } = new AddSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_SrcAtop(background, source, amount); + return PorterDuffFunctions.AddSrcAtop(background, source, amount); } /// @@ -484,7 +484,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -492,17 +492,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_SrcAtop : PixelBlender + internal class SubtractSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_SrcAtop Instance { get; } = new Subtract_SrcAtop(); + public static SubtractSrcAtop Instance { get; } = new SubtractSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_SrcAtop(background, source, amount); + return PorterDuffFunctions.SubtractSrcAtop(background, source, amount); } /// @@ -523,7 +523,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -531,17 +531,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_SrcAtop : PixelBlender + internal class ScreenSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_SrcAtop Instance { get; } = new Screen_SrcAtop(); + public static ScreenSrcAtop Instance { get; } = new ScreenSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_SrcAtop(background, source, amount); + return PorterDuffFunctions.ScreenSrcAtop(background, source, amount); } /// @@ -562,7 +562,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -570,17 +570,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_SrcAtop : PixelBlender + internal class DarkenSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_SrcAtop Instance { get; } = new Darken_SrcAtop(); + public static DarkenSrcAtop Instance { get; } = new DarkenSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_SrcAtop(background, source, amount); + return PorterDuffFunctions.DarkenSrcAtop(background, source, amount); } /// @@ -601,7 +601,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -609,17 +609,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_SrcAtop : PixelBlender + internal class LightenSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_SrcAtop Instance { get; } = new Lighten_SrcAtop(); + public static LightenSrcAtop Instance { get; } = new LightenSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_SrcAtop(background, source, amount); + return PorterDuffFunctions.LightenSrcAtop(background, source, amount); } /// @@ -640,7 +640,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -648,17 +648,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_SrcAtop : PixelBlender + internal class OverlaySrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_SrcAtop Instance { get; } = new Overlay_SrcAtop(); + public static OverlaySrcAtop Instance { get; } = new OverlaySrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_SrcAtop(background, source, amount); + return PorterDuffFunctions.OverlaySrcAtop(background, source, amount); } /// @@ -679,7 +679,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlaySrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -687,17 +687,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_SrcAtop : PixelBlender + internal class HardLightSrcAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_SrcAtop Instance { get; } = new HardLight_SrcAtop(); + public static HardLightSrcAtop Instance { get; } = new HardLightSrcAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_SrcAtop(background, source, amount); + return PorterDuffFunctions.HardLightSrcAtop(background, source, amount); } /// @@ -718,7 +718,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_SrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightSrcAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -726,17 +726,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_SrcOver : PixelBlender + internal class NormalSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_SrcOver Instance { get; } = new Normal_SrcOver(); + public static NormalSrcOver Instance { get; } = new NormalSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_SrcOver(background, source, amount); + return PorterDuffFunctions.NormalSrcOver(background, source, amount); } /// @@ -757,7 +757,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -765,17 +765,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_SrcOver : PixelBlender + internal class MultiplySrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_SrcOver Instance { get; } = new Multiply_SrcOver(); + public static MultiplySrcOver Instance { get; } = new MultiplySrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_SrcOver(background, source, amount); + return PorterDuffFunctions.MultiplySrcOver(background, source, amount); } /// @@ -796,7 +796,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplySrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -804,17 +804,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_SrcOver : PixelBlender + internal class AddSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_SrcOver Instance { get; } = new Add_SrcOver(); + public static AddSrcOver Instance { get; } = new AddSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_SrcOver(background, source, amount); + return PorterDuffFunctions.AddSrcOver(background, source, amount); } /// @@ -835,7 +835,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -843,17 +843,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_SrcOver : PixelBlender + internal class SubtractSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_SrcOver Instance { get; } = new Subtract_SrcOver(); + public static SubtractSrcOver Instance { get; } = new SubtractSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_SrcOver(background, source, amount); + return PorterDuffFunctions.SubtractSrcOver(background, source, amount); } /// @@ -874,7 +874,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -882,17 +882,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_SrcOver : PixelBlender + internal class ScreenSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_SrcOver Instance { get; } = new Screen_SrcOver(); + public static ScreenSrcOver Instance { get; } = new ScreenSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_SrcOver(background, source, amount); + return PorterDuffFunctions.ScreenSrcOver(background, source, amount); } /// @@ -913,7 +913,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -921,17 +921,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_SrcOver : PixelBlender + internal class DarkenSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_SrcOver Instance { get; } = new Darken_SrcOver(); + public static DarkenSrcOver Instance { get; } = new DarkenSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_SrcOver(background, source, amount); + return PorterDuffFunctions.DarkenSrcOver(background, source, amount); } /// @@ -952,7 +952,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -960,17 +960,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_SrcOver : PixelBlender + internal class LightenSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_SrcOver Instance { get; } = new Lighten_SrcOver(); + public static LightenSrcOver Instance { get; } = new LightenSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_SrcOver(background, source, amount); + return PorterDuffFunctions.LightenSrcOver(background, source, amount); } /// @@ -991,7 +991,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -999,17 +999,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_SrcOver : PixelBlender + internal class OverlaySrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_SrcOver Instance { get; } = new Overlay_SrcOver(); + public static OverlaySrcOver Instance { get; } = new OverlaySrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_SrcOver(background, source, amount); + return PorterDuffFunctions.OverlaySrcOver(background, source, amount); } /// @@ -1030,7 +1030,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlaySrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1038,17 +1038,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_SrcOver : PixelBlender + internal class HardLightSrcOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_SrcOver Instance { get; } = new HardLight_SrcOver(); + public static HardLightSrcOver Instance { get; } = new HardLightSrcOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_SrcOver(background, source, amount); + return PorterDuffFunctions.HardLightSrcOver(background, source, amount); } /// @@ -1069,7 +1069,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1077,17 +1077,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_SrcIn : PixelBlender + internal class NormalSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_SrcIn Instance { get; } = new Normal_SrcIn(); + public static NormalSrcIn Instance { get; } = new NormalSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_SrcIn(background, source, amount); + return PorterDuffFunctions.NormalSrcIn(background, source, amount); } /// @@ -1108,7 +1108,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1116,17 +1116,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_SrcIn : PixelBlender + internal class MultiplySrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_SrcIn Instance { get; } = new Multiply_SrcIn(); + public static MultiplySrcIn Instance { get; } = new MultiplySrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_SrcIn(background, source, amount); + return PorterDuffFunctions.MultiplySrcIn(background, source, amount); } /// @@ -1147,7 +1147,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplySrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1155,17 +1155,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_SrcIn : PixelBlender + internal class AddSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_SrcIn Instance { get; } = new Add_SrcIn(); + public static AddSrcIn Instance { get; } = new AddSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_SrcIn(background, source, amount); + return PorterDuffFunctions.AddSrcIn(background, source, amount); } /// @@ -1186,7 +1186,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1194,17 +1194,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_SrcIn : PixelBlender + internal class SubtractSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_SrcIn Instance { get; } = new Subtract_SrcIn(); + public static SubtractSrcIn Instance { get; } = new SubtractSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_SrcIn(background, source, amount); + return PorterDuffFunctions.SubtractSrcIn(background, source, amount); } /// @@ -1225,7 +1225,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1233,17 +1233,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_SrcIn : PixelBlender + internal class ScreenSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_SrcIn Instance { get; } = new Screen_SrcIn(); + public static ScreenSrcIn Instance { get; } = new ScreenSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_SrcIn(background, source, amount); + return PorterDuffFunctions.ScreenSrcIn(background, source, amount); } /// @@ -1264,7 +1264,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1272,17 +1272,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_SrcIn : PixelBlender + internal class DarkenSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_SrcIn Instance { get; } = new Darken_SrcIn(); + public static DarkenSrcIn Instance { get; } = new DarkenSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_SrcIn(background, source, amount); + return PorterDuffFunctions.DarkenSrcIn(background, source, amount); } /// @@ -1303,7 +1303,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1311,17 +1311,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_SrcIn : PixelBlender + internal class LightenSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_SrcIn Instance { get; } = new Lighten_SrcIn(); + public static LightenSrcIn Instance { get; } = new LightenSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_SrcIn(background, source, amount); + return PorterDuffFunctions.LightenSrcIn(background, source, amount); } /// @@ -1342,7 +1342,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1350,17 +1350,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_SrcIn : PixelBlender + internal class OverlaySrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_SrcIn Instance { get; } = new Overlay_SrcIn(); + public static OverlaySrcIn Instance { get; } = new OverlaySrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_SrcIn(background, source, amount); + return PorterDuffFunctions.OverlaySrcIn(background, source, amount); } /// @@ -1381,7 +1381,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlaySrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1389,17 +1389,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_SrcIn : PixelBlender + internal class HardLightSrcIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_SrcIn Instance { get; } = new HardLight_SrcIn(); + public static HardLightSrcIn Instance { get; } = new HardLightSrcIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_SrcIn(background, source, amount); + return PorterDuffFunctions.HardLightSrcIn(background, source, amount); } /// @@ -1420,7 +1420,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_SrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightSrcIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1428,17 +1428,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_SrcOut : PixelBlender + internal class NormalSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_SrcOut Instance { get; } = new Normal_SrcOut(); + public static NormalSrcOut Instance { get; } = new NormalSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_SrcOut(background, source, amount); + return PorterDuffFunctions.NormalSrcOut(background, source, amount); } /// @@ -1459,7 +1459,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1467,17 +1467,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_SrcOut : PixelBlender + internal class MultiplySrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_SrcOut Instance { get; } = new Multiply_SrcOut(); + public static MultiplySrcOut Instance { get; } = new MultiplySrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_SrcOut(background, source, amount); + return PorterDuffFunctions.MultiplySrcOut(background, source, amount); } /// @@ -1498,7 +1498,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplySrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1506,17 +1506,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_SrcOut : PixelBlender + internal class AddSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_SrcOut Instance { get; } = new Add_SrcOut(); + public static AddSrcOut Instance { get; } = new AddSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_SrcOut(background, source, amount); + return PorterDuffFunctions.AddSrcOut(background, source, amount); } /// @@ -1537,7 +1537,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1545,17 +1545,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_SrcOut : PixelBlender + internal class SubtractSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_SrcOut Instance { get; } = new Subtract_SrcOut(); + public static SubtractSrcOut Instance { get; } = new SubtractSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_SrcOut(background, source, amount); + return PorterDuffFunctions.SubtractSrcOut(background, source, amount); } /// @@ -1576,7 +1576,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1584,17 +1584,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_SrcOut : PixelBlender + internal class ScreenSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_SrcOut Instance { get; } = new Screen_SrcOut(); + public static ScreenSrcOut Instance { get; } = new ScreenSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_SrcOut(background, source, amount); + return PorterDuffFunctions.ScreenSrcOut(background, source, amount); } /// @@ -1615,7 +1615,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1623,17 +1623,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_SrcOut : PixelBlender + internal class DarkenSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_SrcOut Instance { get; } = new Darken_SrcOut(); + public static DarkenSrcOut Instance { get; } = new DarkenSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_SrcOut(background, source, amount); + return PorterDuffFunctions.DarkenSrcOut(background, source, amount); } /// @@ -1654,7 +1654,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1662,17 +1662,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_SrcOut : PixelBlender + internal class LightenSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_SrcOut Instance { get; } = new Lighten_SrcOut(); + public static LightenSrcOut Instance { get; } = new LightenSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_SrcOut(background, source, amount); + return PorterDuffFunctions.LightenSrcOut(background, source, amount); } /// @@ -1693,7 +1693,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1701,17 +1701,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_SrcOut : PixelBlender + internal class OverlaySrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_SrcOut Instance { get; } = new Overlay_SrcOut(); + public static OverlaySrcOut Instance { get; } = new OverlaySrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_SrcOut(background, source, amount); + return PorterDuffFunctions.OverlaySrcOut(background, source, amount); } /// @@ -1732,7 +1732,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlaySrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1740,17 +1740,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_SrcOut : PixelBlender + internal class HardLightSrcOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_SrcOut Instance { get; } = new HardLight_SrcOut(); + public static HardLightSrcOut Instance { get; } = new HardLightSrcOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_SrcOut(background, source, amount); + return PorterDuffFunctions.HardLightSrcOut(background, source, amount); } /// @@ -1771,7 +1771,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_SrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightSrcOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1779,17 +1779,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_Dest : PixelBlender + internal class NormalDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_Dest Instance { get; } = new Normal_Dest(); + public static NormalDest Instance { get; } = new NormalDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_Dest(background, source, amount); + return PorterDuffFunctions.NormalDest(background, source, amount); } /// @@ -1810,7 +1810,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1818,17 +1818,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_Dest : PixelBlender + internal class MultiplyDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_Dest Instance { get; } = new Multiply_Dest(); + public static MultiplyDest Instance { get; } = new MultiplyDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_Dest(background, source, amount); + return PorterDuffFunctions.MultiplyDest(background, source, amount); } /// @@ -1849,7 +1849,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1857,17 +1857,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_Dest : PixelBlender + internal class AddDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_Dest Instance { get; } = new Add_Dest(); + public static AddDest Instance { get; } = new AddDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_Dest(background, source, amount); + return PorterDuffFunctions.AddDest(background, source, amount); } /// @@ -1888,7 +1888,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1896,17 +1896,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_Dest : PixelBlender + internal class SubtractDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_Dest Instance { get; } = new Subtract_Dest(); + public static SubtractDest Instance { get; } = new SubtractDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_Dest(background, source, amount); + return PorterDuffFunctions.SubtractDest(background, source, amount); } /// @@ -1927,7 +1927,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1935,17 +1935,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_Dest : PixelBlender + internal class ScreenDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_Dest Instance { get; } = new Screen_Dest(); + public static ScreenDest Instance { get; } = new ScreenDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_Dest(background, source, amount); + return PorterDuffFunctions.ScreenDest(background, source, amount); } /// @@ -1966,7 +1966,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -1974,17 +1974,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_Dest : PixelBlender + internal class DarkenDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_Dest Instance { get; } = new Darken_Dest(); + public static DarkenDest Instance { get; } = new DarkenDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_Dest(background, source, amount); + return PorterDuffFunctions.DarkenDest(background, source, amount); } /// @@ -2005,7 +2005,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2013,17 +2013,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_Dest : PixelBlender + internal class LightenDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_Dest Instance { get; } = new Lighten_Dest(); + public static LightenDest Instance { get; } = new LightenDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_Dest(background, source, amount); + return PorterDuffFunctions.LightenDest(background, source, amount); } /// @@ -2044,7 +2044,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2052,17 +2052,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_Dest : PixelBlender + internal class OverlayDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_Dest Instance { get; } = new Overlay_Dest(); + public static OverlayDest Instance { get; } = new OverlayDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_Dest(background, source, amount); + return PorterDuffFunctions.OverlayDest(background, source, amount); } /// @@ -2083,7 +2083,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2091,17 +2091,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_Dest : PixelBlender + internal class HardLightDest : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_Dest Instance { get; } = new HardLight_Dest(); + public static HardLightDest Instance { get; } = new HardLightDest(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_Dest(background, source, amount); + return PorterDuffFunctions.HardLightDest(background, source, amount); } /// @@ -2122,7 +2122,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_Dest(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightDest(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2130,17 +2130,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_DestAtop : PixelBlender + internal class NormalDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_DestAtop Instance { get; } = new Normal_DestAtop(); + public static NormalDestAtop Instance { get; } = new NormalDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_DestAtop(background, source, amount); + return PorterDuffFunctions.NormalDestAtop(background, source, amount); } /// @@ -2161,7 +2161,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2169,17 +2169,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_DestAtop : PixelBlender + internal class MultiplyDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_DestAtop Instance { get; } = new Multiply_DestAtop(); + public static MultiplyDestAtop Instance { get; } = new MultiplyDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_DestAtop(background, source, amount); + return PorterDuffFunctions.MultiplyDestAtop(background, source, amount); } /// @@ -2200,7 +2200,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2208,17 +2208,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_DestAtop : PixelBlender + internal class AddDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_DestAtop Instance { get; } = new Add_DestAtop(); + public static AddDestAtop Instance { get; } = new AddDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_DestAtop(background, source, amount); + return PorterDuffFunctions.AddDestAtop(background, source, amount); } /// @@ -2239,7 +2239,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2247,17 +2247,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_DestAtop : PixelBlender + internal class SubtractDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_DestAtop Instance { get; } = new Subtract_DestAtop(); + public static SubtractDestAtop Instance { get; } = new SubtractDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_DestAtop(background, source, amount); + return PorterDuffFunctions.SubtractDestAtop(background, source, amount); } /// @@ -2278,7 +2278,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2286,17 +2286,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_DestAtop : PixelBlender + internal class ScreenDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_DestAtop Instance { get; } = new Screen_DestAtop(); + public static ScreenDestAtop Instance { get; } = new ScreenDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_DestAtop(background, source, amount); + return PorterDuffFunctions.ScreenDestAtop(background, source, amount); } /// @@ -2317,7 +2317,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2325,17 +2325,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_DestAtop : PixelBlender + internal class DarkenDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_DestAtop Instance { get; } = new Darken_DestAtop(); + public static DarkenDestAtop Instance { get; } = new DarkenDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_DestAtop(background, source, amount); + return PorterDuffFunctions.DarkenDestAtop(background, source, amount); } /// @@ -2356,7 +2356,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2364,17 +2364,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_DestAtop : PixelBlender + internal class LightenDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_DestAtop Instance { get; } = new Lighten_DestAtop(); + public static LightenDestAtop Instance { get; } = new LightenDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_DestAtop(background, source, amount); + return PorterDuffFunctions.LightenDestAtop(background, source, amount); } /// @@ -2395,7 +2395,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2403,17 +2403,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_DestAtop : PixelBlender + internal class OverlayDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_DestAtop Instance { get; } = new Overlay_DestAtop(); + public static OverlayDestAtop Instance { get; } = new OverlayDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_DestAtop(background, source, amount); + return PorterDuffFunctions.OverlayDestAtop(background, source, amount); } /// @@ -2434,7 +2434,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2442,17 +2442,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_DestAtop : PixelBlender + internal class HardLightDestAtop : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_DestAtop Instance { get; } = new HardLight_DestAtop(); + public static HardLightDestAtop Instance { get; } = new HardLightDestAtop(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_DestAtop(background, source, amount); + return PorterDuffFunctions.HardLightDestAtop(background, source, amount); } /// @@ -2473,7 +2473,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_DestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightDestAtop(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2481,17 +2481,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_DestOver : PixelBlender + internal class NormalDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_DestOver Instance { get; } = new Normal_DestOver(); + public static NormalDestOver Instance { get; } = new NormalDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_DestOver(background, source, amount); + return PorterDuffFunctions.NormalDestOver(background, source, amount); } /// @@ -2512,7 +2512,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2520,17 +2520,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_DestOver : PixelBlender + internal class MultiplyDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_DestOver Instance { get; } = new Multiply_DestOver(); + public static MultiplyDestOver Instance { get; } = new MultiplyDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_DestOver(background, source, amount); + return PorterDuffFunctions.MultiplyDestOver(background, source, amount); } /// @@ -2551,7 +2551,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2559,17 +2559,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_DestOver : PixelBlender + internal class AddDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_DestOver Instance { get; } = new Add_DestOver(); + public static AddDestOver Instance { get; } = new AddDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_DestOver(background, source, amount); + return PorterDuffFunctions.AddDestOver(background, source, amount); } /// @@ -2590,7 +2590,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2598,17 +2598,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_DestOver : PixelBlender + internal class SubtractDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_DestOver Instance { get; } = new Subtract_DestOver(); + public static SubtractDestOver Instance { get; } = new SubtractDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_DestOver(background, source, amount); + return PorterDuffFunctions.SubtractDestOver(background, source, amount); } /// @@ -2629,7 +2629,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2637,17 +2637,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_DestOver : PixelBlender + internal class ScreenDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_DestOver Instance { get; } = new Screen_DestOver(); + public static ScreenDestOver Instance { get; } = new ScreenDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_DestOver(background, source, amount); + return PorterDuffFunctions.ScreenDestOver(background, source, amount); } /// @@ -2668,7 +2668,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2676,17 +2676,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_DestOver : PixelBlender + internal class DarkenDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_DestOver Instance { get; } = new Darken_DestOver(); + public static DarkenDestOver Instance { get; } = new DarkenDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_DestOver(background, source, amount); + return PorterDuffFunctions.DarkenDestOver(background, source, amount); } /// @@ -2707,7 +2707,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2715,17 +2715,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_DestOver : PixelBlender + internal class LightenDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_DestOver Instance { get; } = new Lighten_DestOver(); + public static LightenDestOver Instance { get; } = new LightenDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_DestOver(background, source, amount); + return PorterDuffFunctions.LightenDestOver(background, source, amount); } /// @@ -2746,7 +2746,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2754,17 +2754,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_DestOver : PixelBlender + internal class OverlayDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_DestOver Instance { get; } = new Overlay_DestOver(); + public static OverlayDestOver Instance { get; } = new OverlayDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_DestOver(background, source, amount); + return PorterDuffFunctions.OverlayDestOver(background, source, amount); } /// @@ -2785,7 +2785,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2793,17 +2793,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_DestOver : PixelBlender + internal class HardLightDestOver : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_DestOver Instance { get; } = new HardLight_DestOver(); + public static HardLightDestOver Instance { get; } = new HardLightDestOver(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_DestOver(background, source, amount); + return PorterDuffFunctions.HardLightDestOver(background, source, amount); } /// @@ -2824,7 +2824,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_DestOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightDestOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2832,17 +2832,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_DestIn : PixelBlender + internal class NormalDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_DestIn Instance { get; } = new Normal_DestIn(); + public static NormalDestIn Instance { get; } = new NormalDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_DestIn(background, source, amount); + return PorterDuffFunctions.NormalDestIn(background, source, amount); } /// @@ -2863,7 +2863,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2871,17 +2871,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_DestIn : PixelBlender + internal class MultiplyDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_DestIn Instance { get; } = new Multiply_DestIn(); + public static MultiplyDestIn Instance { get; } = new MultiplyDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_DestIn(background, source, amount); + return PorterDuffFunctions.MultiplyDestIn(background, source, amount); } /// @@ -2902,7 +2902,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2910,17 +2910,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_DestIn : PixelBlender + internal class AddDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_DestIn Instance { get; } = new Add_DestIn(); + public static AddDestIn Instance { get; } = new AddDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_DestIn(background, source, amount); + return PorterDuffFunctions.AddDestIn(background, source, amount); } /// @@ -2941,7 +2941,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2949,17 +2949,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_DestIn : PixelBlender + internal class SubtractDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_DestIn Instance { get; } = new Subtract_DestIn(); + public static SubtractDestIn Instance { get; } = new SubtractDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_DestIn(background, source, amount); + return PorterDuffFunctions.SubtractDestIn(background, source, amount); } /// @@ -2980,7 +2980,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -2988,17 +2988,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_DestIn : PixelBlender + internal class ScreenDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_DestIn Instance { get; } = new Screen_DestIn(); + public static ScreenDestIn Instance { get; } = new ScreenDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_DestIn(background, source, amount); + return PorterDuffFunctions.ScreenDestIn(background, source, amount); } /// @@ -3019,7 +3019,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3027,17 +3027,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_DestIn : PixelBlender + internal class DarkenDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_DestIn Instance { get; } = new Darken_DestIn(); + public static DarkenDestIn Instance { get; } = new DarkenDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_DestIn(background, source, amount); + return PorterDuffFunctions.DarkenDestIn(background, source, amount); } /// @@ -3058,7 +3058,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3066,17 +3066,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_DestIn : PixelBlender + internal class LightenDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_DestIn Instance { get; } = new Lighten_DestIn(); + public static LightenDestIn Instance { get; } = new LightenDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_DestIn(background, source, amount); + return PorterDuffFunctions.LightenDestIn(background, source, amount); } /// @@ -3097,7 +3097,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3105,17 +3105,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_DestIn : PixelBlender + internal class OverlayDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_DestIn Instance { get; } = new Overlay_DestIn(); + public static OverlayDestIn Instance { get; } = new OverlayDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_DestIn(background, source, amount); + return PorterDuffFunctions.OverlayDestIn(background, source, amount); } /// @@ -3136,7 +3136,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3144,17 +3144,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_DestIn : PixelBlender + internal class HardLightDestIn : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_DestIn Instance { get; } = new HardLight_DestIn(); + public static HardLightDestIn Instance { get; } = new HardLightDestIn(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_DestIn(background, source, amount); + return PorterDuffFunctions.HardLightDestIn(background, source, amount); } /// @@ -3175,7 +3175,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_DestIn(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightDestIn(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3183,17 +3183,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_DestOut : PixelBlender + internal class NormalDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_DestOut Instance { get; } = new Normal_DestOut(); + public static NormalDestOut Instance { get; } = new NormalDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_DestOut(background, source, amount); + return PorterDuffFunctions.NormalDestOut(background, source, amount); } /// @@ -3214,7 +3214,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3222,17 +3222,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_DestOut : PixelBlender + internal class MultiplyDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_DestOut Instance { get; } = new Multiply_DestOut(); + public static MultiplyDestOut Instance { get; } = new MultiplyDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_DestOut(background, source, amount); + return PorterDuffFunctions.MultiplyDestOut(background, source, amount); } /// @@ -3253,7 +3253,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3261,17 +3261,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_DestOut : PixelBlender + internal class AddDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_DestOut Instance { get; } = new Add_DestOut(); + public static AddDestOut Instance { get; } = new AddDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_DestOut(background, source, amount); + return PorterDuffFunctions.AddDestOut(background, source, amount); } /// @@ -3292,7 +3292,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3300,17 +3300,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_DestOut : PixelBlender + internal class SubtractDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_DestOut Instance { get; } = new Subtract_DestOut(); + public static SubtractDestOut Instance { get; } = new SubtractDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_DestOut(background, source, amount); + return PorterDuffFunctions.SubtractDestOut(background, source, amount); } /// @@ -3331,7 +3331,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3339,17 +3339,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_DestOut : PixelBlender + internal class ScreenDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_DestOut Instance { get; } = new Screen_DestOut(); + public static ScreenDestOut Instance { get; } = new ScreenDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_DestOut(background, source, amount); + return PorterDuffFunctions.ScreenDestOut(background, source, amount); } /// @@ -3370,7 +3370,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3378,17 +3378,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_DestOut : PixelBlender + internal class DarkenDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_DestOut Instance { get; } = new Darken_DestOut(); + public static DarkenDestOut Instance { get; } = new DarkenDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_DestOut(background, source, amount); + return PorterDuffFunctions.DarkenDestOut(background, source, amount); } /// @@ -3409,7 +3409,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3417,17 +3417,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_DestOut : PixelBlender + internal class LightenDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_DestOut Instance { get; } = new Lighten_DestOut(); + public static LightenDestOut Instance { get; } = new LightenDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_DestOut(background, source, amount); + return PorterDuffFunctions.LightenDestOut(background, source, amount); } /// @@ -3448,7 +3448,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3456,17 +3456,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_DestOut : PixelBlender + internal class OverlayDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_DestOut Instance { get; } = new Overlay_DestOut(); + public static OverlayDestOut Instance { get; } = new OverlayDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_DestOut(background, source, amount); + return PorterDuffFunctions.OverlayDestOut(background, source, amount); } /// @@ -3487,7 +3487,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3495,17 +3495,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_DestOut : PixelBlender + internal class HardLightDestOut : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_DestOut Instance { get; } = new HardLight_DestOut(); + public static HardLightDestOut Instance { get; } = new HardLightDestOut(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_DestOut(background, source, amount); + return PorterDuffFunctions.HardLightDestOut(background, source, amount); } /// @@ -3526,7 +3526,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_DestOut(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightDestOut(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3534,17 +3534,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_Clear : PixelBlender + internal class NormalClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_Clear Instance { get; } = new Normal_Clear(); + public static NormalClear Instance { get; } = new NormalClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_Clear(background, source, amount); + return PorterDuffFunctions.NormalClear(background, source, amount); } /// @@ -3565,7 +3565,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3573,17 +3573,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_Clear : PixelBlender + internal class MultiplyClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_Clear Instance { get; } = new Multiply_Clear(); + public static MultiplyClear Instance { get; } = new MultiplyClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_Clear(background, source, amount); + return PorterDuffFunctions.MultiplyClear(background, source, amount); } /// @@ -3604,7 +3604,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3612,17 +3612,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_Clear : PixelBlender + internal class AddClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_Clear Instance { get; } = new Add_Clear(); + public static AddClear Instance { get; } = new AddClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_Clear(background, source, amount); + return PorterDuffFunctions.AddClear(background, source, amount); } /// @@ -3643,7 +3643,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3651,17 +3651,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_Clear : PixelBlender + internal class SubtractClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_Clear Instance { get; } = new Subtract_Clear(); + public static SubtractClear Instance { get; } = new SubtractClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_Clear(background, source, amount); + return PorterDuffFunctions.SubtractClear(background, source, amount); } /// @@ -3682,7 +3682,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3690,17 +3690,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_Clear : PixelBlender + internal class ScreenClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_Clear Instance { get; } = new Screen_Clear(); + public static ScreenClear Instance { get; } = new ScreenClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_Clear(background, source, amount); + return PorterDuffFunctions.ScreenClear(background, source, amount); } /// @@ -3721,7 +3721,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3729,17 +3729,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_Clear : PixelBlender + internal class DarkenClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_Clear Instance { get; } = new Darken_Clear(); + public static DarkenClear Instance { get; } = new DarkenClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_Clear(background, source, amount); + return PorterDuffFunctions.DarkenClear(background, source, amount); } /// @@ -3760,7 +3760,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3768,17 +3768,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_Clear : PixelBlender + internal class LightenClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_Clear Instance { get; } = new Lighten_Clear(); + public static LightenClear Instance { get; } = new LightenClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_Clear(background, source, amount); + return PorterDuffFunctions.LightenClear(background, source, amount); } /// @@ -3799,7 +3799,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3807,17 +3807,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_Clear : PixelBlender + internal class OverlayClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_Clear Instance { get; } = new Overlay_Clear(); + public static OverlayClear Instance { get; } = new OverlayClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_Clear(background, source, amount); + return PorterDuffFunctions.OverlayClear(background, source, amount); } /// @@ -3838,7 +3838,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3846,17 +3846,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_Clear : PixelBlender + internal class HardLightClear : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_Clear Instance { get; } = new HardLight_Clear(); + public static HardLightClear Instance { get; } = new HardLightClear(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_Clear(background, source, amount); + return PorterDuffFunctions.HardLightClear(background, source, amount); } /// @@ -3877,7 +3877,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_Clear(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightClear(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3885,17 +3885,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Normal_Xor : PixelBlender + internal class NormalXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Normal_Xor Instance { get; } = new Normal_Xor(); + public static NormalXor Instance { get; } = new NormalXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Normal_Xor(background, source, amount); + return PorterDuffFunctions.NormalXor(background, source, amount); } /// @@ -3916,7 +3916,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3924,17 +3924,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Multiply_Xor : PixelBlender + internal class MultiplyXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Multiply_Xor Instance { get; } = new Multiply_Xor(); + public static MultiplyXor Instance { get; } = new MultiplyXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Multiply_Xor(background, source, amount); + return PorterDuffFunctions.MultiplyXor(background, source, amount); } /// @@ -3955,7 +3955,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Multiply_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.MultiplyXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -3963,17 +3963,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Add_Xor : PixelBlender + internal class AddXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Add_Xor Instance { get; } = new Add_Xor(); + public static AddXor Instance { get; } = new AddXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Add_Xor(background, source, amount); + return PorterDuffFunctions.AddXor(background, source, amount); } /// @@ -3994,7 +3994,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Add_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.AddXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -4002,17 +4002,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Subtract_Xor : PixelBlender + internal class SubtractXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Subtract_Xor Instance { get; } = new Subtract_Xor(); + public static SubtractXor Instance { get; } = new SubtractXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Subtract_Xor(background, source, amount); + return PorterDuffFunctions.SubtractXor(background, source, amount); } /// @@ -4033,7 +4033,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Subtract_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.SubtractXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -4041,17 +4041,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Screen_Xor : PixelBlender + internal class ScreenXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Screen_Xor Instance { get; } = new Screen_Xor(); + public static ScreenXor Instance { get; } = new ScreenXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Screen_Xor(background, source, amount); + return PorterDuffFunctions.ScreenXor(background, source, amount); } /// @@ -4072,7 +4072,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Screen_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.ScreenXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -4080,17 +4080,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Darken_Xor : PixelBlender + internal class DarkenXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Darken_Xor Instance { get; } = new Darken_Xor(); + public static DarkenXor Instance { get; } = new DarkenXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Darken_Xor(background, source, amount); + return PorterDuffFunctions.DarkenXor(background, source, amount); } /// @@ -4111,7 +4111,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Darken_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.DarkenXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -4119,17 +4119,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Lighten_Xor : PixelBlender + internal class LightenXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Lighten_Xor Instance { get; } = new Lighten_Xor(); + public static LightenXor Instance { get; } = new LightenXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Lighten_Xor(background, source, amount); + return PorterDuffFunctions.LightenXor(background, source, amount); } /// @@ -4150,7 +4150,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Lighten_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.LightenXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -4158,17 +4158,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class Overlay_Xor : PixelBlender + internal class OverlayXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static Overlay_Xor Instance { get; } = new Overlay_Xor(); + public static OverlayXor Instance { get; } = new OverlayXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.Overlay_Xor(background, source, amount); + return PorterDuffFunctions.OverlayXor(background, source, amount); } /// @@ -4189,7 +4189,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Overlay_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.OverlayXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -4197,17 +4197,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } } - internal class HardLight_Xor : PixelBlender + internal class HardLightXor : PixelBlender { /// /// Gets the static instance of this blender. /// - public static HardLight_Xor Instance { get; } = new HardLight_Xor(); + public static HardLightXor Instance { get; } = new HardLightXor(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.HardLight_Xor(background, source, amount); + return PorterDuffFunctions.HardLightXor(background, source, amount); } /// @@ -4228,7 +4228,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.HardLight_Xor(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.HardLightXor(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index e60d8ca90a..34fe4d4cda 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -36,51 +36,49 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders <# string[] composers = new []{ - "Src" , - "SrcAtop" , - "SrcOver" , - "SrcIn" , - "SrcOut" , - "Dest" , - "DestAtop" , - "DestOver" , - "DestIn" , - "DestOut" , - "Clear" , - "Xor" , + "Src", + "SrcAtop", + "SrcOver", + "SrcIn", + "SrcOut", + "Dest", + "DestAtop", + "DestOver", + "DestIn", + "DestOut", + "Clear", + "Xor", }; string[] blenders = new []{ - "Normal" , - "Multiply" , - "Add" , - "Subtract" , - "Screen" , - "Darken" , - "Lighten" , - "Overlay" , + "Normal", + "Multiply", + "Add", + "Subtract", + "Screen", + "Darken", + "Lighten", + "Overlay", "HardLight" }; - - foreach(var composer in composers) { foreach(var blender in blenders) { - string blender_composer= $"{blender}_{composer}"; + string blender_composer= $"{blender}{composer}"; #> - internal class <#= blender_composer#> : PixelBlender + internal class <#= blender_composer#> : PixelBlender { /// /// Gets the static instance of this blender. /// - public static <#= blender_composer#> Instance { get; } = new <#= blender_composer#>(); + public static <#=blender_composer#> Instance { get; } = new <#=blender_composer#>(); /// public override TPixel Blend(TPixel background, TPixel source, float amount) { - return PorterDuffFunctions.<#= blender_composer#>(background, source, amount); + return PorterDuffFunctions.<#=blender_composer#>(background, source, amount); } /// @@ -101,7 +99,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.<#= blender_composer#>(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.<#=blender_composer#>(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs index b8c3faf4f5..4b0ffdd485 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs @@ -15,10 +15,9 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders - #region Blenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -27,7 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -36,7 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -45,7 +44,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -54,7 +53,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -63,13 +62,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -78,7 +77,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -87,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -96,7 +95,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -105,7 +104,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -114,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Normal_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 NormalClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -124,138 +123,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Normal_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel NormalXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Normal_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(NormalXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplySrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -264,7 +263,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplySrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -273,7 +272,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplySrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -282,7 +281,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplySrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -291,7 +290,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplySrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -300,13 +299,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -315,7 +314,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -324,7 +323,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -333,7 +332,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -342,7 +341,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -351,7 +350,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Multiply_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 MultiplyClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -361,138 +360,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplySrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplySrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplySrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplySrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplySrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplySrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplySrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplySrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplySrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplySrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Multiply_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel MultiplyXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Multiply_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(MultiplyXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -501,7 +500,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -510,7 +509,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -519,7 +518,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -528,7 +527,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -537,13 +536,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -552,7 +551,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -561,7 +560,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -570,7 +569,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -579,7 +578,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -588,7 +587,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Add_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 AddClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -598,138 +597,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Add_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel AddXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Add_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(AddXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -738,7 +737,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -747,7 +746,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -756,7 +755,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -765,7 +764,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -774,13 +773,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -789,7 +788,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -798,7 +797,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -807,7 +806,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -816,7 +815,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -825,7 +824,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Subtract_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 SubtractClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -835,138 +834,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Subtract_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel SubtractXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Subtract_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(SubtractXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -975,7 +974,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -984,7 +983,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -993,7 +992,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1002,7 +1001,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1011,13 +1010,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1026,7 +1025,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1035,7 +1034,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1044,7 +1043,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1053,7 +1052,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1062,7 +1061,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Screen_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 ScreenClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1072,138 +1071,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Screen_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel ScreenXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Screen_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(ScreenXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1212,7 +1211,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1221,7 +1220,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1230,7 +1229,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1239,7 +1238,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1248,13 +1247,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1263,7 +1262,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1272,7 +1271,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1281,7 +1280,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1290,7 +1289,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1299,7 +1298,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Darken_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 DarkenClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1309,138 +1308,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Darken_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel DarkenXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Darken_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(DarkenXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1449,7 +1448,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1458,7 +1457,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1467,7 +1466,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1476,7 +1475,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1485,13 +1484,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1500,7 +1499,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1509,7 +1508,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1518,7 +1517,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1527,7 +1526,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1536,7 +1535,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Lighten_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 LightenClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1546,138 +1545,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Lighten_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel LightenXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Lighten_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(LightenXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlaySrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1686,7 +1685,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlaySrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1695,7 +1694,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlaySrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1704,7 +1703,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlaySrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1713,7 +1712,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlaySrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1722,13 +1721,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1737,7 +1736,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1746,7 +1745,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1755,7 +1754,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1764,7 +1763,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1773,7 +1772,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Overlay_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 OverlayClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1783,138 +1782,138 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlaySrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlaySrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlaySrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlaySrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlaySrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlaySrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlaySrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlaySrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlaySrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlaySrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel Overlay_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel OverlayXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(Overlay_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(OverlayXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightSrc(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1923,7 +1922,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightSrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1932,7 +1931,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightSrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1941,7 +1940,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightSrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1950,7 +1949,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightSrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1959,13 +1958,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightDest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightDestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1974,7 +1973,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightDestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1983,7 +1982,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightDestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -1992,7 +1991,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightDestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -2001,7 +2000,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightXor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -2010,7 +2009,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 HardLight_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 HardLightClear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -2020,136 +2019,134 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Src(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightSrc(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_Src(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightSrc(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightSrcAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_SrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightSrcAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightSrcOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_SrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightSrcOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightSrcIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_SrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightSrcIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_SrcOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightSrcOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_SrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightSrcOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Dest(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightDest(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_Dest(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightDest(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestAtop(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightDestAtop(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_DestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightDestAtop(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestOver(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightDestOver(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_DestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightDestOver(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestIn(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightDestIn(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_DestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightDestIn(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_DestOut(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightDestOut(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_DestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightDestOut(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Clear(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightClear(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_Clear(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightClear(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel HardLight_Xor(TPixel backdrop, TPixel source, float opacity) + public static TPixel HardLightXor(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(HardLight_Xor(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(HardLightXor(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } - - #endregion } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt index 3045b1e81c..5e46a89a85 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders <# void GeneratePixelBlenders(string blender) { #> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Src(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>Src(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>SrcAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>SrcOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>SrcIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_SrcOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>SrcOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -70,13 +70,13 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Dest(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>Dest(Vector4 backdrop, Vector4 source, float opacity) { return backdrop; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestAtop(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>DestAtop(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestOver(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>DestOver(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestIn(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>DestIn(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_DestOut(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>DestOut(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Xor(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>Xor(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 <#=blender#>_Clear(Vector4 backdrop, Vector4 source, float opacity) + public static Vector4 <#=blender#>Clear(Vector4 backdrop, Vector4 source, float opacity) { opacity = opacity.Clamp(0, 1); source.W *= opacity; @@ -134,43 +134,42 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders <# void GenerateGenericPixelBlender(string blender, string composer) { #> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static TPixel <#=blender#>_<#=composer#>(TPixel backdrop, TPixel source, float opacity) + public static TPixel <#=blender#><#=composer#>(TPixel backdrop, TPixel source, float opacity) where TPixel : struct, IPixel { TPixel dest = default; - dest.PackFromVector4(<#=blender#>_<#=composer#>(backdrop.ToVector4(),source.ToVector4(),opacity)); + dest.PackFromVector4(<#=blender#><#=composer#>(backdrop.ToVector4(),source.ToVector4(),opacity)); return dest; } <# } #> - #region Blenders <# string[] composers = new []{ - "Src" , - "SrcAtop" , - "SrcOver" , - "SrcIn" , - "SrcOut" , - "Dest" , - "DestAtop" , - "DestOver" , - "DestIn" , - "DestOut" , - "Clear" , - "Xor" , + "Src", + "SrcAtop", + "SrcOver", + "SrcIn", + "SrcOut", + "Dest", + "DestAtop", + "DestOver", + "DestIn", + "DestOut", + "Clear", + "Xor", }; string[] blenders = new []{ - "Normal" , - "Multiply" , - "Add" , - "Subtract" , - "Screen" , - "Darken" , - "Lighten" , - "Overlay" , + "Normal", + "Multiply", + "Add", + "Subtract", + "Screen", + "Darken", + "Lighten", + "Overlay", "HardLight" }; @@ -185,7 +184,5 @@ string[] blenders = new []{ } #> - - #endregion } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index c84cd9a7b1..e10c8fe918 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders /// Desired transformed color, without taking Alpha channel in account /// The final color [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Vector4 SrcOver_Reference(Vector4 backdrop, Vector4 source, Vector4 xform) + private static Vector4 SrcOverReference(Vector4 backdrop, Vector4 source, Vector4 xform) { // calculate weights float xw = backdrop.W * source.W; diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs index ad9366bc52..ca6a28192d 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs @@ -20,30 +20,30 @@ namespace SixLabors.ImageSharp.PixelFormats { switch (mode) { - case PixelBlenderMode.Multiply: return DefaultPixelBlenders.Multiply_SrcOver.Instance; - case PixelBlenderMode.Add: return DefaultPixelBlenders.Add_SrcOver.Instance; - case PixelBlenderMode.Subtract: return DefaultPixelBlenders.Subtract_SrcOver.Instance; - case PixelBlenderMode.Screen: return DefaultPixelBlenders.Screen_SrcOver.Instance; - case PixelBlenderMode.Darken: return DefaultPixelBlenders.Darken_SrcOver.Instance; - case PixelBlenderMode.Lighten: return DefaultPixelBlenders.Lighten_SrcOver.Instance; - case PixelBlenderMode.Overlay: return DefaultPixelBlenders.Overlay_SrcOver.Instance; - case PixelBlenderMode.HardLight: return DefaultPixelBlenders.HardLight_SrcOver.Instance; - case PixelBlenderMode.Src: return DefaultPixelBlenders.Normal_Src.Instance; - case PixelBlenderMode.Atop: return DefaultPixelBlenders.Normal_SrcAtop.Instance; - case PixelBlenderMode.Over: return DefaultPixelBlenders.Normal_SrcOver.Instance; - case PixelBlenderMode.In: return DefaultPixelBlenders.Normal_SrcIn.Instance; - case PixelBlenderMode.Out: return DefaultPixelBlenders.Normal_SrcOut.Instance; - case PixelBlenderMode.Dest: return DefaultPixelBlenders.Normal_Dest.Instance; - case PixelBlenderMode.DestAtop: return DefaultPixelBlenders.Normal_DestAtop.Instance; - case PixelBlenderMode.DestOver: return DefaultPixelBlenders.Normal_DestOver.Instance; - case PixelBlenderMode.DestIn: return DefaultPixelBlenders.Normal_DestIn.Instance; - case PixelBlenderMode.DestOut: return DefaultPixelBlenders.Normal_DestOut.Instance; - case PixelBlenderMode.Clear: return DefaultPixelBlenders.Normal_Clear.Instance; - case PixelBlenderMode.Xor: return DefaultPixelBlenders.Normal_Xor.Instance; + case PixelBlenderMode.Multiply: return DefaultPixelBlenders.MultiplySrcOver.Instance; + case PixelBlenderMode.Add: return DefaultPixelBlenders.AddSrcOver.Instance; + case PixelBlenderMode.Subtract: return DefaultPixelBlenders.SubtractSrcOver.Instance; + case PixelBlenderMode.Screen: return DefaultPixelBlenders.ScreenSrcOver.Instance; + case PixelBlenderMode.Darken: return DefaultPixelBlenders.DarkenSrcOver.Instance; + case PixelBlenderMode.Lighten: return DefaultPixelBlenders.LightenSrcOver.Instance; + case PixelBlenderMode.Overlay: return DefaultPixelBlenders.OverlaySrcOver.Instance; + case PixelBlenderMode.HardLight: return DefaultPixelBlenders.HardLightSrcOver.Instance; + case PixelBlenderMode.Src: return DefaultPixelBlenders.NormalSrc.Instance; + case PixelBlenderMode.Atop: return DefaultPixelBlenders.NormalSrcAtop.Instance; + case PixelBlenderMode.Over: return DefaultPixelBlenders.NormalSrcOver.Instance; + case PixelBlenderMode.In: return DefaultPixelBlenders.NormalSrcIn.Instance; + case PixelBlenderMode.Out: return DefaultPixelBlenders.NormalSrcOut.Instance; + case PixelBlenderMode.Dest: return DefaultPixelBlenders.NormalDest.Instance; + case PixelBlenderMode.DestAtop: return DefaultPixelBlenders.NormalDestAtop.Instance; + case PixelBlenderMode.DestOver: return DefaultPixelBlenders.NormalDestOver.Instance; + case PixelBlenderMode.DestIn: return DefaultPixelBlenders.NormalDestIn.Instance; + case PixelBlenderMode.DestOut: return DefaultPixelBlenders.NormalDestOut.Instance; + case PixelBlenderMode.Clear: return DefaultPixelBlenders.NormalClear.Instance; + case PixelBlenderMode.Xor: return DefaultPixelBlenders.NormalXor.Instance; case PixelBlenderMode.Normal: default: - return DefaultPixelBlenders.Normal_SrcOver.Instance; + return DefaultPixelBlenders.NormalSrcOver.Instance; } } } diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index a70d9fc11e..3133e0b366 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Benchmarks for (int i = 0; i < destination.Length; i++) { - destinationSpan[i] = PorterDuffFunctions.Normal_SrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); + destinationSpan[i] = PorterDuffFunctions.NormalSrcOver(backgroundSpan[i], sourceSpan[i], amount[i]); } PixelOperations.Instance.PackFromVector4(destinationSpan, destination, destination.Length); @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Benchmarks for (int i = 0; i < destination.Length; i++) { - destination[i] = PorterDuffFunctions.Normal_SrcOver(destination[i], source[i], amount[i]); + destination[i] = PorterDuffFunctions.NormalSrcOver(destination[i], source[i], amount[i]); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index c34bdc56e4..9a196d9d5b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -1,10 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; using System.Numerics; -using System.Text; using SixLabors.ImageSharp.PixelFormats.PixelBlenders; using SixLabors.ImageSharp.Tests.TestUtilities; using Xunit; @@ -22,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(NormalBlendFunctionData))] public void NormalBlendFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Normal_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.NormalSrcOver((Vector4)back, source, amount); Assert.Equal(expected, actual); } @@ -41,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(MultiplyFunctionData))] public void MultiplyFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Multiply_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.MultiplySrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -60,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(AddFunctionData))] public void AddFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Multiply_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.MultiplySrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -79,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(SubstractFunctionData))] public void SubstractFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Subtract_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.SubtractSrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -98,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(ScreenFunctionData))] public void ScreenFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Screen_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.ScreenSrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -117,7 +114,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(DarkenFunctionData))] public void DarkenFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Darken_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.DarkenSrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -136,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(LightenFunctionData))] public void LightenFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Lighten_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.LightenSrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -155,7 +152,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(OverlayFunctionData))] public void OverlayFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.Overlay_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.OverlaySrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } @@ -174,7 +171,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders [MemberData(nameof(HardLightFunctionData))] public void HardLightFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected) { - Vector4 actual = PorterDuffFunctions.HardLight_SrcOver((Vector4)back, source, amount); + Vector4 actual = PorterDuffFunctions.HardLightSrcOver((Vector4)back, source, amount); VectorAssert.Equal(expected, actual, 5); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs index a53591dbc2..3ea9bcad40 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs @@ -2,9 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Collections.Generic; -using System.Numerics; -using System.Text; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats.PixelBlenders; using SixLabors.ImageSharp.Tests.TestUtilities; @@ -14,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders { using SixLabors.Memory; - public class PorterDuffFunctionsTests_TPixel + public class PorterDuffFunctionsTestsTPixel { private static Span AsSpan(T value) where T : struct @@ -34,26 +31,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void NormalBlendFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Normal_SrcOver((TPixel)(TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)(TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(NormalBlendFunctionData))] - public void NormalBlendFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void NormalBlendFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Normal_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.NormalSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(NormalBlendFunctionData))] - public void NormalBlendFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void NormalBlendFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Normal_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.NormalSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -73,26 +70,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void MultiplyFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Multiply_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.MultiplySrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(MultiplyFunctionData))] - public void MultiplyFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void MultiplyFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Multiply_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.MultiplySrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(MultiplyFunctionData))] - public void MultiplyFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void MultiplyFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Multiply_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.MultiplySrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -112,26 +109,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void AddFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Add_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.AddSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(AddFunctionData))] - public void AddFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void AddFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Add_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.AddSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(AddFunctionData))] - public void AddFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void AddFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Add_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.AddSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -151,26 +148,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void SubstractFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Subtract_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.SubtractSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(SubstractFunctionData))] - public void SubstractFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void SubstractFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Subtract_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.SubtractSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(SubstractFunctionData))] - public void SubstractFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void SubstractFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Subtract_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.SubtractSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -190,26 +187,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void ScreenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Screen_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.ScreenSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(ScreenFunctionData))] - public void ScreenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void ScreenFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Screen_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.ScreenSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(ScreenFunctionData))] - public void ScreenFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void ScreenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Screen_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.ScreenSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -229,26 +226,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void DarkenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Darken_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.DarkenSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(DarkenFunctionData))] - public void DarkenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void DarkenFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Darken_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.DarkenSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(DarkenFunctionData))] - public void DarkenFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void DarkenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Darken_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.DarkenSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -268,26 +265,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void LightenFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Lighten_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.LightenSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(LightenFunctionData))] - public void LightenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void LightenFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Lighten_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.LightenSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(LightenFunctionData))] - public void LightenFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void LightenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Lighten_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.LightenSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -307,26 +304,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void OverlayFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.Overlay_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.OverlaySrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(OverlayFunctionData))] - public void OverlayFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void OverlayFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.Overlay_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.OverlaySrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(OverlayFunctionData))] - public void OverlayFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void OverlayFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Overlay_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.OverlaySrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -346,26 +343,26 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders public void HardLightFunction(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = PorterDuffFunctions.HardLight_SrcOver((TPixel)back, source, amount); + TPixel actual = PorterDuffFunctions.HardLightSrcOver((TPixel)back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(HardLightFunctionData))] - public void HardLightFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void HardLightFunctionBlender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultPixelBlenders.HardLight_SrcOver().Blend(back, source, amount); + TPixel actual = new DefaultPixelBlenders.HardLightSrcOver().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } [Theory] [MemberData(nameof(HardLightFunctionData))] - public void HardLightFunction_Blender_Bulk(TestPixel back, TestPixel source, float amount, TestPixel expected) + public void HardLightFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.HardLight_SrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + var dest = new Span(new TPixel[1]); + new DefaultPixelBlenders.HardLightSrcOver().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs index 1a4121c974..3923a56752 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs @@ -17,50 +17,50 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public static TheoryData BlenderMappings = new TheoryData() { - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Normal }, - { new TestPixel(), typeof(DefaultPixelBlenders.Screen_SrcOver), PixelBlenderMode.Screen }, - { new TestPixel(), typeof(DefaultPixelBlenders.HardLight_SrcOver), PixelBlenderMode.HardLight }, - { new TestPixel(), typeof(DefaultPixelBlenders.Overlay_SrcOver), PixelBlenderMode.Overlay }, - { new TestPixel(), typeof(DefaultPixelBlenders.Darken_SrcOver), PixelBlenderMode.Darken }, - { new TestPixel(), typeof(DefaultPixelBlenders.Lighten_SrcOver), PixelBlenderMode.Lighten }, - { new TestPixel(), typeof(DefaultPixelBlenders.Add_SrcOver), PixelBlenderMode.Add }, - { new TestPixel(), typeof(DefaultPixelBlenders.Subtract_SrcOver), PixelBlenderMode.Subtract }, - { new TestPixel(), typeof(DefaultPixelBlenders.Multiply_SrcOver), PixelBlenderMode.Multiply }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Normal }, + { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelBlenderMode.Screen }, + { new TestPixel(), typeof(DefaultPixelBlenders.HardLightSrcOver), PixelBlenderMode.HardLight }, + { new TestPixel(), typeof(DefaultPixelBlenders.OverlaySrcOver), PixelBlenderMode.Overlay }, + { new TestPixel(), typeof(DefaultPixelBlenders.DarkenSrcOver), PixelBlenderMode.Darken }, + { new TestPixel(), typeof(DefaultPixelBlenders.LightenSrcOver), PixelBlenderMode.Lighten }, + { new TestPixel(), typeof(DefaultPixelBlenders.AddSrcOver), PixelBlenderMode.Add }, + { new TestPixel(), typeof(DefaultPixelBlenders.SubtractSrcOver), PixelBlenderMode.Subtract }, + { new TestPixel(), typeof(DefaultPixelBlenders.MultiplySrcOver), PixelBlenderMode.Multiply }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Src), PixelBlenderMode.Src }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcAtop), PixelBlenderMode.Atop }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Over }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcIn), PixelBlenderMode.In }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOut), PixelBlenderMode.Out }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Dest), PixelBlenderMode.Dest }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestAtop), PixelBlenderMode.DestAtop }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOver), PixelBlenderMode.DestOver }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestIn), PixelBlenderMode.DestIn }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOut), PixelBlenderMode.DestOut }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Clear), PixelBlenderMode.Clear }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Xor), PixelBlenderMode.Xor }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrc), PixelBlenderMode.Src }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcAtop), PixelBlenderMode.Atop }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Over }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcIn), PixelBlenderMode.In }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOut), PixelBlenderMode.Out }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDest), PixelBlenderMode.Dest }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestAtop), PixelBlenderMode.DestAtop }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOver), PixelBlenderMode.DestOver }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestIn), PixelBlenderMode.DestIn }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOut), PixelBlenderMode.DestOut }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalClear), PixelBlenderMode.Clear }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalXor), PixelBlenderMode.Xor }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Normal }, - { new TestPixel(), typeof(DefaultPixelBlenders.Screen_SrcOver), PixelBlenderMode.Screen }, - { new TestPixel(), typeof(DefaultPixelBlenders.HardLight_SrcOver), PixelBlenderMode.HardLight }, - { new TestPixel(), typeof(DefaultPixelBlenders.Overlay_SrcOver), PixelBlenderMode.Overlay }, - { new TestPixel(), typeof(DefaultPixelBlenders.Darken_SrcOver), PixelBlenderMode.Darken }, - { new TestPixel(), typeof(DefaultPixelBlenders.Lighten_SrcOver), PixelBlenderMode.Lighten }, - { new TestPixel(), typeof(DefaultPixelBlenders.Add_SrcOver), PixelBlenderMode.Add }, - { new TestPixel(), typeof(DefaultPixelBlenders.Subtract_SrcOver), PixelBlenderMode.Subtract }, - { new TestPixel(), typeof(DefaultPixelBlenders.Multiply_SrcOver), PixelBlenderMode.Multiply }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Src), PixelBlenderMode.Src }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcAtop), PixelBlenderMode.Atop }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOver), PixelBlenderMode.Over }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcIn), PixelBlenderMode.In }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_SrcOut), PixelBlenderMode.Out }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Dest), PixelBlenderMode.Dest }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestAtop), PixelBlenderMode.DestAtop }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOver), PixelBlenderMode.DestOver }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestIn), PixelBlenderMode.DestIn }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_DestOut), PixelBlenderMode.DestOut }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Clear), PixelBlenderMode.Clear }, - { new TestPixel(), typeof(DefaultPixelBlenders.Normal_Xor), PixelBlenderMode.Xor }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Normal }, + { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelBlenderMode.Screen }, + { new TestPixel(), typeof(DefaultPixelBlenders.HardLightSrcOver), PixelBlenderMode.HardLight }, + { new TestPixel(), typeof(DefaultPixelBlenders.OverlaySrcOver), PixelBlenderMode.Overlay }, + { new TestPixel(), typeof(DefaultPixelBlenders.DarkenSrcOver), PixelBlenderMode.Darken }, + { new TestPixel(), typeof(DefaultPixelBlenders.LightenSrcOver), PixelBlenderMode.Lighten }, + { new TestPixel(), typeof(DefaultPixelBlenders.AddSrcOver), PixelBlenderMode.Add }, + { new TestPixel(), typeof(DefaultPixelBlenders.SubtractSrcOver), PixelBlenderMode.Subtract }, + { new TestPixel(), typeof(DefaultPixelBlenders.MultiplySrcOver), PixelBlenderMode.Multiply }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrc), PixelBlenderMode.Src }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcAtop), PixelBlenderMode.Atop }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Over }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcIn), PixelBlenderMode.In }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOut), PixelBlenderMode.Out }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDest), PixelBlenderMode.Dest }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestAtop), PixelBlenderMode.DestAtop }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOver), PixelBlenderMode.DestOver }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestIn), PixelBlenderMode.DestIn }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOut), PixelBlenderMode.DestOut }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalClear), PixelBlenderMode.Clear }, + { new TestPixel(), typeof(DefaultPixelBlenders.NormalXor), PixelBlenderMode.Xor }, }; From 18c4a7fef050d81df501b1dec3ac6b3081eb7e2f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 14 Aug 2018 10:40:33 +0100 Subject: [PATCH 10/40] Fix 1 bit bmp decoding and add extra test images. --- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 4 +--- .../Formats/Bmp/BmpDecoderTests.cs | 5 +---- tests/ImageSharp.Tests/TestImages.cs | 20 +++++++++++++++++- tests/Images/Input/Bmp/pal1.bmp | Bin 0 -> 1086 bytes tests/Images/Input/Bmp/pal1p1.bmp | Bin 0 -> 1082 bytes tests/Images/Input/Bmp/pal4.bmp | Bin 0 -> 4198 bytes 6 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 tests/Images/Input/Bmp/pal1.bmp create mode 100644 tests/Images/Input/Bmp/pal1p1.bmp create mode 100644 tests/Images/Input/Bmp/pal4.bmp diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 128ae08542..d67beb0368 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -373,11 +373,9 @@ namespace SixLabors.ImageSharp.Formats.Bmp for (int x = 0; x < arrayWidth; x++) { int colOffset = x * ppb; - - for (int shift = 0; shift < ppb && (x + shift) < width; shift++) + for (int shift = 0, newX = colOffset; shift < ppb && newX < width; shift++, newX++) { int colorIndex = ((rowSpan[offset] >> (8 - bits - (shift * bits))) & mask) * 4; - int newX = colOffset + shift; // Stored in b-> g-> r order. rgba.Bgr = Unsafe.As(ref colors[colorIndex]); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs index 09c3d1545f..5f2de9f51e 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs @@ -17,10 +17,7 @@ namespace SixLabors.ImageSharp.Tests { public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; - public static readonly string[] AllBmpFiles = - { - Car, F, NegHeight, CoreHeader, V5Header, RLE, RLEInverted, Bit8, Bit8Inverted, Bit16, Bit16Inverted - }; + public static readonly string[] AllBmpFiles = All; public static readonly TheoryData RatioFiles = new TheoryData diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 142b923ed1..5eb70117e3 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -165,12 +165,30 @@ namespace SixLabors.ImageSharp.Tests public const string V5Header = "Bmp/BITMAPV5HEADER.bmp"; public const string RLE = "Bmp/RunLengthEncoded.bmp"; public const string RLEInverted = "Bmp/RunLengthEncoded-inverted.bmp"; + public const string Bit1 = "Bmp/pal1.bmp"; + public const string Bit1Pal1 = "Bmp/pal1p1.bmp"; + public const string Bit4 = "Bmp/pal4.bmp"; public const string Bit8 = "Bmp/test8.bmp"; public const string Bit8Inverted = "Bmp/test8-inverted.bmp"; public const string Bit16 = "Bmp/test16.bmp"; public const string Bit16Inverted = "Bmp/test16-inverted.bmp"; - public static readonly string[] All = { Car, F, NegHeight, CoreHeader, V5Header, RLE, RLEInverted, Bit8, Bit8Inverted, Bit16, Bit16Inverted }; + public static readonly string[] All + = { + Car, + F, + NegHeight, + CoreHeader, + V5Header, RLE, + RLEInverted, + Bit1, + Bit1Pal1, + Bit4, + Bit8, + Bit8Inverted, + Bit16, + Bit16Inverted + }; } public static class Gif diff --git a/tests/Images/Input/Bmp/pal1.bmp b/tests/Images/Input/Bmp/pal1.bmp new file mode 100644 index 0000000000000000000000000000000000000000..4776f827786ad054037baa9ae27e211332a5c596 GIT binary patch literal 1086 zcmbW0&uZI15XQ%nY(#59jS;9P7a2;cQ+vxPm{dOI(8H2bsB4<%ka{V?PvD+hY$#?8 z$piEv3I)GFjzW2Y)VJi2vi)XON=yGx=$PGs{ruZ+XLfaXbl{Q10p=$dDaHt+g`WiU z{(U7$a`h=w#_+oKc7*q&vL|{`AAd5{BjBY#PVJx z8GM%I8od5H@96*bkNEu7e~I|jAJ#g{|Kab%;;#{P{pg^r-_LbMl*QybP5rh!s{0q| zg}E8V^m)2jT7F<|U5|=4Qa}9XwCBdzcG~bEb=(#euT$B`(Q~I``P%;>bnvIrfB4Vy zcW&(e;92k8@e%g#uHZkRd)7askok#hkJ1-rw|bgwQ**gquW^3^vvd1Jk(wR`Xdf>RPZjsmLkTaT+rag2 zuq^LSGL5SwQ6(Xd5a1D;r4-me zc-;AK{_3JM><>J_^K1A!e|4Nfw>;S}!KnMmvd0}n{hKex!cL1pv1*0J_8UiCV1OO{s1F--A literal 0 HcmV?d00001 diff --git a/tests/Images/Input/Bmp/pal4.bmp b/tests/Images/Input/Bmp/pal4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..7fd36303caea2b0aaf12469efee44ecd3cdbb5fa GIT binary patch literal 4198 zcmbW2u}|Yj6vhX00z$4x#6Mu!Alak|pe<0ERg?~0gOrLURYXaLsLt8~g{3iB2{uZz zqJ$HVAUE<4^TaA4ENfxqR^1Hi-8htmG78Olips)9W;Oll3{}cj?yzhV7>i0dT(&Y6f za-)oZU4LR|8nWIsZMU5f==T-gl29V@ekBli+ra1ikxv22`h9N;_&)H^ExN3B3;5ex zyFQ0MIkEb4_`^fhAC)SwfUoLT_>z9#dtZM8eK7yrsuaw`B_2Tab{9kx4qXPc7{cq!c41t6V`20q{9E3Lc-Q9!@I4}FJLHI(H`fYNqIO7yfG02;&G*kOPRl-f3~il7uG9&ZIa=?r$4~5SN>=CqV^a13-6@{ zf}a^6`qx#T;D_j+OeT`H`rr4zf&MnzZ;bv@{Y^Y(*_d50Q2)^{Zz7y=ISTz~5&d?K zz-tvNfa-rf$?%(H z6O*P)Q2lv|A0+c|8;wSrK!38(4}Zl+weU_&w9ubQu82ZE_zV54P<-z8ucV)Mt8!5< z{x{kU^eX|t*1KNUOT<6XU!TQr$i+jz z>bLNse;s(wW8fqvNBff@RK=(sOVoZOJ>>ez0eEo{+E{dZ#1ym>WJFTOB2zUr^){Fg*BH~%`fzJqJ z`XONR^Le4%)?lIE4_mFv`}@rzTCLV}I#vA;2mYLe;C&c6`&Pych}_8vDOu(5&qJ@iAM zw`tqK=0PiMrPCnb=lyHg+0U?W^{;@k8>E zq|d!>ulrM4A}xIy4$cSH(RK8F{Fpo@>6`s8_)1`Z5C2Q}2feEPixK{#KRbXyi25*a zn-JIm{u}TQ5a>am2mDXq>F^(%p9B9L_(upNYJ`}jz0i;U75xfd(vSad^#|y0?liA< ju67>20smn6|LoB;q<-ha>+|dL$M3*DrfIqOjN^X*G&$+8 literal 0 HcmV?d00001 From 633a8ce5039acc44c000df966bf6f27856e0488a Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 17 Aug 2018 14:05:24 -0700 Subject: [PATCH 11/40] Replace == null with is null --- .../Processing/Processors/Text/DrawTextProcessor.cs | 5 +++-- src/ImageSharp/Common/Helpers/DebugGuard.cs | 2 +- src/ImageSharp/Common/Helpers/Guard.cs | 6 +++--- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 4 ++-- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 2 +- .../Decoder/ColorConverters/JpegColorConverter.cs | 3 ++- .../Formats/Jpeg/Components/GenericBlock8x8.cs | 9 +++++---- src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs | 4 ++-- src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs | 6 +++--- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 4 ++-- src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs | 2 +- src/ImageSharp/Image.Decode.cs | 2 +- src/ImageSharp/ImageExtensions.cs | 6 +++--- src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs | 9 +++++---- src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs | 2 +- .../Profiles/Exif/ExifTagDescriptionAttribute.cs | 3 ++- src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs | 10 +++++----- .../MetaData/Profiles/ICC/Curves/IccCurveSegment.cs | 4 ++-- .../Profiles/ICC/Curves/IccOneDimensionalCurve.cs | 2 +- .../MetaData/Profiles/ICC/Curves/IccResponseCurve.cs | 2 +- .../ICC/DataWriter/IccDataWriter.Primitives.cs | 2 +- .../ICC/DataWriter/IccDataWriter.TagDataEntry.cs | 6 +++--- src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs | 4 ++-- .../MetaData/Profiles/ICC/IccTagDataEntry.cs | 2 +- .../ICC/MultiProcessElements/IccMultiProcessElement.cs | 2 +- .../ICC/TagDataEntries/IccChromaticityTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccColorantTableTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccCurveTagDataEntry.cs | 2 +- .../Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccDateTimeTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccLut16TagDataEntry.cs | 2 +- .../Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccLutAToBTagDataEntry.cs | 10 +++++----- .../ICC/TagDataEntries/IccLutBToATagDataEntry.cs | 10 +++++----- .../ICC/TagDataEntries/IccMeasurementTagDataEntry.cs | 2 +- .../IccMultiLocalizedUnicodeTagDataEntry.cs | 2 +- .../IccMultiProcessElementsTagDataEntry.cs | 2 +- .../TagDataEntries/IccTextDescriptionTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccUcrBgTagDataEntry.cs | 2 +- .../ICC/TagDataEntries/IccUnknownTagDataEntry.cs | 2 +- .../MetaData/Profiles/ICC/Various/IccClut.cs | 2 +- src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs | 2 +- .../Processing/DefaultInternalImageProcessorContext.cs | 4 ++-- .../Quantization/OctreeFrameQuantizer{TPixel}.cs | 6 +++--- .../Quantization/WuFrameQuantizer{TPixel}.cs | 2 +- .../Processors/Transforms/AutoOrientProcessor.cs | 4 ++-- .../Processors/Transforms/RotateProcessor.cs | 2 +- .../Processors/Transforms/TransformHelpers.cs | 2 +- .../Processing/Processors/Transforms/SkewTest.cs | 4 ++-- .../Processing/Transforms/AffineTransformTests.cs | 4 ++-- .../Processing/Transforms/ProjectiveTransformTests.cs | 4 ++-- 57 files changed, 101 insertions(+), 96 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs index 6da635c981..1095de325f 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor.cs @@ -37,9 +37,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text { Guard.NotNull(text, nameof(text)); Guard.NotNull(font, nameof(font)); - if (brush == null && pen == null) + + if (brush is null && pen is null) { - throw new ArgumentNullException($"at least one of {nameof(brush)} or {nameof(pen)} must not be null"); + throw new ArgumentNullException($"Expected a {nameof(brush)} or {nameof(pen)}. Both were null"); } this.Options = options; diff --git a/src/ImageSharp/Common/Helpers/DebugGuard.cs b/src/ImageSharp/Common/Helpers/DebugGuard.cs index 5a1d3a2e35..2cf18b2456 100644 --- a/src/ImageSharp/Common/Helpers/DebugGuard.cs +++ b/src/ImageSharp/Common/Helpers/DebugGuard.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp public static void NotNull(T value, string parameterName) where T : class { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } diff --git a/src/ImageSharp/Common/Helpers/Guard.cs b/src/ImageSharp/Common/Helpers/Guard.cs index d090790622..b4a29f9fb5 100644 --- a/src/ImageSharp/Common/Helpers/Guard.cs +++ b/src/ImageSharp/Common/Helpers/Guard.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp public static void NotNull(T value, string parameterName) where T : class { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp /// is empty or contains only blanks. public static void NotNullOrWhiteSpace(string value, string parameterName) { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp /// is empty. public static void NotNullOrEmpty(ICollection value, string parameterName) { - if (value == null) + if (value is null) { throw new ArgumentNullException(parameterName); } diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 3832a30c68..2a4d981ebb 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -377,7 +377,7 @@ namespace SixLabors.ImageSharp.Formats.Gif ImageFrame currentFrame = null; ImageFrame imageFrame; - if (previousFrame == null) + if (previousFrame is null) { // This initializes the image to become fully transparent because the alpha channel is zero. image = new Image(this.configuration, imageWidth, imageHeight, this.metaData); @@ -485,7 +485,7 @@ namespace SixLabors.ImageSharp.Formats.Gif private void RestoreToBackground(ImageFrame frame) where TPixel : struct, IPixel { - if (this.restoreArea == null) + if (this.restoreArea is null) { return; } diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 1fb706ae18..5532900355 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { foreach (ImageFrame frame in image.Frames) { - if (quantized == null) + if (quantized is null) { quantized = this.quantizer.CreateFrameQuantizer().QuantizeFrame(frame); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs index 40b8d391a3..8aeb01d7f0 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs @@ -44,7 +44,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters public static JpegColorConverter GetConverter(JpegColorSpace colorSpace) { JpegColorConverter converter = Converters.FirstOrDefault(c => c.ColorSpace == colorSpace); - if (converter == null) + + if (converter is null) { throw new Exception($"Could not find any converter for JpegColorSpace {colorSpace}!"); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs index c150242593..2e20da266b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs @@ -58,13 +58,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components public void LoadAndStretchEdges(IPixelSource source, int sourceX, int sourceY) where TPixel : struct, IPixel { - var buffer = source.PixelBuffer as Buffer2D; - if (buffer == null) + if (source.PixelBuffer is Buffer2D buffer) + { + this.LoadAndStretchEdges(buffer, sourceX, sourceY); + } + else { throw new InvalidOperationException("LoadAndStretchEdges() is only valid for TPixel == T !"); } - - this.LoadAndStretchEdges(buffer, sourceX, sourceY); } /// diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 1eb4dad898..7561afa1ef 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -538,7 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg if (ProfileResolver.IsProfile(profile, ProfileResolver.ExifMarker)) { this.isExif = true; - if (this.exifData == null) + if (this.exifData is null) { // The first 6 bytes (Exif00) will be skipped, because this is Jpeg specific this.exifData = profile.Skip(Exif00).ToArray(); @@ -575,7 +575,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg byte[] profile = new byte[remaining]; this.InputStream.Read(profile, 0, remaining); - if (this.iccData == null) + if (this.iccData is null) { this.iccData = profile; } diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 1a3bb77234..889aa07007 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -628,7 +628,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg byte[] data = exifProfile?.ToByteArray(); - if (data == null || data.Length == 0) + if (data is null || data.Length == 0) { return; } @@ -687,7 +687,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// private void WriteIccProfile(IccProfile iccProfile) { - if (iccProfile == null) + if (iccProfile is null) { return; } @@ -698,7 +698,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg byte[] data = iccProfile.ToByteArray(); - if (data == null || data.Length == 0) + if (data is null || data.Length == 0) { return; } diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index e1ec3c1d66..aa96b926ca 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.Formats.Png this.ReadPhysicalChunk(metadata, chunk.Data.GetSpan()); break; case PngChunkType.Data: - if (image == null) + if (image is null) { this.InitializeImage(metadata, out image); } @@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Formats.Png } } - if (image == null) + if (image is null) { throw new ImageFormatException("PNG Image does not contain a data chunk"); } diff --git a/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs index fd9c4ac63e..55432d60b1 100644 --- a/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs +++ b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib public void AllocateNewBytes(int bytes) { this.currentDataRemaining = bytes; - if (this.compressedStream == null) + if (this.compressedStream is null) { this.InitializeInflateStream(); } diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 3b014e7bd6..894551e08f 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp where TPixel : struct, IPixel { IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format); - if (decoder == null) + if (decoder is null) { return (null, null); } diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index 9a46400fd5..bf312cb6f5 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp string ext = Path.GetExtension(filePath); IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext); - if (format == null) + if (format is null) { var sb = new StringBuilder(); sb.AppendLine($"Can't find a format that is associated with the file extention '{ext}'. Registered formats with there extensions include:"); @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format); - if (encoder == null) + if (encoder is null) { var sb = new StringBuilder(); sb.AppendLine($"Can't find encoder for file extention '{ext}' using image format '{format.Name}'. Registered encoders include:"); @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp Guard.NotNull(format, nameof(format)); IImageEncoder encoder = source.GetConfiguration().ImageFormatsManager.FindEncoder(format); - if (encoder == null) + if (encoder is null) { var sb = new StringBuilder(); sb.AppendLine("Can't find encoder for provided mime type. Available encoded:"); diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index 6f5af8ffcd..1dd8857217 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return null; } - if (this.data == null || this.data.Length < (this.thumbnailOffset + this.thumbnailLength)) + if (this.data is null || this.data.Length < (this.thumbnailOffset + this.thumbnailLength)) { return null; } @@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// The public byte[] ToByteArray() { - if (this.values == null) + if (this.values is null) { return this.data; } @@ -262,7 +262,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private void SyncResolution(ExifTag tag, double resolution) { ExifValue value = this.GetValue(tag); - if (value == null) + + if (value is null) { return; } @@ -283,7 +284,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif return; } - if (this.data == null) + if (this.data is null) { this.values = new List(); return; diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs index db1d0c6228..798cb93cee 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs @@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private object ConvertValue(ExifDataType dataType, ReadOnlySpan buffer, uint numberOfComponents) { - if (buffer == null || buffer.Length == 0) + if (buffer.Length == 0) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs index 4021227f57..e419ff9dc2 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs @@ -37,7 +37,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif public static string GetDescription(ExifTag tag, object value) { FieldInfo field = tag.GetType().GetTypeInfo().GetDeclaredField(tag.ToString()); - if (field == null) + + if (field is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs index 87e3e44949..e6da9b7d1e 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif { get { - if (this.Value == null) + if (this.Value is null) { return false; } @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif { get { - if (this.Value == null) + if (this.Value is null) { return 4; } @@ -213,7 +213,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// public override string ToString() { - if (this.Value == null) + if (this.Value is null) { return null; } @@ -589,7 +589,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif type = type.GetElementType(); } - if (type == null || type == typeof(ushort)) + if (type is null || type == typeof(ushort)) { return new ExifValue(tag, ExifDataType.Short, value, isArray); } @@ -616,7 +616,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// private void CheckValue(object value) { - if (value == null) + if (value is null) { return; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs index 157453f1b1..516887bcd6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public virtual bool Equals(IccCurveSegment other) { - if (other == null) + if (other is null) { return false; } @@ -40,4 +40,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return this.Signature == other.Signature; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs index 2ad9079e13..7076e51447 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccOneDimensionalCurve other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs index 6873c5f4d6..02ab301bd2 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccResponseCurve other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs index bf39a08491..a58f62519c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs @@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc Guard.MustBeGreaterThan(length, 0, nameof(length)); - if (value == null) + if (value is null) { value = string.Empty; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 18280faaf5..51ea2d4e4a 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -901,7 +901,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc { int size, count = 0; - if (value.Ascii == null) + if (value.Ascii is null) { count += this.WriteUInt32(0); } @@ -914,7 +914,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc this.dataStream.Position += size; } - if (value.Unicode == null) + if (value.Unicode is null) { count += this.WriteUInt32(0); count += this.WriteUInt32(0); @@ -929,7 +929,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc this.dataStream.Position += size; } - if (value.ScriptCode == null) + if (value.ScriptCode is null) { count += this.WriteUInt16(0); count += this.WriteByte(0); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs index 2b2fe1e4ec..d45da54a46 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs @@ -200,7 +200,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return; } - if (this.data == null) + if (this.data is null) { this.header = new IccProfileHeader(); return; @@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return; } - if (this.data == null) + if (this.data is null) { this.entries = new List(); return; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs index 231f3818ad..2687e10b66 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public virtual bool Equals(IccTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs index 3da482b1f4..db2d56cc3d 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public virtual bool Equals(IccMultiProcessElement other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs index c008463eec..a87dae8c5d 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc this.ChannelValues = channelValues; int channelLength = channelValues[0].Length; - bool channelsNotSame = channelValues.Any(t => t == null || t.Length != channelLength); + bool channelsNotSame = channelValues.Any(t => t is null || t.Length != channelLength); Guard.IsFalse(channelsNotSame, nameof(channelValues), "The number of values per channel is not the same for all channels"); } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs index 6df2f556f0..54c2056151 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccColorantOrderTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs index 90b1c304ba..dd99a2f9fb 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccColorantTableTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs index b2bbb7b566..cc1aea3192 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccCrdInfoTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs index 40666934f4..38a2f4522c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccCurveTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs index 7f034cebfe..e6a6cdff2a 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccDataTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs index 004603a0e5..792c653f6c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccDateTimeTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs index 8a7d068f98..6f4d039885 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccFix16ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index f296a8b077..9a7f2123e2 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLut16TagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs index f94d500c39..bc0335cd8b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs @@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLut8TagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs index c4f3f8a2a7..22d5f7b2f1 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLutAToBTagDataEntry other) { - if (other == null) + if (other is null) { return false; } @@ -200,8 +200,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves) { - bool thisNull = thisCurves == null; - bool entryNull = entryCurves == null; + bool thisNull = thisCurves is null; + bool entryNull = entryCurves is null; if (thisNull && entryNull) { @@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Vector3? CreateMatrix3x1(float[] matrix) { - if (matrix == null) + if (matrix is null) { return null; } @@ -281,7 +281,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Matrix4x4? CreateMatrix3x3(float[,] matrix) { - if (matrix == null) + if (matrix is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs index 17bbf915ba..a739358b56 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccLutBToATagDataEntry other) { - if (other == null) + if (other is null) { return false; } @@ -200,8 +200,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves) { - bool thisNull = thisCurves == null; - bool entryNull = entryCurves == null; + bool thisNull = thisCurves is null; + bool entryNull = entryCurves is null; if (thisNull && entryNull) { @@ -271,7 +271,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Vector3? CreateMatrix3x1(float[] matrix) { - if (matrix == null) + if (matrix is null) { return null; } @@ -281,7 +281,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc private Matrix4x4? CreateMatrix3x3(float[,] matrix) { - if (matrix == null) + if (matrix is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs index f32e17714d..262129a380 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs @@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMeasurementTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs index c006c95569..5652fd99eb 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs index dcfe010aa1..1429a0a878 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccMultiProcessElementsTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs index cc67dd1b16..ca1e4c4915 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The converted entry public static explicit operator IccMultiLocalizedUnicodeTagDataEntry(IccTextDescriptionTagDataEntry textEntry) { - if (textEntry == null) + if (textEntry is null) { return null; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs index c8b95d8354..03013d548b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUInt32ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs index b780183df2..c950ab4f68 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUInt64ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs index 920b9efc03..40dbaf3b01 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUInt8ArrayTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs index 28759a54cd..94bfcbfd99 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUcrBgTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs index 68a0ff2f43..d3153c3b2d 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccUnknownTagDataEntry other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs index 3f9d865b77..4878d96e4b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// public bool Equals(IccClut other) { - if (other == null) + if (other is null) { return false; } diff --git a/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs b/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs index c2c0277f9e..cf66f5d5e8 100644 --- a/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.PixelFormats hex = ToRgbaHex(hex); - if (hex == null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint packedValue)) + if (hex is null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint packedValue)) { throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); } diff --git a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs index a392b8d8e8..43ba259725 100644 --- a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs +++ b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing /// public Image Apply() { - if (!this.mutate && this.destination == null) + if (!this.mutate && this.destination is null) { // Ensure we have cloned it if we are not mutating as we might have failed to register any processors this.destination = this.source.Clone(); @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing /// public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - if (!this.mutate && this.destination == null) + if (!this.mutate && this.destination is null) { // This will only work if the first processor applied is the cloning one thus // realistically for this optimization to work the resize must the first processor diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs index 0eb3db864c..3eac70eea5 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeFrameQuantizer{TPixel}.cs @@ -233,7 +233,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { // If so, check if I have a previous node setup. This will only occur if the first color in the image // happens to be black, with an alpha component of zero. - if (this.previousNode == null) + if (this.previousNode is null) { this.previousColor = pixel; this.root.AddColor(ref pixel, this.maxColorBits, 0, this, ref rgba); @@ -309,7 +309,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization { // Find the deepest level containing at least one reducible node int index = this.maxColorBits - 1; - while ((index > 0) && (this.ReducibleNodes[index] == null)) + while ((index > 0) && (this.ReducibleNodes[index] is null)) { index--; } @@ -440,7 +440,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization | ((rgba.R & Mask[level]) >> shift); OctreeNode child = this.children[index]; - if (child == null) + if (child is null) { // Create a new child node and store it in the array child = new OctreeNode(level + 1, colorBits, octree); diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs index 619107f971..021dc62fbf 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuFrameQuantizer{TPixel}.cs @@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization /// protected override TPixel[] GetPalette() { - if (this.palette == null) + if (this.palette is null) { this.palette = new TPixel[this.colors]; for (int k = 0; k < this.colors; k++) diff --git a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs index c077914ff6..a610ae5bb3 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AutoOrientProcessor.cs @@ -73,13 +73,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// The private static OrientationMode GetExifOrientation(Image source) { - if (source.MetaData.ExifProfile == null) + if (source.MetaData.ExifProfile is null) { return OrientationMode.Unknown; } ExifValue value = source.MetaData.ExifProfile.GetValue(ExifTag.Orientation); - if (value == null) + if (value is null) { return OrientationMode.Unknown; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index b18d882c24..93c847d598 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms protected override void AfterImageApply(Image source, Image destination, Rectangle sourceRectangle) { ExifProfile profile = destination.MetaData.ExifProfile; - if (profile == null) + if (profile is null) { return; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs index 1b676139b3..b22fa64cfd 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformHelpers.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms where TPixel : struct, IPixel { ExifProfile profile = image.MetaData.ExifProfile; - if (profile == null) + if (profile is null) { return; } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs index ae2b12e87d..d1d2ea0771 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs @@ -73,9 +73,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); - if (property == null) + if (property is null) { - throw new Exception("Invalid property name!"); + throw new Exception($"No resampler named '{name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs index 8ec8409add..edc6994e7a 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs @@ -228,9 +228,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); - if (property == null) + if (property is null) { - throw new Exception("Invalid property name!"); + throw new Exception($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index f0a924d270..8cf9dd62f5 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -124,9 +124,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); - if (property == null) + if (property is null) { - throw new Exception("Invalid property name!"); + throw new Exception($"No resampler named {name}"); } return (IResampler)property.GetValue(null); From 9b8d160faf839e681615924a7644e0e8024c99c2 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 17 Aug 2018 14:27:19 -0700 Subject: [PATCH 12/40] Throw NRE directly in trival contexts (eliminating method call / extra stack entry) --- src/ImageSharp/Formats/Bmp/BmpDecoder.cs | 1 - src/ImageSharp/Formats/Gif/LzwDecoder.cs | 4 +--- src/ImageSharp/ImageFrameCollection.cs | 9 ++------- .../MetaData/Profiles/ICC/DataReader/IccDataReader.cs | 4 ++-- .../ICC/MultiProcessElements/IccClutProcessElement.cs | 3 +-- .../MultiProcessElements/IccCurveSetProcessElement.cs | 3 +-- .../Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs | 3 +-- .../IccMultiLocalizedUnicodeTagDataEntry.cs | 3 +-- .../IccProfileSequenceDescTagDataEntry.cs | 3 +-- .../IccProfileSequenceIdentifierTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccScreeningTagDataEntry.cs | 4 +--- .../ICC/TagDataEntries/IccSignatureTagDataEntry.cs | 5 ++--- .../Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs | 3 +-- .../ICC/TagDataEntries/IccUcrBgTagDataEntry.cs | 10 +++------- .../ICC/TagDataEntries/IccUnknownTagDataEntry.cs | 3 +-- .../Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs | 3 +-- .../Profiles/ICC/Various/IccColorantTableEntry.cs | 4 +--- .../Profiles/ICC/Various/IccLocalizedString.cs | 7 ++----- src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs | 3 +-- .../Binarization/BinaryOrderedDitherProcessor.cs | 4 +--- .../Dithering/OrderedDitherPaletteProcessor.cs | 3 +-- .../Processors/Dithering/PaletteDitherProcessorBase.cs | 4 ++-- 28 files changed, 34 insertions(+), 73 deletions(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index d3cb50d6ba..3d079cf619 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -25,7 +25,6 @@ namespace SixLabors.ImageSharp.Formats.Bmp { /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel { Guard.NotNull(stream, nameof(stream)); diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index 3c7b6a4af6..07594e81a1 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -56,9 +56,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// is null. public LzwDecoder(MemoryAllocator memoryAllocator, Stream stream) { - Guard.NotNull(stream, nameof(stream)); - - this.stream = stream; + this.stream = stream ?? throw new ArgumentNullException(nameof(stream)); this.prefix = memoryAllocator.Allocate(MaxStackSize, AllocationOptions.Clean); this.suffix = memoryAllocator.Allocate(MaxStackSize, AllocationOptions.Clean); diff --git a/src/ImageSharp/ImageFrameCollection.cs b/src/ImageSharp/ImageFrameCollection.cs index 929dd7e36e..59571ce92e 100644 --- a/src/ImageSharp/ImageFrameCollection.cs +++ b/src/ImageSharp/ImageFrameCollection.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.Memory; namespace SixLabors.ImageSharp { @@ -23,9 +22,7 @@ namespace SixLabors.ImageSharp internal ImageFrameCollection(Image parent, int width, int height, TPixel backgroundColor) { - Guard.NotNull(parent, nameof(parent)); - - this.parent = parent; + this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, backgroundColor)); @@ -33,9 +30,7 @@ namespace SixLabors.ImageSharp internal ImageFrameCollection(Image parent, int width, int height, MemorySource memorySource) { - Guard.NotNull(parent, nameof(parent)); - - this.parent = parent; + this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller this.frames.Add(new ImageFrame(parent.GetConfiguration(), width, height, memorySource)); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs index 49b453a464..cc0f8f34dc 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using System.Text; namespace SixLabors.ImageSharp.MetaData.Profiles.Icc @@ -28,8 +29,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The data to read public IccDataReader(byte[] data) { - Guard.NotNull(data, nameof(data)); - this.data = data; + this.data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs index 384ae850f3..6aba186326 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs @@ -17,8 +17,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccClutProcessElement(IccClut clutValue) : base(IccMultiProcessElementSignature.Clut, clutValue?.InputChannelCount ?? 1, clutValue?.OutputChannelCount ?? 1) { - Guard.NotNull(clutValue, nameof(clutValue)); - this.ClutValue = clutValue; + this.ClutValue = clutValue ?? throw new ArgumentNullException(nameof(clutValue)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs index 0aa0306845..7585fc2128 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs @@ -18,8 +18,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccCurveSetProcessElement(IccOneDimensionalCurve[] curves) : base(IccMultiProcessElementSignature.CurveSet, curves?.Length ?? 1, curves?.Length ?? 1) { - Guard.NotNull(curves, nameof(curves)); - this.Curves = curves; + this.Curves = curves ?? throw new ArgumentNullException(nameof(curves)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs index e6a6cdff2a..9b24bffe85 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs @@ -42,8 +42,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccDataTagDataEntry(byte[] data, bool isAscii, IccProfileTag tagSignature) : base(IccTypeSignature.Data, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentException(nameof(data)); this.IsAscii = isAscii; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs index 6f4d039885..a76310927b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature) : base(IccTypeSignature.S15Fixed16Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs index 5652fd99eb..48ed048bf9 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs @@ -29,8 +29,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccMultiLocalizedUnicodeTagDataEntry(IccLocalizedString[] texts, IccProfileTag tagSignature) : base(IccTypeSignature.MultiLocalizedUnicode, tagSignature) { - Guard.NotNull(texts, nameof(texts)); - this.Texts = texts; + this.Texts = texts ?? throw new ArgumentNullException(nameof(texts)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs index c420046347..da6fcd7a2a 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs @@ -30,8 +30,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccProfileSequenceDescTagDataEntry(IccProfileDescription[] descriptions, IccProfileTag tagSignature) : base(IccTypeSignature.ProfileSequenceDesc, tagSignature) { - Guard.NotNull(descriptions, nameof(descriptions)); - this.Descriptions = descriptions; + this.Descriptions = descriptions ?? throw new ArgumentNullException(nameof(descriptions)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs index 3336155242..51528a0736 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs @@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccProfileSequenceIdentifierTagDataEntry(IccProfileSequenceIdentifier[] data, IccProfileTag tagSignature) : base(IccTypeSignature.ProfileSequenceIdentifier, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs index de6264824f..0bf8abfcac 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs @@ -30,10 +30,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccScreeningTagDataEntry(IccScreeningFlag flags, IccScreeningChannel[] channels, IccProfileTag tagSignature) : base(IccTypeSignature.Screening, tagSignature) { - Guard.NotNull(channels, nameof(channels)); - this.Flags = flags; - this.Channels = channels; + this.Channels = channels ?? throw new ArgumentNullException(nameof(channels)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs index e469e7eab5..da557e644f 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs @@ -28,12 +28,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccSignatureTagDataEntry(string signatureData, IccProfileTag tagSignature) : base(IccTypeSignature.Signature, tagSignature) { - Guard.NotNull(signatureData, nameof(signatureData)); - this.SignatureData = signatureData; + this.SignatureData = signatureData ?? throw new ArgumentNullException(nameof(signatureData)); } /// - /// Gets the Signature + /// Gets the signature data /// public string SignatureData { get; } diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs index 1cf321893d..f10712d96c 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccTextTagDataEntry(string text, IccProfileTag tagSignature) : base(IccTypeSignature.Text, tagSignature) { - Guard.NotNull(text, nameof(text)); - this.Text = text; + this.Text = text ?? throw new ArgumentNullException(nameof(text)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs index 4d9979a4fc..19430dc7b8 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUFix16ArrayTagDataEntry(float[] data, IccProfileTag tagSignature) : base(IccTypeSignature.U16Fixed16Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs index b0c225d85a..d9c093bda0 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt16ArrayTagDataEntry(ushort[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt16Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs index 03013d548b..8031919290 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt32ArrayTagDataEntry(uint[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt32Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs index c950ab4f68..2973b9ae6b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs @@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt64ArrayTagDataEntry(ulong[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt64Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs index 40dbaf3b01..2391ce96a6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUInt8ArrayTagDataEntry(byte[] data, IccProfileTag tagSignature) : base(IccTypeSignature.UInt8Array, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs index 94bfcbfd99..eed4f97d47 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs @@ -32,13 +32,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUcrBgTagDataEntry(ushort[] ucrCurve, ushort[] bgCurve, string description, IccProfileTag tagSignature) : base(IccTypeSignature.UcrBg, tagSignature) { - Guard.NotNull(ucrCurve, nameof(ucrCurve)); - Guard.NotNull(bgCurve, nameof(bgCurve)); - Guard.NotNull(description, nameof(description)); - - this.UcrCurve = ucrCurve; - this.BgCurve = bgCurve; - this.Description = description; + this.UcrCurve = ucrCurve ?? throw new ArgumentNullException(nameof(ucrCurve)); + this.BgCurve = bgCurve ?? throw new ArgumentNullException(nameof(bgCurve)); + this.Description = description ?? throw new ArgumentNullException(nameof(description)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs index d3153c3b2d..da206a968b 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs @@ -27,8 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccUnknownTagDataEntry(byte[] data, IccProfileTag tagSignature) : base(IccTypeSignature.Unknown, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs index 1623923261..c1c14d8cbb 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs @@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc public IccXyzTagDataEntry(Vector3[] data, IccProfileTag tagSignature) : base(IccTypeSignature.Xyz, tagSignature) { - Guard.NotNull(data, nameof(data)); - this.Data = data; + this.Data = data ?? throw new ArgumentNullException(nameof(data)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs index 22e4a05237..56aa8b335d 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs @@ -28,9 +28,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// Third PCS value public IccColorantTableEntry(string name, ushort pcs1, ushort pcs2, ushort pcs3) { - Guard.NotNull(name, nameof(name)); - - this.Name = name; + this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.Pcs1 = pcs1; this.Pcs2 = pcs2; this.Pcs3 = pcs3; diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs index 18e28e94c3..00ededca4d 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs @@ -29,11 +29,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The text value of this string public IccLocalizedString(CultureInfo culture, string text) { - Guard.NotNull(culture, nameof(culture)); - Guard.NotNull(text, nameof(text)); - - this.Culture = culture; - this.Text = text; + this.Culture = culture ?? throw new ArgumentNullException(nameof(culture)); + this.Text = text ?? throw new ArgumentNullException(nameof(text)); } /// diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs index a846311439..c46d6884b6 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs @@ -16,8 +16,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// The LUT values public IccLut(float[] values) { - Guard.NotNull(values, nameof(values)); - this.Values = values; + this.Values = values ?? throw new ArgumentNullException(nameof(values)); } /// diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs index 95f4ef472e..048af82619 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs @@ -33,9 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization /// The color to use for pixels that are below the threshold. public BinaryOrderedDitherProcessor(IOrderedDither dither, TPixel upperColor, TPixel lowerColor) { - Guard.NotNull(dither, nameof(dither)); - - this.Dither = dither; + this.Dither = dither ?? throw new ArgumentNullException(nameof(dither)); this.UpperColor = upperColor; this.LowerColor = lowerColor; } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs index 4100fef8c2..b5e2eebc2b 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherPaletteProcessor.cs @@ -34,8 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering public OrderedDitherPaletteProcessor(IOrderedDither dither, TPixel[] palette) : base(palette) { - Guard.NotNull(dither, nameof(dither)); - this.Dither = dither; + this.Dither = dither ?? throw new ArgumentNullException(nameof(dither)); } /// diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs index e70c8acd29..a1bbe72733 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessorBase.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; @@ -28,8 +29,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering /// The palette to select substitute colors from. protected PaletteDitherProcessorBase(TPixel[] palette) { - Guard.NotNull(palette, nameof(palette)); - this.Palette = palette; + this.Palette = palette ?? throw new ArgumentNullException(nameof(palette)); this.paletteVector = new Vector4[this.Palette.Length]; PixelOperations.Instance.ToScaledVector4(this.Palette, this.paletteVector, this.Palette.Length); } From c789b6d696dfce37206fc59942fb8ffcd2df2f4f Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 17 Aug 2018 14:30:45 -0700 Subject: [PATCH 13/40] Add readonly annotations --- .../MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs | 4 ++-- src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs | 6 +++--- src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs index e419ff9dc2..286fdbe57f 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs @@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] internal sealed class ExifTagDescriptionAttribute : Attribute { - private object value; - private string description; + private readonly object value; + private readonly string description; /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs index dc75697e29..ade373341e 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs @@ -20,9 +20,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif private ExifParts allowedParts; private IList values; private List dataOffsets; - private List ifdIndexes; - private List exifIndexes; - private List gpsIndexes; + private readonly List ifdIndexes; + private readonly List exifIndexes; + private readonly List gpsIndexes; /// /// Initializes a new instance of the class. diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs index d45da54a46..dac56c608e 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// /// The byte array to read the ICC profile from /// - private byte[] data; + private readonly byte[] data; /// /// The backing file for the property From de51d0c51608ba076869a3b0cd1dad28c5bc3bcf Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 17 Aug 2018 15:03:27 -0700 Subject: [PATCH 14/40] Eliminate headers allocation when writting huffman table --- src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 889aa07007..f7b6fe9967 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -550,7 +550,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg private void WriteDefineHuffmanTables(int componentCount) { // Table identifiers. - byte[] headers = { 0x00, 0x10, 0x01, 0x11 }; + Span headers = stackalloc byte[] { 0x00, 0x10, 0x01, 0x11 }; + int markerlen = 2; HuffmanSpec[] specs = HuffmanSpec.TheHuffmanSpecs; From 6b662f843a9f387c6f4f7366a5bb33f64071cdee Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 17 Aug 2018 15:16:18 -0700 Subject: [PATCH 15/40] Eliminate string allocation in ExifReader --- src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs index 798cb93cee..72db6305dd 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs @@ -76,7 +76,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif { var values = new List(); - if (this.ReadString(2) == "II") + // II == 0x4949 + if (this.ReadUInt16() == 0x4949) { this.endianness = Endianness.LittleEndian; } From 74a16f1083b8cb1578f4e16920eda1c665fa83ff Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 19 Aug 2018 10:09:26 +0100 Subject: [PATCH 16/40] Update refs and fix line endings --- .../Drawing/SolidFillBlendedShapesTests.cs | 302 +++++++++--------- tests/Images/External | 2 +- 2 files changed, 152 insertions(+), 152 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index 7ec63c4397..b31a18ac45 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -1,158 +1,158 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; -using System.Linq; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; -using SixLabors.Primitives; -using Xunit; - -// ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Drawing -{ - [GroupOutput("Drawing")] - public class SolidFillBlendedShapesTests - { - public static IEnumerable modes = - ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))).Select(x => new object[] { x }); - - [Theory] - [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] - public void _1DarkBlueRect_2BlendHotPinkRect( - TestImageProvider provider, - PixelBlenderMode mode) - where TPixel : struct, IPixel - { - using (Image img = provider.GetImage()) - { - int scaleX = img.Width / 100; - int scaleY = img.Height / 100; - img.Mutate( - x => x.Fill( - NamedColors.DarkBlue, - new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) - ) - .Fill(new GraphicsOptions(true) { BlenderMode = mode }, - NamedColors.HotPink, - new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) - ); - - VerifyImage(provider, mode, img); - } - } - - [Theory] - [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] - public void _1DarkBlueRect_2BlendHotPinkRect_3BlendTransparentEllipse( - TestImageProvider provider, - PixelBlenderMode mode) - where TPixel : struct, IPixel - { - using (Image img = provider.GetImage()) - { - int scaleX = img.Width / 100; - int scaleY = img.Height / 100; - img.Mutate( - x => x.Fill( - NamedColors.DarkBlue, - new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); - img.Mutate( - x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, - NamedColors.HotPink, - new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); - img.Mutate( - x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, - NamedColors.Transparent, - new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) - ); - - VerifyImage(provider, mode, img); - } - } - - [Theory] - [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] - public void _1DarkBlueRect_2BlendHotPinkRect_3BlendSemiTransparentRedEllipse( - TestImageProvider provider, - PixelBlenderMode mode) - where TPixel : struct, IPixel - { - using (Image img = provider.GetImage()) - { - int scaleX = (img.Width / 100); - int scaleY = (img.Height / 100); - img.Mutate( - x => x.Fill( - NamedColors.DarkBlue, - new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); - img.Mutate( - x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, - NamedColors.HotPink, - new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); - var c = NamedColors.Red.ToVector4(); - c.W *= 0.5f; - var pixel = default(TPixel); - pixel.PackFromVector4(c); - - img.Mutate( - x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, - pixel, - new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) - ); - - VerifyImage(provider, mode, img); ; - } - } - - [Theory] - [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] - public void _1DarkBlueRect_2BlendBlackEllipse(TestImageProvider provider, PixelBlenderMode mode) - where TPixel : struct, IPixel - { - using(Image dstImg = provider.GetImage(), srcImg = provider.GetImage()) - { - int scaleX = (dstImg.Width / 100); +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. +using System; +using System.Collections.Generic; +using System.Linq; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; +using SixLabors.Primitives; +using Xunit; + +// ReSharper disable InconsistentNaming +namespace SixLabors.ImageSharp.Tests.Drawing +{ + [GroupOutput("Drawing")] + public class SolidFillBlendedShapesTests + { + public static IEnumerable modes = + ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))).Select(x => new object[] { x }); + + [Theory] + [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] + public void _1DarkBlueRect_2BlendHotPinkRect( + TestImageProvider provider, + PixelBlenderMode mode) + where TPixel : struct, IPixel + { + using (Image img = provider.GetImage()) + { + int scaleX = img.Width / 100; + int scaleY = img.Height / 100; + img.Mutate( + x => x.Fill( + NamedColors.DarkBlue, + new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) + ) + .Fill(new GraphicsOptions(true) { BlenderMode = mode }, + NamedColors.HotPink, + new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) + ); + + VerifyImage(provider, mode, img); + } + } + + [Theory] + [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] + public void _1DarkBlueRect_2BlendHotPinkRect_3BlendTransparentEllipse( + TestImageProvider provider, + PixelBlenderMode mode) + where TPixel : struct, IPixel + { + using (Image img = provider.GetImage()) + { + int scaleX = img.Width / 100; + int scaleY = img.Height / 100; + img.Mutate( + x => x.Fill( + NamedColors.DarkBlue, + new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); + img.Mutate( + x => x.Fill( + new GraphicsOptions(true) { BlenderMode = mode }, + NamedColors.HotPink, + new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); + img.Mutate( + x => x.Fill( + new GraphicsOptions(true) { BlenderMode = mode }, + NamedColors.Transparent, + new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) + ); + + VerifyImage(provider, mode, img); + } + } + + [Theory] + [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] + public void _1DarkBlueRect_2BlendHotPinkRect_3BlendSemiTransparentRedEllipse( + TestImageProvider provider, + PixelBlenderMode mode) + where TPixel : struct, IPixel + { + using (Image img = provider.GetImage()) + { + int scaleX = (img.Width / 100); + int scaleY = (img.Height / 100); + img.Mutate( + x => x.Fill( + NamedColors.DarkBlue, + new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); + img.Mutate( + x => x.Fill( + new GraphicsOptions(true) { BlenderMode = mode }, + NamedColors.HotPink, + new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); + var c = NamedColors.Red.ToVector4(); + c.W *= 0.5f; + var pixel = default(TPixel); + pixel.PackFromVector4(c); + + img.Mutate( + x => x.Fill( + new GraphicsOptions(true) { BlenderMode = mode }, + pixel, + new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) + ); + + VerifyImage(provider, mode, img); ; + } + } + + [Theory] + [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] + public void _1DarkBlueRect_2BlendBlackEllipse(TestImageProvider provider, PixelBlenderMode mode) + where TPixel : struct, IPixel + { + using(Image dstImg = provider.GetImage(), srcImg = provider.GetImage()) + { + int scaleX = (dstImg.Width / 100); int scaleY = (dstImg.Height / 100); - - dstImg.Mutate( - x => x.Fill( - NamedColors.DarkBlue, + + dstImg.Mutate( + x => x.Fill( + NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); - - srcImg.Mutate( - x => x.Fill( - NamedColors.Black, + + srcImg.Mutate( + x => x.Fill( + NamedColors.Black, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); dstImg.Mutate( x => x.DrawImage(new GraphicsOptions(true) { BlenderMode = mode }, srcImg) - ); - - VerifyImage(provider, mode, dstImg); - } - } - - private static void VerifyImage(TestImageProvider provider, PixelBlenderMode mode, Image img) - where TPixel : struct, IPixel - { - img.DebugSave( - provider, - new { mode }, - appendPixelTypeToFileName: false, - appendSourceFileOrDescription: false); - - var comparer = ImageComparer.TolerantPercentage(0.01f, 3); - img.CompareFirstFrameToReferenceOutput(comparer, - provider, - new { mode }, - appendPixelTypeToFileName: false, - appendSourceFileOrDescription: false); - } - } + ); + + VerifyImage(provider, mode, dstImg); + } + } + + private static void VerifyImage(TestImageProvider provider, PixelBlenderMode mode, Image img) + where TPixel : struct, IPixel + { + img.DebugSave( + provider, + new { mode }, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + var comparer = ImageComparer.TolerantPercentage(0.01f, 3); + img.CompareFirstFrameToReferenceOutput(comparer, + provider, + new { mode }, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + } + } } \ No newline at end of file diff --git a/tests/Images/External b/tests/Images/External index 98fb7e2e4d..825220cdc4 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 98fb7e2e4d5935b1c733bd2b206b6145b71ef378 +Subproject commit 825220cdc4e9d1b4b3b474c63139e18e1cdb800e From b189ff77461d2db29be6160b7d39d4d1ea2e8498 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Mon, 20 Aug 2018 17:41:58 +0200 Subject: [PATCH 17/40] Split PixelBlendMode enumeration into PixelColorBlendingMode and PixelAlphaCompositionMode --- .../Processing/BrushApplicator.cs | 2 +- .../Processing/DrawImageExtensions.cs | 4 +- .../Processors/Drawing/DrawImageProcessor.cs | 40 ++- .../Processors/Drawing/FillProcessor.cs | 37 ++- .../Processing/TextGraphicsOptions.cs | 10 +- src/ImageSharp/GraphicsOptions.cs | 24 +- ...erMode.cs => PixelAlphaCompositionMode.cs} | 63 +---- .../PixelFormats/PixelColorBlendingMode.cs | 56 ++++ .../PixelOperations{TPixel}.PixelBenders.cs | 265 ++++++++++++++---- .../Overlays/BackgroundColorProcessor.cs | 2 +- .../Processors/Overlays/GlowProcessor.cs | 2 +- .../Processors/Overlays/VignetteProcessor.cs | 4 +- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 28 +- .../Drawing/FillSolidBrushTests.cs | 68 ++--- .../Drawing/SolidFillBlendedShapesTests.cs | 24 +- .../PorterDuffCompositorTests.cs | 101 ++++--- .../PixelOperationsTests.Blender.cs | 74 ++--- 17 files changed, 513 insertions(+), 291 deletions(-) rename src/ImageSharp/PixelFormats/{PixelBlenderMode.cs => PixelAlphaCompositionMode.cs} (53%) create mode 100644 src/ImageSharp/PixelFormats/PixelColorBlendingMode.cs diff --git a/src/ImageSharp.Drawing/Processing/BrushApplicator.cs b/src/ImageSharp.Drawing/Processing/BrushApplicator.cs index 41b47a822e..770d440656 100644 --- a/src/ImageSharp.Drawing/Processing/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Processing/BrushApplicator.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Processing { this.Target = target; this.Options = options; - this.Blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.Blender = PixelOperations.Instance.GetPixelBlender(options); } /// diff --git a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs index 7c9d7c280a..df6080162f 100644 --- a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing /// The blending mode. /// The opacity of the image to blend. Must be between 0 and 1. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode blender, float opacity) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender)); @@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Processing /// The opacity of the image to blend. Must be between 0 and 1. /// The location to draw the blended image. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity, Point location) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode blender, float opacity, Point location) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender)); diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs index faf3fe7115..a114daa848 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The location to draw the blended image. /// The opacity of the image to blend. Must be between 0 and 1. public DrawImageProcessor(Image image, Point location, float opacity) - : this(image, location, opacity, GraphicsOptions.Default.BlenderMode) + : this(image, location, opacity, GraphicsOptions.Default.ColorBlendingMode) { } @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// Opacity must be between 0 and 1. /// public DrawImageProcessor(Image image, Point location, GraphicsOptions options) - : this(image, location, options.BlendPercentage, options.BlenderMode) + : this(image, location, options.BlendPercentage, options.ColorBlendingMode, options.AlphaCompositionMode) { } @@ -73,9 +73,21 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The image to blend with the currently processing image. /// The opacity of the image to blend. Must be between 0 and 1. /// The blending mode to use when drawing the image. - public DrawImageProcessor(Image image, float opacity, PixelBlenderMode blenderMode) + public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode blenderMode) : this(image, Point.Empty, opacity, blenderMode) { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The Color blending mode to use when drawing the image. + /// The Alpha blending mode to use when drawing the image. + public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode blenderMode, PixelAlphaCompositionMode alphaMode) + : this(image, Point.Empty, opacity, blenderMode, alphaMode) + { } /// @@ -85,13 +97,31 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The location to draw the blended image. /// The opacity of the image to blend. Must be between 0 and 1. /// The blending mode to use when drawing the image. - public DrawImageProcessor(Image image, Point location, float opacity, PixelBlenderMode blenderMode) + public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode blenderMode) + { + Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); + + this.Image = image; + this.Opacity = opacity; + this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode, PixelAlphaCompositionMode.SrcOver); + this.Location = location; + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The location to draw the blended image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The blending mode to use when drawing the image. + /// The Alpha blending mode to use when drawing the image. + public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode blenderMode, PixelAlphaCompositionMode alphaMode) { Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); this.Image = image; this.Opacity = opacity; - this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode); + this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode, alphaMode); this.Location = location; } diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs index c9d6777ce6..7311a53da7 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs @@ -102,14 +102,35 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing private bool IsSolidBrushWithoutBlending(out SolidBrush solidBrush) { - solidBrush = this.brush as SolidBrush; - - return solidBrush != null - && ((this.options.BlenderMode == PixelBlenderMode.Normal && this.options.BlendPercentage == 1f - && solidBrush.Color.ToVector4().W == 1f) - || (this.options.BlenderMode == PixelBlenderMode.Over && this.options.BlendPercentage == 1f - && solidBrush.Color.ToVector4().W == 1f) - || (this.options.BlenderMode == PixelBlenderMode.Src)); + solidBrush = this.brush as SolidBrush; + + if (solidBrush == null) + { + return false; + } + + if (this.options.ColorBlendingMode != PixelColorBlendingMode.Normal) + { + return false; + } + + if (this.options.AlphaCompositionMode != PixelAlphaCompositionMode.SrcOver && + this.options.AlphaCompositionMode != PixelAlphaCompositionMode.Src) + { + return false; + } + + if (this.options.BlendPercentage != 1f) + { + return false; + } + + if (solidBrush.Color.ToVector4().W != 1f) + { + return false; + } + + return true; } } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs index dfad06768e..fa53706a3c 100644 --- a/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs +++ b/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing private float? dpiY; - private PixelBlenderMode blenderMode; + private PixelColorBlendingMode blenderMode; private float wrapTextWidth; @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Processing this.verticalAlignment = VerticalAlignment.Top; this.antialiasSubpixelDepth = 16; - this.blenderMode = PixelBlenderMode.Normal; + this.blenderMode = PixelColorBlendingMode.Normal; this.blendPercentage = 1; this.antialias = enableAntialiasing; this.dpiX = DefaultTextDpi; @@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Processing /// /// Gets or sets a value indicating the blending percentage to apply to the drawing operation /// - public PixelBlenderMode BlenderMode { get => this.blenderMode; set => this.blenderMode = value; } + public PixelColorBlendingMode BlenderMode { get => this.blenderMode; set => this.blenderMode = value; } /// /// Gets or sets a value indicating whether the text should be drawing with kerning enabled. @@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing { AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, blendPercentage = options.BlendPercentage, - blenderMode = options.BlenderMode + blenderMode = options.ColorBlendingMode }; } @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Processing return new GraphicsOptions(options.Antialias) { AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, - BlenderMode = options.BlenderMode, + ColorBlendingMode = options.BlenderMode, BlendPercentage = options.BlendPercentage }; } diff --git a/src/ImageSharp/GraphicsOptions.cs b/src/ImageSharp/GraphicsOptions.cs index a094abacbe..260fc2d75e 100644 --- a/src/ImageSharp/GraphicsOptions.cs +++ b/src/ImageSharp/GraphicsOptions.cs @@ -21,7 +21,9 @@ namespace SixLabors.ImageSharp private bool? antialias; - private PixelBlenderMode blenderMode; + private PixelColorBlendingMode colorBlendingMode; + + private PixelAlphaCompositionMode alphaCompositionMode; /// /// Initializes a new instance of the struct. @@ -29,7 +31,8 @@ namespace SixLabors.ImageSharp /// If set to true [enable antialiasing]. public GraphicsOptions(bool enableAntialiasing) { - this.blenderMode = PixelBlenderMode.Normal; + this.colorBlendingMode = PixelColorBlendingMode.Normal; + this.alphaCompositionMode = PixelAlphaCompositionMode.SrcOver; this.blendPercentage = 1; this.antialiasSubpixelDepth = 16; this.antialias = enableAntialiasing; @@ -67,12 +70,21 @@ namespace SixLabors.ImageSharp // some API thought post V1. /// - /// Gets or sets a value indicating the blending mode to apply to the drawing operation + /// Gets or sets a value indicating the color blending mode to apply to the drawing operation /// - public PixelBlenderMode BlenderMode + public PixelColorBlendingMode ColorBlendingMode { - get => this.blenderMode; - set => this.blenderMode = value; + get => this.colorBlendingMode; + set => this.colorBlendingMode = value; + } + + /// + /// Gets or sets a value indicating the alpha composition mode to apply to the drawing operation + /// + public PixelAlphaCompositionMode AlphaCompositionMode + { + get => this.alphaCompositionMode; + set => this.alphaCompositionMode = value; } } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs b/src/ImageSharp/PixelFormats/PixelAlphaCompositionMode.cs similarity index 53% rename from src/ImageSharp/PixelFormats/PixelBlenderMode.cs rename to src/ImageSharp/PixelFormats/PixelAlphaCompositionMode.cs index 7a8ab6592a..2758a74808 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs +++ b/src/ImageSharp/PixelFormats/PixelAlphaCompositionMode.cs @@ -4,55 +4,15 @@ namespace SixLabors.ImageSharp.PixelFormats { /// - /// Enumerates the various blending modes. + /// Enumerates the various alpha composition modes. /// - public enum PixelBlenderMode - { + public enum PixelAlphaCompositionMode + { /// - /// Default blending mode, also known as "Normal" or "Alpha Blending" - /// - Normal = 0, - - /// - /// Blends the 2 values by multiplication. - /// - Multiply, - - /// - /// Blends the 2 values by addition. - /// - Add, - - /// - /// Blends the 2 values by subtraction. - /// - Subtract, - - /// - /// Multiplies the complements of the backdrop and source values, then complements the result. - /// - Screen, - - /// - /// Selects the minimum of the backdrop and source values. - /// - Darken, - - /// - /// Selects the max of the backdrop and source values. - /// - Lighten, - - /// - /// Multiplies or screens the values, depending on the backdrop vector values. - /// - Overlay, - - /// - /// Multiplies or screens the colors, depending on the source value. + /// returns the destination over the source. /// - HardLight, - + SrcOver = 0, + /// /// returns the source colors. /// @@ -61,22 +21,17 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// returns the source over the destination. /// - Atop, - - /// - /// returns the destination over the source. - /// - Over, + SrcAtop, /// /// The source where the destination and source overlap. /// - In, + SrcIn, /// /// The destination where the destination and source overlap. /// - Out, + SrcOut, /// /// The destination where the source does not overlap it. diff --git a/src/ImageSharp/PixelFormats/PixelColorBlendingMode.cs b/src/ImageSharp/PixelFormats/PixelColorBlendingMode.cs new file mode 100644 index 0000000000..a68f7d9492 --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelColorBlendingMode.cs @@ -0,0 +1,56 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Enumerates the various color blending modes. + /// + public enum PixelColorBlendingMode + { + /// + /// Default blending mode, also known as "Normal" or "Alpha Blending" + /// + Normal = 0, + + /// + /// Blends the 2 values by multiplication. + /// + Multiply, + + /// + /// Blends the 2 values by addition. + /// + Add, + + /// + /// Blends the 2 values by subtraction. + /// + Subtract, + + /// + /// Multiplies the complements of the backdrop and source values, then complements the result. + /// + Screen, + + /// + /// Selects the minimum of the backdrop and source values. + /// + Darken, + + /// + /// Selects the max of the backdrop and source values. + /// + Lighten, + + /// + /// Multiplies or screens the values, depending on the backdrop vector values. + /// + Overlay, + + /// + /// Multiplies or screens the colors, depending on the source value. + /// + HardLight, + } +} diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs index ca6a28192d..dcddadb6a1 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs @@ -1,50 +1,217 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.PixelFormats.PixelBlenders; - -namespace SixLabors.ImageSharp.PixelFormats -{ - /// - /// Provides access to pixel blenders - /// - public partial class PixelOperations - where TPixel : struct, IPixel - { - /// - /// Find an instance of the pixel blender. - /// - /// The blending mode to apply - /// A . - internal virtual PixelBlender GetPixelBlender(PixelBlenderMode mode) - { - switch (mode) - { - case PixelBlenderMode.Multiply: return DefaultPixelBlenders.MultiplySrcOver.Instance; - case PixelBlenderMode.Add: return DefaultPixelBlenders.AddSrcOver.Instance; - case PixelBlenderMode.Subtract: return DefaultPixelBlenders.SubtractSrcOver.Instance; - case PixelBlenderMode.Screen: return DefaultPixelBlenders.ScreenSrcOver.Instance; - case PixelBlenderMode.Darken: return DefaultPixelBlenders.DarkenSrcOver.Instance; - case PixelBlenderMode.Lighten: return DefaultPixelBlenders.LightenSrcOver.Instance; - case PixelBlenderMode.Overlay: return DefaultPixelBlenders.OverlaySrcOver.Instance; - case PixelBlenderMode.HardLight: return DefaultPixelBlenders.HardLightSrcOver.Instance; - case PixelBlenderMode.Src: return DefaultPixelBlenders.NormalSrc.Instance; - case PixelBlenderMode.Atop: return DefaultPixelBlenders.NormalSrcAtop.Instance; - case PixelBlenderMode.Over: return DefaultPixelBlenders.NormalSrcOver.Instance; - case PixelBlenderMode.In: return DefaultPixelBlenders.NormalSrcIn.Instance; - case PixelBlenderMode.Out: return DefaultPixelBlenders.NormalSrcOut.Instance; - case PixelBlenderMode.Dest: return DefaultPixelBlenders.NormalDest.Instance; - case PixelBlenderMode.DestAtop: return DefaultPixelBlenders.NormalDestAtop.Instance; - case PixelBlenderMode.DestOver: return DefaultPixelBlenders.NormalDestOver.Instance; - case PixelBlenderMode.DestIn: return DefaultPixelBlenders.NormalDestIn.Instance; - case PixelBlenderMode.DestOut: return DefaultPixelBlenders.NormalDestOut.Instance; - case PixelBlenderMode.Clear: return DefaultPixelBlenders.NormalClear.Instance; - case PixelBlenderMode.Xor: return DefaultPixelBlenders.NormalXor.Instance; - - case PixelBlenderMode.Normal: - default: - return DefaultPixelBlenders.NormalSrcOver.Instance; - } - } - } +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats.PixelBlenders; + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides access to pixel blenders + /// + public partial class PixelOperations + where TPixel : struct, IPixel + { + /// + /// Find an instance of the pixel blender. + /// + /// the blending and composition to apply + /// A . + internal PixelBlender GetPixelBlender(GraphicsOptions options) + { + return this.GetPixelBlender(options.ColorBlendingMode, options.AlphaCompositionMode); + } + + /// + /// Find an instance of the pixel blender. + /// + /// The color blending mode to apply + /// The alpha composition mode to apply + /// A . + internal virtual PixelBlender GetPixelBlender(PixelColorBlendingMode colorMode, PixelAlphaCompositionMode alphaMode) + { + switch (alphaMode) + { + case PixelAlphaCompositionMode.Clear: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyClear.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddClear.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractClear.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenClear.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenClear.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenClear.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayClear.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightClear.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalClear.Instance; + } + + case PixelAlphaCompositionMode.Xor: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyXor.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddXor.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractXor.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenXor.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenXor.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenXor.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayXor.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightXor.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalXor.Instance; + } + + case PixelAlphaCompositionMode.Src: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplySrc.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddSrc.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractSrc.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenSrc.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenSrc.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenSrc.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlaySrc.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightSrc.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalSrc.Instance; + } + + case PixelAlphaCompositionMode.SrcAtop: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplySrcAtop.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddSrcAtop.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractSrcAtop.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenSrcAtop.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenSrcAtop.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenSrcAtop.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlaySrcAtop.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightSrcAtop.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalSrcAtop.Instance; + } + + case PixelAlphaCompositionMode.SrcIn: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplySrcIn.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddSrcIn.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractSrcIn.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenSrcIn.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenSrcIn.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenSrcIn.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlaySrcIn.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightSrcIn.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalSrcIn.Instance; + } + + case PixelAlphaCompositionMode.SrcOut: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplySrcOut.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddSrcOut.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractSrcOut.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenSrcOut.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenSrcOut.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenSrcOut.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlaySrcOut.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightSrcOut.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalSrcOut.Instance; + } + + case PixelAlphaCompositionMode.Dest: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyDest.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddDest.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractDest.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenDest.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenDest.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenDest.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayDest.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightDest.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalDest.Instance; + } + + case PixelAlphaCompositionMode.DestAtop: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyDestAtop.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddDestAtop.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractDestAtop.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenDestAtop.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenDestAtop.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenDestAtop.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayDestAtop.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightDestAtop.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalDestAtop.Instance; + } + + case PixelAlphaCompositionMode.DestIn: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyDestIn.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddDestIn.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractDestIn.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenDestIn.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenDestIn.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenDestIn.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayDestIn.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightDestIn.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalDestIn.Instance; + } + + case PixelAlphaCompositionMode.DestOut: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyDestOut.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddDestOut.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractDestOut.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenDestOut.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenDestOut.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenDestOut.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayDestOut.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightDestOut.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalDestOut.Instance; + } + + case PixelAlphaCompositionMode.DestOver: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplyDestOver.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddDestOver.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractDestOver.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenDestOver.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenDestOver.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenDestOver.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlayDestOver.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightDestOver.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalDestOver.Instance; + } + + case PixelAlphaCompositionMode.SrcOver: + default: + switch (colorMode) + { + case PixelColorBlendingMode.Multiply: return DefaultPixelBlenders.MultiplySrcOver.Instance; + case PixelColorBlendingMode.Add: return DefaultPixelBlenders.AddSrcOver.Instance; + case PixelColorBlendingMode.Subtract: return DefaultPixelBlenders.SubtractSrcOver.Instance; + case PixelColorBlendingMode.Screen: return DefaultPixelBlenders.ScreenSrcOver.Instance; + case PixelColorBlendingMode.Darken: return DefaultPixelBlenders.DarkenSrcOver.Instance; + case PixelColorBlendingMode.Lighten: return DefaultPixelBlenders.LightenSrcOver.Instance; + case PixelColorBlendingMode.Overlay: return DefaultPixelBlenders.OverlaySrcOver.Instance; + case PixelColorBlendingMode.HardLight: return DefaultPixelBlenders.HardLightSrcOver.Instance; + case PixelColorBlendingMode.Normal: + default: return DefaultPixelBlenders.NormalSrcOver.Instance; + } + } + } + } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs index c7fa2ff19c..ecbeebeb06 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays amountSpan[i] = this.GraphicsOptions.BlendPercentage; } - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); + PixelBlender blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions); ParallelFor.WithConfiguration( minY, maxY, diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index 6042493310..eb91fec043 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays { this.GlowColor = color; this.Radius = radius; - this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.blender = PixelOperations.Instance.GetPixelBlender(options); this.GraphicsOptions = options; } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index b8bd6c5a53..63780df476 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays { this.VignetteColor = color; this.GraphicsOptions = options; - this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.blender = PixelOperations.Instance.GetPixelBlender(options); } /// @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays this.VignetteColor = color; this.RadiusX = radiusX; this.RadiusY = radiusY; - this.blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.blender = PixelOperations.Instance.GetPixelBlender(options); this.GraphicsOptions = options; } diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 40ad92adc2..f50df3b347 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -25,16 +25,16 @@ namespace SixLabors.ImageSharp.Tests }; [Theory] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Normal)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Multiply)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Add)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Subtract)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Screen)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Darken)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Lighten)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Overlay)] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.HardLight)] - public void ImageShouldApplyDrawImage(TestImageProvider provider, PixelBlenderMode mode) + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Normal)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Multiply)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Add)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Subtract)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Screen)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Darken)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Lighten)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Overlay)] + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.HardLight)] + public void ImageShouldApplyDrawImage(TestImageProvider provider, PixelColorBlendingMode mode) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) @@ -47,8 +47,8 @@ namespace SixLabors.ImageSharp.Tests } [Theory] - [WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Normal)] - public void ImageShouldDrawTransformedImage(TestImageProvider provider, PixelBlenderMode mode) + [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Normal)] + public void ImageShouldDrawTransformedImage(TestImageProvider provider, PixelColorBlendingMode mode) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests Rgba32 backgroundPixel = background[0, 0]; Rgba32 overlayPixel = overlay[Math.Abs(xy) + 1, Math.Abs(xy) + 1]; - background.Mutate(x => x.DrawImage(overlay, PixelBlenderMode.Normal, 1F, new Point(xy, xy))); + background.Mutate(x => x.DrawImage(overlay, PixelColorBlendingMode.Normal, 1F, new Point(xy, xy))); Assert.Equal(Rgba32.White, backgroundPixel); Assert.Equal(overlayPixel, background[0, 0]); @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests Rgba32 backgroundPixel = background[xy - 1, xy - 1]; Rgba32 overlayPixel = overlay[0, 0]; - background.Mutate(x => x.DrawImage(overlay, PixelBlenderMode.Normal, 1F, new Point(xy, xy))); + background.Mutate(x => x.DrawImage(overlay, PixelColorBlendingMode.Normal, 1F, new Point(xy, xy))); Assert.Equal(Rgba32.White, backgroundPixel); Assert.Equal(overlayPixel, background[xy, xy]); diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 45f1340be9..e86d41f574 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -98,38 +98,38 @@ namespace SixLabors.ImageSharp.Tests.Drawing useReferenceOutputFrom: nameof(this.FillRegion)); } - public static readonly TheoryData BlendData = - new TheoryData() + public static readonly TheoryData BlendData = + new TheoryData() { - { false, "Blue", 0.5f, PixelBlenderMode.Normal, 1.0f }, - { false, "Blue", 1.0f, PixelBlenderMode.Normal, 0.5f }, - { false, "Green", 0.5f, PixelBlenderMode.Normal, 0.3f }, - { false, "HotPink", 0.8f, PixelBlenderMode.Normal, 0.8f }, - - { false, "Blue", 0.5f, PixelBlenderMode.Multiply, 1.0f }, - { false, "Blue", 1.0f, PixelBlenderMode.Multiply, 0.5f }, - { false, "Green", 0.5f, PixelBlenderMode.Multiply, 0.3f }, - { false, "HotPink", 0.8f, PixelBlenderMode.Multiply, 0.8f }, - - { false, "Blue", 0.5f, PixelBlenderMode.Add, 1.0f }, - { false, "Blue", 1.0f, PixelBlenderMode.Add, 0.5f }, - { false, "Green", 0.5f, PixelBlenderMode.Add, 0.3f }, - { false, "HotPink", 0.8f, PixelBlenderMode.Add, 0.8f }, - - { true, "Blue", 0.5f, PixelBlenderMode.Normal, 1.0f }, - { true, "Blue", 1.0f, PixelBlenderMode.Normal, 0.5f }, - { true, "Green", 0.5f, PixelBlenderMode.Normal, 0.3f }, - { true, "HotPink", 0.8f, PixelBlenderMode.Normal, 0.8f }, - - { true, "Blue", 0.5f, PixelBlenderMode.Multiply, 1.0f }, - { true, "Blue", 1.0f, PixelBlenderMode.Multiply, 0.5f }, - { true, "Green", 0.5f, PixelBlenderMode.Multiply, 0.3f }, - { true, "HotPink", 0.8f, PixelBlenderMode.Multiply, 0.8f }, - - { true, "Blue", 0.5f, PixelBlenderMode.Add, 1.0f }, - { true, "Blue", 1.0f, PixelBlenderMode.Add, 0.5f }, - { true, "Green", 0.5f, PixelBlenderMode.Add, 0.3f }, - { true, "HotPink", 0.8f, PixelBlenderMode.Add, 0.8f }, + { false, "Blue", 0.5f, PixelColorBlendingMode.Normal, 1.0f }, + { false, "Blue", 1.0f, PixelColorBlendingMode.Normal, 0.5f }, + { false, "Green", 0.5f, PixelColorBlendingMode.Normal, 0.3f }, + { false, "HotPink", 0.8f, PixelColorBlendingMode.Normal, 0.8f }, + + { false, "Blue", 0.5f, PixelColorBlendingMode.Multiply, 1.0f }, + { false, "Blue", 1.0f, PixelColorBlendingMode.Multiply, 0.5f }, + { false, "Green", 0.5f, PixelColorBlendingMode.Multiply, 0.3f }, + { false, "HotPink", 0.8f, PixelColorBlendingMode.Multiply, 0.8f }, + + { false, "Blue", 0.5f, PixelColorBlendingMode.Add, 1.0f }, + { false, "Blue", 1.0f, PixelColorBlendingMode.Add, 0.5f }, + { false, "Green", 0.5f, PixelColorBlendingMode.Add, 0.3f }, + { false, "HotPink", 0.8f, PixelColorBlendingMode.Add, 0.8f }, + + { true, "Blue", 0.5f, PixelColorBlendingMode.Normal, 1.0f }, + { true, "Blue", 1.0f, PixelColorBlendingMode.Normal, 0.5f }, + { true, "Green", 0.5f, PixelColorBlendingMode.Normal, 0.3f }, + { true, "HotPink", 0.8f, PixelColorBlendingMode.Normal, 0.8f }, + + { true, "Blue", 0.5f, PixelColorBlendingMode.Multiply, 1.0f }, + { true, "Blue", 1.0f, PixelColorBlendingMode.Multiply, 0.5f }, + { true, "Green", 0.5f, PixelColorBlendingMode.Multiply, 0.3f }, + { true, "HotPink", 0.8f, PixelColorBlendingMode.Multiply, 0.8f }, + + { true, "Blue", 0.5f, PixelColorBlendingMode.Add, 1.0f }, + { true, "Blue", 1.0f, PixelColorBlendingMode.Add, 0.5f }, + { true, "Green", 0.5f, PixelColorBlendingMode.Add, 0.3f }, + { true, "HotPink", 0.8f, PixelColorBlendingMode.Add, 0.8f }, }; [Theory] @@ -139,7 +139,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing bool triggerFillRegion, string newColorName, float alpha, - PixelBlenderMode blenderMode, + PixelColorBlendingMode blenderMode, float blendPercentage) where TPixel : struct, IPixel { @@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing var options = new GraphicsOptions(false) { - BlenderMode = blenderMode, + ColorBlendingMode = blenderMode, BlendPercentage = blendPercentage }; @@ -185,7 +185,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(blenderMode); + PixelBlender blender = PixelOperations.Instance.GetPixelBlender(blenderMode, PixelAlphaCompositionMode.SrcOver); TPixel expectedPixel = blender.Blend(bgColor, fillColor, blendPercentage); image.ComparePixelBufferTo(expectedPixel); diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index b31a18ac45..f6a5b5cdd2 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -16,13 +16,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing public class SolidFillBlendedShapesTests { public static IEnumerable modes = - ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))).Select(x => new object[] { x }); + ((PixelColorBlendingMode[])Enum.GetValues(typeof(PixelColorBlendingMode))).Select(x => new object[] { x }); [Theory] [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] public void _1DarkBlueRect_2BlendHotPinkRect( TestImageProvider provider, - PixelBlenderMode mode) + PixelColorBlendingMode mode) where TPixel : struct, IPixel { using (Image img = provider.GetImage()) @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) ) - .Fill(new GraphicsOptions(true) { BlenderMode = mode }, + .Fill(new GraphicsOptions(true) { ColorBlendingMode = mode }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) ); @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] public void _1DarkBlueRect_2BlendHotPinkRect_3BlendTransparentEllipse( TestImageProvider provider, - PixelBlenderMode mode) + PixelColorBlendingMode mode) where TPixel : struct, IPixel { using (Image img = provider.GetImage()) @@ -60,12 +60,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = mode }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = mode }, NamedColors.Transparent, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) ); @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] public void _1DarkBlueRect_2BlendHotPinkRect_3BlendSemiTransparentRedEllipse( TestImageProvider provider, - PixelBlenderMode mode) + PixelColorBlendingMode mode) where TPixel : struct, IPixel { using (Image img = provider.GetImage()) @@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = mode }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); var c = NamedColors.Red.ToVector4(); @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing img.Mutate( x => x.Fill( - new GraphicsOptions(true) { BlenderMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = mode }, pixel, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) ); @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Theory] [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] - public void _1DarkBlueRect_2BlendBlackEllipse(TestImageProvider provider, PixelBlenderMode mode) + public void _1DarkBlueRect_2BlendBlackEllipse(TestImageProvider provider, PixelColorBlendingMode mode) where TPixel : struct, IPixel { using(Image dstImg = provider.GetImage(), srcImg = provider.GetImage()) @@ -131,14 +131,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); dstImg.Mutate( - x => x.DrawImage(new GraphicsOptions(true) { BlenderMode = mode }, srcImg) + x => x.DrawImage(new GraphicsOptions(true) { ColorBlendingMode = mode }, srcImg) ); VerifyImage(provider, mode, dstImg); } } - private static void VerifyImage(TestImageProvider provider, PixelBlenderMode mode, Image img) + private static void VerifyImage(TestImageProvider provider, PixelColorBlendingMode mode, Image img) where TPixel : struct, IPixel { img.DebugSave( diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs index 120619fb5a..316a7b216e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs @@ -1,47 +1,56 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders -{ - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; - - using Xunit; - - public class PorterDuffCompositorTests - { - // TODO: Add other modes to compare. - public static readonly TheoryData CompositingOperators = - new TheoryData - { - PixelBlenderMode.Src, - PixelBlenderMode.Atop, - PixelBlenderMode.Over, - PixelBlenderMode.In, - PixelBlenderMode.Out, - PixelBlenderMode.Dest, - PixelBlenderMode.DestAtop, - PixelBlenderMode.DestOver, - PixelBlenderMode.DestIn, - PixelBlenderMode.DestOut, - PixelBlenderMode.Clear, - PixelBlenderMode.Xor - }; - - [Theory] - [WithFile(TestImages.Png.PDDest, nameof(CompositingOperators), PixelTypes.Rgba32)] - public void PorterDuffOutputIsCorrect(TestImageProvider provider, PixelBlenderMode mode) - { - var srcFile = TestFile.Create(TestImages.Png.PDSrc); - using (Image src = srcFile.CreateImage()) - using (Image dest = provider.GetImage()) - { - using (Image res = dest.Clone(x => x.DrawImage(new GraphicsOptions { BlenderMode = mode }, src))) - { - res.DebugSave(provider, mode.ToString()); - res.CompareToReferenceOutput(provider, mode.ToString()); - } - } - } - } +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders +{ + using SixLabors.ImageSharp.PixelFormats; + using SixLabors.ImageSharp.Processing; + + using Xunit; + + public class PorterDuffCompositorTests + { + // TODO: Add other modes to compare. + public static readonly TheoryData CompositingOperators = + new TheoryData + { + PixelAlphaCompositionMode.Src, + PixelAlphaCompositionMode.SrcAtop, + PixelAlphaCompositionMode.SrcOver, + PixelAlphaCompositionMode.SrcIn, + PixelAlphaCompositionMode.SrcOut, + PixelAlphaCompositionMode.Dest, + PixelAlphaCompositionMode.DestAtop, + PixelAlphaCompositionMode.DestOver, + PixelAlphaCompositionMode.DestIn, + PixelAlphaCompositionMode.DestOut, + PixelAlphaCompositionMode.Clear, + PixelAlphaCompositionMode.Xor + }; + + [Theory] + [WithFile(TestImages.Png.PDDest, nameof(CompositingOperators), PixelTypes.Rgba32)] + public void PorterDuffOutputIsCorrect(TestImageProvider provider, PixelAlphaCompositionMode mode) + { + var srcFile = TestFile.Create(TestImages.Png.PDSrc); + using (Image src = srcFile.CreateImage()) + using (Image dest = provider.GetImage()) + { + GraphicsOptions options = new GraphicsOptions + { + AlphaCompositionMode = mode + }; + + using (Image res = dest.Clone(x => x.DrawImage(options, src))) + { + string combinedMode = mode.ToString(); + + if (combinedMode != "Src" && combinedMode.StartsWith("Src")) combinedMode = combinedMode.Substring(3); + + res.DebugSave(provider, combinedMode); + res.CompareToReferenceOutput(provider, combinedMode); + } + } + } + } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs index 3923a56752..8f574ca169 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs @@ -12,64 +12,36 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.PixelFormats { public class PixelBlenderTests - { - - - public static TheoryData BlenderMappings = new TheoryData() + { + public static TheoryData BlenderMappings = new TheoryData() { - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Normal }, - { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelBlenderMode.Screen }, - { new TestPixel(), typeof(DefaultPixelBlenders.HardLightSrcOver), PixelBlenderMode.HardLight }, - { new TestPixel(), typeof(DefaultPixelBlenders.OverlaySrcOver), PixelBlenderMode.Overlay }, - { new TestPixel(), typeof(DefaultPixelBlenders.DarkenSrcOver), PixelBlenderMode.Darken }, - { new TestPixel(), typeof(DefaultPixelBlenders.LightenSrcOver), PixelBlenderMode.Lighten }, - { new TestPixel(), typeof(DefaultPixelBlenders.AddSrcOver), PixelBlenderMode.Add }, - { new TestPixel(), typeof(DefaultPixelBlenders.SubtractSrcOver), PixelBlenderMode.Subtract }, - { new TestPixel(), typeof(DefaultPixelBlenders.MultiplySrcOver), PixelBlenderMode.Multiply }, - - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrc), PixelBlenderMode.Src }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcAtop), PixelBlenderMode.Atop }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Over }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcIn), PixelBlenderMode.In }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOut), PixelBlenderMode.Out }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDest), PixelBlenderMode.Dest }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestAtop), PixelBlenderMode.DestAtop }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOver), PixelBlenderMode.DestOver }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestIn), PixelBlenderMode.DestIn }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOut), PixelBlenderMode.DestOut }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalClear), PixelBlenderMode.Clear }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalXor), PixelBlenderMode.Xor }, - - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Normal }, - { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelBlenderMode.Screen }, - { new TestPixel(), typeof(DefaultPixelBlenders.HardLightSrcOver), PixelBlenderMode.HardLight }, - { new TestPixel(), typeof(DefaultPixelBlenders.OverlaySrcOver), PixelBlenderMode.Overlay }, - { new TestPixel(), typeof(DefaultPixelBlenders.DarkenSrcOver), PixelBlenderMode.Darken }, - { new TestPixel(), typeof(DefaultPixelBlenders.LightenSrcOver), PixelBlenderMode.Lighten }, - { new TestPixel(), typeof(DefaultPixelBlenders.AddSrcOver), PixelBlenderMode.Add }, - { new TestPixel(), typeof(DefaultPixelBlenders.SubtractSrcOver), PixelBlenderMode.Subtract }, - { new TestPixel(), typeof(DefaultPixelBlenders.MultiplySrcOver), PixelBlenderMode.Multiply }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrc), PixelBlenderMode.Src }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcAtop), PixelBlenderMode.Atop }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelBlenderMode.Over }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcIn), PixelBlenderMode.In }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOut), PixelBlenderMode.Out }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDest), PixelBlenderMode.Dest }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestAtop), PixelBlenderMode.DestAtop }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOver), PixelBlenderMode.DestOver }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestIn), PixelBlenderMode.DestIn }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalDestOut), PixelBlenderMode.DestOut }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalClear), PixelBlenderMode.Clear }, - { new TestPixel(), typeof(DefaultPixelBlenders.NormalXor), PixelBlenderMode.Xor }, - + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelColorBlendingMode.Normal }, + { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelColorBlendingMode.Screen }, + { new TestPixel(), typeof(DefaultPixelBlenders.HardLightSrcOver), PixelColorBlendingMode.HardLight }, + { new TestPixel(), typeof(DefaultPixelBlenders.OverlaySrcOver), PixelColorBlendingMode.Overlay }, + { new TestPixel(), typeof(DefaultPixelBlenders.DarkenSrcOver), PixelColorBlendingMode.Darken }, + { new TestPixel(), typeof(DefaultPixelBlenders.LightenSrcOver), PixelColorBlendingMode.Lighten }, + { new TestPixel(), typeof(DefaultPixelBlenders.AddSrcOver), PixelColorBlendingMode.Add }, + { new TestPixel(), typeof(DefaultPixelBlenders.SubtractSrcOver), PixelColorBlendingMode.Subtract }, + { new TestPixel(), typeof(DefaultPixelBlenders.MultiplySrcOver), PixelColorBlendingMode.Multiply }, + + { new TestPixel(), typeof(DefaultPixelBlenders.NormalSrcOver), PixelColorBlendingMode.Normal }, + { new TestPixel(), typeof(DefaultPixelBlenders.ScreenSrcOver), PixelColorBlendingMode.Screen }, + { new TestPixel(), typeof(DefaultPixelBlenders.HardLightSrcOver), PixelColorBlendingMode.HardLight }, + { new TestPixel(), typeof(DefaultPixelBlenders.OverlaySrcOver), PixelColorBlendingMode.Overlay }, + { new TestPixel(), typeof(DefaultPixelBlenders.DarkenSrcOver), PixelColorBlendingMode.Darken }, + { new TestPixel(), typeof(DefaultPixelBlenders.LightenSrcOver), PixelColorBlendingMode.Lighten }, + { new TestPixel(), typeof(DefaultPixelBlenders.AddSrcOver), PixelColorBlendingMode.Add }, + { new TestPixel(), typeof(DefaultPixelBlenders.SubtractSrcOver), PixelColorBlendingMode.Subtract }, + { new TestPixel(), typeof(DefaultPixelBlenders.MultiplySrcOver), PixelColorBlendingMode.Multiply }, }; [Theory] [MemberData(nameof(BlenderMappings))] - public void ReturnsCorrectBlender(TestPixel pixel, Type type, PixelBlenderMode mode) + public void ReturnsCorrectBlender(TestPixel pixel, Type type, PixelColorBlendingMode mode) where TPixel : struct, IPixel { - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(mode); + PixelBlender blender = PixelOperations.Instance.GetPixelBlender(mode, PixelAlphaCompositionMode.SrcOver); Assert.IsType(type, blender); } } From 590dd3b8e64efd3df35c0a046d9d6afafc9e2a2d Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 20 Aug 2018 10:27:18 -0700 Subject: [PATCH 18/40] Optimize Equals & GetHashCode methods within PixelFormats --- src/ImageSharp/PixelFormats/Alpha8.cs | 5 +---- src/ImageSharp/PixelFormats/Argb32.cs | 7 +------ src/ImageSharp/PixelFormats/Bgr565.cs | 5 +---- src/ImageSharp/PixelFormats/Bgra32.cs | 10 ++-------- src/ImageSharp/PixelFormats/Bgra4444.cs | 5 +---- src/ImageSharp/PixelFormats/Bgra5551.cs | 5 +---- src/ImageSharp/PixelFormats/Byte4.cs | 5 +---- src/ImageSharp/PixelFormats/HalfSingle.cs | 5 +---- src/ImageSharp/PixelFormats/HalfVector2.cs | 5 +---- src/ImageSharp/PixelFormats/HalfVector4.cs | 5 +---- src/ImageSharp/PixelFormats/NormalizedByte2.cs | 5 +---- src/ImageSharp/PixelFormats/NormalizedByte4.cs | 5 +---- src/ImageSharp/PixelFormats/Rgba32.cs | 7 +------ src/ImageSharp/PixelFormats/Rgba64.cs | 5 +---- src/ImageSharp/PixelFormats/Short2.cs | 5 +---- src/ImageSharp/PixelFormats/Short4.cs | 5 +---- 16 files changed, 17 insertions(+), 72 deletions(-) diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs index 0b16fed0a5..a8d97d31a2 100644 --- a/src/ImageSharp/PixelFormats/Alpha8.cs +++ b/src/ImageSharp/PixelFormats/Alpha8.cs @@ -208,10 +208,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// /// Packs a into a byte. diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs index ccb17a2a5e..51d3964ef8 100644 --- a/src/ImageSharp/PixelFormats/Argb32.cs +++ b/src/ImageSharp/PixelFormats/Argb32.cs @@ -362,12 +362,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - int hash = HashHelpers.Combine(this.R.GetHashCode(), this.G.GetHashCode()); - hash = HashHelpers.Combine(hash, this.B.GetHashCode()); - return HashHelpers.Combine(hash, this.A.GetHashCode()); - } + public override int GetHashCode() => this.Argb.GetHashCode(); /// /// Gets the representation without normalizing to [0, 1] diff --git a/src/ImageSharp/PixelFormats/Bgr565.cs b/src/ImageSharp/PixelFormats/Bgr565.cs index f9a0ce9dce..570b975dba 100644 --- a/src/ImageSharp/PixelFormats/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/Bgr565.cs @@ -224,10 +224,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// /// Packs the components into a . diff --git a/src/ImageSharp/PixelFormats/Bgra32.cs b/src/ImageSharp/PixelFormats/Bgra32.cs index 14b2da07c9..233df2f29e 100644 --- a/src/ImageSharp/PixelFormats/Bgra32.cs +++ b/src/ImageSharp/PixelFormats/Bgra32.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -105,19 +104,14 @@ namespace SixLabors.ImageSharp.PixelFormats /// public bool Equals(Bgra32 other) { - return this.R == other.R && this.G == other.G && this.B == other.B && this.A == other.A; + return this.Bgra == other.Bgra; } /// public override bool Equals(object obj) => obj is Bgra32 other && this.Equals(other); /// - public override int GetHashCode() - { - int hash = HashHelpers.Combine(this.R.GetHashCode(), this.G.GetHashCode()); - hash = HashHelpers.Combine(hash, this.B.GetHashCode()); - return HashHelpers.Combine(hash, this.A.GetHashCode()); - } + public override int GetHashCode() => this.Bgra.GetHashCode(); /// /// Gets the representation without normalizing to [0, 1] diff --git a/src/ImageSharp/PixelFormats/Bgra4444.cs b/src/ImageSharp/PixelFormats/Bgra4444.cs index b006aa5d2f..90f967f898 100644 --- a/src/ImageSharp/PixelFormats/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/Bgra4444.cs @@ -215,10 +215,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// /// Packs the components into a . diff --git a/src/ImageSharp/PixelFormats/Bgra5551.cs b/src/ImageSharp/PixelFormats/Bgra5551.cs index 90a6251428..3a18c03e83 100644 --- a/src/ImageSharp/PixelFormats/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/Bgra5551.cs @@ -221,10 +221,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// The hash code for the packed vector. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// /// Packs the components into a . diff --git a/src/ImageSharp/PixelFormats/Byte4.cs b/src/ImageSharp/PixelFormats/Byte4.cs index 4269557270..bb1b350f07 100644 --- a/src/ImageSharp/PixelFormats/Byte4.cs +++ b/src/ImageSharp/PixelFormats/Byte4.cs @@ -210,10 +210,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// /// Returns a string representation of the current instance. diff --git a/src/ImageSharp/PixelFormats/HalfSingle.cs b/src/ImageSharp/PixelFormats/HalfSingle.cs index 54c615f9b4..09b4636492 100644 --- a/src/ImageSharp/PixelFormats/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/HalfSingle.cs @@ -229,10 +229,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); [MethodImpl(MethodImplOptions.AggressiveInlining)] private Vector4 ToByteScaledVector4() diff --git a/src/ImageSharp/PixelFormats/HalfVector2.cs b/src/ImageSharp/PixelFormats/HalfVector2.cs index 4a135a77cb..befa49736c 100644 --- a/src/ImageSharp/PixelFormats/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/HalfVector2.cs @@ -231,10 +231,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// public override bool Equals(object obj) diff --git a/src/ImageSharp/PixelFormats/HalfVector4.cs b/src/ImageSharp/PixelFormats/HalfVector4.cs index 62a25bc2b8..885e022921 100644 --- a/src/ImageSharp/PixelFormats/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/HalfVector4.cs @@ -224,10 +224,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// public override bool Equals(object obj) diff --git a/src/ImageSharp/PixelFormats/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/NormalizedByte2.cs index 75a9075942..dc220aef6b 100644 --- a/src/ImageSharp/PixelFormats/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/NormalizedByte2.cs @@ -257,10 +257,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode();; /// public override string ToString() diff --git a/src/ImageSharp/PixelFormats/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/NormalizedByte4.cs index fc3845eb28..293d536e53 100644 --- a/src/ImageSharp/PixelFormats/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/NormalizedByte4.cs @@ -250,10 +250,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// public override string ToString() diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs index 79794ee462..066f80ecde 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.cs @@ -437,12 +437,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - int hash = HashHelpers.Combine(this.R.GetHashCode(), this.G.GetHashCode()); - hash = HashHelpers.Combine(hash, this.B.GetHashCode()); - return HashHelpers.Combine(hash, this.A.GetHashCode()); - } + public override int GetHashCode() => Rgba.GetHashCode(); /// /// Gets the representation without normalizing to [0, 1] diff --git a/src/ImageSharp/PixelFormats/Rgba64.cs b/src/ImageSharp/PixelFormats/Rgba64.cs index a66485ba40..8e6be1e8c4 100644 --- a/src/ImageSharp/PixelFormats/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/Rgba64.cs @@ -295,9 +295,6 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); } } \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/Short2.cs b/src/ImageSharp/PixelFormats/Short2.cs index c298c5a486..9fc7618b91 100644 --- a/src/ImageSharp/PixelFormats/Short2.cs +++ b/src/ImageSharp/PixelFormats/Short2.cs @@ -249,10 +249,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// public override string ToString() diff --git a/src/ImageSharp/PixelFormats/Short4.cs b/src/ImageSharp/PixelFormats/Short4.cs index 5683ffceea..641f154f94 100644 --- a/src/ImageSharp/PixelFormats/Short4.cs +++ b/src/ImageSharp/PixelFormats/Short4.cs @@ -247,10 +247,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// Hash code for the instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() - { - return this.PackedValue.GetHashCode(); - } + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// /// Returns a string representation of the current instance. From 67e1445787f65e5ff4e9d8db2415291fe02dd2b5 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 20 Aug 2018 12:05:27 -0700 Subject: [PATCH 19/40] Remove trailing semicolon --- src/ImageSharp/PixelFormats/NormalizedByte2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/NormalizedByte2.cs index dc220aef6b..8592fdd6a7 100644 --- a/src/ImageSharp/PixelFormats/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/NormalizedByte2.cs @@ -257,7 +257,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() => this.PackedValue.GetHashCode();; + public override int GetHashCode() => this.PackedValue.GetHashCode(); /// public override string ToString() From 760dfcc937008e4845d135945a766f24e9094586 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 20 Aug 2018 14:18:10 -0700 Subject: [PATCH 20/40] =?UTF-8?q?=F0=9F=91=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ImageSharp/PixelFormats/Rgba32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs index 066f80ecde..cf66538c52 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.cs @@ -437,7 +437,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() => Rgba.GetHashCode(); + public override int GetHashCode() => this.Rgba.GetHashCode(); /// /// Gets the representation without normalizing to [0, 1] From 0abd6c2e6826df12c31560a406894c305fe26f4b Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Tue, 21 Aug 2018 12:35:35 +0200 Subject: [PATCH 21/40] Fixed missing Alpha Composition property in TextGraphicsOptions --- .../Processing/TextGraphicsOptions.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs index fa53706a3c..3c682a761b 100644 --- a/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs +++ b/src/ImageSharp.Drawing/Processing/TextGraphicsOptions.cs @@ -32,7 +32,9 @@ namespace SixLabors.ImageSharp.Processing private float? dpiY; - private PixelColorBlendingMode blenderMode; + private PixelColorBlendingMode colorBlendingMode; + + private PixelAlphaCompositionMode alphaCompositionMode; private float wrapTextWidth; @@ -53,7 +55,8 @@ namespace SixLabors.ImageSharp.Processing this.verticalAlignment = VerticalAlignment.Top; this.antialiasSubpixelDepth = 16; - this.blenderMode = PixelColorBlendingMode.Normal; + this.colorBlendingMode = PixelColorBlendingMode.Normal; + this.alphaCompositionMode = PixelAlphaCompositionMode.SrcOver; this.blendPercentage = 1; this.antialias = enableAntialiasing; this.dpiX = DefaultTextDpi; @@ -80,9 +83,14 @@ namespace SixLabors.ImageSharp.Processing // some API thought post V1. /// - /// Gets or sets a value indicating the blending percentage to apply to the drawing operation + /// Gets or sets a value indicating the color blending percentage to apply to the drawing operation + /// + public PixelColorBlendingMode ColorBlendingMode { get => this.colorBlendingMode; set => this.colorBlendingMode = value; } + + /// + /// Gets or sets a value indicating the color blending percentage to apply to the drawing operation /// - public PixelColorBlendingMode BlenderMode { get => this.blenderMode; set => this.blenderMode = value; } + public PixelAlphaCompositionMode AlphaCompositionMode { get => this.alphaCompositionMode; set => this.alphaCompositionMode = value; } /// /// Gets or sets a value indicating whether the text should be drawing with kerning enabled. @@ -135,7 +143,8 @@ namespace SixLabors.ImageSharp.Processing { AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, blendPercentage = options.BlendPercentage, - blenderMode = options.ColorBlendingMode + colorBlendingMode = options.ColorBlendingMode, + alphaCompositionMode = options.AlphaCompositionMode }; } @@ -151,7 +160,8 @@ namespace SixLabors.ImageSharp.Processing return new GraphicsOptions(options.Antialias) { AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, - ColorBlendingMode = options.BlenderMode, + ColorBlendingMode = options.ColorBlendingMode, + AlphaCompositionMode = options.AlphaCompositionMode, BlendPercentage = options.BlendPercentage }; } From c3a325b68518ac6bf6718f73607caa0772dde01f Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Tue, 21 Aug 2018 15:56:49 +0200 Subject: [PATCH 22/40] refactored DrawImageProcessor methods --- .../Processors/Drawing/DrawImageProcessor.cs | 67 +++++++++---------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs index a114daa848..760086183e 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -40,6 +40,29 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing public DrawImageProcessor(Image image, GraphicsOptions options) : this(image, Point.Empty, options) { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The blending mode to use when drawing the image. + public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode colorBlendingMode) + : this(image, Point.Empty, opacity, colorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The Color blending mode to use when drawing the image. + /// The Alpha blending mode to use when drawing the image. + public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode) + : this(image, Point.Empty, opacity, colorBlendingMode, alphaCompositionMode) + { } /// @@ -49,7 +72,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The location to draw the blended image. /// The opacity of the image to blend. Must be between 0 and 1. public DrawImageProcessor(Image image, Point location, float opacity) - : this(image, location, opacity, GraphicsOptions.Default.ColorBlendingMode) + : this(image, location, opacity, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode) { } @@ -65,46 +88,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing public DrawImageProcessor(Image image, Point location, GraphicsOptions options) : this(image, location, options.BlendPercentage, options.ColorBlendingMode, options.AlphaCompositionMode) { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The opacity of the image to blend. Must be between 0 and 1. - /// The blending mode to use when drawing the image. - public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode blenderMode) - : this(image, Point.Empty, opacity, blenderMode) - { } - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The opacity of the image to blend. Must be between 0 and 1. - /// The Color blending mode to use when drawing the image. - /// The Alpha blending mode to use when drawing the image. - public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode blenderMode, PixelAlphaCompositionMode alphaMode) - : this(image, Point.Empty, opacity, blenderMode, alphaMode) - { - } - /// /// Initializes a new instance of the class. /// /// The image to blend with the currently processing image. /// The location to draw the blended image. /// The opacity of the image to blend. Must be between 0 and 1. - /// The blending mode to use when drawing the image. - public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode blenderMode) + /// The blending mode to use when drawing the image. + public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode colorBlendingMode) + : this(image, location, opacity, colorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode) { - Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); - - this.Image = image; - this.Opacity = opacity; - this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode, PixelAlphaCompositionMode.SrcOver); - this.Location = location; } /// @@ -113,15 +108,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The image to blend with the currently processing image. /// The location to draw the blended image. /// The opacity of the image to blend. Must be between 0 and 1. - /// The blending mode to use when drawing the image. - /// The Alpha blending mode to use when drawing the image. - public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode blenderMode, PixelAlphaCompositionMode alphaMode) + /// The blending mode to use when drawing the image. + /// The Alpha blending mode to use when drawing the image. + public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode) { Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); this.Image = image; this.Opacity = opacity; - this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode, alphaMode); + this.Blender = PixelOperations.Instance.GetPixelBlender(colorBlendingMode, alphaCompositionMode); this.Location = location; } From 1035f239083beeb205831ab623ed82d692766916 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 22 Aug 2018 09:37:09 +0200 Subject: [PATCH 23/40] rearranged DrawImage method arguments. Fixed tests accordingly --- .../Processing/DrawImageExtensions.cs | 85 +++++++++++------ .../Processors/Drawing/DrawImageProcessor.cs | 93 +------------------ .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 8 +- .../Drawing/SolidFillBlendedShapesTests.cs | 2 +- .../PorterDuffCompositorTests.cs | 2 +- 5 files changed, 68 insertions(+), 122 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs index df6080162f..8ccbe22acb 100644 --- a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity) where TPixel : struct, IPixel - => source.ApplyProcessor(new DrawImageProcessor(image, opacity)); + => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); /// /// Draws the given image together with the current one by blending their pixels. @@ -30,63 +30,92 @@ namespace SixLabors.ImageSharp.Processing /// The pixel format. /// The image this method extends. /// The image to blend with the currently processing image. - /// The blending mode. + /// The blending mode. /// The opacity of the image to blend. Must be between 0 and 1. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode blender, float opacity) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity) where TPixel : struct, IPixel - => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender)); - + => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); + /// /// Draws the given image together with the current one by blending their pixels. /// /// The pixel format. /// The image this method extends. - /// The options, including the blending type and blending amount. /// The image to blend with the currently processing image. + /// The color blending mode. + /// The alpha composition mode. + /// The opacity of the image to blend. Must be between 0 and 1. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, GraphicsOptions options, Image image) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) where TPixel : struct, IPixel - => source.ApplyProcessor(new DrawImageProcessor(image, options)); - + => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity)); + /// /// Draws the given image together with the current one by blending their pixels. /// - /// The image this method extends. + /// The pixel format. + /// The image this method extends. /// The image to blend with the currently processing image. + /// The options, including the blending type and blending amount. + /// The . + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); + + /// + /// Draws the given image together with the current one by blending their pixels. + /// /// The pixel format. - /// The opacity of the image to blend. Must be between 0 and 1. + /// The image this method extends. + /// The image to blend with the currently processing image. /// The location to draw the blended image. + /// The opacity of the image to blend. Must be between 0 and 1. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity, Point location) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, float opacity) where TPixel : struct, IPixel - => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity)); - + => source.ApplyProcessor(new DrawImageProcessor(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); + /// /// Draws the given image together with the current one by blending their pixels. - /// - /// The image this method extends. - /// The image to blend with the currently processing image. + /// /// The pixel format. - /// The type of bending to apply. - /// The opacity of the image to blend. Must be between 0 and 1. + /// The image this method extends. + /// The image to blend with the currently processing image. /// The location to draw the blended image. + /// The color blending to apply. + /// The opacity of the image to blend. Must be between 0 and 1. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode blender, float opacity, Point location) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, float opacity) where TPixel : struct, IPixel - => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender)); - + => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); + /// /// Draws the given image together with the current one by blending their pixels. - /// - /// The image this method extends. - /// The options containing the blend mode and opacity. - /// The image to blend with the currently processing image. + /// /// The pixel format. + /// The image this method extends. + /// The image to blend with the currently processing image. /// The location to draw the blended image. + /// The color blending to apply. + /// The alpha composition mode. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) + where TPixel : struct, IPixel + => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity)); + + /// + /// Draws the given image together with the current one by blending their pixels. + /// + /// The pixel format. + /// The image this method extends. + /// The image to blend with the currently processing image. + /// The location to draw the blended image. + /// The options containing the blend mode and opacity. /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, GraphicsOptions options, Image image, Point location) + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options) where TPixel : struct, IPixel - => source.ApplyProcessor(new DrawImageProcessor(image, location, options)); + => source.ApplyProcessor(new DrawImageProcessor(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs index 760086183e..324d25e097 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -18,99 +18,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing /// The pixel format. internal class DrawImageProcessor : ImageProcessor where TPixel : struct, IPixel - { + { /// /// Initializes a new instance of the class. /// /// The image to blend with the currently processing image. - /// The opacity of the image to blend. Must be between 0 and 1. - public DrawImageProcessor(Image image, float opacity) - : this(image, Point.Empty, opacity) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// - /// The options containing the opacity of the image to blend and blending mode. - /// Opacity must be between 0 and 1. - /// - public DrawImageProcessor(Image image, GraphicsOptions options) - : this(image, Point.Empty, options) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The opacity of the image to blend. Must be between 0 and 1. - /// The blending mode to use when drawing the image. - public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode colorBlendingMode) - : this(image, Point.Empty, opacity, colorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The opacity of the image to blend. Must be between 0 and 1. - /// The Color blending mode to use when drawing the image. - /// The Alpha blending mode to use when drawing the image. - public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode) - : this(image, Point.Empty, opacity, colorBlendingMode, alphaCompositionMode) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The location to draw the blended image. - /// The opacity of the image to blend. Must be between 0 and 1. - public DrawImageProcessor(Image image, Point location, float opacity) - : this(image, location, opacity, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The location to draw the blended image. - /// - /// The options containing the opacity of the image to blend and blending mode. - /// Opacity must be between 0 and 1. - /// - public DrawImageProcessor(Image image, Point location, GraphicsOptions options) - : this(image, location, options.BlendPercentage, options.ColorBlendingMode, options.AlphaCompositionMode) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The location to draw the blended image. - /// The opacity of the image to blend. Must be between 0 and 1. - /// The blending mode to use when drawing the image. - public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode colorBlendingMode) - : this(image, location, opacity, colorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image to blend with the currently processing image. - /// The location to draw the blended image. - /// The opacity of the image to blend. Must be between 0 and 1. + /// The location to draw the blended image. /// The blending mode to use when drawing the image. - /// The Alpha blending mode to use when drawing the image. - public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode) + /// The Alpha blending mode to use when drawing the image. + /// The opacity of the image to blend. Must be between 0 and 1. + public DrawImageProcessor(Image image, Point location, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity) { Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index f50df3b347..740b30a8c3 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests using (var blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes)) { blend.Mutate(x => x.Resize(image.Width / 2, image.Height / 2)); - image.Mutate(x => x.DrawImage(blend, mode, .75f, new Point(image.Width / 4, image.Height / 4))); + image.Mutate(x => x.DrawImage(blend, new Point(image.Width / 4, image.Height / 4), mode, .75f) ); image.DebugSave(provider, new { mode }); } } @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests new Rectangle(0, 0, destBounds.Width, destBounds.Height))); var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2); - image.Mutate(x => x.DrawImage(blend, mode, .75F, position)); + image.Mutate(x => x.DrawImage(blend, position, mode, .75F)); image.DebugSave(provider, new[] { "Transformed" }); } } @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests Rgba32 backgroundPixel = background[0, 0]; Rgba32 overlayPixel = overlay[Math.Abs(xy) + 1, Math.Abs(xy) + 1]; - background.Mutate(x => x.DrawImage(overlay, PixelColorBlendingMode.Normal, 1F, new Point(xy, xy))); + background.Mutate(x => x.DrawImage(overlay, new Point(xy, xy), PixelColorBlendingMode.Normal, 1F)); Assert.Equal(Rgba32.White, backgroundPixel); Assert.Equal(overlayPixel, background[0, 0]); @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests Rgba32 backgroundPixel = background[xy - 1, xy - 1]; Rgba32 overlayPixel = overlay[0, 0]; - background.Mutate(x => x.DrawImage(overlay, PixelColorBlendingMode.Normal, 1F, new Point(xy, xy))); + background.Mutate(x => x.DrawImage(overlay, new Point(xy, xy), PixelColorBlendingMode.Normal, 1F)); Assert.Equal(Rgba32.White, backgroundPixel); Assert.Equal(overlayPixel, background[xy, xy]); diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index f6a5b5cdd2..6c0efce7a1 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); dstImg.Mutate( - x => x.DrawImage(new GraphicsOptions(true) { ColorBlendingMode = mode }, srcImg) + x => x.DrawImage(srcImg, new GraphicsOptions(true) { ColorBlendingMode = mode }) ); VerifyImage(provider, mode, dstImg); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs index 316a7b216e..9c3ea90d53 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders AlphaCompositionMode = mode }; - using (Image res = dest.Clone(x => x.DrawImage(options, src))) + using (Image res = dest.Clone(x => x.DrawImage(src, options))) { string combinedMode = mode.ToString(); From c47f09a3117969485d958ad0b26b2e043585cefb Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 22 Aug 2018 12:18:38 +0200 Subject: [PATCH 24/40] Updated SolidFill tests to cover all possible Blending-Composition combinations, reference images not in place yet --- .../Drawing/SolidFillBlendedShapesTests.cs | 72 ++++++++++++------- .../TestUtilities/TestImageExtensions.cs | 2 +- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index 6c0efce7a1..3686cceb6c 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -15,14 +15,26 @@ namespace SixLabors.ImageSharp.Tests.Drawing [GroupOutput("Drawing")] public class SolidFillBlendedShapesTests { - public static IEnumerable modes = - ((PixelColorBlendingMode[])Enum.GetValues(typeof(PixelColorBlendingMode))).Select(x => new object[] { x }); + public static IEnumerable modes = GetAllModeCombinations(); + + private static IEnumerable GetAllModeCombinations() + { + foreach (var blending in Enum.GetValues(typeof(PixelColorBlendingMode))) + { + foreach (var composition in Enum.GetValues(typeof(PixelAlphaCompositionMode))) + { + yield return new object[] { blending, composition }; + } + } + } + [Theory] [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] public void _1DarkBlueRect_2BlendHotPinkRect( TestImageProvider provider, - PixelColorBlendingMode mode) + PixelColorBlendingMode blending, + PixelAlphaCompositionMode composition) where TPixel : struct, IPixel { using (Image img = provider.GetImage()) @@ -34,12 +46,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) ) - .Fill(new GraphicsOptions(true) { ColorBlendingMode = mode }, + .Fill(new GraphicsOptions(true) { ColorBlendingMode = blending }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) ); - VerifyImage(provider, mode, img); + VerifyImage(provider, blending, composition, img); } } @@ -47,7 +59,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] public void _1DarkBlueRect_2BlendHotPinkRect_3BlendTransparentEllipse( TestImageProvider provider, - PixelColorBlendingMode mode) + PixelColorBlendingMode blending, + PixelAlphaCompositionMode composition) where TPixel : struct, IPixel { using (Image img = provider.GetImage()) @@ -60,17 +73,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = blending }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = blending }, NamedColors.Transparent, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) ); - VerifyImage(provider, mode, img); + VerifyImage(provider, blending, composition, img); } } @@ -78,7 +91,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] public void _1DarkBlueRect_2BlendHotPinkRect_3BlendSemiTransparentRedEllipse( TestImageProvider provider, - PixelColorBlendingMode mode) + PixelColorBlendingMode blending, + PixelAlphaCompositionMode composition) where TPixel : struct, IPixel { using (Image img = provider.GetImage()) @@ -91,7 +105,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = blending }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); var c = NamedColors.Red.ToVector4(); @@ -101,18 +115,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = mode }, + new GraphicsOptions(true) { ColorBlendingMode = blending }, pixel, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) ); - VerifyImage(provider, mode, img); ; + VerifyImage(provider, blending, composition, img); ; } } [Theory] [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] - public void _1DarkBlueRect_2BlendBlackEllipse(TestImageProvider provider, PixelColorBlendingMode mode) + public void _1DarkBlueRect_2BlendBlackEllipse( + TestImageProvider provider, + PixelColorBlendingMode blending, + PixelAlphaCompositionMode composition) where TPixel : struct, IPixel { using(Image dstImg = provider.GetImage(), srcImg = provider.GetImage()) @@ -131,28 +148,35 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); dstImg.Mutate( - x => x.DrawImage(srcImg, new GraphicsOptions(true) { ColorBlendingMode = mode }) + x => x.DrawImage(srcImg, new GraphicsOptions(true) { ColorBlendingMode = blending }) ); - VerifyImage(provider, mode, dstImg); + VerifyImage(provider, blending, composition, dstImg); } } - private static void VerifyImage(TestImageProvider provider, PixelColorBlendingMode mode, Image img) + private static void VerifyImage(TestImageProvider provider, PixelColorBlendingMode blending, PixelAlphaCompositionMode composition, Image img) where TPixel : struct, IPixel { img.DebugSave( provider, - new { mode }, + new { blending }, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); - var comparer = ImageComparer.TolerantPercentage(0.01f, 3); - img.CompareFirstFrameToReferenceOutput(comparer, - provider, - new { mode }, - appendPixelTypeToFileName: false, - appendSourceFileOrDescription: false); + try + { + var comparer = ImageComparer.TolerantPercentage(0.01f, 3); + img.CompareFirstFrameToReferenceOutput(comparer, + provider, + new { blending }, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + } + catch(System.IO.FileNotFoundException) + { + // temporary hack until reference images are in place. + } } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 6880486635..a935873670 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -365,7 +365,7 @@ namespace SixLabors.ImageSharp.Tests if (!File.Exists(referenceOutputFile)) { - throw new Exception("Reference output file missing: " + referenceOutputFile); + throw new System.IO.FileNotFoundException("Reference output file missing: " + referenceOutputFile, referenceOutputFile); } IImageDecoder decoder = TestEnvironment.GetReferenceDecoder(referenceOutputFile); From 55cc1350d01e3cff3b88f0a0c9802c57898cb089 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 22 Aug 2018 13:20:15 +0200 Subject: [PATCH 25/40] Fixing SolidFill tests again... --- .../Drawing/SolidFillBlendedShapesTests.cs | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index 3686cceb6c..3a572e29dc 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -21,10 +21,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing { foreach (var blending in Enum.GetValues(typeof(PixelColorBlendingMode))) { + // until reference images are in place, we will only test SrcOver + yield return new object[] { blending, PixelAlphaCompositionMode.SrcOver }; + + /* foreach (var composition in Enum.GetValues(typeof(PixelAlphaCompositionMode))) { yield return new object[] { blending, composition }; - } + }*/ } } @@ -46,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) ) - .Fill(new GraphicsOptions(true) { ColorBlendingMode = blending }, + .Fill(new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode=composition }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) ); @@ -73,12 +77,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = blending }, + new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = blending }, + new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, NamedColors.Transparent, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) ); @@ -105,7 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = blending }, + new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, NamedColors.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); var c = NamedColors.Red.ToVector4(); @@ -115,7 +119,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing img.Mutate( x => x.Fill( - new GraphicsOptions(true) { ColorBlendingMode = blending }, + new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, pixel, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) ); @@ -148,14 +152,18 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); dstImg.Mutate( - x => x.DrawImage(srcImg, new GraphicsOptions(true) { ColorBlendingMode = blending }) + x => x.DrawImage(srcImg, new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition }) ); VerifyImage(provider, blending, composition, dstImg); } } - private static void VerifyImage(TestImageProvider provider, PixelColorBlendingMode blending, PixelAlphaCompositionMode composition, Image img) + private static void VerifyImage( + TestImageProvider provider, + PixelColorBlendingMode blending, + PixelAlphaCompositionMode composition, + Image img) where TPixel : struct, IPixel { img.DebugSave( @@ -163,20 +171,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing new { blending }, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); - - try - { - var comparer = ImageComparer.TolerantPercentage(0.01f, 3); - img.CompareFirstFrameToReferenceOutput(comparer, - provider, - new { blending }, - appendPixelTypeToFileName: false, - appendSourceFileOrDescription: false); - } - catch(System.IO.FileNotFoundException) - { - // temporary hack until reference images are in place. - } + + var comparer = ImageComparer.TolerantPercentage(0.01f, 3); + img.CompareFirstFrameToReferenceOutput(comparer, + provider, + new { blending }, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); } } } \ No newline at end of file From 0ef96379e754701eb153565edb78c9504ffb6891 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 22 Aug 2018 14:57:45 +0200 Subject: [PATCH 26/40] fixed argument name to help reflection match the file names --- .../ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index 3a572e29dc..92cfc24343 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -161,21 +161,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing private static void VerifyImage( TestImageProvider provider, - PixelColorBlendingMode blending, + PixelColorBlendingMode mode, PixelAlphaCompositionMode composition, Image img) where TPixel : struct, IPixel { img.DebugSave( provider, - new { blending }, + new { mode }, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); var comparer = ImageComparer.TolerantPercentage(0.01f, 3); img.CompareFirstFrameToReferenceOutput(comparer, provider, - new { blending }, + new { mode }, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); } From d4ca89027bf7e46568857c315608f07d4ae39b54 Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Wed, 22 Aug 2018 16:26:52 +0200 Subject: [PATCH 27/40] Refactored IsSolidBrushWithoutBlending into GraphicsOptions so it can be called from more places, and also allows for specific tests. --- .../Processors/Drawing/FillProcessor.cs | 23 +---- src/ImageSharp/GraphicsOptions.cs | 89 +++++++++++++++++++ .../PixelFormats/PixelOperationsTests.cs | 11 +++ 3 files changed, 101 insertions(+), 22 deletions(-) diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs index 7311a53da7..3285e75a7b 100644 --- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs @@ -109,28 +109,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing return false; } - if (this.options.ColorBlendingMode != PixelColorBlendingMode.Normal) - { - return false; - } - - if (this.options.AlphaCompositionMode != PixelAlphaCompositionMode.SrcOver && - this.options.AlphaCompositionMode != PixelAlphaCompositionMode.Src) - { - return false; - } - - if (this.options.BlendPercentage != 1f) - { - return false; - } - - if (solidBrush.Color.ToVector4().W != 1f) - { - return false; - } - - return true; + return this.options.IsOpaqueColorWithoutBlending(solidBrush.Color); } } } \ No newline at end of file diff --git a/src/ImageSharp/GraphicsOptions.cs b/src/ImageSharp/GraphicsOptions.cs index 260fc2d75e..2d20c17732 100644 --- a/src/ImageSharp/GraphicsOptions.cs +++ b/src/ImageSharp/GraphicsOptions.cs @@ -36,6 +36,57 @@ namespace SixLabors.ImageSharp this.blendPercentage = 1; this.antialiasSubpixelDepth = 16; this.antialias = enableAntialiasing; + } + + /// + /// Initializes a new instance of the struct. + /// + /// If set to true [enable antialiasing]. + /// blending percentage to apply to the drawing operation + public GraphicsOptions(bool enableAntialiasing, float opacity) + { + Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); + + this.colorBlendingMode = PixelColorBlendingMode.Normal; + this.alphaCompositionMode = PixelAlphaCompositionMode.SrcOver; + this.blendPercentage = opacity; + this.antialiasSubpixelDepth = 16; + this.antialias = enableAntialiasing; + } + + /// + /// Initializes a new instance of the struct. + /// + /// If set to true [enable antialiasing]. + /// blending percentage to apply to the drawing operation + /// color blending mode to apply to the drawing operation + public GraphicsOptions(bool enableAntialiasing, PixelColorBlendingMode blending, float opacity) + { + Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); + + this.colorBlendingMode = blending; + this.alphaCompositionMode = PixelAlphaCompositionMode.SrcOver; + this.blendPercentage = opacity; + this.antialiasSubpixelDepth = 16; + this.antialias = enableAntialiasing; + } + + /// + /// Initializes a new instance of the struct. + /// + /// If set to true [enable antialiasing]. + /// blending percentage to apply to the drawing operation + /// color blending mode to apply to the drawing operation + /// alpha composition mode to apply to the drawing operation + public GraphicsOptions(bool enableAntialiasing, PixelColorBlendingMode blending, PixelAlphaCompositionMode composition, float opacity) + { + Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); + + this.colorBlendingMode = blending; + this.alphaCompositionMode = composition; + this.blendPercentage = opacity; + this.antialiasSubpixelDepth = 16; + this.antialias = enableAntialiasing; } /// @@ -85,6 +136,44 @@ namespace SixLabors.ImageSharp { get => this.alphaCompositionMode; set => this.alphaCompositionMode = value; + } + + /// + /// Evaluates if a given SOURCE color can completely replace a BACKDROP color given the current blending and composition settings. + /// + /// The pixel format + /// the color + /// true if the color can be considered opaque + /// + /// Blending and composition is an expensive operation, in some cases, like + /// filling with a solid color, the blending can be avoided by a plain color replacement. + /// This method can be useful for such processors to select the fast path. + /// + internal bool IsOpaqueColorWithoutBlending(TPixel color) + where TPixel : struct, IPixel + { + if (this.ColorBlendingMode != PixelColorBlendingMode.Normal) + { + return false; + } + + if (this.AlphaCompositionMode != PixelAlphaCompositionMode.SrcOver && + this.AlphaCompositionMode != PixelAlphaCompositionMode.Src) + { + return false; + } + + if (this.BlendPercentage != 1f) + { + return false; + } + + if (color.ToVector4().W != 1f) + { + return false; + } + + return true; } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs index e084379ba4..9e41fd94f3 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs @@ -88,6 +88,17 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats where TPixel : struct, IPixel { Assert.NotNull(PixelOperations.Instance); + } + + [Fact] + public void IsOpaqueColor() + { + Assert.True(new GraphicsOptions(true).IsOpaqueColorWithoutBlending(ImageSharp.PixelFormats.Rgba32.Red)); + + Assert.False(new GraphicsOptions(true, 0.5f).IsOpaqueColorWithoutBlending(ImageSharp.PixelFormats.Rgba32.Red)); + Assert.False(new GraphicsOptions(true).IsOpaqueColorWithoutBlending(ImageSharp.PixelFormats.Rgba32.Transparent)); + Assert.False(new GraphicsOptions(true, PixelColorBlendingMode.Lighten, 1).IsOpaqueColorWithoutBlending(ImageSharp.PixelFormats.Rgba32.Red)); + Assert.False(new GraphicsOptions(true, PixelColorBlendingMode.Normal,PixelAlphaCompositionMode.DestOver, 1).IsOpaqueColorWithoutBlending(ImageSharp.PixelFormats.Rgba32.Red)); } } From afec8c65ba1cc41201d17ffae067d66e9deb4362 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 22 Aug 2018 14:39:09 -0700 Subject: [PATCH 28/40] Update dotnet SDK --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5a146cea6e..2515ca82a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 2.1.300 + dotnet: 2.1.401 mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 From bddacf1cecd348bd4b1982dae522685339472214 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 22 Aug 2018 14:39:24 -0700 Subject: [PATCH 29/40] Drop netcoreapp2.0 test target --- appveyor.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5d84e6cea3..fccac0c44d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,9 +12,6 @@ environment: - target_framework: netcoreapp2.1 is_32bit: True - - target_framework: netcoreapp2.0 - is_32bit: False - - target_framework: net471 is_32bit: False @@ -27,8 +24,6 @@ environment: - target_framework: net462 is_32bit: True - #- target_framework: netcoreapp2.0 # As far as I understand, 32 bit test execution is not supported by "dotnet xunit" - # is_32bit: True #- target_framework: mono # is_32bit: False #- target_framework: mono From 0954df11b078be6bf92ecdeb30aa513740490631 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 22 Aug 2018 14:39:39 -0700 Subject: [PATCH 30/40] Drop netcoreapp2.0 build target --- tests/ImageSharp.Tests/ImageSharp.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index d153ecf50f..38a9e27002 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -1,8 +1,8 @@  - net471;netcoreapp2.0;netcoreapp2.1;net47;net462 + net471;netcoreapp2.1;net47;net462 True - 7.2 + 7.3 full portable True From caaedc19da4a3126a01a54dee277b0bea233a31e Mon Sep 17 00:00:00 2001 From: Vicente Penades Date: Thu, 23 Aug 2018 12:26:24 +0200 Subject: [PATCH 31/40] SolidFillBlendedShapesTests now tests all composition/blending combinations. --- .../Drawing/SolidFillBlendedShapesTests.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs index 92cfc24343..a8fb187ced 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs @@ -19,16 +19,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing private static IEnumerable GetAllModeCombinations() { - foreach (var blending in Enum.GetValues(typeof(PixelColorBlendingMode))) + foreach (var composition in Enum.GetValues(typeof(PixelAlphaCompositionMode))) { - // until reference images are in place, we will only test SrcOver - yield return new object[] { blending, PixelAlphaCompositionMode.SrcOver }; - - /* - foreach (var composition in Enum.GetValues(typeof(PixelAlphaCompositionMode))) + foreach (var blending in Enum.GetValues(typeof(PixelColorBlendingMode))) { yield return new object[] { blending, composition }; - }*/ + } } } @@ -161,21 +157,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing private static void VerifyImage( TestImageProvider provider, - PixelColorBlendingMode mode, + PixelColorBlendingMode blending, PixelAlphaCompositionMode composition, Image img) where TPixel : struct, IPixel { img.DebugSave( provider, - new { mode }, + new { composition, blending }, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); var comparer = ImageComparer.TolerantPercentage(0.01f, 3); img.CompareFirstFrameToReferenceOutput(comparer, provider, - new { mode }, + new { composition, blending }, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); } From e7a701f85e7e9dd0a1a81f90d630dd7fa4cb6cfc Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 23 Aug 2018 07:06:12 -0700 Subject: [PATCH 32/40] Drop net47 from test library --- tests/ImageSharp.Tests/ImageSharp.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 38a9e27002..5ef8f0111f 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -1,6 +1,6 @@  - net471;netcoreapp2.1;net47;net462 + net462;net471;netcoreapp2.1 True 7.3 full From 90fbef6b172d9e5d2a76a9664d5945b689451ae0 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 23 Aug 2018 07:15:05 -0700 Subject: [PATCH 33/40] Add run-tests.ps1 to Solution --- ImageSharp.sln | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ImageSharp.sln b/ImageSharp.sln index 3ff5b09d41..0291d9f93a 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -1,7 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.3 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}" @@ -19,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt NuGet.config = NuGet.config .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md README.md = README.md + run-tests.ps1 = run-tests.ps1 EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{815C0625-CD3D-440F-9F80-2D83856AB7AE}" @@ -46,9 +46,6 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{561B880A-D9EE-44EF-90F5-817C54A9D9AB}" EndProject Global - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -133,4 +130,7 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5F8B9D1F-CD8B-4CC5-8216-D531E25BD795} EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal From 29fc3c2a8209743b5184272edacce7383daac9f0 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 23 Aug 2018 07:15:18 -0700 Subject: [PATCH 34/40] Update run-tests.ps1 to use .NETCORE2.1 --- run-tests.ps1 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/run-tests.ps1 b/run-tests.ps1 index 3218d9d679..4aeaa14908 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -41,8 +41,8 @@ function CheckSubmoduleStatus() { } -if ( ($targetFramework -eq "netcoreapp2.0") -and ($env:CI -eq "True") -and ($is32Bit -ne "True")) { - # We execute CodeCoverage.cmd only for one specific job on CI (netcoreapp2.0 + 64bit ) +if ( ($targetFramework -eq "netcoreapp2.1") -and ($env:CI -eq "True") -and ($is32Bit -ne "True")) { + # We execute CodeCoverage.cmd only for one specific job on CI (netcoreapp2.1 + 64bit ) $testRunnerCmd = ".\tests\CodeCoverage\CodeCoverage.cmd" } elseif ($targetFramework -eq "mono") { @@ -70,11 +70,6 @@ else { cd .\tests\ImageSharp.Tests $xunitArgs = "-nobuild -c Release -framework $targetFramework" - if ($targetFramework -eq "netcoreapp2.0") { - # There were issues matching the correct installed runtime if we do not specify it explicitly: - $xunitArgs += " --fx-version 2.0.0" - } - if ($targetFramework -eq "netcoreapp2.1") { # There were issues matching the correct installed runtime if we do not specify it explicitly: $xunitArgs += " --fx-version 2.1.0" From 299a8c2bafc768338d08a3ce9e8592074a88f584 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 23 Aug 2018 07:27:56 -0700 Subject: [PATCH 35/40] Update CodeCoverage to use .NETCORE2.1 --- tests/CodeCoverage/CodeCoverage.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index f0ed3da1bf..01e342b3d2 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -12,7 +12,7 @@ dotnet restore ImageSharp.sln rem Clean the solution to force a rebuild with /p:codecov=true dotnet clean ImageSharp.sln -c Release rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f netcoreapp2.0 /p:codecov=true" -register:user -threshold:10 -oldStyle -safemode:off -output:.\ImageSharp.Coverage.xml -hideskipped:All -returntargetcode -filter:"+[SixLabors.ImageSharp*]*" +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f netcoreapp2.1 /p:codecov=true" -register:user -threshold:10 -oldStyle -safemode:off -output:.\ImageSharp.Coverage.xml -hideskipped:All -returntargetcode -filter:"+[SixLabors.ImageSharp*]*" if %errorlevel% neq 0 exit /b %errorlevel% From d9e86a8e0509923958baed136c994bfde1267607 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 23 Aug 2018 07:33:26 -0700 Subject: [PATCH 36/40] Update manual build nstructions in README --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b54a9b2075..a420c07c8e 100644 --- a/README.md +++ b/README.md @@ -117,12 +117,9 @@ For more examples check out: If you prefer, you can compile ImageSharp yourself (please do and help!) -- Using [Visual Studio 2017 Preview](https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-preview-relnotes) +- Using [Visual Studio 2017](https://visualstudio.microsoft.com/vs/) - Make sure you have the latest version installed - - Make sure you have [the newest 2.1 RC1 SDK installed](https://www.microsoft.com/net/core#windows) - -- Using [Visual Studio 2017](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes) - - If you are unable and/or don't want to build ImageSharp.Tests against 2.1 RC, remove the `netcoreapp2.1` target [from TargetFrameworks](https://github.com/SixLabors/ImageSharp/blob/master/tests/ImageSharp.Tests/ImageSharp.Tests.csproj#L3) locally + - Make sure you have [the .NET Core 2.1 SDK](https://www.microsoft.com/net/core#windows) installed Alternatively, you can work from command line and/or with a lightweight editor on **both Linux/Unix and Windows**: From 4083b90a20dff89bb2f7141c34ce07f8601176bd Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 23 Aug 2018 19:18:36 +0100 Subject: [PATCH 37/40] Update reference images --- tests/Images/External | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Images/External b/tests/Images/External index 825220cdc4..6a43d335f2 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 825220cdc4e9d1b4b3b474c63139e18e1cdb800e +Subproject commit 6a43d335f216d6325a6a9fd8d35942ade12b7c7b From 2d63e31b489d943838e99e6be5c446c3543d5b14 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 23 Aug 2018 21:09:50 +0100 Subject: [PATCH 38/40] Add image blending tests to match the SVG spec examples --- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 53 ++++++++++++++++-- tests/ImageSharp.Tests/TestImages.cs | 3 + tests/Images/External | 2 +- tests/Images/Input/Png/ducky.png | Bin 0 -> 40960 bytes tests/Images/Input/Png/rainbow.png | Bin 0 -> 1447 bytes 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 tests/Images/Input/Png/ducky.png create mode 100644 tests/Images/Input/Png/rainbow.png diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 740b30a8c3..496692d969 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -5,14 +5,14 @@ using System; using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Processors.Transforms; +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Processors.Transforms; - + [GroupOutput("Drawing")] public class DrawImageTest : FileTestBase { private const PixelTypes PixelTypes = Tests.PixelTypes.Rgba32; @@ -41,11 +41,32 @@ namespace SixLabors.ImageSharp.Tests using (var blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes)) { blend.Mutate(x => x.Resize(image.Width / 2, image.Height / 2)); - image.Mutate(x => x.DrawImage(blend, new Point(image.Width / 4, image.Height / 4), mode, .75f) ); + image.Mutate(x => x.DrawImage(blend, new Point(image.Width / 4, image.Height / 4), mode, .75f)); image.DebugSave(provider, new { mode }); } } + [Theory] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Normal)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Multiply)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Add)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Subtract)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Screen)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Darken)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Lighten)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.Overlay)] + [WithFile(TestImages.Png.Rainbow, PixelTypes, PixelColorBlendingMode.HardLight)] + public void ImageBlendingMatchesSvgSpecExamples(TestImageProvider provider, PixelColorBlendingMode mode) + where TPixel : struct, IPixel + { + using (Image background = provider.GetImage()) + using (var source = Image.Load(TestFile.Create(TestImages.Png.Ducky).Bytes)) + { + background.Mutate(x => x.DrawImage(source, mode, 1F)); + VerifyImage(provider, mode, background); + } + } + [Theory] [WithFileCollection(nameof(TestFiles), PixelTypes, PixelColorBlendingMode.Normal)] public void ImageShouldDrawTransformedImage(TestImageProvider provider, PixelColorBlendingMode mode) @@ -84,7 +105,7 @@ namespace SixLabors.ImageSharp.Tests { overlay.Mutate(x => x.Fill(Rgba32.Black)); - int xy = -25; + const int xy = -25; Rgba32 backgroundPixel = background[0, 0]; Rgba32 overlayPixel = overlay[Math.Abs(xy) + 1, Math.Abs(xy) + 1]; @@ -106,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests { overlay.Mutate(x => x.Fill(Rgba32.Black)); - int xy = 25; + const int xy = 25; Rgba32 backgroundPixel = background[xy - 1, xy - 1]; Rgba32 overlayPixel = overlay[0, 0]; @@ -118,5 +139,25 @@ namespace SixLabors.ImageSharp.Tests background.DebugSave(provider, testOutputDetails: "Positive"); } } + + private static void VerifyImage( + TestImageProvider provider, + PixelColorBlendingMode mode, + Image img) + where TPixel : struct, IPixel + { + img.DebugSave( + provider, + new { mode }, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + var comparer = ImageComparer.TolerantPercentage(0.01F, 3); + img.CompareFirstFrameToReferenceOutput(comparer, + provider, + new { mode }, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 5eb70117e3..1ee3f96757 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -68,6 +68,9 @@ namespace SixLabors.ImageSharp.Tests public const string Ratio1x4 = "Png/ratio-1x4.png"; public const string Ratio4x1 = "Png/ratio-4x1.png"; + public const string Ducky = "Png/ducky.png"; + public const string Rainbow = "Png/rainbow.png"; + public static class Bad { // Odd chunk lengths diff --git a/tests/Images/External b/tests/Images/External index 6a43d335f2..fcf311bf15 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 6a43d335f216d6325a6a9fd8d35942ade12b7c7b +Subproject commit fcf311bf15bea061e552e4cc357cafe2d4f4bd70 diff --git a/tests/Images/Input/Png/ducky.png b/tests/Images/Input/Png/ducky.png new file mode 100644 index 0000000000000000000000000000000000000000..e67e720eaf3395343845b38beb95ea3c9b8d049f GIT binary patch literal 40960 zcmafZWmH^Euyko3pju7b^fjb|fd&TT^ohA2QwT?N{)N4OTsJy|WK6>z`ySWtL84 zN(YC*$yHBT2#X~pnfXyxbqM@hm0DY}9urry4v89>j-60SlgU|n@moz**WK0C({`2f zY2#h{(@FQVJ^>)Hj5RF{Q2{1?9OoiTF#8ZILCxa?0EQtq1=9l*wWT{u>im&0$0mM7 zwb#IPo!`OOkO2tP436s0eh3${cJ^OrShESsOM`~(_8L1 z*a#kEsVr;re>27Ib}UO=;9&;=pBOX7Z03w+)#oz0NCEig&w3pH{?1BCwQx1JG;wip za=cWizIk3d%df6T`4Qc>+hA6|eLJmvo+SpDPDa}|UVme*K?P4S14h@L%;)$3;Nl<7 zWJ|prKqW!eXjrk1n0i-j?NqF^K@Mz!8{mryq_?29$A((?EbeN?i2qX2>?@e1hJ=xs zMrpLnrkGQYv|}p|a!-Nu>Pe0$mhFR)H;5w@9$ory%32_Ef?4>#Hk3hO)?jnRRBeVz~=P@_dSmwsz}&ACKwZo zxbQ3CNAw|tOPRuWpYXUUnXmDv#V~eK9SOoapE$lwf}GU|aS^0shzh@`<^E8`MQcWE zCf5qBkS3G%%=c5{RkQe^H!s6QR2{V_vy$IEgLMG!f!~2?6yhY_TEtrDTtqul%T9>? zp(v()z{mU}yIgv6I`*WnBFP@9H6~|l#-Mrqm2O}a*&@Zn5Nch-ABGdP6TK5mFW4tU znW6H{Ntd%WI#OU-TxB0we@_30txv9KKJ;Cm))CL+Y_{DmO75itcwavU!S;&Af3n3n zL8c6+9{40qQ;_14Z~?wZl%=k~s*VnkWO1dcPxSfjlffq)ppZy;m|!UTo0`%N=@9df z^pNF{CPQ)Yqd;QODC`x68|MS;1J*+fywrf~fI=v9y;z}ip@g~YzjkV4b&Xj$w`R*4 z%ZMG6vExKebsu_WdII{=dB1Yv@+5UCb@y3ZI}N+wL(N0%L#kPw;xfxR4t)+MjxQOo z8DSg*mOtr{rE>m>o2l_=5Wf$^(L~qEI+9W<#MkI8!ceubva(DYiyX6_SRBnwB`cxi zV$LLBj?k7DP$ntuHYjWwvO}>MgVIzhM5azoFsHaDZ;#@QHIJ>O`qQeUc_*o)ZqRJd zzp28MkABu)3D3~a5<(Qro$ojFSp7ezfZ}s<;~~7%&<-RBD$k zCbwj_q6Im0t5XKVy{vHr>74tbJm&AckhUlE*jPupj+$_<2*4Ax9^XL2u z*GALIjW?$dXR2PzGP8R_d*=hZys>NT~UiP5naQ$iJ|X6q=2O1-HNQ zgA9umi}vASR`6`{glW~k7pE3Us#NrPo9mmf{*bml{92shS%yZP&byuNX79#KjGWG& zqY4n4^yX8*DO3N$A(kw zA8W{Kq-x-tIGhTc7M$W%7gljr4OVT0m;@L7vacomAAQcQNH5i|%ze52fB6~s)?T08 zQa->xX+8-;7p`}oyq@}l)`L1<$g5@y`we~{0-w8|y`MzTXE1beE-XNw*g$okF683v zRE(c_%B+v2qnC934; zfY|4Q?kXE&zW zU0U*A7c)AQ#JzrV)a_&&o_9yDNib| zPi+}tbYi5*rR}E1oI_XE)Rb9S8G@T>t*2AITH$&6qxeVo%P`OPKT@8L<$lM_cQ1Mf*e4zl2%*HmN@xfn1LVG3SQ8$M)P`s-26P@hIR%!bft0 zD4t#}T=TYtXbEZcgJ+%#T5@KM=V3f|JSM$9dBu83d40&e5ni5iTv>Z9`W**RF3+vt zXZG*7LElpB&rq>(pPtH55aD$f-g@>?QJj83!y<6HMTBA)-n9EXBtDg(1u6&Hu&x*h zdk*i7k5zuJ%voZp^}I2-X??T2)OZ5#ijH_z9vksiIeP$EC%mrC&dH3?0n96HXKtSv_|E0H6B529t&N6Zicik%yG7hlaDY zhqsxV6~M*J&dGzt$;t!7#lptI!F~y{O922<(B&k>G<}RuyOGk#hEsZi&nIoU5~ca~ z6_pXcz#-avAzd_c%wDw1!Qq1p^T3A1IQ9`*xM6%nmP8y@%PvMCwoAUIQ<)MoJ9_Kh z*KRi8=oC2*?sh@H1% zmvHvz^1W!`d5bSWj*+YP*$5*Aspn~jf8)84w+{5g)BDb#ZL3F&adAV$_VBUuQBdb{ zWXHncY_iMw)Tk&(FG%K%aY=*=+ORe^@`0({+wy#zKl%$VbHbK)9{KFx7;hVY^kfVW z{j78MQp|!!i2a7yfP(z_R0#;p?%6G<%KUXli*fG5v{hj}ZcV*PK2EEtoW@@5TIy}4 z?>th3(z?4YdG}WUr~3G8iup$u?cH8;@X=F9jQ3r3ANy=wF(k>{C0f#L!=1|CIk0LY z*)i@WXro2Oy><;MnHPE*M{Q6^uHtc?m*awztJoH%GN!3rDOh|pvzp9)4mw6o3=FmE z?OU!)yzCZ*(`+z`Lrxb+g7B^`TWAcEb=OqhYn)k0^-_E`pUP(Bd?|nT?8P*<=Buym zSqsvmQQL97@y7b4&y<1y`GoBs0Z!KwFewFQU5Ab3G>zdP8j8+a7b~~p&!#Hl<9WgA z+x_B`_>)a0F*v$V%e+l?UHE8mp4Q#mq2IUOmQJ;8RQs_FBG693^V9?hE5dI`q6WSuLMmOs1ibzF(ucJv6^DitD8GZ-SE4#$Q;5O11f3~|K0gCC&PG{=|=;o@V_h}>jz7saOsA((^(6A_l zvefctB{AF~Ey6WxN`dHFw{EGfkHOH71&KAt z#Gl|(3!LFm2P>26U5`{<4QyBk+H5&vhrQU9y*sv71R%3;QeNaO^84;FurW~}#ekH` z8^pwsa$%YePe#a=j}E3BIUj--E9*PZr(ulJ>tO;H?tXD#psE9u=$Yx`w134dNi8-8 zV|tN+c-7jP_bF*E)Dup<(Gmr)*BqRbPMF%*pZ0y{q%khb{@V+0XLY;%^b+2}pYJ0B zIXQvxiZU*vAqHxwKqOET94sO=2T2-?bQzeBG~ZO8#(I1GbCZ*5BEFdULv-v?RAPLZ zV21tW#}FAQC_Tk86&_5Yqc_cJsQ|Xquk)m*v^S2Y%m@*sn>&&J0>E1i<=diUEgA5p z!~XncQUVdFT^hMOASgtF1k?wjVUwEaVkzymCuPw_Aq{G$M{)6?fgy)Oz{9c)x2fic zof~3D+4p$X&-|JaM~Y1id3P#>J=YQQ2Ptirk(D)9BN`;B~ zHFt%Ki5-Y52?of(RU0%Sp#16={V0mTKp`dtMNO0%M5+kkv9Wf&Nb<|#j zWrWug=3_np892K2Q3NQeim8_cZ2T*`2(v>}OCDON{{W#!{v?V)N3cvQ3T2>J4$K2l z&L@7Y>gN94{ZB`4*LN;b1r&EB!uX$iAL@3Y^g^wIf9^6~8nH(X((+Bh{&p!fcQh*^ z>|Q84A5mhWM{eHtgLsp1SUDg5b9JSo*e!+Wq8&_YcN-JljoTV=c7n4NZhH#SlC&|kiP7Qj^`U64|l zV!<;eW&kgnHNXfb+1weSX^h3BIk2n-CuZhi%GU)sXzKxrOhaMl%#7wGu4NyYzf)z; zxysGJgsTS4lT8t*}3pt_xZE7fGlLSr{?dh}L= z{XfSBOIYnTomAi58n$>_7p~}6?__)Y`Av)U$lbwq6`N1$_J#CW79bHH@1On=IeZYX zbB(Lt`dJNh$_Rkf6qUA>I*_J7ZkJ(4!M>7E$bigOt4LwF< zpHZGV46thsN+s_?9U`BzBaz-T<|O>?&w(W8hi}bmai3zZikaJywo8M;6$9+VNccuK2^-Hqb1ZO%3qoyNRFGnT9}9J8fL1-PK^`CTGT*~Pu=9`1ms~Lc z@7Q@*q`spvqt>ya&5Qs7+9Sy}s0cfBffpbpH1W`LET^ywxyEU2ZBwBI*jqT5I5UAGT{x|kHy!f^YU24#rQFyp{kW~ zqFf?*9Jr-=`#&ER97xcbo0LW+RO2h2N_EQu#VI_o;f1g1z1& z$lH0y-t;dZ#(n#I(KY525n8Rj5Qq$R2>VOk7nv<}q5Ej6UB!_BDU@LW(5+IIo6%SBL?3rk_bnMcK zemuvnkwjH@3Dex66;jCSybE1_-T&_(G6AmGD3bP^hJ0^+vZjeGAitgexdS|4sM2D8l1N-2%#8u7=47iiaw5GRHaw zg3>`KLI?OfYN(iv`P5)a(R7|$0H&h@KhjoGJ{zX$r#+-O56iy7ZHrQB(aP%vnN0*F zr9Miz+S11Ob&p4}fW#gx@E2UradL1na_oQ!3g+@Z2M!?q^U+QDE60DF?r0D?BGctM zLPgYhr>x^v6aMEjqFi{lU%37n;4+pJP%jA2<`P6?rfJznxvj@o`r%`X8HJfixPvH8 zveX=p$`f#;A(*O=4|ZsPDgTx~iau&;`BB_<4cZrhB8qCatto zs8#S{c^J+=f1G${?Sqv-1M;Kb?OfVKX3DOAAE@T17X4X73olS5#CF;WiZ0mpw(9Vi zML|`CH}(SorPVq{+o_GJ*lq~BmtX+qL$pvVEcNGDn2+0nRo-N`7i0V`GtVTCVka3@ zkd)w=&=UB-kvu%}gs|0YmlXNgi4qV^D3uB2V#9IL2>vsZzw4O0i308M;no5q(sv)@ z&y{GLmU>*#P2l|4q3jIv&_~(})LF5pU6^`O>Kf4cVRiDLK@uw}Hr$YS6(24PAuzQX zCprAZk7|{J=F-JQnCpCYXC;4#ln)*AQ8a*dD`=Mj(4gV+rPBy3E5<`FSDPHFNryx) zB~_CaYMAA6{YK?J{Vy-BW5^`-okhe_cnS0Dea(rp)}8ik#tnzSJZNB7OK@H4^HJ?n z^Yh5Ug2bc*LDpg)TwYZnl6#snka2-p2xxMgJt^@QAf?U=3cJw`SXnTjFdZ{VVjP~2L3r%c0YS|K`FhT=?_4*8nwW<#9l3vlbn!{^zt=GG`H#|9DFj31d{?kx06?BuP>*y-wb;!h1DaM!& zB`mWz7#1}2NIisz%z%A`2^=+}u+H#>08z1(AhU4TA^m(b<5*1i+InYL;*6hB#=arf z%1)Me^ocq9A3X8V-SUA%RpToB147SWmg)EyoaJHE&+v+66O+YfK)(kd)D>C~h_GA7hOvwJ-4V5%k0pNQTr5wH$_&J; z1B2P`DtiP2+M)12#{q>}jF6RoGDfRU4vr6-neUW#nW0esII(n}c9}F8{t4!j+@{I~bbm#*e@(L`WF+V!`hK2I_Zw7&yUDSNfo`rECrY>yI z7WF(6f^N z-i>aHgSGWt4Q*nLJO(~sxz^R+f|7>vTXKnhetP04`{AEKyYgjbxsk1H229NXII}r+ zi=4qp;5b#I^(rCZi2w!?>VT`<_~2Y;DLLS~pGz!k_zZ)3T&D&&J@lDe5cuJ~hY-MmDKR$;{!bWKA62v#s_BcB z6~6fRjZt)r%(Otb5TRxTb>;1l$yfVI_u7OA5m^L2C^E)C<>|Ok3mV2}6p5&2oth8s3gOTSFd0_2`+1<_Sx$uQ$T;fYbh&N-vUuHf)IDy!? zmL3hC*ZrHym((yv4dyNdWeA+Q#ddMH9$*#$WGtn~9_prAh~F3D%QwKGfdPVvG7Z-Z zclztBis6rrK*dgwPQ6QqG;MepCk_zf#~2eogPHI2e8o3DzsE-FSjyH2l`E&l&1mz{2F6QPlq;wd+X*Q>OT&xmhSjF?jP&#YT6&Nglehvy*7J)i{xvxm}aIEvN%o zqSqDJi@)xr%y5bf*a#jHX99lf@Am<~T~jW&n#yv6r#3<7peA))t3dM4`tcHbB#nBNvQ zBN&}NUmFIG%?=)0{m6E=@>)1C-VkQvT{fnIY$w?UP{qRs0*@&7_j6iW19~6=&R3Yc zW;Y;S>puWqzdxe9K|7$kCl#B{YH#Z5hcs2l4CF649y??N3@XLcw*SoZEe;YeI8XsV zcA44ux7CM^5#b3i4+E_(#PQ z#kguEubBuQJWCBcCC*Z{<|2buOop6uto&L!6HJ z+v0DJ`RwC`uops7%5zYaIKLp_rA@W%tPmX=MjGz984a;!e zjcuW0<4P*??jvQK4QNERT^1pBs;S3eNj!F9g+0khA+~9ZV0gp@G0v^$Dks&#{G$+x zZnf4U`nf$vjtVDPVHOuF8}e}%*$mGmpOotmH5L%neLcQU60YGNGAJR&*DO(hYwe3v zkTOtl0siQc|1mXelnDt7^ClwMft04+(r5xTcy0Tjg5>Fq{%!Fa;)6mOx$$wBJ4?H_ z_D1kBFK=VHG6pgz0OZ~)jt|=E4DPDAE~6N8-Ou5ejUkB$MfWI@LH9~Ca;qodZ_3N! zu+Hy)VZ&N8@=1Sa&SS~S?)K-S zq`?Q!s>)IVLS4qi8DOxIEh>LX_*nhNS==x)Jn_d>u|z578D1SrC*C|aY*OF+R*7D( z-uKgE-EIk^-&rR6Mdi3aEHTJU9Ka6}y^7%8^6FgQOxpAzw`BH?xWA#i@8u|~qu zHX67?Md3*Wxp7aD26}At6s8FQkU=;0GN`a17ywYgwj(BAlzo&N3|A*RI>y^X(U)H` zu3y>Y>@cnstNG1-1}M>sP8Qr_Wq*BMjG-R+%Pqifv=uenv7tJ1Bw&*b;kO`KeG>*) zS0oCQPrC-7l#`L-q7bFidE+@mbsD8NxttI?e5>d+jy!cogl^nQPI2{UD8Kg8X25|2 z{SiPn=^McdF5ZXyNvq-PgR2>3%5FBHCTQupqJf5-qku zq4bES}$K6kx&I(^J1P4o4%tgSY1=hW%wehak`v9q2Ev7J4Ap!%-sK~v}R zUFD+LC>2GxWVkF}ml(EabPNe*5BgWLZ8}IxYZ~`~A=|p8xy!xe>ZU563}3|OF9RX9 zY1hU{9uEz($6POr{EsniKKuex6mB0hhjBmAMIlXW&ibYPa0vc^YM`Td zf17douyos5v9n%#dy&Q_)Rl?^Sf+m$jn-$U7z0nJUfh0${XhcS225;gtj^NDZuVT& z-?d*W=WHqy@vi0wSv5V)%B-JiPj-$pJN9m9i6k_=na2yjkCfq|(iL(r;fRVc0|s)- z6Yayb8FI%R7uzo?@({^3jHQ(rQ#9>a+Y#Htvx9!sCZ3f$-?;Dwa*e!fUXgk)bh@qH zQk)&;K3k_UcJK`P4XMGBOT%M_!HR+-TvPh`-7nK2+4Fx&o04w6|&#Wv*+_ zeJ$1uEqB*!lwp?YZ=vUL0^%hy5wQXFy?^A}aOn5*=oJbZ$R; zSJkh2e(C8a$3+K7s@kqj#zFAQO;c@JfHuLcwmsnGDK(@?9A^jS#?xy z2+ZX0JAp|AzJN)D)2;WDf6H+C?f~uz&?4I)J^ZWHubwsBYyX~8<9v2Old$M;l2brr z!r*QxegJ}$S%-Ry@=CH@(53U^6wBi;yR!ek0)rtBX?M$S^L6LvIOq#*ipIz8vQtF3 z;nZZh`b)tRWNTO8(~giP8M)n1@XGc2KWD-{y;)U zGPCsIaAPC}m%0c7J8gQmb{FSa86-5NUknJxX9V;Qxa&Tzd4;9w6=LA(6M)!CeUCr> zbhqt->Dl4!Ccu5OpC@^yQ3TfRhLmY|E1r8=E!^ywxd8!N&ds7`!QWv?W6qg7e~~TU zeivv7j1_2bE)mc+*y(W4=GQSgiPaL?$uuTS@ta?(lwq4-SH%c%HE(1_;j8#vyv=h+ z7?U0gapOXc_1pBJLl_Yz$4QWw({H}XtUqhultvAODJ2|4f_jEM?RJy%Td z5BlI*=Vx))*F8-dl(nVR3K^kzr|uG^2K(^Qxdt4g!C;7~(}NYIx?tu%Exv>S5~~*; zX?n*D^;`mLd7u8<6UT#7kSC-1r|4{AzZu{2lwC@?=xjV1nB?lX>?2}@;O*Gc^xcl7 zwUZ9sjjdHElHpwq#7Jh$s^)grGT9p*0Y$ETm*fZ1R&pQP0PGHus+; zvk$J(ZuoWhL;qf{WoA9CkgQUP?wl;@MSVqvf0Ch;FLYzJFG`dQ!Z{w}Su6Erco>~J zBH_43t36D4je9({`Xd~;S)#@1#&Z>47@@cG@kbQtQV(~{1CsTpwGcfaqtn8>4(Nxu z)h)7KH!=s|V}1NMFJ@Mo(oFzjggU-H3UX<^EH^-Wvl&y}?hRl6kPvJJ20%26lqt2k zH-F%fLe3P*N1XWgwHGc7UR^R7v;4ma*c|!5Sr&_zV}&8v2GpUmMRvGSMYf|9MRt~3 z$aJW5zkF%kY(4ine&u5*!8iWE^rmXJl_Uzl&J2JV)bA1`UA$)D<7K>C{&CsdN^Nxc zp&NcQp9@r*W;S90H&yK?=#LUevEXJnxfx&ZaWRtyY45yBY1*pouWv@pR=eWTm3pM+ z$Bd(Cz~1O9>YRkS@}Rd6Yr;8Ae};142R=G3MXHu)ibWSS@Hb zap$hwYkRx@m*O;@ZWbyg`du*vM>@u3TL$Qz^z*w*l2*@k7yVi8dGAJb;DNl(!~P{A z#1nh`vM5%36Et)c4}rHU$!d6{SiLy<7770TIy&lI}{S;*sOw9PS>mgsE?N) z{|(|h^4V1Lm09cl{JIu;jX|>yYe{l+xzb;AHf&ep_rTP8`7p9N-Fw0A9g=K$bb#fA zZTdqnaFy_`bna8TbHF{>+44%zj+c;o_X_(Hn$xzCg%Up)P74{xsIStoiOlK*z~8%8 zrBZ>tPEdJ5Dp}ko`RL$0=0d}JYo!0q7YQE!_rN~kM0CvK{@2=R13lZLlu8~1U80I( znAgrET$19x_2<(s3M+u%-tVr=a+|e(_ipVke;9RvxkQAFF$ zz%9MGciPRtiA=Efd0J!oI*nDRYY}O`)JjXpb5F->n)FXsuonlO@tE%^nJ&i@UGI0B z{1dbWzLqLA{CQBga%un^EO_*9SEA&*#DdZ5SOk?@7n@QG?p1V|M~NlwcU7HgSHUop zieW)mekqfyab1ryTpQ?IEf|jL2>h1o(n&DsDX>57*10dT;B2X z8wl}hwvamZPc@8w(>KALU~2OC3pWSs$MLKr*y8E>uLh8{CTNW-+)K&-O#hrQEoP1T z=>+1XLJ{DxaZ|j)Ix_s8Iri2sJ_MmW(*C&o1qfHA?|YXW#n=dQ1r_QO{LmkplN%9ZMA`ptc7HlxIl8BQ!4}avTF4ENVC0DDvfS9msIZs zbkc&WSDsFg3>PelG&Up%Ku{hW#U~lLdy~&^eDIMBkNQ5zQsBCta>ye0?M(YjNSijQ zx~oDhnZq03LD6f&|Huu;8N5054p6)4lU(+TgPsf`sN{K%$Omr&VS!1#Xjz z*jlL9ityZsx)9S)?P<--lQi9>-jzd>*+be6w!e;kmLyU3EewlxgmSY>Gs04 z=HG|?&R-Pw;FU|gg#(lO~c(Av7s$6-BhcWLk4>OkW^J|pRkFEsCf zEei=I&=&H1ZLQc-{M+apo9%5qd)jd+sN;H>WvJGRRpT?Gs>9`y&UnN*iFZSKi0UrW z7J8z_V;rB+@VrB}Y@3$X_cI;OGR8wHOr|~2b=zp!uB@HgCU0B*lai|xTx5I0SlHUn zJE(hS&%%V(Myi>ac8onVEY#vH23As4^F>_w$vq_GMSaS@ThYEjDgR4nVE)y&EvJ$0 z!PO~$={6(peOatT#E9-anOO1+QgSpoKGTauob@1BS?C#43iMnugJwU}BCr@lM0V_S z>OPk`vN1nx((tZwkYG&q2K-z1B@nDXFONQbve|887Rfu}3A*nN{kVI8pa=WWy~!Yj zkVG#?T{?qsKjtBMTVqbnF{|j*FD|j+yVvmG&$fY{6B)2w-Z0$Hwgsxlwp-`(eXoF$ zG)6jgY)Pl-xlSsl`#gLaFm4q5V3iDJos6l~$z-bq?6Mo5wAL=Ado1dS| z-fiG=!GSbT4j3|~N5Ti!uSy*M74R=1<~ofWSzB65Y%ae7zKBe{-M{R<3yG~E5Q4ku z-sixlykLdHp0b}5D_(QDt-BL>sSc$?086$ye+>GNQwNL(jm8croz@H<-$8hM>J?N3seBBX-+XdgJx75*fw-BPJ^<-M zk`Yu}-sC3`=AHCAcSbukSI*UKEme^d8A9r1VyAKv@LZl*eA}*4t47Ap$vOX;R3tfVuD7rp3pGGXhSK3GBY_IN(zkE>E_CMx?MMWH z_Yfpw-{aR8&M8+sljkS{Zren9DL{VR`HpRX7B(6<+qR0cf7hl#SzbwfOGnyKol(Ry-hfe;VPj#*@v+V=FL>Hbpf(lfO?HZjW|`h|S!z@&Rvi00 zB|Hdc6M+62IO+hN1i*@N#bKheojB4l*!^qfWswizDIyQo{+kw|O*eYZ;a%0+e!joj zG$gmL$<2s#=g3U@64HXFcjsB7$YO7hq5HRq+9GJM(3qE0SMWk{zh?5LvJ}$mY0LaL z5Oq{S;os)8C1AkVb1$sJcESaem1n+c{NxAF{M1eJDaTYl&J#dqkxeg!8lSA^W1S!F zYpgYDP|SoNgghbLS@^1+$}VB}Km@lId3Wn7(35cpm6d`b#|yz0%cC~DS51&-hQAZL z@;+nwpFv`-q7TDCCom#sgACYS1N8n>sAegpr&f!9bGyPuln3&P7uSA)trk7R<5q-Z!60J^u+SJCZZ8#ar;E;ckjieERlI;p& z;>vMWvdmxrVUx=Dz%n-ivJp{vdUWuvjhvmIyq+|=r^AL|pW{nwZYcF36g56@TndU7 z`{K42s1Am6yAKQ9%+KG%D^5nT{4p#nCa!C>fpi%^V=uKX){AT!UcCCsCiSrL{TGQd z$-VJDHm%axZ(|N;!lC5RpV-FiSBfp+%T6t0inU>AMVg1Rq=kdY1=Jb$pslw(x!p3cgHG zRAHcoN&qVYbU(?SNG+0M`+!sf0kOSI zZ}SqzM|09Gc(;#AOGn?8WX6-oWR_6A$IydTwU>F8y_|^&_yPo*J3Yl3dR~`>@0J8P zw={bzZ!TKVX=qH2f7d;aP%J+Vvyw7Qk{y42{NO$;5lL@IT%%7WliFy&s6Aew(JZW5 zJc--)o&dp^|LRK)R*TWh2!*pHR0&D2|I9K;ocouh3djZ<@o8^CJ(-&T-J`Q7E9J;C zd3#A#r~+Y(5?9hRpBzaQc!e3E*<`6VQs5SIQDdxMbyD)-2O_f$$1j1F!_q36C!0Lp zd6U@SzacIamAYG+WSJGLyCKgZ#Re-_7x}AZ*OZ~EpP8NR+Ec5!}uNA=4@XE4VU}6@jqsT3YlHa1}?p#T?4kw<5@)`R+WtfOojRV7Z1 zh1~$RV4iJlP{o^(=k=$!TgZDY*F@cuj7X;8=iSwcfo!$4h(Lrv5dBzsL5)WRh(EAS z@1dPxn)F0o1&galz5DQ?Nj}4Tw4M_|6){%$BZ9n(TjRVB_-7xWg|r{6Uk7y5pp!*s z(UUJx=bw?^rH=^pxGwWsN$PvX!9rl?D<WdiHwHF>_c4PWm;9gUeMD?s-nq*|4_kUl(KJP z$;wRN+E>fAwIEcO?tNN;PM^FKJ@O~bMn7$QZiAHVR(0->l|1Mb#chq2?-}va{_0F7 z5>7ZPlJvW0)A=m5nN4MDDXPJt-FHKF^tCRC_?&(snFD}6rNS4n4HpI(*|S3VBnC%F zCu0UH`h1ykUZtq$rGTTcYMwJ#_`Tj~xUJwUUvmqb{7;mr_^*;I4V~?H2@cz{*?6K` zg!VH2cxMy7VR4 zhM4K3b@2gMim7#T4O;Pj&Tezx##gLu=Fjp34lLGKl@1SqIpnXE1#VN>Cqg1GhlLGe z`(!kF!ouuG@zFK5ee^XR1HMkTZSICa8<$Q}i)?8dGFwZs{cd|8oy*b?r(Y3a#XR&8 zl)<31g0MQ#eB3>GGhFc(DWzgUJy;1!{QM#RlhgDuxxa7pP7Cq$PQycUM(aDAM(cKE zZQZ<|s=2@Ituus}#iiww3KtjB6O@3e%vZ^M(+U_+J7b-?Y5YsGl18B-FBHNa&h6bc z4*gMgp2>T{zqJyz0^8;XewOc1uoRjl@Yo7u|HP|4}uKHlJ0cYQTjtH?!l(DbjB9TmgT*sao7tsqY_`aLse zv}<+l+SvnDYJJNz>8Pj-K3MEMmZ-5EqG#!C9pDgC^LhlqS)J0r87(h|8C|l8ap~4! zs#~EUUZKYj0Ljf=>Z_t2@U>xz`$mb&x-8lZxUJg^k_85siMdyq`Cb%TcdE*r2sV_G z2d|@0qWSW~H?NU?M7|)wi)#KwBZWr|&WDXX4OS#wb90AQCHmvMUC1o2v>NlY2nGM? z^~8tfF6bryc4?Coty1D|XqHcKfv7UjNs@-%cbWRX2&N7XutKeTW##0heA@XodTIkX zTu=ILguQjvHdtSTl6$Svg#+%(_Ap3idQMi|*N%8icH~urR;tO}Dki3LD@Zq!d(*{p z@!WQHD=xoDXK(TJ>=!xRX>E9}h+I3@JU8)ngywE*Fsl|pIrNX2;5>X`93j3+nm?FI98h>``NXNMwq@j z-8maa+V|Z@I%xt+J_Qz2cO#(nS<35iSRzhp_H&F?PiF3*BITCG+p9Bp7g(r0(Ghcr z*L`qxn9?AG?uFF+iwQG)@C7Hr!lz#$h*NeSjXS4)AluqIYKyap^S(xmas5_Cm#lH$ zvMrP0G@|6@6`>4+x&G=zG5ua)YZjb*HTSyxS*GP+xVSPfR9tiahQzr4 znQ5XUHUcC_znYr80FW-?i<80*bY);c;}Sk7puC1YjH%JT>bFDSMwOo-3qmSKYz7RMZT7b^$!sD_McFCr{X$C?g$C(GJMH_Lt+2Wc@UdXIa)nhc z6YG-1ljkpq0b*>X;f%yl33(To+qNOx%R_|htoe#R(IIu8$3m? zJMA|W3oUe#-NuVwB=Uz1!ZpO$;SNsIp8S1)>})yqp6k_ZL)G&B+^r%=cojn zMd718=pKD-fPdTBCB(X~Q9XfVxYAL)pWR|5)Y8PN!sA^f?}76~!F*?5fce#BpU@r) zu1FwULsu270|yTm8`u-jyleJ^X@1B@{a6Z$C}#yHj!jqtnw)s2Z?1-4libQ?pos$j}65tT4RKh?j*{*i^8=z1JQqVOZU`)x(Wm(9(rxi*&tzPO0-B| z0%R>=Ff}Fc$)h)(JF6DQS0dMqe3#nnRwzh=*PswuV_Mp_nxkl}Iq1{{kHeoPAr*{n zr}GoDCGvEED;vlj#@krGFIAAwMY-8VWsv>-0+J1doD$oAOm$j~U05PQP(v{k_JPIi)HMc4`gD z6=2W){QEG3Qa3>O81dV*g~*A`0}@A7(SKRIIwfzX7BlJ$HSWmhIUP>>wLP2cwI!1H zcV1;Zwl()2@AAA-&N;RV4LZJPM6P(*M6S51yz2;YZ-X{}kd*F(6YI`-$bAgAMm+eZ z(T9&3cNJAW8FnYG9FWj=1*J?+UOGzm9CdQw4FE>W$`L6){HiP^hQSbLKp(!Kj1R$r zY)eAo2Cw#1X89BHGb+S z8D~sIiKGb}>CkzMb62?|Iwl_@JwB5k<&f#LDaG(S?p>Y8biHHv{+DX|H?%?(6<)vA zXY3Z^*Ghywn~JHX9D4=)$WIc4pWcmY*}><#)N1V*krb z;ojpf);@S0x?{Jj0Sn;HV9ug}LzLfyiN_VCmo0t5wjFp>v5s|jhyQ;7*FY%0#PsAi z%W3XSjB|fZjCOZqj&e^6jt$@F<@Wt9>GlbRy>eK4v>iC)z`HdL9M-&xS}+Y5nyx}Q zRF?fB(>?v=9CzQ9x$a)sL!av79{+3~H|LAJ-7{a!aW8(Whg*DgmRt2BK_XDfex7h^ zuTQx33gI@B+i0J=0PQXTa(}{A3lQG;!gmw-h9d9%;`K(v?|iT{f+MCJmT!baoScJB zz5qu&5ywtcjaPI0I3WKS9Kix0G4%*7SbqhG@(^A=&L_8dlV*#c=L4;~AL+4Z-@PMy zdzVNL40GmOnYnHH*%$15pzo|*kM!xK z0w99206_@70z9b@EER@5YKi^?_n^xA4307GPsx$)$*DtJT#me|5sp~xNRH`l@`VU2nrHHEZ-Nx zxub%FSEvXfBcSYgG}*js#^`stM7r}(S1*xlS}q@ekWg`9=N9zcNOe!+34 z;P_*5l$$L$)_pz4?fGre?Ewa#bMW_CY!{^mg#5z*!8DI)TDD4ln(1ZKzm(+h&qzf+-^V?t@NMBYdb$-?Wx0ayWw_NpNxC&skxGSIo9t~W z+OGiFCqQ_lzQ%`GyfcjVf<=JHu}}|`gW8yup%7M)cSK2ffJ5qGjv5Cft{$O`JAJTM zgCo8?Y|H+FaSR_`{ilE^523@5kkJ5nS%7GK{}YMs9gp;y`MM9YYM(!M^uC$Buh}!B z@5%#D4yxJpP|ndkkI6|bLCtjQzj?lUF=L!tbMB>X<$%-NqQn%pP=El+%N`c;lb|ZV zg0ci?P>&QasitB8A*=!p!m8V(P%{Nbg+ia*ze$=}?7B&zlWd2^Q3c@OKj^?fxf4+Q zIGu&t!%t5EBeul00GzS+~| zOGQe4A_ci71;}RQBOG&&0O1c=08-1#wgm{^QMB+%4rJd&S(u99O+m;z00i|wIS8$M zi&cQb03jE^VdHR6#-05{5dJd@>$8s&jeT+q)PrNvTE;nq5KG~oHTCM;2@`p@GWivc zpAcr%YJB&jnFqGd7&hFy%Ij;8_hue^Vc5G5KArR2!DmO+?0ahb(F3z{-2UlFcR
#N!+2sk6B{E=H;9&{j*Ruvns%aPl7A&PAsqpFn z+3kYk_8ueM(`OBKmEY;#RCm}dS~!LjLDIk<9( zR}?lqs$AoNPxNv3eLUAIi9#$va{tHsx<^0J*UkEj0QvXc?qva)_pKb4e|4r?{o{ly zmx8PpAX@|ouRrBY^ZNrJx(<9Mj&~FDR!RH97U327hjI^V(ghH~5jE)oh;Owb_P2lc zotSsvz`?--7{S3$1R)MYe499E82b*&5!3@ffFtA}Qnm;XTC(&z2(3^M5_Wq=i`J}1 z5=VAEIOfydWnMpntGqIM|GWX8JNUxj((0E_>8yTnq^o{9$5qcx+6%0!1;`=ULDii5 zAI@;wete31C3}J^p86)Y`9q&^tH)m8R%T6c%M+)#rHQG6WvW~3VR=Pm9F}=9)C3iI z%#>rS`;*}KbFY!^<+luU8-CQoZM!~cD!`lF%{0#Rc7d`@X1(V0f2iE1l6AJpwvaPi zmvHOk+$Bo57by9jt{mgRPv=^K4j^|+MNB~eJyAF}Fn9e8zWcqeg`pwoIq?r}o1Zs_wk3Lqi8BE$)R;MBpf&CZZ+yh}s5n9M(*2ls;!YiFi1c=Ttt{?^o3ZmZzAT(q1O4_aW^q=nC z=Jhd5Q%rf_g}xuCd1ZWQ&4TeqYhLc_>YvYa4XPRGQLUXLhnTIHn-^Kr{{N6dtp|I! zviF_t7D_!TE`E>O_K7dL@>3LYB`3KRf+K*E=V4hWNJ0o^Nxjy4GMVaByj?lRg9Asn zRZ5^Y{XD~MQfPz%Y$Cjovs)?0H=V!U5my@nV7sqN28E!xKlo766j=bR)NmohBk(`|TVM8cAFdO8o8vsUt0K-O=8wJNkz|b6 zYo%m52JhS2CqNFy0nxPp5I*mKGezOmQV$3%SU$X>4EaasF(LaQXm5 zDB~ekd|3b^K!!1nVxUqO#|q{lv2YIs5g>-hE!%gUcJAQ@^C=w;PsZH8w657)mm^82r1eU1q()x=_}ms&InOAyfm1oPk?2Pg5nc<^cp+cRCpJuoU)z)kNLt%|-enOjI74%04j&&%50H_2M0RcRK zQ7NM-wvw<)%W0Y|*LJIakaR1r%5n?k^iThLFE>MZ$fHt_hp+7C9{Yrn^H27Xdh~O% zKi$_oEqGr1axb^&>)9?}+W-g(LYRhv5!TT{w*L-Q4)^LBNI?OFH`Mb{AS#d!T_cio zgM;u2KrOfZ)&pidVCE&hcvDl~;+V!~%Q(!LfpZP;z|E2L+MB z5ejxm^{f>OKaeUm>$jPLXdFNeNj10Mo9y29@Thlr7kcdut|ZZ;AusWfrX`7;t-7&o zd4fS^k4Pv~ps9}w#f`U58lWVKN%<5)HUIhM@2r1Pe121g+xYK&+^VUg-J+fo-NMWX zF0bDyZqbj`Fl#*&v@`+H8X0hu$%+L?zV;6w&qy6+eKyxUCIxw1 zHeE(&HB0I-?{mG~3tti(%0HHVqn9hvb|pX5ail^(NH|A$MGF}Ua!9|qPQRVcHrNM9 zrK~s*`A3(o8Gkw=|G?2`-aSkcZ|EE(2SG&wAcR^tYuu6JDiC0y3@`u&Wn4Kjb57rk6+g> z8Svqzyu|Ky-Ovuz8rC#P$xW8gql(e4-{~QtQ;g)4R-FA(ki9&DA?G1c-u%m?Tc>2V z^qu`({+UDFve6@5-sn*-Z{i5I{JbG<)fEF=ftuRv%`;!@<6ik{FSk_r2kRH>xMe@kzO;{x+UFMSpB5}WCTa=#efsSW z>l%a>EM1RwIT4?~rc&X0nSzj@)5I${$Uh7a-~fsMh@90zA1nY8;0P7~0ESny__{$k z03qyC)20@bg2JW=tw_#+gPcg`WeGYB3L(TI2MK_v0ssN!;UI>9se| zoZGsh|Cd^qWHu0UawAD7t>(iN9$3kRBIyJa)P&|fT`1yiQxRT_AO+d|d&w^O0FL?- z)&6qM)mLY^qHpE6m8zAO$(DRI*Dd__T$lHi-fpoR7F#68%=>C@xAdDm-O6ugyX8ud z$pKb5N|wg!l%LaJT3*fqvs6oPOq)uP~Ono z=2gRf(N>UX@8Sj$C;QTBJ#MTwOW1&g8&2p&UcyCFO~Th{>v%Dnl2#t+ppSw?dMyr& zLw`q3{`DNUg^T^mc=-% zz*(kkm&<9FOJPI1N@Xa9fudtmT6p#2q$~PShPKOcO9kCx?Q6dF ziBi1yl^pBunE$n2Hh-y-_yUDu#e$<$aM1cyDbO}bIcOcT_x<_~!Wx=)`CObThoByG z5R#)s9fVvfu9>c#CFov3431#F73-LH+NhQfwLTEw=yLkV;h7H<0T9XnMo^xx9u`ys zAlR=g9M23D)45pFGl2L$5OOE05CuEn+ZV$GM|kYykna1gM+C^dL-M>!y*37(pJ^*h zjA>q(JzM25yCB5Jsx^Yy1p*Y!?+W7q62dMy0I{gGYN-b0)6F=|0jUVR*IUU4a9*5Q zA=9dF^mKUv5JB?-lzJy=RVWdJu7=gAe8RESKT5hnCENLegwSc3KnMmDD+Jz3K}<-8YS3zh za?oN%b8_fw;h8Rya|^BbOf|{5oWwp}>H)C?{Z)FPA^{FBBSl!Hh3Y3`*b{h%p` zuFri#i@a-{{DZwlv|zwFQjJ$SS0|40e`h4so-7TfX>Mi&3kjxfFrai1Zc#I;W+7oG zDW!wVR743YeFHo=xQ#GNPFg{teYKnuXZ&&>H(yTwf*=5pxt~bcQ@+HW7BDP(_A>(I zvw}(MzamH$ei=oPnkWPcxeCd5P?1uScc1_eaubzI^PpiVp`MI9hE}Pf?@3iK;AJ1O zGMy)_RTWyF=4C=e`cvq&=TR1eLwSd_TnP?q+SPC7Bc#y-ih{#B2z@9Tg;!iRAmMrv zUa6L*#FuqS`({;+;Ku;hTr1J3w)wg0PO?KJ3HBgIX}|j~PMg;UN4Am7`UJ z++)IN-DjRH<6cuCq8|J|my2#!^Q-_=pnqoA`a(H$h;l16Ga zKw%nV+=CN`B)WJc?vh>-Qe>AnoREW-9X{E-Qz6M_)xhf%;*?S23y_sx>1BYtsF3Oz zf$-Fo{oI_7_jgaqW>a3--#rZ^pX@JX>F1sy^ir*6A2RD&-s`<<_iw zk5>-m9l&89Esf_MawOEl9&Z;MAv84wL7@q=bZx_*qarvk@4N;DK;YPZJTgE4fH)ih z5SGW+4`4_+3_A9YT5v3&01l0tn)#M1s~EY@++!+2TChmaX_OKC0772~oyGvdpTzd) zTI_gm(8(WSk&Jf~WnLjG?J7;Z`raUcN=nXOmNGmi0OlGP{oJgN4REtm&JiF$f}%XF<*3LDgj!!r zDM+63gp~@h3M|B;RV$ftayfW~2ZO#5@&=sUItw)&H(SPfn8shH9AC~J9NwH>VV;>nrRdQVom1S%FL;KF z=c@pNMh04`>`7fIMvd|fLPt{#nsaHfnycSSudd2V0gzyt9~8n$_80a^8II!tG2=W>z2dh~0n)Tf z?m_cKO4rXT=vPxhVO)lSZ#y>$G=9c7s-4zEcZ4nPDDc(fquw2E7p?^VQy14?x zAdx-ExWX>NEE4t?1kwV9WCn-w5AqoLNQ$K%v@!w5T0$eQ4)&}T5J(AlKFgA8{}3Zh zwD#1mO8eis%>F+jAb2vDJ{)okTH;8;c?c2MNyP0t@B)L5z|dNS)1aP~kfR*2Rx4^? z3#otu<=`6138U-m!yB`>Q&Z~$N3f7rU?HrEn^zCi#lk1AO2Xu;yCZbGc>kB`2_yV}V&bgmh4N_$DqXS>RhodyOs z$UAlOipWVf%XvxGORqvj zdb*`wQeN>nCFA57f?@8z4sdg&9E4o+KGEOi)57(#)>)*GY?*SGmD;XA>QVgN3|C6$ zo$?5jgO(;b@lXhRiWeBXB4GAUL!AdnHc#LJLmUVmS?63)3!vcHDmp$17iq#ZFi;IS z2Pzpg<*H^SfwhDj)xfC$!z+h{rCvF>hGyY9d-eFM8XqVKr9xO0z=%U~qLNSo77%c+ zIEIJBUP;Pvf?|aG>+fp>hmR1V`-*xHUWLjJ1)&0zYSsgYDhfIY4+@Z7k0!f!&KPrr zcej&kXk0OFU}ss*y@$(_%|S8D`9m3l!JfmxxVV~!h2?<71r5&jz&$4Lk1PusHAv}lIjvEK%qjVhLFlK*%H*s!<04K|c+>-?T&-6ogQMnGniMP?%!SIz>1oFnHz+3$0XyQ`Sla82omb zT?f!tFKmA^?kvi zFm0{2rv=JdounMRD2`ByRwtTcQ4DK!5)js*Cn!j=Q8f&BL&8lbA0Z(?SgX`i9tsk0 z@(jW$IfvyMgi|MkQ~?ajH*idHHQ>Mrxn8<<(Y4mKw3Z~UGuImx01A?FEQD2YNHC^R z5a7^y>w$4tUI zu>gd3f6)iBcSh3fdZh2k_lK$Wb)&|%ugRF#S(fOE@(wPNFHLs2VU#EZHCTYem$san z8@tf9FD`Dp*73Ed)i_*CT03T?YGi6?Vtn2Wiv6+fb;by(ASGBGo|0vxvBXO*1?)cAmw>voo=cZ+~muCN>GxZs+ zzuc@4E>W8S0$@;jDB?9+WXy|!f^mbQi%boQqsXlNUl-N-MC5S9@ilT%K48P6;XuN_ z@#ur7p#MUOKnG$m4+a9mHFS4dIn4!2MF+-4FMuty%DfQQq}Vj-jn|@P!>E znajG$65YY6gL0q*21dAfaTvnQqxAC(8m}@28T;}V8;6K$A1*EltDFhvveqnJ#5&d7 zbg+>a1F0Aat-k3^@Vk3=C$fJ)=A$fWhwztyKJG!0=E+ zPa<%Qsj>YvwrdxRYl;F8N&x`MfHCgp+d5o#tslWb$vQ0Oe&`rDKNVjTUNK+5ScT

~HF(=>l09;Lr^SjvsDb^dzaj5y4DtSnmWCv5U?H*G(YQ zGRM)ywlGW1#zh4ZUW3Ccae#zJP{>E+5J~_8wPpyRa1-?sI+yGrM%6YvqCxmWj<8R)zP;3qz6x5PNVWw6kELu<_+?>~ z#tEg!Gj>QdP#$ZYQmAH~dB7pXh#votQdw>xv(_ioc-GUcn~Pd-KJh1P%^_5hKUogN zxntC(gikmTp$N|9LlrE9RKf8q+0}Kh>xp?FLbw`*S-^tMU2i$Ig=8WB;6CWQEX)NEU4P&{?p#q0)}b;Bc?as663;S0S<1SACDkm zI^1j^A*aFECm?zyv7}WOn~Q7@?QxO0z^cV*J|*0$mP1!793m_tFWGaeoF7nViISlb zB=e{YEng(ytYZl{p_IU|rdlkhhC(UADEmLShr*O1B-ymc;5aw~PQiKNBpz%troH3f zSn-f4UWS_39Fp}kZ3@D*@z>I>lXv<6PS~F77gvV>2KT}$AMKmsRVBOv4qZb!2OAZZq8`?I zCG|KYb>2H8(YpleR5@T$Fh;9EM%d*t&FVmz!e3**#afWgfRfB=BX2n=7VMT)|@ z-ndb=4~!cMAk?e?f&+5#bvho2#E1H`2S_KmWkDvOCNA{IIJ$*&aQJ=z)m9&`q##iJQ(%;pT8N{LQtS z!Oiu69A|N7VL$AX8_%)4qu7nW3B!e_<`yI<365(IGpZJ8yjdtkHNLi-F))LIyYVh~0Fg$EW#3FpZ9T5T>fhsD`7&q5GE zgd^Lv@s4iS21n+);Hdm|DjT+Ee=_EW8b6p_Gws9H4PfEe>@xu3_Zh*5L(A;xT@Q!d z6Rx?x*8DEUZ69o}^Reb#ojWRtV_Qze@AtnQ3+iYf0g3L9-6ujT%!gJ0Vy#zRJuJLZ zw&ZSYhl;M!-12B z@Wa5MvcPa+O0GkIgx|0IuuoGEfMR((XFy4~W;j2`)N$-wbR1jGn@Bt$v>0+dfz<$I zop5Z9$9@7pT1L%p+iAH0sNZE3ljh^#I5vQA{X;lq*F&X&5$+2HBq1@!fJ66*YiZ$? zl)q8;%bIp|-R;>cUHknrl1&Gn8hz18^U`Wpc}8|?Y0l?5%98a_%N6DUF~h03xgHKH zafWacD7o<75v=C&%OXfHw)Ok5{pvUd3AHiKNNpBsEN%=p4*Awi-dI=%Veo2DUteM1Ebam0c%};gywXTMy$nC+rWWW;}j8+XvSf zfV{)oJz|;W8{9a*96i+hI6ELjszHe{4^>4u2t84F)D}2=I847sP>&E^g`RVAj{~z4 z-3Mm%ed^Ghp(jsr-c~wxRC`(9`#RSox+4X_Ik>R8;HDfJx0=W-nNkF95Ecg`nC2Ti zD2zAjA7MKWiK!9CP#GWzHL}I|+)yMvgj>21ynN1XgdoAmL+C}GLO%r%pfJ`%ivdN* zFSJgi7}S*1c!Y2=gF_Brp%jY2?*$GI2Ip+%0kLz}Ih*qWht8R6VNM>Lof2oonYljt z{q|eEB4F(ExNR^h7p|3##kqtUyc?$v@6=_S>k9zv4@cH|Y!i+dt~2-0Djv>L=NoOO z^EbG)9oLq}K~QO&-eB-xm}+nzymHugO0WP23LgU`H0_#t=pI<^p^EAtfXvBgJT!0U zd-L)VC&#Nsk-7G=ftR$G>p>u;V{CF6CvT|_;{C_8E%MKP!<#ca0CK3iJNUusARddjQJRu(!v7NN&Dm& z1}DFt^YOnmsszIMbM7qD`G!X`B1aEO5DaI>kpaYCi{qSCrL{7Jw;HlN1|Z(CQ3k>y z&db&dFM9I|V!*LKoqrVKaZL6Rt})jXrO+|ir-2$f4=Nz8XQ)6-6#^8pNHu_i`=H7s z+y}cCR9dKy?uEVDM{w|BhVZ`+)WdR*CllQVpX@!S@rC{;&$kKP&ha^I<+)$)C{G@a z_kC~yLrrN8fwKhj4sH^U(|8ynNHjl!sUbGJ9g7a$~&dI>xm|SO;b3L`6 z07IyZtP;|71%!~CQ>k#>PzM77NKldh1{SV86$@~1-2sH{39SSf&s~MT)mp!YAUPyE zFgLUQ(6d9YD7p879^U=_`G@9`kwegiH`fui$j-KY&7sieVlUa}?cRGj1F=3Pb8~bZ(jl0NIZ^tr+(;o*C==ZP^b_ z&i?t0I8^vu_FKa5@udNxb3^3}T5ZoYv(N{}4PR(tJf;YCo!C~_)p7;>7SzY~9o7vn zaU5MA&IhN)DXm#H02m-*9j;T@C+DK`iq4g5?5`u|Xo{?Jj*pu%>w1`ac;&TRjBDd7 zBeQU=0YvLtzYy0pgjQa??f)JCqR`6JL*W(50U!tGCf$K~y=NSJ_9XjQPScuEr?i!3 zZ$FG9VmKwW4u-ROiWO{yP|W(S!IMkQK-l{;*gw! z_CaaCCk_WCPV61twg(OzKB$MBliz6T#XvI0*RkwccnCRvTQ?{Y&hO7Bt^|N?_laxE z@%TObE`R;PajmjJjdlKnmN+_j0|_;WwN)rOCfCZ;nlfBd3^+U>1_$b)?Jcwd4nix` zLvYjph)>QBK9yZl{rr&kSI#*j+q>RB|KMCAqqS_{``Sx0y1KZ~x{wA)%%aCkWN|pG z^cDxh;0Q1ctGM72PEVq<_Mf0wI4T`S{O&=#s_7QapMC3k@;zZ1jm+x z0G$2S82p@5_${3Kaka6|)f|%J6I$t5IAK(?$JGO82M&KNSkG#1&KJefxLvOR1~3K? zIZl8{=WIze=fQp{!!`8~ne+2|wD0I1as70z77ef;4^VhS#Na>)q!xrm_NC zKtjdh;V_s`;1F8Tsz}};v(Sot$l`q-HH21Dkb`rxjvaiu-viYz4>@@{1{rwabbINj zpLdjIxGr62dyNkloePV36^Uwf??`4icW`zOgWYuRT&5^~+?*~Bir?0nEj2G{-I7_- z&T()6ZZhU!2{+toMI2R5fdlbc982bbhVl4xFgb}ShTjGUw0-M$*|BvF;rs&_cK)0v zPOJ6I$#FIuSK}610Y$JA)qrh*0}#2soCA)`?`GSWMR0H&t#8S>92pgeAPU!yYov4M z986vHdrb+sN1<5{3Gl z*dbV_+#}>2hvsIuL(k?`9ei=vDf}?SMlo+Zahrl9ZT;^F=VL(NgfR!V^Yp)&ZP=G7k{pikGE$D99;gZ10f+y6;k=`B({yw!EP$x> z?KoN;WPT-(4Km>-hTFJ;g0Oa7)J&x79F!YbDdE-ZTw>xM9lQS+0VEmPGXgcIA(Y&yJm}b8i$H9R) z7RUGJWaBso)3OkL1qi}#un>y*Ovg&Lv3+R&_V6Xg$Ek5v%Af)`Ip@QAaya&Ds-#-@ zsJ1s40v!8fY!?9GcZO?))9SdKn_W+?Re-|-5?w!zrSszjan$SJmqPx4qxOL@kNAhvT5;9eTFck(!r=->@(5lp)^bPOhQ3 z@bt^tR`=`f(9P(gCelSW2g7tD%z`s=gS(7C0OgVr< zj>opg!GU@(?L#wzgKassKQ}-(C}Qdqes}cy08#7X?1V)e_qgBAa=>7p{6^igD7*rY z00*H|2$6yU;N*hB!YW_;14pwAM@LCaA+)aLARY?x6krOiRR)#MIZQnShvggsqD~T%Fp^)o$O&5MHz>s}dm$w~ExsQA!Y{^qZ?l?`*9y4Z)g;Ib$r36OB3xXC!9%p3>v z&Wtmd({RHB7;*JrJ@4!mN(BgFW<9&{{f3h5wC~7K828gbRm|ZTm)SW3i7#zA#ymeA zZBNNL$ytxd7bPa7A6b3+8k7N4Z8P3nH zH8A^oVDA*;x^o^{X1|I1!u|0U05KCBsGKF?QVnx()%c+U)gD2|$pakJ{ITTRAo9v# zVEAyV-EYr!;V~WS@9=Q&DQCV`8~Qt{fn#3MRX^XesdoO5tM@(k!QS58PQIa~?7|z` zO9cqEmM%D-F|dp8Z$t>S0vzTvI4TYxi`RhWbWF=ZA~?c$aCRKh&yTMg)-hFytsCEW z0MU-ivHUsMdBx5TC${j3X`C#WrVVrthMj{y_Hp2bWAj_J9S%zjkBS&baVT(jN;yCK z3y^ax%ZKE+>>~mss1?WIJc9H4YaLZe;oMo~RU<%w85lmaGQ|N7R1QE$!~q0nmy_Fb zXBbXSNEK56`aW20FrXkltO|*Eq#oLqMBKJfNkZPJ@w#|_2S#{B3)XWvM{8dmI)FYff0Qz+)?byuc*a3>zJu&D!cm_x)IY;1#C*>jUKn;LH z4s8#2VmP}mEjdR$Fcb#^3=fHgWQ1a)#6GGJYuAJ>-a%(^7iKo9^o zZ~%gR1Q6J-?ooij=5x=0!YAbh21asD9^#X3Qw72+IeBQcGEg)Q1d(!h^$4MuCFCfM z2dY6}*b}-TDG#kyvQ$!@;c8y$+g7t+^sU{6SM>94cJdBQMdv@$Rx;YP>0);TK!Af< z&;vqg;flX;IG%+t+)Qu5X#)i2uqtgjEDO$u(|Z6yXk``$C5&r31B7wP`2JbOv9-P( zhjHdJ&ha=`&X4nEU9D$eP?Hn#gs=w-uy8&y`(3&QUAiXhGlC%~2kWvQwqt$mpKHeT zi)wN?s;L5%0Q=><*)MPekhFhV#%x{93(G^UVe63pU|t<4t(D3j12D`y7}lv5Ptd)R zboiXazFAK`LFq%Nct{oCz)U$pNEP7lNx6kpQjHq&52m$DdB?Gu`J)%sEj{~e?_wwS z(6agsFSV77Rfv_eRxHawFfZv=D^haPe9aup9FiM~Gct{1#+{dvX&hdqf#jD*7Kb4Y zOR%uM#%*7W$M#|SWSn#0n4FI{o99cmw;CLW4q(Iq3C_;BuwOxC4y$7s5P%U6t56%l zvar5>|8cEIm_T74oHzTm>&7+o%3wKz)+1lQ*=?Cup{NNL*l>K-p~O%M)FCwA0tpsc zt~?+?6|8m2tAmA0fbojPRT?lJ3X*Y4%lqMrjmctW>E$S)qS~kjfrg$9z~tzF~bGs0Su!skDJU51`vNUtws|NQ7a2KQf8qRwW2J9 zUFHas!I;KDG4H(QSd=lxkMfW>Bw^fd7lmlvY~Ox=0nGUE?D#BWef9$+A@`v47AY9( zvWJp6gwJ$r4t^qkjln0;~Tpx}f&Rf?dbZS~f!?nfvQ2{wL4ot~)w(AQV zTF1gD*1_?q`Q^NpJfjN0A_$_+yx2S&2Z|6f;rM_dr?=K8DFMo0&ro?dc&5rg@gWtt zN$BIC8JK2VECK`dKt%|xw7=TtGhFS00iAVA20ni1WPF_DzZ#lLFZy$9$z<1Bl;PTS zqdU2IxjW^uaqS#fC$^1&cmjmsyg~>R9GPVX5o+PrkHGNjSS>F{#_6qjnPX{v1Db21>txr= zJAQC}!XccQ+MQ|JAL~#-5muotgh@EN9NqrNBqzq@>*kn>#KMHAi4oIHw9v!D5hd_Amj@)k5W(T+1!!y@%YxH- z=cbI*AUJQZu-=LDaYFVbGceee=@ZT)tQQ^2uV==3gg$Xc=J(5vJ16$Vy8LcbL(8p} zm!lIdacvAJ50mZFuV+wD@c@S3hT7hoT_KTOYu05Q;E1VUaQ@*pnu8K95h`igoIJL! z!J*%8>)_}51TAv)jJAQC#Qy;E%0Em4C<&YADzpo{OhtfNpSr}*Au&-dO%YJoEb{x(nI5*~Dhz!X2 zO(;PCgPNPxAYBKN?g$Ll)i(TQu7!nFr~q(qjkqqX$L~>T`^4EK%Kw8Hj0T4j(u+TGZc?1qG6|g@-v7U#4gxh+= zJt)U1ht{vhv<|)GrW$|&C@9KvNmu(yhO1kUD>!nSo0gBenpZ}7cY5s&b!8vEq^0z- z?$+XA0wn3$b)z~1BpwjUM{p*_0R#urwB;qid2ovAKEY-RRsJ#wg&>gkKp)h8^I=H zU0Y8601!TpAm1>jR?fjPyN<82KLZDdq!2hd4-)dqB3_A#GT0xMumB0;-BL78c}SLP6CfSjSe5)s&;F?woC;&yJCEI9ZZw7?;w&DJ z$bzH#>Bx~i1Xjunns^z5z{UZEb;C3z>-y66uM$VKhy1*m%6SLo{7f0bIdU9AGws{f zV>!PsW&!@=6jEjQ?UA!HuJsKx-~b8_M&!(Le!Fh$k1}k-_13!9JnO?JoV-zR@V+lv zp)9l_C(%0Avc*1GpLt$QEW`p7LMIOjZ~zf~9Q1!QNG*aw1TY!|inUVdc=qT>00RZV zv`)3wsRND${ak(C$fFG_$KTVkYSJ+8Mz7tWaqVXYwp6@(SL^E2T}x3P*P@!NT{o-~ z^N>)ZS}jYBi9-NNaE{<8I0>~Vj)b#O;t1YRqn>z5Spdag2w=pPAGZt$f`Vu|zD=}G zf1IEgHqW0=bPj9_XrXnA=HAeJt8r`50vNW#V(Z)gKQKB7HEl5Qo8ykoHNx4+GXMie z#-VX$IXJ3fm58>9!aA;T3=ZqalXC-yy>wJMI`L9rW-gWxDK%T0ho4i*7} z$ziRQW*mprv^gx!&p0LXgVUdAtn0^*1Bv}&9Et;S9xW2)0+4HuBGHnQV``K1q!pg zigf5Eq9hh02S9=W2Mz)-I7z5YgW;fYNO0l+2afAYb8^4jO!EvJKR@b-j4ikI!#*_6 zLKcn#oXn@xIhYEt4h|m!#GGFiAP6~*sfEm-Vp-^ErvxBvANFmELB&A@;^DAdBLL!^ z+MbG)p)97rz{Gai#$Mm)*Td1t8|)49THlg*zrUa! zLifKj zM+%^r1rTuBVBXnJGy{V1SQ+LS43vNo;0XJnj31k66vwNTLE!U_0E8`**?R0(+nTzB z(2H>?4(AXlM+lER7(ihTtih$o7f8khhQg}) zC4;*gSB)%hEF5=%b0^{d%Ks;Wb1qq5`k}W9kgleJsjfL+VOD-pN}>y_o7tfoWsqRp zV4Q=S4J>jNZaCBCklrjO3DYq^Y}`9`sNHeyxDr?y<^|LI<3I@e^7FzmD8o5esO9Gy zTsVJF62d49D1go%)7HgwOu(@a3#CDMv@Yvd-Vo0nPyjh)Py?&IgK3^A1rCni4#O|el}h52=On9y3FzEqI>7yoF zz#zo(&=@3)`}OKx&T{n&`?fhilc1wJ-}nsLi;^zKop2g90=th?R266T_{@dA-w`Q)4(d0N|7X0+xFRxACxU z+~WI0xl{({j*iPR&I6!0h6f}7VNk@5hXqAsKc+0e1VkQEeisgI;S$#cXZDVXL)(0> zv{r`7g!uss@A&Z=9;fFM0fb7n%qRB-2k@X2D1jW^{;Z@hi1lgGH85BoLpfyDV&%7? z)yl#uZEGQxph77O21>#y0AX6&SibSHlw(mZ*SKt`Yg#$_K-0>}AKLQLl#}N}H-GP; zx#Vp_8j9cjXj9?Ex*(&ZAeq)_*rFTSrdkq6FslW2C|j=qNFKN0x|T;RW$aVi1hwJ8#74nESY@G;AgE?s5Ln{v=hbQ*3#ph79Iud! zXDO`e=bDxdmoJQ{Yb}}jMYr#QllMR6e~+Om|Kq(H%P#*`Q_&?yn+ql>%*u&cv)X_} z)&VFOJMQ;MHil=GjbB z2?ImZKtkUJfS?+w-tiuSqql2Xrm$+&#QK)PGrrTk@shsYO8{XJMSh7}lvLM<;wDf3Us_0mO?D z=pSKO)Ql@@*LeV&JyQj60S;iGxfbolgZh$p_xCQ69vTYXJE5iIU2~d?-y}fB2#}rvB$)z47Sse#IyFsc3W75L z2jjs(JUAAT;AoU`N(;l}q~Q@3b5;!JW;xq<2R0=NhQsqX0*MUeFgUbL z?aK$HZdDln}46fvBy&Fs3_wAj^ZZ;?abR5%olg?UJ7=as~qTV<4QcsNjtkO-T41SkN9<(eO$uv#9K(Y!W| zQ~T3IYkeIkf#yYEupAX2?2^-3(k>@PH87OM9vuM?AObel7f6=m%XkWx)+&xyMf^%V^){WQ1abWzoIWG?Co!ORa z{m9AV+k|znFnyxM_sz85KR}S*SmGa=c|#uv&9}5x(YmGNJwRe16HovECDUOZrT?9F zJOE)nkf1Cc9(u*C9|T91Gup#}$_K3FNuY%nDB$dtYoHneAiNlX7eMo_TYDN8uz-Pe zwGQhWaO@YDfP;`p+tCRab@siW+~TDk%0ZGT)c_1r4eeh!NBx3q*RYtdYVfh972|d` z=b!SErlL0v_AZegP8^!Ie0*rjnk#95#0S6A1*5U*ha$3tbKPy>-pMT+v+iu8QW>7fD4 zNxUC~CSSl{IiVNZux;3fV6b^87bS3Tj1yHuU|^PG0EKtt$jNbH)#{dv6IQV<$|8s? z*O2ozYCRtR00s-Sw5&<%lccjB)){&Z6c~U6GeA@ldbO+Uz;GfdN-&(*%3wHk%*@%nnS*K_gCV|6 z%nTNs6-N%+#pmJNI5joC2fz|^-|QO_cFT8g`~Zf`0GHW34+i@T=VdKYgh_IApfEUO zQB$jj!_vbp>+%lIk^2dL+Zj)wal}GTiY5m8V}$AT7bmfPo;U}8P-z8 zqa)-UTF3q?{&Kecj5yj>*#G&){E2UR-932t z_ZoPBv8n81m$X*AKd-6e(xZ(9XDb&OAuzHHjylz#^{PSZRW>Q6Zc+&-%^JsA0Yy$` zpaeznju!wiM^wpl&7gC3yV8EY62v|P>Z-?gky7DOy_E?P%@jZ z{n+_&9{OETtCK*mW>*Z=@PGsbv4;ya9;t@RR7KOMgEhyZ0KhR~d5*U4@7z&N8m1=-%S~=1+7mVp@DIR-Y zQ$gRUubcmK{BI52TdwHYwB}!a*j)CW{mn%eDi=A$)h`|F>Xu~a!h1-#;c}WLIRI+X z0w}VU010X$2eU*TP*j@Xh%y|HX>0cM^XY4#f57I+%xN+2xCV`;&1q#;GVL8XID2q# z;4xM4VN!s}AZ1f7TWBh)@GgILh28VuE=mj^mP)W;Dq!z%UY3m5odaP^xADU)8 z3#m{C92&cePV#n3Rrkb_mwPHw`id5%_u?A&p>I) z*4s; z*@wyDgHl9_ArMH=L$fXOfFmU7_LdO9ki%2!TfQ($4v#u$nJI>h|9|tbeO?M}N}_FP zuC+WwfK{tB<h1=G7Ow#{AQzBtu>OvP^@dL5@@>N2&u3m8eOhoTX9D zN`7LH0F0*N;g^A;aeJwa;vpvl%_7e4A9`{QR%k}rNM;h{0tUM$2BN| zx}X$sFf?u98F0ufA(yjTSQQKyG~ZzG^GsPhAoO3L9F}a$nfY!8xx@h(-_NM_aD*pq z36TzIoR96Z9x4JffCMDb-(+7(rXDy%eLO650uoL&EFa?7#9H~f#L4wuF zfe5(*9G08NOi^UOK#P|-K8~hk)&j;dYF3o9Hgq$Y|xqyOF^DNg1>tUK^KLHL?2){p;+rx%(+5m_3Yy*d;X`u>DxH!7CFll}A z1t6gIM^ym8db?Q%H4z*k)Up;VEi*8D=iZ^YQV&35zLcbHezt4OBfl8ucpFVq!5G(C zG|IIWkL_+N9&m?p?>{m#(YVEUbVTP-j-$!s|r`CU&|A_-fPgO!Ar5eLsTiL0uwPc)YE1B%tN+)-yF0a<*!)$+}rRUGwr(PEwBni3bElsgpwy zf|0;C$eBYTZ%xFpaRWu$n9|58Q591btrNhoP)*CsNoB#YZCvY`^7#3-orfgkJl0U4 zbEL%C!#)BKz-G<2n#S=-wr#(fHaIvxjdNZ+D`kp-qsz>ZeMn_3RwUh;Cd{Js%6hvo zl!bgk+ZZGQBK3r=uG9RaDwrIFP`w0}AOSRcR3!C3@p{6ll@kTW6xXJ3s%7=0?zWQg zwMxWqZC^KetiMg^;U77)ZvDjh&FkM^(OU7Aqs^<|kW&K&;gSJ@<12*14#~(b3{I{ zY(#h4>Osvd#lu&&mW}?rb92(F@y|ZE%5UYiZFu+h+SXsbzOC}Iqpjr^xR%nhT}$x< zDatS<@*{MU2fC&ey`(DH0wzl#m>?mcM^yj?XZ7O&6iQPQ@91$z0u;gV4T!L=#%=wu zjY>i~9NS>fcmyTWa$FQ6JV|T&@)qS8a&ST^dyNjJaZ9X$0<~dWj&9D5gJVFXeehBQ z67ISsS^B+MQjZ=6hIRPq*tHAj%jhcw$q^(xSV%6HqwAETiiSjdyz8hS2_MnXT9RAT zQrP#Vj*X{I@RvV5oD74Tb7f}R*0+ABedD`cY+Lt^=C+DUTxX207W>n9M3`{#&Kf5uFcmxQ;M*?jQ*KA zt%pU*!FEh*Sx_D3Gj982ni4pG1Q-MXpxEQ+z$G&^@rscGLPmJRF&FSetsq#)e>1X7 zP3ZKq|AQ|g`&Jh6;!=u4B#V3aQ2)X)7DOw!OIDADUN>d`tQX z+>>;$er&Y++PJ6le!{2;%Vte?(Xj=pk$=I3a+;N}lXtgCZw(!QGoMe{1Hx2nHPx!6jD zn#%`iJ}(I$;@V5cDaSZfU`*|9tC&>PUNP~Wwz6R#ZeKTQtV?(Jy>Pe_87Wu>xVFOnD*G!GQ|-D^ z&bXY=OHLbwU&>c-U|;hy9x05>LMso0s6{J&oNR>JFAiw5d=a@GPtnJ>p* zB^6thE62|g2-&V#5D^lkLMTB)60L;0acP!oUeU_~O-Cu9WoR4C&(GAp^;?SRs~F;1 z3v*rTs@|?OU#8==t{x^R#=Fk7Q!SM0tem>7bN!S*wXPla0XqBA4;Q{p210|{EpO`A zwc|bK9@+V}>$|qRZA-`Iw;b)<{1$=oCfB*)Y{lDWy0-GOl#EVv?InZcRKo>}La)Lh zax^(A4!BCm>q?w2DPUClFXOMj0w+&SY0bwT1m**PYI>WeWvBxWRk9r~oM-|LU!McH zNn_PTgW9*g=aR1NZ@;Z`+gqzTw_JSm@aBtM*M_rPXQdow-FdEK?IbyoKq((3M;pmg zse)ywYGc*%g?v9zHMNCb07DI~8h@n{{FSNDh|tCW$y4aGA_YYAO3ec2llG>2_TQxa*_$R;5n?HyP_EJNqK>st z%M^k&ui%pr+9zR~j^83B;nl6}B?Dd8y5X*?a-wXq@{BP@Ix2>3?5vz}ZQHt2-sm=+ zGQ_#GVx$KRG*P#y2hDx+m> zB?D~x#$|#=D$*=fY7soZ)LJZ6;=@C-w&HAUr~Oq775HOZ=NcX;9MaWZF{ZF%-NbKp zZaU?(?k!XLQE~W7lOEE;Uj{(w-uR)uT~!}HyK~n&esOrqn=3oFT-JSf`#ao`EpKs0 zwqE2qHwl(a3c(bHb*?{6weYEgB~q7haz2c{f{}9GVXFPdr{evh5h@klpgbib=~k)q@HY+Apl;{ea+>yjWN`bow|?gE_KTnC+IDgMVF7Y@n{4Za4s|)a`Fxe< z$r;a-oh@fPSB`kPROU26BL}URB8MF8w!lTc$*~e57ow#>dD}$Jo5~vLQ05 z1FBGp!w-~lkR$XHSp8jxoWH%aujb3)%K>4O9Db}jviWp(c*|KjmoubxI`#&^v0hfG z<){St#To&-df;KH-rmlNQIEE5I{hO}8{Rm$y9y}M9enBGe=zVd(eA2?dbRJna@^r9 z=YO|r^TkU$w_Ml)EJwCpELh$wNG^1po8O>Pz-&@TCWSe?;dD9bWYylX^;6}nN`lu+ zR6e6zrUJ)RUZdK)qn!9(5LFO5jg}3P4HXaqVU3ihY^3WfLpg?P-F_+utL!aE25R{L zjgQd2upycrtobs9P^K!S13NlO`)zKo824burc1Br28u0HdZwXB4}bT8w{Gz0N_W-A zdv))9-zkT8y!q+se~x{qvovug8m1&+e7ZR9U+6fBzFs2Uz< zHjQ_OHxl}c(XvTa%Ud{9sSs$La*TB&1dxDOJKSLDTsuTSkSm}tQUXDM<9DnT9OMy% zRAo6@E;!1`Nd_HlFU_rOD;t#GwrqP8{?RRG2#(VQ%M_KTNMTM@IYu@? z<2$Br~$HJqrG7nHif8`vb1WLaYAcSA#1COKk7Eo;sh=G@nMOcN04SLvjOf3`u;Ov~s#@Qq9kRH-QdPooHAw8sr^pGCXLwZOL>EYxa5{ds0cYAYo TI$7to00000NkvXXu0mjfRM(@o literal 0 HcmV?d00001 diff --git a/tests/Images/Input/Png/rainbow.png b/tests/Images/Input/Png/rainbow.png new file mode 100644 index 0000000000000000000000000000000000000000..05aaa87fa403554ae152041337f39988b7b2b6b0 GIT binary patch literal 1447 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k2}mkgS)K$^jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk+G7+A$UT^vIy;@)2RTYL^^QbFwd*q5h{ner z$6WmIdFuN&yR#nNTP^-(=d<3s*U#QA{kz&af5z^=$8P1Chvw$m{JuRqJ#XjJqwDi) z|D9I5Y`)BH^TL;xU(fc9n{M`T^B48&DLubcir>6i<8Ghz^91`%S5JwBu8s~_dvZ<8{J@=tdy9%cpIVza_4Z}0 zx{R=o$(OtSt`yzB^o-pMBkPMPVM?iKN?(_{yy|he{9M>~x%w<$?g&^=x5>te<-NB0|2yyN{nGXSmZe;KW}Q}ZHTl-Ed6Uh*Nd0$xfBf3lx*wnI4qyMa z_xY{0Ur!pkwe0n$GSoizAWr;f@k~&qV rjS{0_Kt?+Fdq3&m{xyM%>ls*fb}wB$C1ee-9A)ry^>bP0l+XkK4i}PR literal 0 HcmV?d00001 From 983291730afe6a425a703e7d23e0b9f537ac0b49 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Aug 2018 19:41:33 +0100 Subject: [PATCH 39/40] Don't allow duplicate formats in configuration. --- src/ImageSharp/Formats/ImageFormatManager.cs | 17 +++++++++++++++-- tests/ImageSharp.Tests/ConfigurationTests.cs | 14 +++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Formats/ImageFormatManager.cs b/src/ImageSharp/Formats/ImageFormatManager.cs index 63fd02d8d6..fdbc4ee442 100644 --- a/src/ImageSharp/Formats/ImageFormatManager.cs +++ b/src/ImageSharp/Formats/ImageFormatManager.cs @@ -13,6 +13,12 @@ namespace SixLabors.ImageSharp.Formats ///

public class ImageFormatManager { + /// + /// Used for locking against as there is no ConcurrentSet type. + /// + /// + private static readonly object HashLock = new object(); + /// /// The list of supported keyed to mime types. /// @@ -26,7 +32,7 @@ namespace SixLabors.ImageSharp.Formats /// /// The list of supported s. /// - private readonly ConcurrentBag imageFormats = new ConcurrentBag(); + private readonly HashSet imageFormats = new HashSet(); /// /// The list of supported s. @@ -74,7 +80,14 @@ namespace SixLabors.ImageSharp.Formats Guard.NotNull(format, nameof(format)); Guard.NotNull(format.MimeTypes, nameof(format.MimeTypes)); Guard.NotNull(format.FileExtensions, nameof(format.FileExtensions)); - this.imageFormats.Add(format); + + lock (HashLock) + { + if (!this.imageFormats.Contains(format)) + { + this.imageFormats.Add(format); + } + } } /// diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index 1a7183df81..5c5eb9e9d9 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -2,13 +2,9 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Collections.Generic; -using System.IO; using System.Linq; -using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.IO; -using SixLabors.ImageSharp.PixelFormats; using Moq; +using SixLabors.ImageSharp.IO; using Xunit; // ReSharper disable InconsistentNaming @@ -96,5 +92,13 @@ namespace SixLabors.ImageSharp.Tests provider.Verify(x => x.Configure(config)); } + + [Fact] + public void DefaultConfigurationHasCorrectFormatCount() + { + Configuration config = Configuration.Default; + + Assert.Equal(4, config.ImageFormats.Count()); + } } } \ No newline at end of file From 1c72e613c430c284539b014ef93085fcd495e37f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Aug 2018 22:54:31 +0100 Subject: [PATCH 40/40] Add additional tests --- src/ImageSharp/Formats/ImageFormatManager.cs | 6 +++--- tests/ImageSharp.Tests/ConfigurationTests.cs | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/ImageFormatManager.cs b/src/ImageSharp/Formats/ImageFormatManager.cs index fdbc4ee442..e62805d478 100644 --- a/src/ImageSharp/Formats/ImageFormatManager.cs +++ b/src/ImageSharp/Formats/ImageFormatManager.cs @@ -99,9 +99,9 @@ namespace SixLabors.ImageSharp.Formats { Guard.NotNullOrWhiteSpace(extension, nameof(extension)); - if (extension[0] == '.') - { - extension = extension.Substring(1); + if (extension[0] == '.') + { + extension = extension.Substring(1); } return this.imageFormats.FirstOrDefault(x => x.FileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)); diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index 5c5eb9e9d9..4bec25f7a2 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -15,8 +15,8 @@ namespace SixLabors.ImageSharp.Tests /// public class ConfigurationTests { - public Configuration ConfigurationEmpty { get; private set; } - public Configuration DefaultConfiguration { get; private set; } + public Configuration ConfigurationEmpty { get; } + public Configuration DefaultConfiguration { get; } public ConfigurationTests() { @@ -93,6 +93,19 @@ namespace SixLabors.ImageSharp.Tests provider.Verify(x => x.Configure(config)); } + [Fact] + public void ConfigurationCannotAddDuplicates() + { + const int count = 4; + Configuration config = Configuration.Default; + + Assert.Equal(count, config.ImageFormats.Count()); + + config.ImageFormatsManager.AddImageFormat(ImageFormats.Bmp); + + Assert.Equal(count, config.ImageFormats.Count()); + } + [Fact] public void DefaultConfigurationHasCorrectFormatCount() {