Browse Source

Reverted from DebugGuard back to Clamp.

Added missing AgressiveInlinings.
pull/686/head
Vicente Penades 8 years ago
parent
commit
e59e259133
  1. 432
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  2. 4
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  3. 396
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  4. 46
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  5. 31
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

432
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs

File diff suppressed because it is too large

4
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt

@ -80,7 +80,9 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <inheritdoc />
public override TPixel Blend(TPixel background, TPixel source, float amount)
{
return PorterDuffFunctions.<#=blender_composer#>(background, source, amount.Clamp(0,1));
TPixel dest = default;
dest.PackFromVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToVector4(),source.ToVector4(),amount.Clamp(0,1)));
return dest;
}
/// <inheritdoc />

396
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs

@ -19,9 +19,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -29,9 +27,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Normal(backdrop, source));
}
@ -39,9 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Normal(backdrop, source));
}
@ -49,9 +43,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Normal(backdrop, source));
}
@ -59,9 +51,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -75,9 +65,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Normal(source, backdrop));
}
@ -85,9 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Normal(source, backdrop));
}
@ -95,9 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Normal(source, backdrop));
}
@ -105,9 +89,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -115,9 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -125,9 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -267,9 +245,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -277,9 +253,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Multiply(backdrop, source));
}
@ -287,9 +261,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Multiply(backdrop, source));
}
@ -297,9 +269,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Multiply(backdrop, source));
}
@ -307,9 +277,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -323,9 +291,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Multiply(source, backdrop));
}
@ -333,9 +299,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Multiply(source, backdrop));
}
@ -343,9 +307,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Multiply(source, backdrop));
}
@ -353,9 +315,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -363,9 +323,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -373,9 +331,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -515,9 +471,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -525,9 +479,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Add(backdrop, source));
}
@ -535,9 +487,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Add(backdrop, source));
}
@ -545,9 +495,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Add(backdrop, source));
}
@ -555,9 +503,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -571,9 +517,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Add(source, backdrop));
}
@ -581,9 +525,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Add(source, backdrop));
}
@ -591,9 +533,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Add(source, backdrop));
}
@ -601,9 +541,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -611,9 +549,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -621,9 +557,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -763,9 +697,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -773,9 +705,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Subtract(backdrop, source));
}
@ -783,9 +713,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Subtract(backdrop, source));
}
@ -793,9 +721,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Subtract(backdrop, source));
}
@ -803,9 +729,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -819,9 +743,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Subtract(source, backdrop));
}
@ -829,9 +751,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Subtract(source, backdrop));
}
@ -839,9 +759,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Subtract(source, backdrop));
}
@ -849,9 +767,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -859,9 +775,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -869,9 +783,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -1011,9 +923,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -1021,9 +931,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Screen(backdrop, source));
}
@ -1031,9 +939,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Screen(backdrop, source));
}
@ -1041,9 +947,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Screen(backdrop, source));
}
@ -1051,9 +955,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -1067,9 +969,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Screen(source, backdrop));
}
@ -1077,9 +977,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Screen(source, backdrop));
}
@ -1087,9 +985,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Screen(source, backdrop));
}
@ -1097,9 +993,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -1107,9 +1001,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -1117,9 +1009,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -1259,9 +1149,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -1269,9 +1157,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Darken(backdrop, source));
}
@ -1279,9 +1165,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Darken(backdrop, source));
}
@ -1289,9 +1173,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Darken(backdrop, source));
}
@ -1299,9 +1181,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -1315,9 +1195,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Darken(source, backdrop));
}
@ -1325,9 +1203,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Darken(source, backdrop));
}
@ -1335,9 +1211,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Darken(source, backdrop));
}
@ -1345,9 +1219,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -1355,9 +1227,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -1365,9 +1235,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -1507,9 +1375,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -1517,9 +1383,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Lighten(backdrop, source));
}
@ -1527,9 +1391,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Lighten(backdrop, source));
}
@ -1537,9 +1399,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Lighten(backdrop, source));
}
@ -1547,9 +1407,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -1563,9 +1421,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Lighten(source, backdrop));
}
@ -1573,9 +1429,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Lighten(source, backdrop));
}
@ -1583,9 +1437,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Lighten(source, backdrop));
}
@ -1593,9 +1445,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -1603,9 +1453,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -1613,9 +1461,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -1755,9 +1601,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -1765,9 +1609,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, Overlay(backdrop, source));
}
@ -1775,9 +1617,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, Overlay(backdrop, source));
}
@ -1785,9 +1625,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, Overlay(backdrop, source));
}
@ -1795,9 +1633,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -1811,9 +1647,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, Overlay(source, backdrop));
}
@ -1821,9 +1655,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, Overlay(source, backdrop));
}
@ -1831,9 +1663,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, Overlay(source, backdrop));
}
@ -1841,9 +1671,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -1851,9 +1679,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -1861,9 +1687,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -2003,9 +1827,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrc(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -2013,9 +1835,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, HardLight(backdrop, source));
}
@ -2023,9 +1843,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, HardLight(backdrop, source));
}
@ -2033,9 +1851,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, HardLight(backdrop, source));
}
@ -2043,9 +1859,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -2059,9 +1873,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, HardLight(source, backdrop));
}
@ -2069,9 +1881,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, HardLight(source, backdrop));
}
@ -2079,9 +1889,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, HardLight(source, backdrop));
}
@ -2089,9 +1897,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -2099,9 +1905,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightXor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -2109,9 +1913,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightClear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}

46
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt

@ -27,9 +27,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>Src(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return source;
}
@ -37,9 +35,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(backdrop, source, <#=blender#>(backdrop, source));
}
@ -47,9 +43,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(backdrop, source, <#=blender#>(backdrop, source));
}
@ -57,9 +51,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(backdrop, source, <#=blender#>(backdrop, source));
}
@ -67,9 +59,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(backdrop, source);
}
@ -83,9 +73,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Atop(source, backdrop, <#=blender#>(source, backdrop));
}
@ -93,9 +81,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestOver(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Over(source, backdrop, <#=blender#>(source, backdrop));
}
@ -103,9 +89,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestIn(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return In(source, backdrop, <#=blender#>(source, backdrop));
}
@ -113,9 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestOut(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Out(source, backdrop);
}
@ -123,9 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>Xor(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Xor(backdrop, source);
}
@ -133,9 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>Clear(Vector4 backdrop, Vector4 source, float opacity)
{
DebugGuard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
source.W *= opacity;
source.W *= opacity.Clamp(0,1);
return Clear(backdrop, source);
}
@ -186,7 +164,7 @@ string[] blenders = new []{
foreach(var blender in blenders)
{
GeneratePixelBlenders(blender);
GeneratePixelBlenders(blender);
foreach(var composer in composers)
{

31
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

@ -8,7 +8,7 @@ using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
{
/// <summary>
/// Collection of Porter Duff alpha blending functions applying an the 'Over' composition model.
/// Collection of Porter Duff Color Blending and Alpha Composition Functions.
/// </summary>
/// <remarks>
/// These functions are designed to be a general solution for all color cases,
@ -148,31 +148,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return backdrop <= 0.5f ? (2 * backdrop * source) : 1 - ((2 * (1 - source)) * (1 - backdrop));
}
/// <summary>
/// General composition function for all modes, with a general solution for alpha channel
/// </summary>
/// <param name="backdrop">Original Backdrop color</param>
/// <param name="source">Original source color</param>
/// <param name="xform">Desired transformed color, without taking Alpha channel in account</param>
/// <returns>The final color</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector4 SrcOverReference(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;
}
public static Vector4 Over(Vector4 dst, Vector4 src, Vector4 blend)
{
// calculate weights
@ -193,6 +169,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return color;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Atop(Vector4 dst, Vector4 src, Vector4 blend)
{
// calculate weights
@ -212,6 +189,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return color;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 In(Vector4 dst, Vector4 src, Vector4 blend)
{
float alpha = dst.W * src.W;
@ -223,6 +201,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return color;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Out(Vector4 dst, Vector4 src)
{
float alpha = (1 - dst.W) * src.W;
@ -234,6 +213,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return color;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Xor(Vector4 dst, Vector4 src)
{
float srcW = 1 - dst.W;
@ -249,6 +229,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
return color;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector4 Clear(Vector4 backdrop, Vector4 source)
{
return Vector4.Zero;

Loading…
Cancel
Save