fix tests, benchmarks, fuzzes, etc
This commit is contained in:
parent
3484857163
commit
09b296e616
|
@ -28,11 +28,11 @@ timeIt "blendMultiply":
|
||||||
for i in 0 ..< backdrop.data.len:
|
for i in 0 ..< backdrop.data.len:
|
||||||
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
|
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
|
||||||
|
|
||||||
reset()
|
# reset()
|
||||||
|
|
||||||
timeIt "blendLinearBurn":
|
# timeIt "blendLinearBurn":
|
||||||
for i in 0 ..< backdrop.data.len:
|
# for i in 0 ..< backdrop.data.len:
|
||||||
backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
|
# backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ timeIt "blendScreen":
|
||||||
for i in 0 ..< backdrop.data.len:
|
for i in 0 ..< backdrop.data.len:
|
||||||
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
|
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
|
||||||
|
|
||||||
reset()
|
# reset()
|
||||||
|
|
||||||
timeIt "blendLinearDodge":
|
# timeIt "blendLinearDodge":
|
||||||
for i in 0 ..< backdrop.data.len:
|
# for i in 0 ..< backdrop.data.len:
|
||||||
backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
|
# backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
|
@ -132,12 +132,6 @@ timeIt "blendSubtractMask":
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
timeIt "blendIntersectMask":
|
|
||||||
for i in 0 ..< backdrop.data.len:
|
|
||||||
backdrop.data[i] = blendIntersectMask(backdrop.data[i], source.data[i])
|
|
||||||
|
|
||||||
reset()
|
|
||||||
|
|
||||||
timeIt "blendExcludeMask":
|
timeIt "blendExcludeMask":
|
||||||
for i in 0 ..< backdrop.data.len:
|
for i in 0 ..< backdrop.data.len:
|
||||||
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])
|
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])
|
||||||
|
|
|
@ -10,7 +10,7 @@ block:
|
||||||
b.fill(rgba(0, 255, 0, 255))
|
b.fill(rgba(0, 255, 0, 255))
|
||||||
|
|
||||||
timeIt "drawCorrect small-on-big":
|
timeIt "drawCorrect small-on-big":
|
||||||
a.drawCorrect(b, translate(vec2(25, 25)), bmNormal)
|
a.drawCorrect(b, translate(vec2(25, 25)), blendMode = bmNormal)
|
||||||
keep(b)
|
keep(b)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
@ -21,7 +21,7 @@ block:
|
||||||
b.fill(rgba(0, 255, 0, 255))
|
b.fill(rgba(0, 255, 0, 255))
|
||||||
|
|
||||||
timeIt "drawUber small-on-big":
|
timeIt "drawUber small-on-big":
|
||||||
a.drawUber(b, translate(vec2(25, 25)), bmNormal)
|
a.drawUber(b, translate(vec2(25, 25)), blendMode = bmNormal)
|
||||||
keep(b)
|
keep(b)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
@ -32,7 +32,7 @@ block:
|
||||||
b.fill(rgba(0, 255, 0, 255))
|
b.fill(rgba(0, 255, 0, 255))
|
||||||
|
|
||||||
timeIt "drawCorrect small-on-big smooth":
|
timeIt "drawCorrect small-on-big smooth":
|
||||||
a.drawCorrect(b, translate(vec2(25.1, 25.1)), bmNormal)
|
a.drawCorrect(b, translate(vec2(25.1, 25.1)), blendMode = bmNormal)
|
||||||
keep(b)
|
keep(b)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
@ -43,5 +43,5 @@ block:
|
||||||
b.fill(rgba(0, 255, 0, 255))
|
b.fill(rgba(0, 255, 0, 255))
|
||||||
|
|
||||||
timeIt "drawUber small-on-big smooth":
|
timeIt "drawUber small-on-big smooth":
|
||||||
a.drawUber(b, translate(vec2(25.1, 25.1)), bmNormal)
|
a.drawUber(b, translate(vec2(25.1, 25.1)), blendMode = bmNormal)
|
||||||
keep(b)
|
keep(b)
|
||||||
|
|
|
@ -7,13 +7,13 @@ font.size = 16
|
||||||
|
|
||||||
let
|
let
|
||||||
image = newImage(500, 300)
|
image = newImage(500, 300)
|
||||||
mask = newMask(500, 300)
|
# mask = newMask(500, 300)
|
||||||
|
|
||||||
timeIt "typeset":
|
timeIt "typeset":
|
||||||
discard font.typeset(text, bounds = image.wh)
|
discard font.typeset(text, bounds = vec2(image.width.float32, 0))
|
||||||
|
|
||||||
timeIt "rasterize":
|
timeIt "rasterize":
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, text, bounds = image.wh)
|
image.fillText(font, text, bounds = vec2(image.width.float32, 0))
|
||||||
# mask.fill(0)
|
# mask.fill(0)
|
||||||
# mask.fillText(font, text, bounds = mask.wh)
|
# mask.fillText(font, text, bounds = mask.wh)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import benchy, pixie/fileformats/gif
|
import benchy, pixie/fileformats/gif
|
||||||
|
|
||||||
let data = readFile("tests/images/gif/audrey.gif")
|
let data = readFile("tests/fileformats/gif/audrey.gif")
|
||||||
|
|
||||||
timeIt "pixie decode":
|
timeIt "pixie decode":
|
||||||
keep decodeGif(data)
|
keep decodeGif(data)
|
||||||
|
|
|
@ -70,7 +70,7 @@ timeIt "toStraightAlpha":
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
block:
|
block:
|
||||||
var path: Path
|
let path = newPath()
|
||||||
path.ellipse(image.width / 2, image.height / 2, 300, 300)
|
path.ellipse(image.width / 2, image.height / 2, 300, 300)
|
||||||
|
|
||||||
let mask = newMask(image.width, image.height)
|
let mask = newMask(image.width, image.height)
|
||||||
|
|
|
@ -68,7 +68,7 @@ proc blurSlower*(
|
||||||
let image = newImage(1920, 1080)
|
let image = newImage(1920, 1080)
|
||||||
|
|
||||||
proc reset() =
|
proc reset() =
|
||||||
var path: Path
|
let path = newPath()
|
||||||
path.rect(100, 100, 1720, 880)
|
path.rect(100, 100, 1720, 880)
|
||||||
image.fillPath(path, rgba(255, 255, 255, 255))
|
image.fillPath(path, rgba(255, 255, 255, 255))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import benchy, pixie/fileformats/jpg
|
import benchy, pixie/fileformats/jpg
|
||||||
|
|
||||||
let data = readFile("tests/images/jpg/jpeg420exif.jpg")
|
let data = readFile("tests/fileformats/jpg/jpeg420exif.jpg")
|
||||||
|
|
||||||
timeIt "pixie decode":
|
timeIt "pixie decode":
|
||||||
discard decodeJpg(cast[seq[uint8]](data))
|
discard decodeJpg(cast[seq[uint8]](data))
|
||||||
|
|
|
@ -34,7 +34,7 @@ timeIt "ceil":
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
block spread_1:
|
block spread_1:
|
||||||
var p: Path
|
let p = newPath()
|
||||||
p.rect(500, 500, 500, 500)
|
p.rect(500, 500, 500, 500)
|
||||||
|
|
||||||
timeIt "spread_1":
|
timeIt "spread_1":
|
||||||
|
@ -43,7 +43,7 @@ block spread_1:
|
||||||
mask.spread(10)
|
mask.spread(10)
|
||||||
|
|
||||||
block spread_2:
|
block spread_2:
|
||||||
var p: Path
|
let p = newPath()
|
||||||
p.rect(500, 500, 1000, 1000)
|
p.rect(500, 500, 1000, 1000)
|
||||||
|
|
||||||
timeIt "spread_2":
|
timeIt "spread_2":
|
||||||
|
|
|
@ -11,7 +11,7 @@ image.fill(rgba(255, 255, 255, 255))
|
||||||
timeIt "roundedRect":
|
timeIt "roundedRect":
|
||||||
const radius = 20
|
const radius = 20
|
||||||
|
|
||||||
var path: Path
|
let path = newPath()
|
||||||
path.roundedRect(0.5, 0.5, 499, 299, radius, radius, radius, radius)
|
path.roundedRect(0.5, 0.5, 499, 299, radius, radius, radius, radius)
|
||||||
# path.roundedRect(0, 0, 500, 300, radius, radius, radius, radius)
|
# path.roundedRect(0, 0, 500, 300, radius, radius, radius, radius)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import benchy, cairo, nimPNG, pixie/fileformats/png, stb_image/read as stbi,
|
||||||
stb_image/write as stbr
|
stb_image/write as stbr
|
||||||
|
|
||||||
let
|
let
|
||||||
filePath = "tests/images/png/lenna.png"
|
filePath = "tests/fileformats/png/lenna.png"
|
||||||
data = readFile(filePath)
|
data = readFile(filePath)
|
||||||
|
|
||||||
timeIt "pixie decode":
|
timeIt "pixie decode":
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import benchy, pixie/fileformats/svg
|
import benchy, pixie/fileformats/svg
|
||||||
|
|
||||||
let data = readFile("tests/images/svg/Ghostscript_Tiger.svg")
|
let data = readFile("tests/fileformats/svg/Ghostscript_Tiger.svg")
|
||||||
|
|
||||||
timeIt "svg decode":
|
timeIt "svg decode":
|
||||||
keep decodeSvg(data)
|
keep decodeSvg(data)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pixie/common, pixie/fileformats/gif, random, strformat
|
||||||
|
|
||||||
randomize()
|
randomize()
|
||||||
|
|
||||||
let original = readFile("tests/images/gif/sunflower.gif")
|
let original = readFile("tests/fileformats/gif/sunflower.gif")
|
||||||
|
|
||||||
for i in 0 ..< 10_000:
|
for i in 0 ..< 10_000:
|
||||||
var data = original
|
var data = original
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pixie/common, pixie/fileformats/jpg, random, strformat
|
||||||
|
|
||||||
randomize()
|
randomize()
|
||||||
|
|
||||||
let original = cast[seq[uint8]](readFile("tests/images/jpg/jpeg420exif.jpg"))
|
let original = cast[seq[uint8]](readFile("tests/fileformats/jpg/jpeg420exif.jpg"))
|
||||||
|
|
||||||
for i in 0 ..< 10_000:
|
for i in 0 ..< 10_000:
|
||||||
var data = original
|
var data = original
|
||||||
|
|
|
@ -5,7 +5,7 @@ when not defined(pixieLeakCheck):
|
||||||
|
|
||||||
randomize()
|
randomize()
|
||||||
|
|
||||||
let data = readFile("tests/images/svg/Ghostscript_Tiger.svg")
|
let data = readFile("tests/fileformats/svg/Ghostscript_Tiger.svg")
|
||||||
|
|
||||||
for i in 0 ..< 100_000:
|
for i in 0 ..< 100_000:
|
||||||
var image = decodeSvg(data, rand(300 .. 1800), rand(30 .. 1800))
|
var image = decodeSvg(data, rand(300 .. 1800), rand(30 .. 1800))
|
||||||
|
|
|
@ -12,14 +12,12 @@ for i in 0 ..< 10_000:
|
||||||
data[pos] = value
|
data[pos] = value
|
||||||
echo &"{i} {pos} {value.uint8}"
|
echo &"{i} {pos} {value.uint8}"
|
||||||
try:
|
try:
|
||||||
let path = parsePath(data)
|
discard parsePath(data)
|
||||||
doAssert path.commands.len >= 0
|
|
||||||
except PixieError:
|
except PixieError:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
data = data[0 ..< pos]
|
data = data[0 ..< pos]
|
||||||
try:
|
try:
|
||||||
let path = parsePath(data)
|
discard parsePath(data)
|
||||||
doAssert path.commands.len >= 0
|
|
||||||
except PixieError:
|
except PixieError:
|
||||||
discard
|
discard
|
||||||
|
|
|
@ -4,13 +4,11 @@ randomize()
|
||||||
|
|
||||||
for i in 0 ..< 10_000:
|
for i in 0 ..< 10_000:
|
||||||
let file = pngSuiteFiles[rand(pngSuiteFiles.len - 1)]
|
let file = pngSuiteFiles[rand(pngSuiteFiles.len - 1)]
|
||||||
var data = cast[seq[uint8]](
|
var data = readFile(&"tests/fileformats/png/pngsuite/{file}.png")
|
||||||
readFile(&"tests/images/png/pngsuite/{file}.png")
|
|
||||||
)
|
|
||||||
let
|
let
|
||||||
pos = 29 + rand(data.len - 30)
|
pos = 29 + rand(data.len - 30)
|
||||||
value = rand(255).uint8
|
value = rand(255).uint8
|
||||||
data[pos] = value
|
data[pos] = value.char
|
||||||
echo &"{i} {file} {pos} {value}"
|
echo &"{i} {file} {pos} {value}"
|
||||||
try:
|
try:
|
||||||
let img = decodePng(data)
|
let img = decodePng(data)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pixie/common, pixie/fileformats/svg, random, strformat
|
||||||
|
|
||||||
randomize()
|
randomize()
|
||||||
|
|
||||||
let original = readFile("tests/images/svg/Ghostscript_Tiger.svg")
|
let original = readFile("tests/fileformats/svg/Ghostscript_Tiger.svg")
|
||||||
|
|
||||||
for i in 0 ..< 10_000:
|
for i in 0 ..< 10_000:
|
||||||
var data = original
|
var data = original
|
||||||
|
|
|
@ -57,7 +57,7 @@ proc renderEmojiSet(index: int) =
|
||||||
bmOverwrite
|
bmOverwrite
|
||||||
)
|
)
|
||||||
|
|
||||||
rendered.writeFile(&"tests/images/svg/{emojiSet.name}.png")
|
rendered.writeFile(&"tests/fileformats/svg/{emojiSet.name}.png")
|
||||||
|
|
||||||
proc main(index = -1) =
|
proc main(index = -1) =
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
|
|
|
@ -58,7 +58,7 @@ proc renderIconSet(index: int) =
|
||||||
bmOverwrite
|
bmOverwrite
|
||||||
)
|
)
|
||||||
|
|
||||||
rendered.writeFile(&"tests/images/svg/{iconSet.name}.png")
|
rendered.writeFile(&"tests/fileformats/svg/{iconSet.name}.png")
|
||||||
|
|
||||||
proc main(index = -1) =
|
proc main(index = -1) =
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import pixie/fileformats/jpg, pixie/fileformats/stb_image/stb_image
|
import pixie/fileformats/jpg, pixie/fileformats/stb_image/stb_image
|
||||||
|
|
||||||
let original = readFile("tests/images/jpg/jpeg420exif.jpg")
|
let original = readFile("tests/fileformats/jpg/jpeg420exif.jpg")
|
||||||
|
|
|
@ -2,8 +2,8 @@ import chroma, pixie/fileformats/png, pngsuite, stb_image/read as stbi, strforma
|
||||||
|
|
||||||
for file in pngSuiteFiles:
|
for file in pngSuiteFiles:
|
||||||
let
|
let
|
||||||
data = readFile(&"tests/images/png/pngsuite/{file}.png")
|
data = readFile(&"tests/fileformats/png/pngsuite/{file}.png")
|
||||||
pixieLoaded = decodePng(cast[seq[uint8]](data))
|
pixieLoaded = decodePngRaw(data)
|
||||||
|
|
||||||
var
|
var
|
||||||
width, height, channels: int
|
width, height, channels: int
|
||||||
|
|
Loading…
Reference in a new issue