Merge pull request #296 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

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 # Set src as this result for if we do another power
src = result 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*( proc fillUnsafe*(
data: var seq[uint8], value: uint8, start, len: int data: var seq[uint8], value: uint8, start, len: int
) {.raises: [].} = ) {.raises: [].} =

View file

@ -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])

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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))

View file

@ -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))

View file

@ -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":

View file

@ -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)

View file

@ -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":

View file

@ -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)

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

Before

Width:  |  Height:  |  Size: 885 B

After

Width:  |  Height:  |  Size: 885 B

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 617 B

After

Width:  |  Height:  |  Size: 617 B

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 617 B

After

Width:  |  Height:  |  Size: 617 B

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1,004 B

After

Width:  |  Height:  |  Size: 1,004 B

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View file

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View file

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View file

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 807 B

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View file

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 956 B

After

Width:  |  Height:  |  Size: 956 B

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1,013 B

After

Width:  |  Height:  |  Size: 1,013 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

Before

Width:  |  Height:  |  Size: 989 B

After

Width:  |  Height:  |  Size: 989 B

View file

Before

Width:  |  Height:  |  Size: 968 B

After

Width:  |  Height:  |  Size: 968 B

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 890 B

After

Width:  |  Height:  |  Size: 890 B

View file

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 630 B

View file

Before

Width:  |  Height:  |  Size: 890 B

After

Width:  |  Height:  |  Size: 890 B

View file

Before

Width:  |  Height:  |  Size: 890 B

After

Width:  |  Height:  |  Size: 890 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 814 B

View file

Before

Width:  |  Height:  |  Size: 111 B

After

Width:  |  Height:  |  Size: 111 B

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View file

Before

Width:  |  Height:  |  Size: 751 KiB

After

Width:  |  Height:  |  Size: 751 KiB

View file

Before

Width:  |  Height:  |  Size: 636 KiB

After

Width:  |  Height:  |  Size: 636 KiB

View file

Before

Width:  |  Height:  |  Size: 463 KiB

After

Width:  |  Height:  |  Size: 463 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 217 B

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

View file

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 254 B

View file

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 299 B

View file

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 315 B

View file

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View file

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 132 B

View file

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 193 B

View file

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 214 B

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 361 B

View file

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 164 B

View file

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 104 B

View file

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

View file

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

View file

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 167 B

View file

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

View file

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 302 B

View file

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 112 B

View file

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

View file

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 216 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

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