better names

This commit is contained in:
Ryan Oldenburg 2022-06-16 21:54:02 -05:00
parent a519ecdf13
commit 1d486783fa
3 changed files with 32 additions and 32 deletions

View file

@ -11,8 +11,8 @@ when defined(amd64) and allowSimd:
type type
Blender* = proc(backdrop, source: ColorRGBX): ColorRGBX {.gcsafe, raises: [].} Blender* = proc(backdrop, source: ColorRGBX): ColorRGBX {.gcsafe, raises: [].}
## Function signature returned by blender. ## Function signature returned by blender.
Masker* = proc(backdrop, source: uint8): uint8 {.gcsafe, raises: [].} MaskBlender* = proc(backdrop, source: uint8): uint8 {.gcsafe, raises: [].}
## Function signature returned by masker. ## Function signature returned by maskBlender.
when defined(release): when defined(release):
{.push checks: off.} {.push checks: off.}
@ -484,29 +484,29 @@ proc maskBlendExclude*(backdrop, source: uint8): uint8 {.inline.} =
## Exclude blend masks ## Exclude blend masks
max(backdrop, source) - min(backdrop, source) max(backdrop, source) - min(backdrop, source)
proc maskBlendNormalMasker(backdrop, source: uint8): uint8 = proc maskBlendNormalMaskBlender(backdrop, source: uint8): uint8 =
maskBlendNormal(backdrop, source) maskBlendNormal(backdrop, source)
proc maskBlendMaskMasker(backdrop, source: uint8): uint8 = proc maskBlendMaskMaskBlender(backdrop, source: uint8): uint8 =
maskBlendMask(backdrop, source) maskBlendMask(backdrop, source)
proc maskBlendSubtractMasker(backdrop, source: uint8): uint8 = proc maskBlendSubtractMaskBlender(backdrop, source: uint8): uint8 =
maskBlendSubtract(backdrop, source) maskBlendSubtract(backdrop, source)
proc maskBlendExcludeMasker(backdrop, source: uint8): uint8 = proc maskBlendExcludeMaskBlender(backdrop, source: uint8): uint8 =
maskBlendExclude(backdrop, source) maskBlendExclude(backdrop, source)
proc maskBlendOverwriteMasker(backdrop, source: uint8): uint8 = proc maskBlendOverwriteMaskBlender(backdrop, source: uint8): uint8 =
source source
proc masker*(blendMode: BlendMode): Masker {.raises: [PixieError].} = proc maskBlender*(blendMode: BlendMode): MaskBlender {.raises: [PixieError].} =
## Returns a blend masking function for a given blend masking mode. ## Returns a blend masking function for a given blend masking mode.
case blendMode: case blendMode:
of NormalBlend: maskBlendNormalMasker of NormalBlend: maskBlendNormalMaskBlender
of MaskBlend: maskBlendMaskMasker of MaskBlend: maskBlendMaskMaskBlender
of OverwriteBlend: maskBlendOverwriteMasker of OverwriteBlend: maskBlendOverwriteMaskBlender
of SubtractMaskBlend: maskBlendSubtractMasker of SubtractMaskBlend: maskBlendSubtractMaskBlender
of ExcludeMaskBlend: maskBlendExcludeMasker of ExcludeMaskBlend: maskBlendExcludeMaskBlender
else: else:
raise newException(PixieError, "No masker for " & $blendMode) raise newException(PixieError, "No masker for " & $blendMode)
@ -672,30 +672,30 @@ when defined(amd64) and allowSimd:
proc maskBlendExcludeSimd*(backdrop, source: M128i): M128i {.inline.} = proc maskBlendExcludeSimd*(backdrop, source: M128i): M128i {.inline.} =
mm_sub_epi8(mm_max_epu8(backdrop, source), mm_min_epu8(backdrop, source)) mm_sub_epi8(mm_max_epu8(backdrop, source), mm_min_epu8(backdrop, source))
proc maskBlendNormalSimdMasker(backdrop, source: M128i): M128i = proc maskBlendNormalSimdMaskBlender(backdrop, source: M128i): M128i =
maskBlendNormalSimd(backdrop, source) maskBlendNormalSimd(backdrop, source)
proc maskBlendMaskSimdMasker(backdrop, source: M128i): M128i = proc maskBlendMaskSimdMaskBlender(backdrop, source: M128i): M128i =
maskBlendMaskSimd(backdrop, source) maskBlendMaskSimd(backdrop, source)
proc maskBlendExcludeSimdMasker(backdrop, source: M128i): M128i = proc maskBlendExcludeSimdMaskBlender(backdrop, source: M128i): M128i =
maskBlendExcludeSimd(backdrop, source) maskBlendExcludeSimd(backdrop, source)
proc maskBlendSubtractSimdMasker(backdrop, source: M128i): M128i = proc maskBlendSubtractSimdMaskBlender(backdrop, source: M128i): M128i =
maskBlendSubtractSimd(backdrop, source) maskBlendSubtractSimd(backdrop, source)
proc maskerSimd*(blendMode: BlendMode): MaskerSimd {.raises: [PixieError].} = proc maskBlenderSimd*(blendMode: BlendMode): MaskerSimd {.raises: [PixieError].} =
## Returns a blend masking function with SIMD support. ## Returns a blend masking function with SIMD support.
case blendMode: case blendMode:
of NormalBlend: maskBlendNormalSimdMasker of NormalBlend: maskBlendNormalSimdMaskBlender
of MaskBlend: maskBlendMaskSimdMasker of MaskBlend: maskBlendMaskSimdMaskBlender
of OverwriteBlend: overwriteSimdBlender of OverwriteBlend: overwriteSimdBlender
of SubtractMaskBlend: maskBlendSubtractSimdMasker of SubtractMaskBlend: maskBlendSubtractSimdMaskBlender
of ExcludeMaskBlend: maskBlendExcludeSimdMasker of ExcludeMaskBlend: maskBlendExcludeSimdMaskBlender
else: else:
raise newException(PixieError, "No SIMD masker for " & $blendMode) raise newException(PixieError, "No SIMD masker for " & $blendMode)
proc hasSimdMasker*(blendMode: BlendMode): bool {.inline, raises: [].} = proc hasSimdMaskBlender*(blendMode: BlendMode): bool {.inline, raises: [].} =
## Is there a blend masking function with SIMD support? ## Is there a blend masking function with SIMD support?
blendMode in { blendMode in {
NormalBlend, NormalBlend,

View file

@ -714,7 +714,7 @@ proc drawUber(
when type(a) is Image: when type(a) is Image:
let blender = blendMode.blender() let blender = blendMode.blender()
else: # a is a Mask else: # a is a Mask
let masker = blendMode.masker() let maskBlender = blendMode.maskBlender()
if blendMode == MaskBlend: if blendMode == MaskBlend:
if yMin > 0: if yMin > 0:
@ -777,7 +777,7 @@ proc drawUber(
let sample = b.getRgbaSmooth(srcPos.x, srcPos.y).a let sample = b.getRgbaSmooth(srcPos.x, srcPos.y).a
else: # b is a Mask else: # b is a Mask
let sample = b.getValueSmooth(srcPos.x, srcPos.y) let sample = b.getValueSmooth(srcPos.x, srcPos.y)
a.unsafe[x, y] = masker(backdrop, sample) a.unsafe[x, y] = maskBlender(backdrop, sample)
srcPos += dx srcPos += dx
@ -972,8 +972,8 @@ proc drawUber(
x += 16 x += 16
sx += 16 sx += 16
else: # is a Mask else: # is a Mask
if blendMode.hasSimdMasker(): if blendMode.hasSimdMaskBlender():
let maskerSimd = blendMode.maskerSimd() let maskerSimd = blendMode.maskBlenderSimd()
for _ in 0 ..< (xStop - xStart) div 16: for _ in 0 ..< (xStop - xStart) div 16:
let backdrop = mm_loadu_si128(a.data[a.dataIndex(x, y)].addr) let backdrop = mm_loadu_si128(a.data[a.dataIndex(x, y)].addr)
when type(b) is Image: when type(b) is Image:
@ -1089,7 +1089,7 @@ proc drawUber(
let sample = b.unsafe[samplePos.x, samplePos.y].a let sample = b.unsafe[samplePos.x, samplePos.y].a
else: # b is a Mask else: # b is a Mask
let sample = b.unsafe[samplePos.x, samplePos.y] let sample = b.unsafe[samplePos.x, samplePos.y]
a.unsafe[x, y] = masker(backdrop, sample) a.unsafe[x, y] = maskBlender(backdrop, sample)
srcPos += dx srcPos += dx
if blendMode == MaskBlend: if blendMode == MaskBlend:

View file

@ -1443,9 +1443,9 @@ proc fillCoverage(
) = ) =
var x = startX var x = startX
when defined(amd64) and allowSimd: when defined(amd64) and allowSimd:
if blendMode.hasSimdMasker(): if blendMode.hasSimdMaskBlender():
let let
maskerSimd = blendMode.maskerSimd() maskerSimd = blendMode.maskBlenderSimd()
vecZero = mm_setzero_si128() vecZero = mm_setzero_si128()
for _ in 0 ..< coverages.len div 16: for _ in 0 ..< coverages.len div 16:
let let
@ -1465,7 +1465,7 @@ proc fillCoverage(
mm_storeu_si128(mask.data[index].addr, vecZero) mm_storeu_si128(mask.data[index].addr, vecZero)
x += 16 x += 16
let masker = blendMode.masker() let maskBlender = blendMode.maskBlender()
for x in x ..< startX + coverages.len: for x in x ..< startX + coverages.len:
let coverage = coverages[x - startX] let coverage = coverages[x - startX]
if coverage != 0 or blendMode == ExcludeMaskBlend: if coverage != 0 or blendMode == ExcludeMaskBlend:
@ -1473,7 +1473,7 @@ proc fillCoverage(
mask.unsafe[x, y] = coverage mask.unsafe[x, y] = coverage
else: else:
let backdrop = mask.unsafe[x, y] let backdrop = mask.unsafe[x, y]
mask.unsafe[x, y] = masker(backdrop, coverage) mask.unsafe[x, y] = maskBlender(backdrop, coverage)
elif blendMode == MaskBlend: elif blendMode == MaskBlend:
mask.unsafe[x, y] = 0 mask.unsafe[x, y] = 0