Browse Source

Tanners Top Tips!!

pull/2359/head
James Jackson-South 3 years ago
parent
commit
afdc53c090
  1. 198
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  2. 22
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  3. 83
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

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

@ -23,7 +23,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -49,7 +49,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Normal(backdrop, source));
}
@ -79,7 +79,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Normal(backdrop, source));
}
@ -109,7 +109,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -135,7 +135,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -187,7 +187,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Normal(source, backdrop));
}
@ -217,7 +217,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Normal(source, backdrop));
}
@ -247,7 +247,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -273,7 +273,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -299,7 +299,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -325,7 +325,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 NormalClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -568,7 +568,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -594,7 +594,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Multiply(backdrop, source));
}
@ -624,7 +624,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Multiply(backdrop, source));
}
@ -654,7 +654,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -680,7 +680,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplySrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -732,7 +732,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Multiply(source, backdrop));
}
@ -762,7 +762,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Multiply(source, backdrop));
}
@ -792,7 +792,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -818,7 +818,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -844,7 +844,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -870,7 +870,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 MultiplyClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -1113,7 +1113,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -1139,7 +1139,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Add(backdrop, source));
}
@ -1169,7 +1169,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Add(backdrop, source));
}
@ -1199,7 +1199,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -1225,7 +1225,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -1277,7 +1277,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Add(source, backdrop));
}
@ -1307,7 +1307,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Add(source, backdrop));
}
@ -1337,7 +1337,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -1363,7 +1363,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -1389,7 +1389,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -1415,7 +1415,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 AddClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -1658,7 +1658,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -1684,7 +1684,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Subtract(backdrop, source));
}
@ -1714,7 +1714,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Subtract(backdrop, source));
}
@ -1744,7 +1744,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -1770,7 +1770,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -1822,7 +1822,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Subtract(source, backdrop));
}
@ -1852,7 +1852,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Subtract(source, backdrop));
}
@ -1882,7 +1882,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -1908,7 +1908,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -1934,7 +1934,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -1960,7 +1960,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 SubtractClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -2203,7 +2203,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -2229,7 +2229,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Screen(backdrop, source));
}
@ -2259,7 +2259,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Screen(backdrop, source));
}
@ -2289,7 +2289,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -2315,7 +2315,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -2367,7 +2367,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Screen(source, backdrop));
}
@ -2397,7 +2397,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Screen(source, backdrop));
}
@ -2427,7 +2427,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -2453,7 +2453,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -2479,7 +2479,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -2505,7 +2505,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 ScreenClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -2748,7 +2748,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -2774,7 +2774,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Darken(backdrop, source));
}
@ -2804,7 +2804,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Darken(backdrop, source));
}
@ -2834,7 +2834,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -2860,7 +2860,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -2912,7 +2912,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Darken(source, backdrop));
}
@ -2942,7 +2942,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Darken(source, backdrop));
}
@ -2972,7 +2972,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -2998,7 +2998,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -3024,7 +3024,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -3050,7 +3050,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 DarkenClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -3293,7 +3293,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -3319,7 +3319,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Lighten(backdrop, source));
}
@ -3349,7 +3349,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Lighten(backdrop, source));
}
@ -3379,7 +3379,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -3405,7 +3405,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -3457,7 +3457,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Lighten(source, backdrop));
}
@ -3487,7 +3487,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Lighten(source, backdrop));
}
@ -3517,7 +3517,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -3543,7 +3543,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -3569,7 +3569,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -3595,7 +3595,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 LightenClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -3838,7 +3838,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -3864,7 +3864,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, Overlay(backdrop, source));
}
@ -3894,7 +3894,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, Overlay(backdrop, source));
}
@ -3924,7 +3924,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -3950,7 +3950,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlaySrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -4002,7 +4002,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, Overlay(source, backdrop));
}
@ -4032,7 +4032,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, Overlay(source, backdrop));
}
@ -4062,7 +4062,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -4088,7 +4088,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -4114,7 +4114,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -4140,7 +4140,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 OverlayClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}
@ -4383,7 +4383,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrc(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -4409,7 +4409,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, HardLight(backdrop, source));
}
@ -4439,7 +4439,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, HardLight(backdrop, source));
}
@ -4469,7 +4469,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -4495,7 +4495,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightSrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -4547,7 +4547,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, HardLight(source, backdrop));
}
@ -4577,7 +4577,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, HardLight(source, backdrop));
}
@ -4607,7 +4607,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -4633,7 +4633,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightDestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -4659,7 +4659,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightXor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -4685,7 +4685,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 HardLightClear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}

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

@ -33,7 +33,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>Src(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return source;
}
@ -59,7 +59,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(backdrop, source, <#=blender#>(backdrop, source));
}
@ -89,7 +89,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(backdrop, source, <#=blender#>(backdrop, source));
}
@ -119,7 +119,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(backdrop, source);
}
@ -145,7 +145,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>SrcOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(backdrop, source);
}
@ -197,7 +197,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Atop(source, backdrop, <#=blender#>(source, backdrop));
}
@ -227,7 +227,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestOver(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Over(source, backdrop, <#=blender#>(source, backdrop));
}
@ -257,7 +257,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestIn(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return In(source, backdrop);
}
@ -283,7 +283,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>DestOut(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Out(source, backdrop);
}
@ -309,7 +309,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>Xor(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Xor(backdrop, source);
}
@ -335,7 +335,7 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=blender#>Clear(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
source = WithW(source, source * opacity);
return Clear(backdrop, source);
}

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

@ -263,19 +263,22 @@ internal static partial class PorterDuffFunctions
public static Vector4 Over(Vector4 destination, Vector4 source, Vector4 blend)
{
// calculate weights
float blendW = destination.W * source.W;
float dstW = destination.W - blendW;
float srcW = source.W - blendW;
Vector4 sW = PermuteW(source);
Vector4 dW = PermuteW(destination);
Vector4 blendW = sW * dW;
Vector4 dstW = dW - blendW;
Vector4 srcW = sW - blendW;
// calculate final alpha
float alpha = dstW + source.W;
Vector4 alpha = dstW + sW;
// calculate final color
Vector4 color = (destination * dstW) + (source * srcW) + (blend * blendW);
// unpremultiply
color /= MathF.Max(alpha, Constants.Epsilon);
color.W = alpha;
color /= Vector4.Max(alpha, new(Constants.Epsilon));
color.W = alpha.W;
return color;
}
@ -322,18 +325,21 @@ internal static partial class PorterDuffFunctions
public static Vector4 Atop(Vector4 destination, Vector4 source, Vector4 blend)
{
// calculate weights
float blendW = destination.W * source.W;
float dstW = destination.W - blendW;
Vector4 sW = PermuteW(source);
Vector4 dW = PermuteW(destination);
Vector4 blendW = sW * dW;
Vector4 dstW = dW - blendW;
// calculate final alpha
float alpha = destination.W;
Vector4 alpha = dW;
// calculate final color
Vector4 color = (destination * dstW) + (blend * blendW);
// unpremultiply
color /= MathF.Max(alpha, Constants.Epsilon);
color.W = alpha;
color /= Vector4.Max(alpha, new(Constants.Epsilon));
color.W = alpha.W;
return color;
}
@ -373,11 +379,13 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 In(Vector4 destination, Vector4 source)
{
float alpha = destination.W * source.W;
Vector4 sW = PermuteW(source);
Vector4 dW = PermuteW(destination);
Vector4 alpha = dW * sW;
Vector4 color = source * alpha; // premultiply
color /= MathF.Max(alpha, Constants.Epsilon); // unpremultiply
color.W = alpha;
color /= Vector4.Max(alpha, new(Constants.Epsilon)); // unpremultiply
color.W = alpha.W;
return color;
}
@ -411,11 +419,13 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Out(Vector4 destination, Vector4 source)
{
float alpha = (1 - destination.W) * source.W;
Vector4 sW = PermuteW(source);
Vector4 dW = PermuteW(destination);
Vector4 alpha = (Vector4.One - dW) * sW;
Vector4 color = source * alpha; // premultiply
color /= MathF.Max(alpha, Constants.Epsilon); // unpremultiply
color.W = alpha;
color /= Vector4.Max(alpha, new(Constants.Epsilon)); // unpremultiply
color.W = alpha.W;
return color;
}
@ -449,15 +459,18 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Xor(Vector4 destination, Vector4 source)
{
float srcW = 1 - destination.W;
float dstW = 1 - source.W;
Vector4 sW = PermuteW(source);
Vector4 dW = PermuteW(destination);
Vector4 srcW = Vector4.One - dW;
Vector4 dstW = Vector4.One - sW;
float alpha = (source.W * srcW) + (destination.W * dstW);
Vector4 color = (source.W * source * srcW) + (destination.W * destination * dstW);
Vector4 alpha = (sW * srcW) + (dW * dstW);
Vector4 color = (sW * source * srcW) + (dW * destination * dstW);
// unpremultiply
color /= MathF.Max(alpha, Constants.Epsilon);
color.W = alpha;
color /= Vector4.Max(alpha, new(Constants.Epsilon));
color.W = alpha.W;
return color;
}
@ -493,4 +506,28 @@ internal static partial class PorterDuffFunctions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector256<float> Clear(Vector256<float> backdrop, Vector256<float> source) => Vector256<float>.Zero;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector4 WithW(Vector4 value, Vector4 w)
{
// TODO: Provide SSE fallback which uses "shuffle" - just pick XYZ from value and W from w
if (Sse41.IsSupported)
{
return Sse41.Insert(value.AsVector128(), w.AsVector128(), 0b11_11_0000).AsVector4();
}
value.W = w.W;
return value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector4 PermuteW(Vector4 value)
{
if (Sse.IsSupported)
{
return Sse.Shuffle(value.AsVector128(), value.AsVector128(), 0b11111111).AsVector4();
}
return new(value.W);
}
}

Loading…
Cancel
Save