no need for setmem
This commit is contained in:
parent
25cbf803cc
commit
e8da814856
1 changed files with 8 additions and 11 deletions
|
@ -70,17 +70,14 @@ proc `[]=`*(image: Image, x, y: int, rgba: ColorRGBA) {.inline.} =
|
||||||
|
|
||||||
proc fill*(image: Image, rgba: ColorRgba) =
|
proc fill*(image: Image, rgba: ColorRgba) =
|
||||||
## Fills the image with a solid color.
|
## Fills the image with a solid color.
|
||||||
if rgba.r == rgba.g and rgba.r == rgba.b and rgba.r == rgba.a:
|
# SIMD fill until we run out of room.
|
||||||
nimSetMem(image.data[0].addr, rgba.r.cint, image.data.len * 4)
|
let m = mm_set1_epi32(cast[int32](rgba))
|
||||||
else:
|
var i: int
|
||||||
# SIMD fill until we run out of room.
|
while i < image.data.len - 4:
|
||||||
let m = mm_set1_epi32(cast[int32](rgba))
|
mm_store_si128(image.data[i].addr, m)
|
||||||
var i: int
|
i += 4
|
||||||
while i < image.data.len - 4:
|
for j in i ..< image.data.len:
|
||||||
mm_store_si128(image.data[i].addr, m)
|
image.data[j] = rgba
|
||||||
i += 4
|
|
||||||
for j in i ..< image.data.len:
|
|
||||||
image.data[j] = rgba
|
|
||||||
|
|
||||||
proc invert*(image: Image) =
|
proc invert*(image: Image) =
|
||||||
## Inverts all of the colors and alpha.
|
## Inverts all of the colors and alpha.
|
||||||
|
|
Loading…
Reference in a new issue