faster packAlphaValues, better test
This commit is contained in:
parent
61e78bcc6a
commit
50621aec50
2 changed files with 5 additions and 16 deletions
|
@ -105,18 +105,7 @@ when defined(amd64) and not defined(pixieNoSimd):
|
|||
|
||||
proc unpackAlphaValues*(v: M128i): M128i {.inline, raises: [].} =
|
||||
## Unpack the first 32 bits into 4 rgba(0, 0, 0, value)
|
||||
let mask = cast[M128i]([uint8.high.uint64, 0])
|
||||
|
||||
var
|
||||
i = mm_and_si128(v, mask)
|
||||
j = mm_and_si128(v, mm_slli_si128(mask, 1))
|
||||
k = mm_and_si128(v, mm_slli_si128(mask, 2))
|
||||
l = mm_and_si128(v, mm_slli_si128(mask, 3))
|
||||
|
||||
# Shift the values to uint32 `a`
|
||||
i = mm_slli_si128(i, 3)
|
||||
j = mm_slli_si128(j, 6)
|
||||
k = mm_slli_si128(k, 9)
|
||||
l = mm_slli_si128(l, 12)
|
||||
|
||||
result = mm_or_si128(mm_or_si128(i, j), mm_or_si128(k, l))
|
||||
let
|
||||
a = mm_unpacklo_epi8(v, mm_setzero_si128())
|
||||
b = mm_unpacklo_epi8(a, mm_setzero_si128())
|
||||
result = mm_slli_epi32(b, 24) # Shift the values to uint32 `a`
|
||||
|
|
|
@ -145,7 +145,7 @@ block: # Test conversion between image and mask
|
|||
originalMask = newMask(100, 100)
|
||||
|
||||
let p = newPath()
|
||||
p.rect(10, 10, 80, 80)
|
||||
p.circle(50, 50, 25)
|
||||
|
||||
originalImage.fillPath(p, rgba(255, 0, 0, 255))
|
||||
originalMask.fillPath(p)
|
||||
|
|
Loading…
Reference in a new issue