nonsimd path
This commit is contained in:
parent
de13c129e4
commit
64e6db2cef
2 changed files with 65 additions and 24 deletions
|
@ -165,7 +165,7 @@ proc SetSat(C: Color, s: float32): Color {.inline.} =
|
||||||
if satC > 0:
|
if satC > 0:
|
||||||
result = (C - min([C.r, C.g, C.b])) * s / satC
|
result = (C - min([C.r, C.g, C.b])) * s / satC
|
||||||
|
|
||||||
proc blendNormal(backdrop, source: ColorRGBX): ColorRGBX =
|
proc blendNormal*(backdrop, source: ColorRGBX): ColorRGBX =
|
||||||
if backdrop.a == 0 or source.a == 255:
|
if backdrop.a == 0 or source.a == 255:
|
||||||
return source
|
return source
|
||||||
if source.a == 0:
|
if source.a == 0:
|
||||||
|
|
|
@ -913,9 +913,51 @@ proc drawUber(
|
||||||
clamp(srcPos.y, 0, b.height.float32)
|
clamp(srcPos.y, 0, b.height.float32)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if blendMode == bmOverwrite:
|
||||||
|
for x in x ..< xMax:
|
||||||
|
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
|
||||||
|
when type(a) is Image:
|
||||||
|
when type(b) is Image:
|
||||||
|
let source = b.unsafe[samplePos.x, samplePos.y]
|
||||||
|
else: # b is a Mask
|
||||||
|
let source = rgbx(0, 0, 0, b.unsafe[samplePos.x, samplePos.y])
|
||||||
|
a.unsafe[x, y] = source
|
||||||
|
else: # a is a Mask
|
||||||
|
when type(b) is Image:
|
||||||
|
let source = b.unsafe[samplePos.x, samplePos.y].a
|
||||||
|
else: # b is a Mask
|
||||||
|
let source = b.unsafe[samplePos.x, samplePos.y]
|
||||||
|
a.unsafe[x, y] = source
|
||||||
|
srcPos += dx
|
||||||
|
elif blendMode == bmNormal:
|
||||||
|
for x in x ..< xMax:
|
||||||
|
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
|
||||||
|
when type(a) is Image:
|
||||||
|
when type(b) is Image:
|
||||||
|
let source = b.unsafe[samplePos.x, samplePos.y]
|
||||||
|
else: # b is a Mask
|
||||||
|
let source = rgbx(0, 0, 0, b.unsafe[samplePos.x, samplePos.y])
|
||||||
|
if source.a > 0:
|
||||||
|
if source.a == 255:
|
||||||
|
a.unsafe[x, y] = source
|
||||||
|
else:
|
||||||
|
let backdrop = a.unsafe[x, y]
|
||||||
|
a.unsafe[x, y] = blendNormal(backdrop, source)
|
||||||
|
else: # a is a Mask
|
||||||
|
when type(b) is Image:
|
||||||
|
let source = b.unsafe[samplePos.x, samplePos.y].a
|
||||||
|
else: # b is a Mask
|
||||||
|
let source = b.unsafe[samplePos.x, samplePos.y]
|
||||||
|
if source > 0:
|
||||||
|
if source == 255:
|
||||||
|
a.unsafe[x, y] = source
|
||||||
|
else:
|
||||||
|
let backdrop = a.unsafe[x, y]
|
||||||
|
a.unsafe[x, y] = blendAlpha(backdrop, source)
|
||||||
|
srcPos += dx
|
||||||
|
else:
|
||||||
for x in x ..< xMax:
|
for x in x ..< xMax:
|
||||||
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
|
let samplePos = ivec2((srcPos.x - h).int32, (srcPos.y - h).int32)
|
||||||
|
|
||||||
when type(a) is Image:
|
when type(a) is Image:
|
||||||
let backdrop = a.unsafe[x, y]
|
let backdrop = a.unsafe[x, y]
|
||||||
when type(b) is Image:
|
when type(b) is Image:
|
||||||
|
@ -934,7 +976,6 @@ proc drawUber(
|
||||||
else: # b is a Mask
|
else: # b is a Mask
|
||||||
let sample = b.unsafe[samplePos.x, samplePos.y]
|
let sample = b.unsafe[samplePos.x, samplePos.y]
|
||||||
a.unsafe[x, y] = masker(backdrop, sample)
|
a.unsafe[x, y] = masker(backdrop, sample)
|
||||||
|
|
||||||
srcPos += dx
|
srcPos += dx
|
||||||
|
|
||||||
if blendMode == bmMask:
|
if blendMode == bmMask:
|
||||||
|
|
Loading…
Reference in a new issue