Merge pull request from guzba/master

reorganize and update tests/ dir
This commit is contained in:
treeform 2021-10-03 18:22:00 -07:00 committed by GitHub
commit 20386f8514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
401 changed files with 190 additions and 178 deletions
src/pixie
tests

View file

@ -153,6 +153,22 @@ proc minifyBy2*(mask: Mask, power = 1): Mask {.raises: [PixieError].} =
# Set src as this result for if we do another power
src = result
proc magnifyBy2*(mask: Mask, power = 1): Mask {.raises: [PixieError].} =
## Scales mask up by 2 ^ power.
if power < 0:
raise newException(PixieError, "Cannot magnifyBy2 with negative power")
let scale = 2 ^ power
result = newMask(mask.width * scale, mask.height * scale)
for y in 0 ..< result.height:
for x in 0 ..< mask.width:
let
value = mask.getValueUnsafe(x, y div scale)
scaledX = x * scale
idx = result.dataIndex(scaledX, y)
for i in 0 ..< scale:
result.data[idx + i] = value
proc fillUnsafe*(
data: var seq[uint8], value: uint8, start, len: int
) {.raises: [].} =

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

Before

(image error) Size: 1.1 KiB

After

(image error) Size: 1.1 KiB

View file

Before

(image error) Size: 2.4 KiB

After

(image error) Size: 2.4 KiB

View file

Before

(image error) Size: 2.7 KiB

After

(image error) Size: 2.7 KiB

View file

Before

(image error) Size: 885 B

After

(image error) Size: 885 B

View file

Before

(image error) Size: 1.8 KiB

After

(image error) Size: 1.8 KiB

View file

Before

(image error) Size: 3.6 KiB

After

(image error) Size: 3.6 KiB

View file

Before

(image error) Size: 3.6 KiB

After

(image error) Size: 3.6 KiB

View file

Before

(image error) Size: 617 B

After

(image error) Size: 617 B

View file

Before

(image error) Size: 3.6 KiB

After

(image error) Size: 3.6 KiB

View file

Before

(image error) Size: 617 B

After

(image error) Size: 617 B

View file

Before

(image error) Size: 3.3 KiB

After

(image error) Size: 3.3 KiB

View file

Before

(image error) Size: 1,004 B

After

(image error) Size: 1,004 B

View file

Before

(image error) Size: 2.3 KiB

After

(image error) Size: 2.3 KiB

View file

Before

(image error) Size: 4.5 KiB

After

(image error) Size: 4.5 KiB

View file

Before

(image error) Size: 2.6 KiB

After

(image error) Size: 2.6 KiB

View file

Before

(image error) Size: 3.2 KiB

After

(image error) Size: 3.2 KiB

View file

Before

(image error) Size: 36 KiB

After

(image error) Size: 36 KiB

View file

Before

(image error) Size: 36 KiB

After

(image error) Size: 36 KiB

View file

Before

(image error) Size: 6.7 KiB

After

(image error) Size: 6.7 KiB

View file

Before

(image error) Size: 807 B

After

(image error) Size: 807 B

View file

Before

(image error) Size: 3.2 KiB

After

(image error) Size: 3.2 KiB

View file

Before

(image error) Size: 3.6 KiB

After

(image error) Size: 3.6 KiB

View file

Before

(image error) Size: 5.4 KiB

After

(image error) Size: 5.4 KiB

View file

Before

(image error) Size: 3.5 KiB

After

(image error) Size: 3.5 KiB

View file

Before

(image error) Size: 1.1 KiB

After

(image error) Size: 1.1 KiB

View file

Before

(image error) Size: 1.1 KiB

After

(image error) Size: 1.1 KiB

View file

Before

(image error) Size: 327 B

After

(image error) Size: 327 B

View file

Before

(image error) Size: 2.3 KiB

After

(image error) Size: 2.3 KiB

View file

Before

(image error) Size: 2.7 KiB

After

(image error) Size: 2.7 KiB

View file

Before

(image error) Size: 1.2 KiB

After

(image error) Size: 1.2 KiB

View file

Before

(image error) Size: 1.9 KiB

After

(image error) Size: 1.9 KiB

View file

Before

(image error) Size: 1.2 KiB

After

(image error) Size: 1.2 KiB

View file

Before

(image error) Size: 1 KiB

After

(image error) Size: 1 KiB

View file

Before

(image error) Size: 956 B

After

(image error) Size: 956 B

View file

Before

(image error) Size: 1.4 KiB

After

(image error) Size: 1.4 KiB

View file

Before

(image error) Size: 1.8 KiB

After

(image error) Size: 1.8 KiB

View file

Before

(image error) Size: 1,013 B

After

(image error) Size: 1,013 B

View file

Before

(image error) Size: 1.3 KiB

After

(image error) Size: 1.3 KiB

View file

Before

(image error) Size: 6.9 KiB

After

(image error) Size: 6.9 KiB

View file

Before

(image error) Size: 989 B

After

(image error) Size: 989 B

View file

Before

(image error) Size: 968 B

After

(image error) Size: 968 B

View file

Before

(image error) Size: 1.9 KiB

After

(image error) Size: 1.9 KiB

View file

Before

(image error) Size: 1.1 KiB

After

(image error) Size: 1.1 KiB

View file

Before

(image error) Size: 890 B

After

(image error) Size: 890 B

View file

Before

(image error) Size: 630 B

After

(image error) Size: 630 B

View file

Before

(image error) Size: 890 B

After

(image error) Size: 890 B

View file

Before

(image error) Size: 890 B

After

(image error) Size: 890 B

View file

Before

(image error) Size: 1.1 KiB

After

(image error) Size: 1.1 KiB

View file

Before

(image error) Size: 154 B

After

(image error) Size: 154 B

View file

Before

(image error) Size: 814 B

After

(image error) Size: 814 B

View file

Before

(image error) Size: 111 B

After

(image error) Size: 111 B

View file

Before

(image error) Size: 16 KiB

After

(image error) Size: 16 KiB

View file

Before

(image error) Size: 60 KiB

After

(image error) Size: 60 KiB

View file

Before

(image error) Size: 27 KiB

After

(image error) Size: 27 KiB

View file

Before

(image error) Size: 89 KiB

After

(image error) Size: 89 KiB

View file

Before

(image error) Size: 751 KiB

After

(image error) Size: 751 KiB

View file

Before

(image error) Size: 636 KiB

After

(image error) Size: 636 KiB

View file

Before

(image error) Size: 463 KiB

After

(image error) Size: 463 KiB

View file

Before

(image error) Size: 2.2 KiB

After

(image error) Size: 2.2 KiB

View file

Before

(image error) Size: 217 B

After

(image error) Size: 217 B

View file

Before

(image error) Size: 154 B

After

(image error) Size: 154 B

View file

Before

(image error) Size: 247 B

After

(image error) Size: 247 B

View file

Before

(image error) Size: 254 B

After

(image error) Size: 254 B

View file

Before

(image error) Size: 299 B

After

(image error) Size: 299 B

View file

Before

(image error) Size: 315 B

After

(image error) Size: 315 B

View file

Before

(image error) Size: 595 B

After

(image error) Size: 595 B

View file

Before

(image error) Size: 132 B

After

(image error) Size: 132 B

View file

Before

(image error) Size: 193 B

After

(image error) Size: 193 B

View file

Before

(image error) Size: 327 B

After

(image error) Size: 327 B

View file

Before

(image error) Size: 1.5 KiB

After

(image error) Size: 1.5 KiB

View file

Before

(image error) Size: 214 B

After

(image error) Size: 214 B

View file

Before

(image error) Size: 2.8 KiB

After

(image error) Size: 2.8 KiB

View file

Before

(image error) Size: 361 B

After

(image error) Size: 361 B

View file

Before

(image error) Size: 4.1 KiB

After

(image error) Size: 4.1 KiB

View file

Before

(image error) Size: 164 B

After

(image error) Size: 164 B

View file

Before

(image error) Size: 104 B

After

(image error) Size: 104 B

View file

Before

(image error) Size: 145 B

After

(image error) Size: 145 B

View file

Before

(image error) Size: 138 B

After

(image error) Size: 138 B

View file

Before

(image error) Size: 167 B

After

(image error) Size: 167 B

View file

Before

(image error) Size: 145 B

After

(image error) Size: 145 B

View file

Before

(image error) Size: 302 B

After

(image error) Size: 302 B

View file

Before

(image error) Size: 112 B

After

(image error) Size: 112 B

View file

Before

(image error) Size: 146 B

After

(image error) Size: 146 B

View file

Before

(image error) Size: 216 B

After

(image error) Size: 216 B

View file

Before

(image error) Size: 1.3 KiB

After

(image error) Size: 1.3 KiB

Some files were not shown because too many files have changed in this diff Show more