benchmarking blends

This commit is contained in:
Ryan Oldenburg 2020-12-09 01:18:57 -06:00
parent 0986557a90
commit bad415401a
2 changed files with 19 additions and 0 deletions

View file

@ -326,18 +326,21 @@ proc blendNormal(a, b: ColorRGBA): ColorRGBA =
result.g = b.g
result.b = b.b
result = alphaFix(a, b, result)
# blendNormalFloats(a.color, b.color).rgba
proc blendDarken(a, b: ColorRGBA): ColorRGBA =
result.r = min(a.r, b.r)
result.g = min(a.g, b.g)
result.b = min(a.b, b.b)
result = alphaFix(a, b, result)
# blendDarkenFloats(a.color, b.color).rgba
proc blendMultiply(a, b: ColorRGBA): ColorRGBA =
result.r = ((a.r.uint32 * b.r.uint32) div 255).uint8
result.g = ((a.g.uint32 * b.g.uint32) div 255).uint8
result.b = ((a.b.uint32 * b.b.uint32) div 255).uint8
result = alphaFix(a, b, result)
# blendMultiplyFloats(a.color, b.color).rgba
proc blendLinearBurn(a, b: ColorRGBA): ColorRGBA =
result.r = max(0, a.r.int32 + b.r.int32 - 255).uint8

View file

@ -0,0 +1,16 @@
import benchy, chroma, pixie, vmath
let
a = newImage(1000, 1000)
b = newImage(1000, 1000)
b.fill(rgba(127, 127, 127, 255))
timeIt "bmNormal":
a.draw(b, vec2(0, 0), bmNormal)
timeIt "bmDarken":
a.draw(b, vec2(0, 0), bmDarken)
timeIt "bmMultiply":
a.draw(b, vec2(0, 0), bmMultiply)