fix tests, benchmarks, fuzzes, etc

This commit is contained in:
Ryan Oldenburg 2021-10-03 17:49:21 -05:00
parent 3484857163
commit 09b296e616
21 changed files with 37 additions and 47 deletions

View file

@ -28,11 +28,11 @@ timeIt "blendMultiply":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
reset()
# reset()
timeIt "blendLinearBurn":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
# timeIt "blendLinearBurn":
# for i in 0 ..< backdrop.data.len:
# backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
reset()
@ -52,11 +52,11 @@ timeIt "blendScreen":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
reset()
# reset()
timeIt "blendLinearDodge":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
# timeIt "blendLinearDodge":
# for i in 0 ..< backdrop.data.len:
# backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
reset()
@ -132,12 +132,6 @@ timeIt "blendSubtractMask":
reset()
timeIt "blendIntersectMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendIntersectMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendExcludeMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])

View file

@ -10,7 +10,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "drawCorrect small-on-big":
a.drawCorrect(b, translate(vec2(25, 25)), bmNormal)
a.drawCorrect(b, translate(vec2(25, 25)), blendMode = bmNormal)
keep(b)
block:
@ -21,7 +21,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
timeIt "drawUber small-on-big":
a.drawUber(b, translate(vec2(25, 25)), bmNormal)
a.drawUber(b, translate(vec2(25, 25)), blendMode = bmNormal)
keep(b)
block:
@ -32,7 +32,7 @@ block:
b.fill(rgba(0, 255, 0, 255))
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)
block:
@ -43,5 +43,5 @@ block:
b.fill(rgba(0, 255, 0, 255))
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)

View file

@ -7,13 +7,13 @@ font.size = 16
let
image = newImage(500, 300)
mask = newMask(500, 300)
# mask = newMask(500, 300)
timeIt "typeset":
discard font.typeset(text, bounds = image.wh)
discard font.typeset(text, bounds = vec2(image.width.float32, 0))
timeIt "rasterize":
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.fillText(font, text, bounds = mask.wh)

View file

@ -1,6 +1,6 @@
import benchy, pixie/fileformats/gif
let data = readFile("tests/images/gif/audrey.gif")
let data = readFile("tests/fileformats/gif/audrey.gif")
timeIt "pixie decode":
keep decodeGif(data)

View file

@ -70,7 +70,7 @@ timeIt "toStraightAlpha":
reset()
block:
var path: Path
let path = newPath()
path.ellipse(image.width / 2, image.height / 2, 300, 300)
let mask = newMask(image.width, image.height)

View file

@ -68,7 +68,7 @@ proc blurSlower*(
let image = newImage(1920, 1080)
proc reset() =
var path: Path
let path = newPath()
path.rect(100, 100, 1720, 880)
image.fillPath(path, rgba(255, 255, 255, 255))

View file

@ -1,6 +1,6 @@
import benchy, pixie/fileformats/jpg
let data = readFile("tests/images/jpg/jpeg420exif.jpg")
let data = readFile("tests/fileformats/jpg/jpeg420exif.jpg")
timeIt "pixie decode":
discard decodeJpg(cast[seq[uint8]](data))

View file

@ -34,7 +34,7 @@ timeIt "ceil":
reset()
block spread_1:
var p: Path
let p = newPath()
p.rect(500, 500, 500, 500)
timeIt "spread_1":
@ -43,7 +43,7 @@ block spread_1:
mask.spread(10)
block spread_2:
var p: Path
let p = newPath()
p.rect(500, 500, 1000, 1000)
timeIt "spread_2":

View file

@ -11,7 +11,7 @@ image.fill(rgba(255, 255, 255, 255))
timeIt "roundedRect":
const radius = 20
var path: Path
let path = newPath()
path.roundedRect(0.5, 0.5, 499, 299, radius, radius, radius, radius)
# path.roundedRect(0, 0, 500, 300, radius, radius, radius, radius)

View file

@ -2,7 +2,7 @@ import benchy, cairo, nimPNG, pixie/fileformats/png, stb_image/read as stbi,
stb_image/write as stbr
let
filePath = "tests/images/png/lenna.png"
filePath = "tests/fileformats/png/lenna.png"
data = readFile(filePath)
timeIt "pixie decode":

View file

@ -1,6 +1,6 @@
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":
keep decodeSvg(data)

View file

@ -2,7 +2,7 @@ import pixie/common, pixie/fileformats/gif, random, strformat
randomize()
let original = readFile("tests/images/gif/sunflower.gif")
let original = readFile("tests/fileformats/gif/sunflower.gif")
for i in 0 ..< 10_000:
var data = original

View file

@ -2,7 +2,7 @@ import pixie/common, pixie/fileformats/jpg, random, strformat
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:
var data = original

View file

@ -5,7 +5,7 @@ when not defined(pixieLeakCheck):
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:
var image = decodeSvg(data, rand(300 .. 1800), rand(30 .. 1800))

View file

@ -12,14 +12,12 @@ for i in 0 ..< 10_000:
data[pos] = value
echo &"{i} {pos} {value.uint8}"
try:
let path = parsePath(data)
doAssert path.commands.len >= 0
discard parsePath(data)
except PixieError:
discard
data = data[0 ..< pos]
try:
let path = parsePath(data)
doAssert path.commands.len >= 0
discard parsePath(data)
except PixieError:
discard

View file

@ -4,13 +4,11 @@ randomize()
for i in 0 ..< 10_000:
let file = pngSuiteFiles[rand(pngSuiteFiles.len - 1)]
var data = cast[seq[uint8]](
readFile(&"tests/images/png/pngsuite/{file}.png")
)
var data = readFile(&"tests/fileformats/png/pngsuite/{file}.png")
let
pos = 29 + rand(data.len - 30)
value = rand(255).uint8
data[pos] = value
data[pos] = value.char
echo &"{i} {file} {pos} {value}"
try:
let img = decodePng(data)

View file

@ -2,7 +2,7 @@ import pixie/common, pixie/fileformats/svg, random, strformat
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:
var data = original

View file

@ -57,7 +57,7 @@ proc renderEmojiSet(index: int) =
bmOverwrite
)
rendered.writeFile(&"tests/images/svg/{emojiSet.name}.png")
rendered.writeFile(&"tests/fileformats/svg/{emojiSet.name}.png")
proc main(index = -1) =
if index >= 0:

View file

@ -58,7 +58,7 @@ proc renderIconSet(index: int) =
bmOverwrite
)
rendered.writeFile(&"tests/images/svg/{iconSet.name}.png")
rendered.writeFile(&"tests/fileformats/svg/{iconSet.name}.png")
proc main(index = -1) =
if index >= 0:

View file

@ -1,3 +1,3 @@
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")

View file

@ -2,8 +2,8 @@ import chroma, pixie/fileformats/png, pngsuite, stb_image/read as stbi, strforma
for file in pngSuiteFiles:
let
data = readFile(&"tests/images/png/pngsuite/{file}.png")
pixieLoaded = decodePng(cast[seq[uint8]](data))
data = readFile(&"tests/fileformats/png/pngsuite/{file}.png")
pixieLoaded = decodePngRaw(data)
var
width, height, channels: int