better names
This commit is contained in:
parent
a519ecdf13
commit
1d486783fa
3 changed files with 32 additions and 32 deletions
|
@ -11,8 +11,8 @@ when defined(amd64) and allowSimd:
|
|||
type
|
||||
Blender* = proc(backdrop, source: ColorRGBX): ColorRGBX {.gcsafe, raises: [].}
|
||||
## Function signature returned by blender.
|
||||
Masker* = proc(backdrop, source: uint8): uint8 {.gcsafe, raises: [].}
|
||||
## Function signature returned by masker.
|
||||
MaskBlender* = proc(backdrop, source: uint8): uint8 {.gcsafe, raises: [].}
|
||||
## Function signature returned by maskBlender.
|
||||
|
||||
when defined(release):
|
||||
{.push checks: off.}
|
||||
|
@ -484,29 +484,29 @@ proc maskBlendExclude*(backdrop, source: uint8): uint8 {.inline.} =
|
|||
## Exclude blend masks
|
||||
max(backdrop, source) - min(backdrop, source)
|
||||
|
||||
proc maskBlendNormalMasker(backdrop, source: uint8): uint8 =
|
||||
proc maskBlendNormalMaskBlender(backdrop, source: uint8): uint8 =
|
||||
maskBlendNormal(backdrop, source)
|
||||
|
||||
proc maskBlendMaskMasker(backdrop, source: uint8): uint8 =
|
||||
proc maskBlendMaskMaskBlender(backdrop, source: uint8): uint8 =
|
||||
maskBlendMask(backdrop, source)
|
||||
|
||||
proc maskBlendSubtractMasker(backdrop, source: uint8): uint8 =
|
||||
proc maskBlendSubtractMaskBlender(backdrop, source: uint8): uint8 =
|
||||
maskBlendSubtract(backdrop, source)
|
||||
|
||||
proc maskBlendExcludeMasker(backdrop, source: uint8): uint8 =
|
||||
proc maskBlendExcludeMaskBlender(backdrop, source: uint8): uint8 =
|
||||
maskBlendExclude(backdrop, source)
|
||||
|
||||
proc maskBlendOverwriteMasker(backdrop, source: uint8): uint8 =
|
||||
proc maskBlendOverwriteMaskBlender(backdrop, source: uint8): uint8 =
|
||||
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.
|
||||
case blendMode:
|
||||
of NormalBlend: maskBlendNormalMasker
|
||||
of MaskBlend: maskBlendMaskMasker
|
||||
of OverwriteBlend: maskBlendOverwriteMasker
|
||||
of SubtractMaskBlend: maskBlendSubtractMasker
|
||||
of ExcludeMaskBlend: maskBlendExcludeMasker
|
||||
of NormalBlend: maskBlendNormalMaskBlender
|
||||
of MaskBlend: maskBlendMaskMaskBlender
|
||||
of OverwriteBlend: maskBlendOverwriteMaskBlender
|
||||
of SubtractMaskBlend: maskBlendSubtractMaskBlender
|
||||
of ExcludeMaskBlend: maskBlendExcludeMaskBlender
|
||||
else:
|
||||
raise newException(PixieError, "No masker for " & $blendMode)
|
||||
|
||||
|
@ -672,30 +672,30 @@ when defined(amd64) and allowSimd:
|
|||
proc maskBlendExcludeSimd*(backdrop, source: M128i): M128i {.inline.} =
|
||||
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)
|
||||
|
||||
proc maskBlendMaskSimdMasker(backdrop, source: M128i): M128i =
|
||||
proc maskBlendMaskSimdMaskBlender(backdrop, source: M128i): M128i =
|
||||
maskBlendMaskSimd(backdrop, source)
|
||||
|
||||
proc maskBlendExcludeSimdMasker(backdrop, source: M128i): M128i =
|
||||
proc maskBlendExcludeSimdMaskBlender(backdrop, source: M128i): M128i =
|
||||
maskBlendExcludeSimd(backdrop, source)
|
||||
|
||||
proc maskBlendSubtractSimdMasker(backdrop, source: M128i): M128i =
|
||||
proc maskBlendSubtractSimdMaskBlender(backdrop, source: M128i): M128i =
|
||||
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.
|
||||
case blendMode:
|
||||
of NormalBlend: maskBlendNormalSimdMasker
|
||||
of MaskBlend: maskBlendMaskSimdMasker
|
||||
of NormalBlend: maskBlendNormalSimdMaskBlender
|
||||
of MaskBlend: maskBlendMaskSimdMaskBlender
|
||||
of OverwriteBlend: overwriteSimdBlender
|
||||
of SubtractMaskBlend: maskBlendSubtractSimdMasker
|
||||
of ExcludeMaskBlend: maskBlendExcludeSimdMasker
|
||||
of SubtractMaskBlend: maskBlendSubtractSimdMaskBlender
|
||||
of ExcludeMaskBlend: maskBlendExcludeSimdMaskBlender
|
||||
else:
|
||||
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?
|
||||
blendMode in {
|
||||
NormalBlend,
|
||||
|
|
|
@ -714,7 +714,7 @@ proc drawUber(
|
|||
when type(a) is Image:
|
||||
let blender = blendMode.blender()
|
||||
else: # a is a Mask
|
||||
let masker = blendMode.masker()
|
||||
let maskBlender = blendMode.maskBlender()
|
||||
|
||||
if blendMode == MaskBlend:
|
||||
if yMin > 0:
|
||||
|
@ -777,7 +777,7 @@ proc drawUber(
|
|||
let sample = b.getRgbaSmooth(srcPos.x, srcPos.y).a
|
||||
else: # b is a Mask
|
||||
let sample = b.getValueSmooth(srcPos.x, srcPos.y)
|
||||
a.unsafe[x, y] = masker(backdrop, sample)
|
||||
a.unsafe[x, y] = maskBlender(backdrop, sample)
|
||||
|
||||
srcPos += dx
|
||||
|
||||
|
@ -972,8 +972,8 @@ proc drawUber(
|
|||
x += 16
|
||||
sx += 16
|
||||
else: # is a Mask
|
||||
if blendMode.hasSimdMasker():
|
||||
let maskerSimd = blendMode.maskerSimd()
|
||||
if blendMode.hasSimdMaskBlender():
|
||||
let maskerSimd = blendMode.maskBlenderSimd()
|
||||
for _ in 0 ..< (xStop - xStart) div 16:
|
||||
let backdrop = mm_loadu_si128(a.data[a.dataIndex(x, y)].addr)
|
||||
when type(b) is Image:
|
||||
|
@ -1089,7 +1089,7 @@ proc drawUber(
|
|||
let sample = b.unsafe[samplePos.x, samplePos.y].a
|
||||
else: # b is a Mask
|
||||
let sample = b.unsafe[samplePos.x, samplePos.y]
|
||||
a.unsafe[x, y] = masker(backdrop, sample)
|
||||
a.unsafe[x, y] = maskBlender(backdrop, sample)
|
||||
srcPos += dx
|
||||
|
||||
if blendMode == MaskBlend:
|
||||
|
|
|
@ -1443,9 +1443,9 @@ proc fillCoverage(
|
|||
) =
|
||||
var x = startX
|
||||
when defined(amd64) and allowSimd:
|
||||
if blendMode.hasSimdMasker():
|
||||
if blendMode.hasSimdMaskBlender():
|
||||
let
|
||||
maskerSimd = blendMode.maskerSimd()
|
||||
maskerSimd = blendMode.maskBlenderSimd()
|
||||
vecZero = mm_setzero_si128()
|
||||
for _ in 0 ..< coverages.len div 16:
|
||||
let
|
||||
|
@ -1465,7 +1465,7 @@ proc fillCoverage(
|
|||
mm_storeu_si128(mask.data[index].addr, vecZero)
|
||||
x += 16
|
||||
|
||||
let masker = blendMode.masker()
|
||||
let maskBlender = blendMode.maskBlender()
|
||||
for x in x ..< startX + coverages.len:
|
||||
let coverage = coverages[x - startX]
|
||||
if coverage != 0 or blendMode == ExcludeMaskBlend:
|
||||
|
@ -1473,7 +1473,7 @@ proc fillCoverage(
|
|||
mask.unsafe[x, y] = coverage
|
||||
else:
|
||||
let backdrop = mask.unsafe[x, y]
|
||||
mask.unsafe[x, y] = masker(backdrop, coverage)
|
||||
mask.unsafe[x, y] = maskBlender(backdrop, coverage)
|
||||
elif blendMode == MaskBlend:
|
||||
mask.unsafe[x, y] = 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue