Merge pull request #296 from guzba/master
reorganize and update tests/ dir
|
@ -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: [].} =
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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)
|
||||
|
|
Before ![]() (image error) Size: 1.1 KiB After ![]() (image error) Size: 1.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 2.4 KiB After ![]() (image error) Size: 2.4 KiB ![]() ![]() |
Before ![]() (image error) Size: 2.7 KiB After ![]() (image error) Size: 2.7 KiB ![]() ![]() |
Before ![]() (image error) Size: 885 B After ![]() (image error) Size: 885 B ![]() ![]() |
Before ![]() (image error) Size: 1.8 KiB After ![]() (image error) Size: 1.8 KiB ![]() ![]() |
Before ![]() (image error) Size: 3.6 KiB After ![]() (image error) Size: 3.6 KiB ![]() ![]() |
Before ![]() (image error) Size: 3.6 KiB After ![]() (image error) Size: 3.6 KiB ![]() ![]() |
Before ![]() (image error) Size: 617 B After ![]() (image error) Size: 617 B ![]() ![]() |
Before ![]() (image error) Size: 3.6 KiB After ![]() (image error) Size: 3.6 KiB ![]() ![]() |
Before ![]() (image error) Size: 617 B After ![]() (image error) Size: 617 B ![]() ![]() |
Before ![]() (image error) Size: 3.3 KiB After ![]() (image error) Size: 3.3 KiB ![]() ![]() |
Before ![]() (image error) Size: 1,004 B After ![]() (image error) Size: 1,004 B ![]() ![]() |
Before ![]() (image error) Size: 2.3 KiB After ![]() (image error) Size: 2.3 KiB ![]() ![]() |
Before ![]() (image error) Size: 4.5 KiB After ![]() (image error) Size: 4.5 KiB ![]() ![]() |
Before ![]() (image error) Size: 2.6 KiB After ![]() (image error) Size: 2.6 KiB ![]() ![]() |
Before ![]() (image error) Size: 3.2 KiB After ![]() (image error) Size: 3.2 KiB ![]() ![]() |
Before ![]() (image error) Size: 36 KiB After ![]() (image error) Size: 36 KiB ![]() ![]() |
Before ![]() (image error) Size: 36 KiB After ![]() (image error) Size: 36 KiB ![]() ![]() |
Before ![]() (image error) Size: 6.7 KiB After ![]() (image error) Size: 6.7 KiB ![]() ![]() |
Before ![]() (image error) Size: 807 B After ![]() (image error) Size: 807 B ![]() ![]() |
Before ![]() (image error) Size: 3.2 KiB After ![]() (image error) Size: 3.2 KiB ![]() ![]() |
Before ![]() (image error) Size: 3.6 KiB After ![]() (image error) Size: 3.6 KiB ![]() ![]() |
Before ![]() (image error) Size: 5.4 KiB After ![]() (image error) Size: 5.4 KiB ![]() ![]() |
Before ![]() (image error) Size: 3.5 KiB After ![]() (image error) Size: 3.5 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.1 KiB After ![]() (image error) Size: 1.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.1 KiB After ![]() (image error) Size: 1.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 327 B After ![]() (image error) Size: 327 B ![]() ![]() |
Before ![]() (image error) Size: 2.3 KiB After ![]() (image error) Size: 2.3 KiB ![]() ![]() |
Before ![]() (image error) Size: 2.7 KiB After ![]() (image error) Size: 2.7 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.2 KiB After ![]() (image error) Size: 1.2 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.9 KiB After ![]() (image error) Size: 1.9 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.2 KiB After ![]() (image error) Size: 1.2 KiB ![]() ![]() |
Before ![]() (image error) Size: 1 KiB After ![]() (image error) Size: 1 KiB ![]() ![]() |
Before ![]() (image error) Size: 956 B After ![]() (image error) Size: 956 B ![]() ![]() |
Before ![]() (image error) Size: 1.4 KiB After ![]() (image error) Size: 1.4 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.8 KiB After ![]() (image error) Size: 1.8 KiB ![]() ![]() |
Before ![]() (image error) Size: 1,013 B After ![]() (image error) Size: 1,013 B ![]() ![]() |
Before ![]() (image error) Size: 1.3 KiB After ![]() (image error) Size: 1.3 KiB ![]() ![]() |
Before ![]() (image error) Size: 6.9 KiB After ![]() (image error) Size: 6.9 KiB ![]() ![]() |
Before ![]() (image error) Size: 989 B After ![]() (image error) Size: 989 B ![]() ![]() |
Before ![]() (image error) Size: 968 B After ![]() (image error) Size: 968 B ![]() ![]() |
Before ![]() (image error) Size: 1.9 KiB After ![]() (image error) Size: 1.9 KiB ![]() ![]() |
Before ![]() (image error) Size: 1.1 KiB After ![]() (image error) Size: 1.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 890 B After ![]() (image error) Size: 890 B ![]() ![]() |
Before ![]() (image error) Size: 630 B After ![]() (image error) Size: 630 B ![]() ![]() |
Before ![]() (image error) Size: 890 B After ![]() (image error) Size: 890 B ![]() ![]() |
Before ![]() (image error) Size: 890 B After ![]() (image error) Size: 890 B ![]() ![]() |
Before ![]() (image error) Size: 1.1 KiB After ![]() (image error) Size: 1.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 154 B After ![]() (image error) Size: 154 B ![]() ![]() |
Before ![]() (image error) Size: 814 B After ![]() (image error) Size: 814 B ![]() ![]() |
Before ![]() (image error) Size: 111 B After ![]() (image error) Size: 111 B ![]() ![]() |
Before ![]() (image error) Size: 16 KiB After ![]() (image error) Size: 16 KiB ![]() ![]() |
Before ![]() (image error) Size: 60 KiB After ![]() (image error) Size: 60 KiB ![]() ![]() |
Before ![]() (image error) Size: 27 KiB After ![]() (image error) Size: 27 KiB ![]() ![]() |
Before ![]() (image error) Size: 89 KiB After ![]() (image error) Size: 89 KiB ![]() ![]() |
Before ![]() (image error) Size: 751 KiB After ![]() (image error) Size: 751 KiB ![]() ![]() |
Before ![]() (image error) Size: 636 KiB After ![]() (image error) Size: 636 KiB ![]() ![]() |
Before ![]() (image error) Size: 463 KiB After ![]() (image error) Size: 463 KiB ![]() ![]() |
Before ![]() (image error) Size: 2.2 KiB After ![]() (image error) Size: 2.2 KiB ![]() ![]() |
Before ![]() (image error) Size: 217 B After ![]() (image error) Size: 217 B ![]() ![]() |
Before ![]() (image error) Size: 154 B After ![]() (image error) Size: 154 B ![]() ![]() |
Before ![]() (image error) Size: 247 B After ![]() (image error) Size: 247 B ![]() ![]() |
Before ![]() (image error) Size: 254 B After ![]() (image error) Size: 254 B ![]() ![]() |
Before ![]() (image error) Size: 299 B After ![]() (image error) Size: 299 B ![]() ![]() |
Before ![]() (image error) Size: 315 B After ![]() (image error) Size: 315 B ![]() ![]() |
Before ![]() (image error) Size: 595 B After ![]() (image error) Size: 595 B ![]() ![]() |
Before ![]() (image error) Size: 132 B After ![]() (image error) Size: 132 B ![]() ![]() |
Before ![]() (image error) Size: 193 B After ![]() (image error) Size: 193 B ![]() ![]() |
Before ![]() (image error) Size: 327 B After ![]() (image error) Size: 327 B ![]() ![]() |
Before ![]() (image error) Size: 1.5 KiB After ![]() (image error) Size: 1.5 KiB ![]() ![]() |
Before ![]() (image error) Size: 214 B After ![]() (image error) Size: 214 B ![]() ![]() |
Before ![]() (image error) Size: 2.8 KiB After ![]() (image error) Size: 2.8 KiB ![]() ![]() |
Before ![]() (image error) Size: 361 B After ![]() (image error) Size: 361 B ![]() ![]() |
Before ![]() (image error) Size: 4.1 KiB After ![]() (image error) Size: 4.1 KiB ![]() ![]() |
Before ![]() (image error) Size: 164 B After ![]() (image error) Size: 164 B ![]() ![]() |
Before ![]() (image error) Size: 104 B After ![]() (image error) Size: 104 B ![]() ![]() |
Before ![]() (image error) Size: 145 B After ![]() (image error) Size: 145 B ![]() ![]() |
Before ![]() (image error) Size: 138 B After ![]() (image error) Size: 138 B ![]() ![]() |
Before ![]() (image error) Size: 167 B After ![]() (image error) Size: 167 B ![]() ![]() |
Before ![]() (image error) Size: 145 B After ![]() (image error) Size: 145 B ![]() ![]() |
Before ![]() (image error) Size: 302 B After ![]() (image error) Size: 302 B ![]() ![]() |
Before ![]() (image error) Size: 112 B After ![]() (image error) Size: 112 B ![]() ![]() |
Before ![]() (image error) Size: 146 B After ![]() (image error) Size: 146 B ![]() ![]() |
Before ![]() (image error) Size: 216 B After ![]() (image error) Size: 216 B ![]() ![]() |
Before ![]() (image error) Size: 1.3 KiB After ![]() (image error) Size: 1.3 KiB ![]() ![]() |