2021-01-30 22:25:57 +00:00
|
|
|
import benchy, chroma, vmath, pixie/images
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
include pixie/blends
|
|
|
|
|
2020-12-09 07:25:48 +00:00
|
|
|
let
|
2021-01-23 04:54:57 +00:00
|
|
|
backdrop = newImage(256, 256)
|
|
|
|
source = newImage(256, 256)
|
|
|
|
source.fill(rgba(100, 100, 100, 100))
|
|
|
|
|
|
|
|
template reset() =
|
|
|
|
backdrop.fill(rgba(0, 0, 0, 255))
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendNormal":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendNormal(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendNormalFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendNormalFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendDarken":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendDarken(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendDarkenFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendDarkenFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendMultiply":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendMultiplyFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendMultiplyFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendLinearBurn":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendLinearBurnFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLinearBurnFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendColorBurn":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendColorBurn(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendColorBurnFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendColorBurnFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendLighten":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLighten(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendLightenFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLightenFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendScreen":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendScreenFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendScreenFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendLinearDodge":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendLinearDodgeFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLinearDodgeFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendColorDodge":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendColorDodge(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendColorDodgeFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendColorDodgeFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendOverlay":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendOverlay(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendOverlayFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendOverlayFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 13:47:58 +00:00
|
|
|
|
|
|
|
timeIt "blendSoftLight":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendSoftLight(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:04:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendSoftLightFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendSoftLightFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 07:18:57 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendHardLight":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendHardLight(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 07:18:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendHardLightFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendHardLightFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 07:18:57 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendDifference":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendDifference(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendDifferenceFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendDifferenceFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendExclusion":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendExclusion(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendExclusionFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendExclusionFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendHue":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendHue(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendHueFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendHueFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendSaturation":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendSaturation(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendSaturationFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendSaturationFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendColor":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendColor(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendColorFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendColorFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendLuminosity":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLuminosity(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendLuminosityFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendLuminosityFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendMask":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendMask(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendMaskFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendMaskFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendSubtractMask":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendSubtractMask(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendSubtractMaskFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendSubtractMaskFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendIntersectMask":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendIntersectMask(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendIntersectMaskFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendIntersectMaskFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2020-12-09 13:47:58 +00:00
|
|
|
timeIt "blendExcludeMask":
|
2021-01-23 04:54:57 +00:00
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
reset()
|
2020-12-09 08:59:01 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
timeIt "blendExcludeMaskFloats":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendExcludeMaskFloats(
|
|
|
|
backdrop.data[i].color, source.data[i].color
|
|
|
|
).rgba
|
2021-01-23 04:54:57 +00:00
|
|
|
|
2021-01-30 22:25:57 +00:00
|
|
|
reset()
|
2021-01-25 17:49:29 +00:00
|
|
|
|
|
|
|
timeIt "blendNormalPremultiplied":
|
|
|
|
for i in 0 ..< backdrop.data.len:
|
|
|
|
backdrop.data[i] = blendNormalPremultiplied(backdrop.data[i], source.data[i])
|
|
|
|
|
|
|
|
when defined(amd64) and not defined(pixieNoSimd):
|
|
|
|
import nimsimd/sse2
|
|
|
|
|
|
|
|
timeIt "blendNormalPremultiplied [simd]":
|
|
|
|
for i in countup(0, backdrop.data.len - 4, 4):
|
|
|
|
let
|
|
|
|
b = mm_loadu_si128(backdrop.data[i].addr)
|
|
|
|
s = mm_loadu_si128(source.data[i].addr)
|
|
|
|
mm_storeu_si128(backdrop.data[i].addr, blendNormalPremultiplied(b, s))
|