Merge pull request #463 from treeform/dev
New image diff and x-ray system.
1
.gitignore
vendored
|
@ -17,3 +17,4 @@ dump.txt
|
|||
tests/fileformats/jpeg/generated
|
||||
tests/fileformats/jpeg/diffs
|
||||
*.dylib
|
||||
tmp
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import benchy, chroma, pixie/blends, pixie/images, vmath
|
||||
|
||||
let
|
||||
backdrop = newImage(256, 256)
|
||||
source = newImage(256, 256)
|
||||
backdrop = newImage(512, 512)
|
||||
source = newImage(512, 512)
|
||||
source.fill(rgba(100, 100, 100, 100))
|
||||
|
||||
template reset() =
|
|
@ -7,7 +7,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "draw small-on-big NormalBlend":
|
||||
timeIt "small-on-big NormalBlend":
|
||||
a.draw(b, translate(vec2(25, 25)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -18,7 +18,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "draw small-on-big Smooth NormalBlend":
|
||||
timeIt "small-on-big Smooth NormalBlend":
|
||||
a.draw(b, translate(vec2(25.2, 25.2)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -29,7 +29,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "draw big-on-bigger NormalBlend":
|
||||
timeIt "big-on-bigger NormalBlend":
|
||||
a.draw(b, translate(vec2(25, 25)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -40,7 +40,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "draw [scale 0.5]":
|
||||
timeIt "scale x0.5":
|
||||
a.draw(b, translate(vec2(25, 25)) * scale(vec2(0.5, 0.5)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -51,7 +51,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "draw [scale 2]":
|
||||
timeIt "scale x2":
|
||||
a.draw(b, translate(vec2(25, 25)) * scale(vec2(2, 2)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -62,7 +62,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, rand(255).uint8, 0, 255))
|
||||
|
||||
timeIt "draw Smooth [x translate]":
|
||||
timeIt "smooth x-translate":
|
||||
a.draw(b, translate(vec2(25.2, 0)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -73,7 +73,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, rand(255).uint8, 0, 255))
|
||||
|
||||
timeIt "draw Smooth [y translate]":
|
||||
timeIt "smooth y-translate":
|
||||
a.draw(b, translate(vec2(0, 25.2)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -84,7 +84,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, rand(255).uint8, 0, 255))
|
||||
|
||||
timeIt "draw Smooth [x + y translate]":
|
||||
timeIt "smooth translate":
|
||||
a.draw(b, translate(vec2(25.2, 25.2)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -95,7 +95,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, rand(255).uint8, 0, 255))
|
||||
|
||||
timeIt "draw Smooth [rotate 45 deg]":
|
||||
timeIt "smooth rotate 45":
|
||||
a.draw(b, translate(vec2(0, 500)) * rotate(toRadians(45)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -106,7 +106,7 @@ block:
|
|||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rand(255).uint8)
|
||||
|
||||
timeIt "draw mask Smooth [rotate 45 deg]":
|
||||
timeIt "mask smooth rotate 45 deg":
|
||||
a.draw(b, translate(vec2(0, 500)) * rotate(toRadians(45)), NormalBlend)
|
||||
keep(b)
|
||||
|
||||
|
@ -115,7 +115,7 @@ block:
|
|||
a = newImage(100, 100)
|
||||
b = newImage(50, 50)
|
||||
|
||||
timeIt "shadow (no offset)":
|
||||
timeIt "shadow no offset":
|
||||
b.fill(rgba(0, 0, 0, 255))
|
||||
a.draw(b, translate(vec2(25, 25)))
|
||||
|
||||
|
@ -132,7 +132,7 @@ block:
|
|||
a = newImage(100, 100)
|
||||
b = newImage(50, 50)
|
||||
|
||||
timeIt "shadow (with offset)":
|
||||
timeIt "shadow with offset":
|
||||
b.fill(rgba(0, 0, 0, 255))
|
||||
a.draw(b, translate(vec2(25, 25)))
|
||||
|
30
tests/bench_jpeg.nim
Normal file
|
@ -0,0 +1,30 @@
|
|||
import benchy, pixie/fileformats/jpeg, os
|
||||
|
||||
const
|
||||
jpegFiles* = [
|
||||
"tests/fileformats/jpeg/masters/mandrill.jpg",
|
||||
"tests/fileformats/jpeg/masters/exif_overrun.jpg",
|
||||
"tests/fileformats/jpeg/masters/grayscale_test.jpg",
|
||||
"tests/fileformats/jpeg/masters/progressive.jpg"
|
||||
]
|
||||
|
||||
for file in jpegFiles:
|
||||
let data = readFile(file)
|
||||
timeIt "pixie " & file.splitPath.tail & " decode":
|
||||
discard decodeJpeg(data)
|
||||
|
||||
# import stb_image/read as stbi
|
||||
# block:
|
||||
# for file in jpegFiles:
|
||||
# let data = readFile(file)
|
||||
# var name = file.splitPath.tail
|
||||
|
||||
# timeIt "stb " & file.splitPath.tail & " decode":
|
||||
# var width, height, channels: int
|
||||
# discard loadFromMemory(
|
||||
# cast[seq[byte]](data),
|
||||
# width,
|
||||
# height,
|
||||
# channels,
|
||||
# stbi.RGBA
|
||||
# )
|
|
@ -29,6 +29,8 @@ timeIt "GradientLinear horizontal":
|
|||
# timeIt "GradientLinear radial":
|
||||
# discard
|
||||
|
||||
let image100 = newImage(100, 100)
|
||||
|
||||
timeIt "GradientLinear angular":
|
||||
let paint = newPaint(AngularGradientPaint)
|
||||
paint.gradientHandlePositions = @[
|
||||
|
@ -40,4 +42,4 @@ timeIt "GradientLinear angular":
|
|||
ColorStop(color: color(1, 0, 0, 1), position: 0),
|
||||
ColorStop(color: color(1, 0, 0, 0.15625), position: 1.0),
|
||||
]
|
||||
image.fillGradient(paint)
|
||||
image100.fillGradient(paint)
|
67
tests/bench_png.nim
Normal file
|
@ -0,0 +1,67 @@
|
|||
import benchy, pixie/fileformats/png
|
||||
|
||||
let
|
||||
filePath = "tests/fileformats/png/lenna.png"
|
||||
data = readFile(filePath)
|
||||
|
||||
block:
|
||||
let
|
||||
decodedPng = decodePng(data)
|
||||
decodedImage = newImage(decodedPng)
|
||||
|
||||
timeIt "pixie decode":
|
||||
discard decodePng(data)
|
||||
|
||||
timeIt "pixie decode + alpha":
|
||||
discard decodePng(data).convertToImage()
|
||||
|
||||
timeIt "pixie encode":
|
||||
discard encodePng(decodedPng)
|
||||
|
||||
timeIt "pixie encode + alpha":
|
||||
discard encodePng(decodedImage)
|
||||
|
||||
# import nimPNG
|
||||
# block:
|
||||
# timeIt "nimPNG decode":
|
||||
# discard decodePNG32(data)
|
||||
|
||||
# let decoded = decodePNG32(data)
|
||||
# timeIt "nimPNG encode":
|
||||
# discard encodePNG32(decoded.data, decoded.width, decoded.height)
|
||||
|
||||
# import stb_image/read as stbi, stb_image/write as stbr
|
||||
# block:
|
||||
# timeIt "stb_image decode":
|
||||
# var width, height, channels: int
|
||||
# discard loadFromMemory(
|
||||
# cast[seq[byte]](data),
|
||||
# width,
|
||||
# height,
|
||||
# channels,
|
||||
# stbi.RGBA
|
||||
# )
|
||||
|
||||
# var width, height, channels: int
|
||||
# let decoded = loadFromMemory(
|
||||
# cast[seq[byte]](data),
|
||||
# width,
|
||||
# height,
|
||||
# channels,
|
||||
# stbi.RGBA
|
||||
# )
|
||||
|
||||
# timeIt "stb_image encode":
|
||||
# discard writePNG(width, height, channels, decoded).len
|
||||
|
||||
# import cairo
|
||||
# block:
|
||||
# timeIt "cairo decode":
|
||||
# discard imageSurfaceCreateFromPng(filePath.cstring)
|
||||
|
||||
# let decoded = imageSurfaceCreateFromPng(filePath.cstring)
|
||||
# timeIt "cairo encode":
|
||||
# var write: WriteFunc =
|
||||
# proc(closure: pointer, data: cstring, len: int32): Status {.cdecl.} =
|
||||
# StatusSuccess
|
||||
# discard decoded.writeToPng(write, nil)
|
|
@ -1,19 +0,0 @@
|
|||
import benchy, jpegsuite, pixie/fileformats/jpeg, stb_image/read as stbi, strformat
|
||||
|
||||
for file in jpegSuiteFiles:
|
||||
let data = readFile(file)
|
||||
timeIt &"pixie jpeg {(data.len div 1024)}k decode":
|
||||
discard decodeJpeg(data)
|
||||
|
||||
block:
|
||||
for file in jpegSuiteFiles:
|
||||
let data = readFile(file)
|
||||
timeIt &"stb_image jpeg {(data.len div 1024)}k decode":
|
||||
var width, height, channels: int
|
||||
discard loadFromMemory(
|
||||
cast[seq[byte]](data),
|
||||
width,
|
||||
height,
|
||||
channels,
|
||||
stbi.RGBA
|
||||
)
|
|
@ -1,65 +0,0 @@
|
|||
import benchy, cairo, nimPNG, pixie/fileformats/png, stb_image/read as stbi,
|
||||
stb_image/write as stbr
|
||||
|
||||
let
|
||||
filePath = "tests/fileformats/png/lenna.png"
|
||||
data = readFile(filePath)
|
||||
|
||||
block:
|
||||
let
|
||||
decodedPng = decodePng(data)
|
||||
decodedImage = newImage(decodedPng)
|
||||
|
||||
timeIt "pixie decode":
|
||||
discard decodePng(data)
|
||||
|
||||
timeIt "pixie decode + alpha":
|
||||
discard decodePng(data).convertToImage()
|
||||
|
||||
timeIt "pixie encode":
|
||||
discard encodePng(decodedPng)
|
||||
|
||||
timeIt "pixie encode + alpha":
|
||||
discard encodePng(decodedImage)
|
||||
|
||||
block:
|
||||
timeIt "nimPNG decode":
|
||||
discard decodePNG32(data)
|
||||
|
||||
let decoded = decodePNG32(data)
|
||||
timeIt "nimPNG encode":
|
||||
discard encodePNG32(decoded.data, decoded.width, decoded.height)
|
||||
|
||||
block:
|
||||
timeIt "stb_image decode":
|
||||
var width, height, channels: int
|
||||
discard loadFromMemory(
|
||||
cast[seq[byte]](data),
|
||||
width,
|
||||
height,
|
||||
channels,
|
||||
stbi.RGBA
|
||||
)
|
||||
|
||||
var width, height, channels: int
|
||||
let decoded = loadFromMemory(
|
||||
cast[seq[byte]](data),
|
||||
width,
|
||||
height,
|
||||
channels,
|
||||
stbi.RGBA
|
||||
)
|
||||
|
||||
timeIt "stb_image encode":
|
||||
discard writePNG(width, height, channels, decoded).len
|
||||
|
||||
block:
|
||||
timeIt "cairo decode":
|
||||
discard imageSurfaceCreateFromPng(filePath.cstring)
|
||||
|
||||
let decoded = imageSurfaceCreateFromPng(filePath.cstring)
|
||||
timeIt "cairo encode":
|
||||
var write: WriteFunc =
|
||||
proc(closure: pointer, data: cstring, len: int32): Status {.cdecl.} =
|
||||
StatusSuccess
|
||||
discard decoded.writeToPng(write, nil)
|
BIN
tests/fileformats/gif/newtons_cradle.png
Normal file
After Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 258 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 9 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 357 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 183 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 73 KiB |