image + (image|mask) works
This commit is contained in:
parent
243f9a3ba1
commit
debceb255a
1 changed files with 52 additions and 17 deletions
|
@ -693,23 +693,58 @@ proc drawUber(a, b: Image | Mask, mat = mat3(), blendMode = bmNormal) =
|
||||||
a.setValueUnsafe(x, y, masker(backdrop, sample))
|
a.setValueUnsafe(x, y, masker(backdrop, sample))
|
||||||
else:
|
else:
|
||||||
var x = xMin
|
var x = xMin
|
||||||
# when defined(amd64) and not defined(pixieNoSimd):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
# if blendMode.hasSimdBlender():
|
if dx.x == 1 and dx.y == 0 and dy.x == 0 and dy.y == 1:
|
||||||
# if dx.x == 1 and dx.y == 0 and dy.x == 0 and dy.y == 1:
|
# Check we are not rotated before using SIMD blends
|
||||||
# # Check we are not rotated before using SIMD blends
|
when type(a) is Image:
|
||||||
# let blenderSimd = blendMode.blenderSimd()
|
if blendMode.hasSimdBlender():
|
||||||
# for _ in countup(x, xMax - 4, 4):
|
let
|
||||||
# let
|
blenderSimd = blendMode.blenderSimd()
|
||||||
# srcPos = p + dx * x.float32 + dy * y.float32
|
first32 = cast[M128i]([uint32.high, 0, 0, 0]) # First 32 bits
|
||||||
# sx = srcPos.x.int
|
alphaMask = mm_set1_epi32(cast[int32](0xff000000)) # Only `a`
|
||||||
# sy = srcPos.y.int
|
for _ in countup(x, xMax - 4, 4):
|
||||||
# backdrop = mm_loadu_si128(a.data[a.dataIndex(x, y)].addr)
|
let
|
||||||
# source = mm_loadu_si128(b.data[b.dataIndex(sx, sy)].addr)
|
srcPos = p + dx * x.float32 + dy * y.float32
|
||||||
# mm_storeu_si128(
|
sx = srcPos.x.int
|
||||||
# a.data[a.dataIndex(x, y)].addr,
|
sy = srcPos.y.int
|
||||||
# blenderSimd(backdrop, source)
|
backdrop = mm_loadu_si128(a.data[a.dataIndex(x, y)].addr)
|
||||||
# )
|
when type(b) is Image:
|
||||||
# x += 4
|
let source = mm_loadu_si128(b.data[b.dataIndex(sx, sy)].addr)
|
||||||
|
else: # b is a Mask
|
||||||
|
# Need to move 4 mask values into the alpha slots
|
||||||
|
var source = mm_loadu_si128(b.data[b.dataIndex(sx, sy)].addr)
|
||||||
|
source = mm_slli_si128(source, 2)
|
||||||
|
source = mm_shuffle_epi32(source, MM_SHUFFLE(1, 1, 0, 0))
|
||||||
|
|
||||||
|
var
|
||||||
|
i = mm_and_si128(source, first32)
|
||||||
|
j = mm_and_si128(source, mm_slli_si128(first32, 4))
|
||||||
|
k = mm_and_si128(source, mm_slli_si128(first32, 8))
|
||||||
|
l = mm_and_si128(source, mm_slli_si128(first32, 12))
|
||||||
|
|
||||||
|
# Shift the values to `a`
|
||||||
|
i = mm_slli_si128(i, 1)
|
||||||
|
k = mm_slli_si128(k, 3)
|
||||||
|
l = mm_slli_si128(l, 2)
|
||||||
|
|
||||||
|
source = mm_and_si128(
|
||||||
|
mm_or_si128(mm_or_si128(i, j), mm_or_si128(k, l)),
|
||||||
|
alphaMask
|
||||||
|
)
|
||||||
|
|
||||||
|
mm_storeu_si128(
|
||||||
|
a.data[a.dataIndex(x, y)].addr,
|
||||||
|
blenderSimd(backdrop, source)
|
||||||
|
)
|
||||||
|
x += 4
|
||||||
|
|
||||||
|
else: # is a Mask
|
||||||
|
if blendMode.hasSimdMasker():
|
||||||
|
let maskerSimd = blendMode.maskerSimd()
|
||||||
|
when type(b) is Image:
|
||||||
|
discard
|
||||||
|
else: # b is a Mask
|
||||||
|
discard
|
||||||
|
|
||||||
for _ in x ..< xMax:
|
for _ in x ..< xMax:
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in a new issue