Merge pull request #470 from treeform/dev2

Fix non-simd magnifyBy2
This commit is contained in:
Andre von Houck 2022-07-22 11:04:48 -07:00 committed by GitHub
commit 915f74df75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -152,18 +152,17 @@ proc magnifyBy2*(mask: Mask, power = 1): Mask {.raises: [PixieError].} =
x += 16 x += 16
for x in x ..< mask.width: for x in x ..< mask.width:
let let
value = mask.unsafe[x, y div scale] value = mask.unsafe[x, y]
scaledX = x * scale resultIdx = result.dataIndex(x * scale, y * scale)
idx = result.dataIndex(scaledX, y)
for i in 0 ..< scale: for i in 0 ..< scale:
result.data[idx + i] = value result.data[resultIdx + i] = value
# Copy that row of values into (scale - 1) more rows # Copy that row of values into (scale - 1) more rows
let rowStart = result.dataIndex(0, y * scale) let rowStart = result.dataIndex(0, y * scale)
for i in 1 ..< scale: for i in 1 ..< scale:
copyMem( copyMem(
result.data[rowStart + result.width * i].addr, result.data[rowStart + result.width * i].addr,
result.data[rowStart].addr, result.data[rowStart].addr,
result.width * 4 result.width
) )
proc applyOpacity*(target: Mask, opacity: float32) {.hasSimd, raises: [].} = proc applyOpacity*(target: Mask, opacity: float32) {.hasSimd, raises: [].} =