drawBasic
This commit is contained in:
parent
85780637fc
commit
5199b83c32
1 changed files with 53 additions and 3 deletions
|
@ -1,4 +1,41 @@
|
||||||
import benchy, cairo, pixie
|
import benchy, cairo, pixie, pixie/blends
|
||||||
|
|
||||||
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
|
import nimsimd/sse2
|
||||||
|
|
||||||
|
when defined(release):
|
||||||
|
{.push checks: off.}
|
||||||
|
|
||||||
|
proc drawBasic(backdrop, source: Image) =
|
||||||
|
let sourceIsOpaque = source.isOpaque()
|
||||||
|
|
||||||
|
for y in 0 ..< min(backdrop.height, source.height):
|
||||||
|
if sourceIsOpaque:
|
||||||
|
copyMem(
|
||||||
|
backdrop.data[backdrop.dataIndex(0, y)].addr,
|
||||||
|
source.data[source.dataIndex(0, y)].addr,
|
||||||
|
min(backdrop.width, source.width) * 4
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
var x: int
|
||||||
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
|
let vec255 = mm_set1_epi32(cast[int32](uint32.high))
|
||||||
|
for _ in 0 ..< min(backdrop.width, source.width) div 4:
|
||||||
|
let sourceVec = mm_loadu_si128(source.data[source.dataIndex(x, y)].addr)
|
||||||
|
if mm_movemask_epi8(mm_cmpeq_epi8(sourceVec, mm_setzero_si128())) != 0xffff:
|
||||||
|
if (mm_movemask_epi8(mm_cmpeq_epi8(sourceVec, vec255)) and 0x8888) == 0x8888:
|
||||||
|
mm_storeu_si128(backdrop.data[backdrop.dataIndex(x, y)].addr, sourceVec)
|
||||||
|
else:
|
||||||
|
let backdropVec = mm_loadu_si128(backdrop.data[backdrop.dataIndex(x, y)].addr)
|
||||||
|
mm_storeu_si128(
|
||||||
|
backdrop.data[backdrop.dataIndex(x, y)].addr,
|
||||||
|
blendNormalInlineSimd(backdropVec, sourceVec)
|
||||||
|
)
|
||||||
|
x += 4
|
||||||
|
# No scalar for now
|
||||||
|
|
||||||
|
when defined(release):
|
||||||
|
{.pop.}
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let
|
||||||
|
@ -7,7 +44,7 @@ block:
|
||||||
tmp = imageSurfaceCreate(FORMAT_ARGB32, 1568, 940)
|
tmp = imageSurfaceCreate(FORMAT_ARGB32, 1568, 940)
|
||||||
ctx = tmp.create()
|
ctx = tmp.create()
|
||||||
|
|
||||||
timeIt "cairo draw basic":
|
timeIt "cairo draw normal":
|
||||||
# ctx.setSourceRgba(0.5, 0.5, 0.5, 1)
|
# ctx.setSourceRgba(0.5, 0.5, 0.5, 1)
|
||||||
# let operator = ctx.getOperator()
|
# let operator = ctx.getOperator()
|
||||||
# ctx.setOperator(OperatorSource)
|
# ctx.setOperator(OperatorSource)
|
||||||
|
@ -28,13 +65,26 @@ block:
|
||||||
source = readImage("tests/fileformats/svg/masters/Ghostscript_Tiger.png")
|
source = readImage("tests/fileformats/svg/masters/Ghostscript_Tiger.png")
|
||||||
tmp = newImage(1568, 940)
|
tmp = newImage(1568, 940)
|
||||||
|
|
||||||
timeIt "pixie draw basic":
|
timeIt "pixie draw normal":
|
||||||
# tmp.fill(rgbx(127, 127, 127, 255))
|
# tmp.fill(rgbx(127, 127, 127, 255))
|
||||||
tmp.draw(backdrop)
|
tmp.draw(backdrop)
|
||||||
tmp.draw(source)
|
tmp.draw(source)
|
||||||
|
|
||||||
# tmp.writeFile("tmp2.png")
|
# tmp.writeFile("tmp2.png")
|
||||||
|
|
||||||
|
block:
|
||||||
|
let
|
||||||
|
backdrop = readImage("tests/fileformats/svg/masters/dragon2.png")
|
||||||
|
source = readImage("tests/fileformats/svg/masters/Ghostscript_Tiger.png")
|
||||||
|
tmp = newImage(1568, 940)
|
||||||
|
|
||||||
|
timeIt "pixie draw basic":
|
||||||
|
# tmp.fill(rgbx(127, 127, 127, 255))
|
||||||
|
tmp.drawBasic(backdrop)
|
||||||
|
tmp.drawBasic(source)
|
||||||
|
|
||||||
|
# tmp.writeFile("tmp2.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let
|
||||||
backdrop = imageSurfaceCreateFromPng("tests/fileformats/svg/masters/dragon2.png")
|
backdrop = imageSurfaceCreateFromPng("tests/fileformats/svg/masters/dragon2.png")
|
||||||
|
|
Loading…
Reference in a new issue