This commit is contained in:
Ryan Oldenburg 2022-07-31 13:32:12 -05:00
parent dd7bf9f210
commit 6582f7c4ca
2 changed files with 12 additions and 12 deletions

View file

@ -436,26 +436,26 @@ proc drawCorrect(
blended = blender(backdrop, sample)
a.unsafe[x, y] = blended
proc blitLine(
proc blendLine(
a, b: ptr UncheckedArray[ColorRGBX], len: int, blender: Blender
) {.inline.} =
for i in 0 ..< len:
a[i] = blender(a[i], b[i])
proc blitLineOverwrite(
proc blendLineOverwrite(
a, b: ptr UncheckedArray[ColorRGBX], len: int
) {.inline.} =
copyMem(a[0].addr, b[0].addr, len * 4)
proc blitLineNormal(a, b: ptr UncheckedArray[ColorRGBX], len: int) {.hasSimd.} =
proc blendLineNormal(a, b: ptr UncheckedArray[ColorRGBX], len: int) {.hasSimd.} =
for i in 0 ..< len:
a[i] = blendNormal(a[i], b[i])
proc blitLineMask(a, b: ptr UncheckedArray[ColorRGBX], len: int) {.hasSimd.} =
proc blendLineMask(a, b: ptr UncheckedArray[ColorRGBX], len: int) {.hasSimd.} =
for i in 0 ..< len:
a[i] = blendMask(a[i], b[i])
proc blitRect(a, b: Image, pos: Ivec2, blendMode: BlendMode) =
proc blendRect(a, b: Image, pos: Ivec2, blendMode: BlendMode) =
let
px = pos.x.int
py = pos.y.int
@ -474,14 +474,14 @@ proc blitRect(a, b: Image, pos: Ivec2, blendMode: BlendMode) =
case blendMode:
of NormalBlend:
for y in yStart ..< yEnd:
blitLineNormal(
blendLineNormal(
a.getUncheckedArray(xStart + px, y + py),
b.getUncheckedArray(xStart, y),
xEnd - xStart
)
of OverwriteBlend:
for y in yStart ..< yEnd:
blitLineOverwrite(
blendLineOverwrite(
a.getUncheckedArray(xStart + px, y + py),
b.getUncheckedArray(xStart, y),
xEnd - xStart
@ -493,7 +493,7 @@ proc blitRect(a, b: Image, pos: Ivec2, blendMode: BlendMode) =
for y in yStart ..< yEnd:
if xStart + px > 0:
zeroMem(a.data[a.dataIndex(0, y + py)].addr, (xStart + px) * 4)
blitLineMask(
blendLineMask(
a.getUncheckedArray(xStart + px, y + py),
b.getUncheckedArray(xStart, y),
xEnd - xStart
@ -511,7 +511,7 @@ proc blitRect(a, b: Image, pos: Ivec2, blendMode: BlendMode) =
else:
let blender = blendMode.blender()
for y in yStart ..< yEnd:
blitLine(
blendLine(
a.getUncheckedArray(xStart + px, y + py),
b.getUncheckedArray(xStart, y),
xEnd - xStart,
@ -559,7 +559,7 @@ proc draw*(
if hasRotationOrScaling or smooth:
a.drawCorrect(b, inverseTransform.inverse(), blendMode, false)
else:
a.blitRect(b, ivec2(transform[2, 0].int32, transform[2, 1].int32), blendMode)
a.blendRect(b, ivec2(transform[2, 0].int32, transform[2, 1].int32), blendMode)
proc drawTiled*(
dst, src: Image, mat: Mat3, blendMode = NormalBlend

View file

@ -568,7 +568,7 @@ proc blendLineNormalSse2*(
for i in i ..< len:
line[i] = blendNormal(line[i], rgbx)
proc blitLineNormalSse2*(
proc blendLineNormalSse2*(
a, b: ptr UncheckedArray[ColorRGBX], len: int
) {.simd.} =
var i: int
@ -653,7 +653,7 @@ proc blendLineMaskSse2*(
for i in i ..< len:
line[i] = blendMask(line[i], rgbx)
proc blitLineMaskSse2*(
proc blendLineMaskSse2*(
a, b: ptr UncheckedArray[ColorRGBX], len: int
) {.simd.} =
var i: int