no need for setmem

This commit is contained in:
Ryan Oldenburg 2020-12-08 21:51:09 -06:00
parent 25cbf803cc
commit e8da814856

View file

@ -70,17 +70,14 @@ proc `[]=`*(image: Image, x, y: int, rgba: ColorRGBA) {.inline.} =
proc fill*(image: Image, rgba: ColorRgba) =
## Fills the image with a solid color.
if rgba.r == rgba.g and rgba.r == rgba.b and rgba.r == rgba.a:
nimSetMem(image.data[0].addr, rgba.r.cint, image.data.len * 4)
else:
# SIMD fill until we run out of room.
let m = mm_set1_epi32(cast[int32](rgba))
var i: int
while i < image.data.len - 4:
mm_store_si128(image.data[i].addr, m)
i += 4
for j in i ..< image.data.len:
image.data[j] = rgba
# SIMD fill until we run out of room.
let m = mm_set1_epi32(cast[int32](rgba))
var i: int
while i < image.data.len - 4:
mm_store_si128(image.data[i].addr, m)
i += 4
for j in i ..< image.data.len:
image.data[j] = rgba
proc invert*(image: Image) =
## Inverts all of the colors and alpha.