blends exports

This commit is contained in:
Ryan Oldenburg 2021-02-13 20:57:58 -06:00
parent 28f831249f
commit fc23bda80f
2 changed files with 11 additions and 7 deletions

View file

@ -160,7 +160,7 @@ proc SetSat(C: Color, s: float32): Color {.inline.} =
if satC > 0:
result = (C - min([C.r, C.g, C.b])) * s / satC
proc blendNormal*(backdrop, source: ColorRGBA): ColorRGBA =
proc blendNormal(backdrop, source: ColorRGBA): ColorRGBA =
if backdrop.a == 0:
return source
if source.a == 255:
@ -541,7 +541,7 @@ when defined(amd64) and not defined(pixieNoSimd):
alphaMask
)
proc blendNormalSimd*(backdrop, source: M128i): M128i =
proc blendNormalSimd(backdrop, source: M128i): M128i =
let
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
oddMask = mm_set1_epi16(cast[int16](0xff00))
@ -570,7 +570,7 @@ when defined(amd64) and not defined(pixieNoSimd):
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
)
proc blendMaskSimd*(backdrop, source: M128i): M128i =
proc blendMaskSimd(backdrop, source: M128i): M128i =
let
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
oddMask = mm_set1_epi16(cast[int16](0xff00))
@ -591,7 +591,7 @@ when defined(amd64) and not defined(pixieNoSimd):
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
proc blendOverwriteSimd*(backdrop, source: M128i): M128i =
proc blendOverwriteSimd(backdrop, source: M128i): M128i =
source
proc blenderSimd*(blendMode: BlendMode): BlenderSimd =
@ -605,7 +605,7 @@ when defined(amd64) and not defined(pixieNoSimd):
proc hasSimdBlender*(blendMode: BlendMode): bool =
blendMode in {bmNormal, bmMask, bmOverwrite}
proc maskNormalSimd*(backdrop, source: M128i): M128i =
proc maskNormalSimd(backdrop, source: M128i): M128i =
## Blending masks
let
oddMask = mm_set1_epi16(cast[int16](0xff00))
@ -642,7 +642,7 @@ when defined(amd64) and not defined(pixieNoSimd):
mm_or_si128(blendedEven, mm_slli_epi16(blendedOdd, 8))
proc maskMaskSimd*(backdrop, source: M128i): M128i =
proc maskMaskSimd(backdrop, source: M128i): M128i =
let
oddMask = mm_set1_epi16(cast[int16](0xff00))
div255 = mm_set1_epi16(cast[int16](0x8081))

View file

@ -1050,6 +1050,10 @@ proc fillShapes(
coverages = newSeq[uint8](mask.width)
hits = newSeq[(float32, int16)](4)
when defined(amd64) and not defined(pixieNoSimd):
let maskerSimd = bmNormal.maskerSimd()
for y in startY ..< stopY:
# Reset buffer for this row
zeroMem(coverages[0].addr, coverages.len)
@ -1076,7 +1080,7 @@ proc fillShapes(
let backdrop = mm_loadu_si128(mask.data[mask.dataIndex(x, y)].addr)
mm_storeu_si128(
mask.data[mask.dataIndex(x, y)].addr,
maskNormalSimd(backdrop, coverage)
maskerSimd(backdrop, coverage)
)
x += 16