This commit is contained in:
Sebastian Köln 2019-06-24 18:23:10 +03:00
commit 17f0e50878
93 changed files with 1886 additions and 606 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ target
node_modules node_modules
/examples/c_canvas_minimal/build /examples/c_canvas_minimal/build
/shaders/build /shaders/build
/c/build
# Editors # Editors
*.swp *.swp

247
Cargo.lock generated
View File

@ -44,7 +44,7 @@ name = "approx"
version = "0.3.2" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -90,7 +90,7 @@ dependencies = [
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "0.1.2" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -98,7 +98,7 @@ name = "backtrace"
version = "0.3.15" version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
@ -142,6 +142,11 @@ name = "block"
version = "0.1.6" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "build_const"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.3.1" version = "1.3.1"
@ -154,6 +159,7 @@ dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_canvas 0.1.0", "pathfinder_canvas 0.1.0",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -169,6 +175,7 @@ dependencies = [
"metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_canvas 0.1.0", "pathfinder_canvas 0.1.0",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -184,6 +191,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_canvas 0.1.0", "pathfinder_canvas 0.1.0",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -198,6 +206,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_canvas 0.1.0", "pathfinder_canvas 0.1.0",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -213,6 +222,7 @@ dependencies = [
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_canvas 0.1.0", "pathfinder_canvas 0.1.0",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -221,6 +231,23 @@ dependencies = [
"sdl2-sys 0.32.6 (registry+https://github.com/rust-lang/crates.io-index)", "sdl2-sys 0.32.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "cbindgen"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.36" version = "1.0.36"
@ -251,7 +278,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -366,6 +393,14 @@ dependencies = [
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "crc"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.2.0" version = "1.2.0"
@ -545,7 +580,7 @@ version = "0.19.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -815,6 +850,11 @@ dependencies = [
"gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "half"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "harfbuzz" name = "harfbuzz"
version = "0.3.1" version = "0.3.1"
@ -855,6 +895,11 @@ dependencies = [
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "hex"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "1.2.0" version = "1.2.0"
@ -875,7 +920,7 @@ dependencies = [
"num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "png 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -889,7 +934,7 @@ dependencies = [
"lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1017,7 +1062,7 @@ name = "line_drawing"
version = "0.7.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1059,7 +1104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1070,6 +1115,16 @@ dependencies = [
"lyon_geom 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "lyon_geom 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "lzma-rs"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "lzw" name = "lzw"
version = "0.10.0" version = "0.10.0"
@ -1158,6 +1213,15 @@ name = "nodrop"
version = "0.1.13" version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "nom"
version = "4.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "num" name = "num"
version = "0.1.42" version = "0.1.42"
@ -1165,7 +1229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1183,7 +1247,7 @@ name = "num-integer"
version = "0.1.39" version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1192,7 +1256,7 @@ version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1201,7 +1265,7 @@ version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1210,13 +1274,16 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.6" version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
@ -1271,7 +1338,7 @@ name = "ordered-float"
version = "1.0.2" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1329,12 +1396,18 @@ dependencies = [
name = "pathfinder_c" name = "pathfinder_c"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cbindgen 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
"metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_canvas 0.1.0", "pathfinder_canvas 0.1.0",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
"pathfinder_metal 0.1.0",
"pathfinder_renderer 0.1.0", "pathfinder_renderer 0.1.0",
"pathfinder_simd 0.3.0", "pathfinder_simd 0.3.0",
] ]
@ -1344,12 +1417,25 @@ name = "pathfinder_canvas"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_renderer 0.1.0", "pathfinder_renderer 0.1.0",
"pathfinder_text 0.1.0", "pathfinder_text 0.1.0",
"skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)", "skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)",
] ]
[[package]]
name = "pathfinder_content"
version = "0.1.0"
dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0",
"pathfinder_simd 0.3.0",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "pathfinder_demo" name = "pathfinder_demo"
version = "0.1.0" version = "0.1.0"
@ -1359,6 +1445,7 @@ dependencies = [
"image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -1375,13 +1462,8 @@ dependencies = [
name = "pathfinder_geometry" name = "pathfinder_geometry"
version = "0.3.0" version = "0.3.0"
dependencies = [ dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_simd 0.3.0", "pathfinder_simd 0.3.0",
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1402,6 +1484,7 @@ name = "pathfinder_gpu"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_simd 0.3.0", "pathfinder_simd 0.3.0",
] ]
@ -1423,6 +1506,7 @@ dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_demo 0.1.0", "pathfinder_demo 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
@ -1462,6 +1546,7 @@ dependencies = [
"fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
"pathfinder_simd 0.3.0", "pathfinder_simd 0.3.0",
@ -1485,11 +1570,25 @@ name = "pathfinder_svg"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_renderer 0.1.0", "pathfinder_renderer 0.1.0",
"usvg 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "usvg 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "pathfinder_swf"
version = "0.1.0"
dependencies = [
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0",
"pathfinder_renderer 0.1.0",
"swf-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"swf-tree 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "pathfinder_text" name = "pathfinder_text"
version = "0.1.0" version = "0.1.0"
@ -1497,6 +1596,7 @@ dependencies = [
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_renderer 0.1.0", "pathfinder_renderer 0.1.0",
"skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)", "skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)",
@ -1507,6 +1607,7 @@ name = "pathfinder_ui"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_content 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
"pathfinder_simd 0.3.0", "pathfinder_simd 0.3.0",
@ -1610,7 +1711,7 @@ name = "rand"
version = "0.6.5" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1628,7 +1729,7 @@ name = "rand_chacha"
version = "0.1.1" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1689,7 +1790,7 @@ name = "rand_pcg"
version = "0.1.2" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1779,6 +1880,14 @@ dependencies = [
"ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "remove_dir_all"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "roxmltree" name = "roxmltree"
version = "0.6.1" version = "0.6.1"
@ -2029,6 +2138,58 @@ dependencies = [
"phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "swf-fixed"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "swf-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lzma-rs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
"swf-fixed 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"swf-tree 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "swf-tree"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
"swf-fixed 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "swf_basic"
version = "0.1.0"
dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0",
"pathfinder_renderer 0.1.0",
"pathfinder_swf 0.1.0",
"sdl2 0.32.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sdl2-sys 0.32.6 (registry+https://github.com/rust-lang/crates.io-index)",
"swf-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"swf-tree 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "0.15.34" version = "0.15.34"
@ -2050,6 +2211,19 @@ dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "tempfile"
version = "3.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "term" name = "term"
version = "0.5.2" version = "0.5.2"
@ -2105,6 +2279,14 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "toml"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.1.0" version = "0.1.0"
@ -2388,14 +2570,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
"checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335" "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf"
"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637" "checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637"
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum cbindgen 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1f861ef68cabbb271d373a7795014052bff37edce22c620d95e395e8719d7dc5"
"checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d" "checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d"
"checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
@ -2413,6 +2597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
"checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" "checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9"
"checksum core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d95a72b5e50e549969dd88eff3047495fe5b8c6f028635442c2b708be707e669" "checksum core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d95a72b5e50e549969dd88eff3047495fe5b8c6f028635442c2b708be707e669"
"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
"checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b"
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
@ -2458,10 +2643,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum glutin_gles2_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89996c30857ae1b4de4b5189abf1ea822a20a9fe9e1c93e5e7b862ff0bdd5cdf" "checksum glutin_gles2_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89996c30857ae1b4de4b5189abf1ea822a20a9fe9e1c93e5e7b862ff0bdd5cdf"
"checksum glutin_glx_sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1290a5ca5e46fcfa7f66f949cc9d9194b2cb6f2ed61892c8c2b82343631dba57" "checksum glutin_glx_sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1290a5ca5e46fcfa7f66f949cc9d9194b2cb6f2ed61892c8c2b82343631dba57"
"checksum glutin_wgl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f801bbc91efc22dd1c4818a47814fc72bf74d024510451b119381579bfa39021" "checksum glutin_wgl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f801bbc91efc22dd1c4818a47814fc72bf74d024510451b119381579bfa39021"
"checksum half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9353c2a89d550b58fa0061d8ed8d002a7d8cdf2494eb0e432859bd3a9e543836"
"checksum harfbuzz 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46f7426266a5ece3e49eae6f48e602c0f8c39917354a847eac9c06437dcde8da" "checksum harfbuzz 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46f7426266a5ece3e49eae6f48e602c0f8c39917354a847eac9c06437dcde8da"
"checksum harfbuzz-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e1042ab0b3e7bc1ff64f7f5935778b644ff2194a1cae5ec52167127d3fd23961" "checksum harfbuzz-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e1042ab0b3e7bc1ff64f7f5935778b644ff2194a1cae5ec52167127d3fd23961"
"checksum harfbuzz_rs 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "534c8e9b15d8db6e69654b07dad955f4132757194e7d2bba620d38cf08996088" "checksum harfbuzz_rs 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "534c8e9b15d8db6e69654b07dad955f4132757194e7d2bba620d38cf08996088"
"checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da"
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
"checksum image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebdff791af04e30089bde8ad2a632b86af433b40c04db8d70ad4b21487db7a6a" "checksum image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebdff791af04e30089bde8ad2a632b86af433b40c04db8d70ad4b21487db7a6a"
"checksum image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "293e54ce142a936a39da748ba8178ae6aa1914b82d846a4278f11590c89bf116" "checksum image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "293e54ce142a936a39da748ba8178ae6aa1914b82d846a4278f11590c89bf116"
@ -2487,6 +2674,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum lyon_geom 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ea0ba5f8d2d91d6d895aca54d1ec0d84ddfa4826f33fbfe8abb39f08f9e4153" "checksum lyon_geom 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ea0ba5f8d2d91d6d895aca54d1ec0d84ddfa4826f33fbfe8abb39f08f9e4153"
"checksum lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9dc8e0746b7cca11960b602f7fe037bb067746a01eab4aa502fed1494544843" "checksum lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9dc8e0746b7cca11960b602f7fe037bb067746a01eab4aa502fed1494544843"
"checksum lzma-rs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9550ba35a4d6bb6be7f273bce93af3a3141c517bf7d7298763a7149e1bdb9af5"
"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" "checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084"
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
@ -2498,13 +2686,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e752e3c216bc8a491c5b59fa46da10f1379ae450b19ac688e07f4bb55042e98" "checksum nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e752e3c216bc8a491c5b59fa46da10f1379ae450b19ac688e07f4bb55042e98"
"checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b" "checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
"checksum num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2" "checksum num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124" "checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
"checksum num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e" "checksum num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e"
"checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10" "checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32"
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
"checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" "checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d"
@ -2546,6 +2735,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828"
"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58"
"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
"checksum roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "330d8f80a274bc3cb608908ee345970e7e24b96907f1ad69615a498bec57871c" "checksum roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "330d8f80a274bc3cb608908ee345970e7e24b96907f1ad69615a498bec57871c"
"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
@ -2576,14 +2766,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
"checksum svgdom 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ddce601e49ed213b0126ff4172cd9f5f8dba5f1df2277ecbe0e298f9865baba" "checksum svgdom 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ddce601e49ed213b0126ff4172cd9f5f8dba5f1df2277ecbe0e298f9865baba"
"checksum svgtypes 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "444c882c28925ae0585df228a90f9951569588646ceca4753560de93cdd02258" "checksum svgtypes 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "444c882c28925ae0585df228a90f9951569588646ceca4753560de93cdd02258"
"checksum swf-fixed 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3c575807f18641c5e079568b53630a46baf441da57caccd9ced9a9ee70f941"
"checksum swf-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b6349830c1ed5d26b97d801e3fb8664556e12a01560e3479e3961e8f5675a05"
"checksum swf-tree 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c075cea0328cc5f6ee694bcd1c43534d1186a730d79258b10735f8f08e2f1baa"
"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef"
"checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
"checksum ttf-parser 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29637063e570f7e5260924119666113215386c1b94e1d1ceb4525e269dfbe2d0" "checksum ttf-parser 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29637063e570f7e5260924119666113215386c1b94e1d1ceb4525e269dfbe2d0"
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"

View File

@ -2,6 +2,7 @@
members = [ members = [
"c", "c",
"canvas", "canvas",
"content",
"demo/android/rust", "demo/android/rust",
"demo/common", "demo/common",
"demo/magicleap", "demo/magicleap",
@ -12,6 +13,7 @@ members = [
"examples/canvas_moire", "examples/canvas_moire",
"examples/canvas_text", "examples/canvas_text",
"examples/lottie_basic", "examples/lottie_basic",
"examples/swf_basic",
"geometry", "geometry",
"gl", "gl",
"gpu", "gpu",
@ -20,6 +22,7 @@ members = [
"renderer", "renderer",
"simd", "simd",
"svg", "svg",
"swf",
"text", "text",
"ui", "ui",
"utils/area-lut", "utils/area-lut",

View File

@ -3,17 +3,23 @@ name = "pathfinder_c"
version = "0.1.0" version = "0.1.0"
authors = ["Patrick Walton <pcwalton@mimiga.net>"] authors = ["Patrick Walton <pcwalton@mimiga.net>"]
edition = "2018" edition = "2018"
build = "build.rs"
[lib] [lib]
crate-type = ["staticlib"] crate-type = ["staticlib"]
[dependencies] [dependencies]
font-kit = "0.2"
foreign-types = "0.3"
gl = "0.6" gl = "0.6"
libc = "0.2" libc = "0.2"
[dependencies.pathfinder_canvas] [dependencies.pathfinder_canvas]
path = "../canvas" path = "../canvas"
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"
@ -28,3 +34,12 @@ path = "../renderer"
[dependencies.pathfinder_simd] [dependencies.pathfinder_simd]
path = "../simd" path = "../simd"
[target.'cfg(target_os = "macos")'.dependencies]
metal = "0.14"
[target.'cfg(target_os = "macos")'.dependencies.pathfinder_metal]
path = "../metal"
[build-dependencies]
cbindgen = "0.8"

20
c/build.rs Normal file
View File

@ -0,0 +1,20 @@
// pathfinder/c/build.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cbindgen;
use std::env;
use std::fs;
fn main() {
fs::create_dir_all("build/include/pathfinder").expect("Failed to create directories!");
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::generate(crate_dir).expect("cbindgen failed!")
.write_to_file("build/include/pathfinder/pathfinder.h");
}

19
c/cbindgen.toml Normal file
View File

@ -0,0 +1,19 @@
language = "C"
header = """\
/* Generated code. Do not edit; instead run `cargo build` in `pathfinder_c`. */
extern \"C\" {
"""
trailer = "}"
include_guard = "PF_PATHFINDER_H"
include_version = true
[parse]
parse_deps = true
include = [
"pathfinder_canvas",
"pathfinder_content",
"pathfinder_geometry",
"pathfinder_gl",
"pathfinder_renderer",
]

View File

@ -1,222 +0,0 @@
// pathfinder/c/include/pathfinder/pathfinder.h
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#ifndef PF_PATHFINDER_H
#define PF_PATHFINDER_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// Macros
// `canvas`
#define PF_LINE_CAP_BUTT 0
#define PF_LINE_CAP_SQUARE 1
#define PF_LINE_CAP_ROUND 2
#define PF_LINE_JOIN_MITER 0
#define PF_LINE_JOIN_BEVEL 1
#define PF_LINE_JOIN_ROUND 2
// `geometry`
#define PF_ARC_DIRECTION_CW 0
#define PF_ARC_DIRECTION_CCW 1
// `gl`
#define PF_GL_VERSION_GL3 0
#define PF_GL_VERSION_GLES3 1
// `renderer`
#define PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR 0x1
// Types
// `canvas`
struct PFCanvas;
typedef struct PFCanvas *PFCanvasRef;
struct PFPath;
typedef struct PFPath *PFPathRef;
struct PFCanvasFontContext;
typedef struct PFCanvasFontContext *PFCanvasFontContextRef;
struct PFFillStyle;
typedef struct PFFillStyle *PFFillStyleRef;
typedef uint8_t PFLineCap;
typedef uint8_t PFLineJoin;
typedef uint8_t PFArcDirection;
struct PFTextMetrics {
float width;
};
typedef struct PFTextMetrics PFTextMetrics;
// `geometry`
struct PFColorF {
float r, g, b, a;
};
typedef struct PFColorF PFColorF;
struct PFColorU {
uint8_t r, g, b, a;
};
typedef struct PFColorU PFColorU;
struct PFVector2F {
float x, y;
};
typedef struct PFVector2F PFVector2F;
struct PFVector2I {
int32_t x, y;
};
typedef struct PFVector2I PFVector2I;
struct PFRectF {
PFVector2F origin, lower_right;
};
typedef struct PFRectF PFRectF;
struct PFRectI {
PFVector2I origin, lower_right;
};
typedef struct PFRectI PFRectI;
// `gl`
struct PFGLDevice;
typedef struct PFGLDevice *PFGLDeviceRef;
struct PFGLDestFramebuffer;
typedef struct PFGLDestFramebuffer *PFGLDestFramebufferRef;
typedef const void *(*PFGLFunctionLoader)(const char *data, void *userdata);
struct PFGLRenderer;
typedef struct PFGLRenderer *PFGLRendererRef;
typedef uint32_t PFGLVersion;
// `gpu`
struct PFResourceLoader;
typedef struct PFResourceLoader *PFResourceLoaderRef;
// `renderer`
typedef uint8_t PFRendererOptionsFlags;
struct PFRendererOptions {
PFColorF background_color;
PFRendererOptionsFlags flags;
};
struct PFBuildOptions {
uint32_t placeholder;
};
typedef struct PFRendererOptions PFRendererOptions;
typedef struct PFBuildOptions PFBuildOptions;
struct PFScene;
typedef struct PFScene *PFSceneRef;
struct PFSceneProxy;
typedef struct PFSceneProxy *PFSceneProxyRef;
// Functions
// `canvas`
PFCanvasRef PFCanvasCreate(PFCanvasFontContextRef font_context, const PFVector2F *size);
void PFCanvasDestroy(PFCanvasRef canvas);
PFCanvasFontContextRef PFCanvasFontContextCreateWithSystemSource();
void PFCanvasFontContextDestroy(PFCanvasFontContextRef font_context);
PFCanvasFontContextRef PFCanvasFontContextClone(PFCanvasFontContextRef font_context);
PFSceneRef PFCanvasCreateScene(PFCanvasRef canvas);
void PFCanvasFillRect(PFCanvasRef canvas, const PFRectF *rect);
void PFCanvasStrokeRect(PFCanvasRef canvas, const PFRectF *rect);
void PFCanvasFillText(PFCanvasRef canvas,
const char *string,
size_t string_len,
const PFVector2F *position);
void PFCanvasStrokeText(PFCanvasRef canvas,
const char *string,
size_t string_len,
const PFVector2F *position);
void PFCanvasMeasureText(PFCanvasRef canvas,
const char *string,
size_t string_len,
PFTextMetrics *out_text_metrics);
void PFCanvasSetLineWidth(PFCanvasRef canvas, float new_line_width);
void PFCanvasSetLineCap(PFCanvasRef canvas, PFLineCap new_line_cap);
void PFCanvasSetLineJoin(PFCanvasRef canvas, PFLineJoin new_line_join);
void PFCanvasSetMiterLimit(PFCanvasRef canvas, float new_miter_limit);
void PFCanvasSetLineDash(PFCanvasRef canvas,
const float *new_line_dashes,
size_t new_line_dash_count);
void PFCanvasSetLineDashOffset(PFCanvasRef canvas, float offset);
void PFCanvasSetFillStyle(PFCanvasRef canvas, PFFillStyleRef fill_style);
void PFCanvasSetStrokeStyle(PFCanvasRef canvas, PFFillStyleRef stroke_style);
void PFCanvasFillPath(PFCanvasRef canvas, PFPathRef path);
void PFCanvasStrokePath(PFCanvasRef canvas, PFPathRef path);
PFPathRef PFPathCreate();
void PFPathDestroy(PFPathRef path);
PFPathRef PFPathClone(PFPathRef path);
void PFPathMoveTo(PFPathRef path, const PFVector2F *to);
void PFPathLineTo(PFPathRef path, const PFVector2F *to);
void PFPathQuadraticCurveTo(PFPathRef path, const PFVector2F *ctrl, const PFVector2F *to);
void PFPathBezierCurveTo(PFPathRef path,
const PFVector2F *ctrl0,
const PFVector2F *ctrl1,
const PFVector2F *to);
void PFPathArc(PFPathRef path,
const PFVector2F *center,
float radius,
float start_angle,
float end_angle,
PFArcDirection direction);
void PFPathArcTo(PFPathRef path, const PFVector2F *ctrl, const PFVector2F *to, float radius);
void PFPathRect(PFPathRef path, const PFRectF *rect);
void PFPathEllipse(PFPathRef path,
const PFVector2F *center,
const PFVector2F *axes,
float rotation,
float start_angle,
float end_angle);
void PFPathClosePath(PFPathRef path);
PFFillStyleRef PFFillStyleCreateColor(PFColorU color);
void PFFillStyleDestroy(PFFillStyleRef fill_style);
// `gl`
PFGLDestFramebufferRef PFGLDestFramebufferCreateFullWindow(const PFVector2I *window_size);
void PFGLDestFramebufferDestroy(PFGLDestFramebufferRef dest_framebuffer);
PFGLDeviceRef PFGLDeviceCreate(PFGLVersion version, uint32_t default_framebuffer);
void PFGLDeviceDestroy(PFGLDeviceRef device);
void PFGLLoadWith(PFGLFunctionLoader loader, void *userdata);
PFGLRendererRef PFGLRendererCreate(PFGLDeviceRef device,
PFResourceLoaderRef resources,
PFGLDestFramebufferRef dest_framebuffer,
const PFRendererOptions *options);
void PFGLRendererDestroy(PFGLRendererRef renderer);
/// Returns a borrowed reference to the device.
PFGLDeviceRef PFGLRendererGetDevice(PFGLRendererRef renderer);
void PFSceneProxyBuildAndRenderGL(PFSceneProxyRef scene_proxy,
PFGLRendererRef renderer,
const PFBuildOptions *build_options);
// `gpu`
PFResourceLoaderRef PFFilesystemResourceLoaderLocate();
void PFResourceLoaderDestroy(PFResourceLoaderRef loader);
// `renderer`
PFSceneProxyRef PFSceneProxyCreateFromSceneAndRayonExecutor(PFSceneRef scene);
void PFSceneProxyDestroy(PFSceneProxyRef scene_proxy);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -10,14 +10,16 @@
//! C bindings to Pathfinder. //! C bindings to Pathfinder.
use font_kit::handle::Handle;
use foreign_types::ForeignTypeRef;
use gl; use gl;
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, FillStyle, LineJoin}; use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, FillStyle, LineJoin};
use pathfinder_canvas::{Path2D, TextMetrics}; use pathfinder_canvas::{Path2D, TextMetrics};
use pathfinder_geometry::basic::rect::{RectF, RectI}; use pathfinder_content::color::{ColorF, ColorU};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_content::outline::ArcDirection;
use pathfinder_geometry::color::{ColorF, ColorU}; use pathfinder_content::stroke::LineCap;
use pathfinder_geometry::outline::ArcDirection; use pathfinder_geometry::rect::{RectF, RectI};
use pathfinder_geometry::stroke::LineCap; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_gl::{GLDevice, GLVersion}; use pathfinder_gl::{GLDevice, GLVersion};
use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader}; use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader};
use pathfinder_renderer::concurrent::rayon::RayonExecutor; use pathfinder_renderer::concurrent::rayon::RayonExecutor;
@ -32,6 +34,11 @@ use std::os::raw::{c_char, c_void};
use std::slice; use std::slice;
use std::str; use std::str;
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
use metal::{CAMetalLayer, CoreAnimationLayerRef};
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
use pathfinder_metal::MetalDevice;
// Constants // Constants
// `canvas` // `canvas`
@ -44,7 +51,7 @@ pub const PF_LINE_JOIN_MITER: u8 = 0;
pub const PF_LINE_JOIN_BEVEL: u8 = 1; pub const PF_LINE_JOIN_BEVEL: u8 = 1;
pub const PF_LINE_JOIN_ROUND: u8 = 2; pub const PF_LINE_JOIN_ROUND: u8 = 2;
// `geometry` // `content`
pub const PF_ARC_DIRECTION_CW: u8 = 0; pub const PF_ARC_DIRECTION_CW: u8 = 0;
pub const PF_ARC_DIRECTION_CCW: u8 = 1; pub const PF_ARC_DIRECTION_CCW: u8 = 1;
@ -55,6 +62,9 @@ pub const PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR: u8 = 0x1;
// Types // Types
// External: `font-kit`
pub type FKHandleRef = *mut Handle;
// `canvas` // `canvas`
pub type PFCanvasRef = *mut CanvasRenderingContext2D; pub type PFCanvasRef = *mut CanvasRenderingContext2D;
pub type PFPathRef = *mut Path2D; pub type PFPathRef = *mut Path2D;
@ -68,6 +78,22 @@ pub struct PFTextMetrics {
pub width: f32, pub width: f32,
} }
// `content`
#[repr(C)]
pub struct PFColorF {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[repr(C)]
pub struct PFColorU {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
// `geometry` // `geometry`
#[repr(C)] #[repr(C)]
pub struct PFVector2F { pub struct PFVector2F {
@ -89,20 +115,6 @@ pub struct PFRectI {
pub origin: PFVector2I, pub origin: PFVector2I,
pub lower_right: PFVector2I, pub lower_right: PFVector2I,
} }
#[repr(C)]
pub struct PFColorF {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[repr(C)]
pub struct PFColorU {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
// `gl` // `gl`
pub type PFGLDeviceRef = *mut GLDevice; pub type PFGLDeviceRef = *mut GLDevice;
@ -112,10 +124,18 @@ pub type PFGLFunctionLoader = extern "C" fn(name: *const c_char, userdata: *mut
// `gpu` // `gpu`
pub type PFGLDestFramebufferRef = *mut DestFramebuffer<GLDevice>; pub type PFGLDestFramebufferRef = *mut DestFramebuffer<GLDevice>;
pub type PFGLRendererRef = *mut Renderer<GLDevice>; pub type PFGLRendererRef = *mut Renderer<GLDevice>;
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
pub type PFMetalDestFramebufferRef = *mut DestFramebuffer<MetalDevice>;
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
pub type PFMetalRendererRef = *mut Renderer<MetalDevice>;
// FIXME(pcwalton): Double-boxing is unfortunate. Remove this when `std::raw::TraitObject` is // FIXME(pcwalton): Double-boxing is unfortunate. Remove this when `std::raw::TraitObject` is
// stable? // stable?
pub type PFResourceLoaderRef = *mut Box<dyn ResourceLoader>; pub type PFResourceLoaderRef = *mut Box<dyn ResourceLoader>;
// `metal`
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
pub type PFMetalDeviceRef = *mut MetalDevice;
// `renderer` // `renderer`
pub type PFSceneRef = *mut Scene; pub type PFSceneRef = *mut Scene;
pub type PFSceneProxyRef = *mut SceneProxy; pub type PFSceneProxyRef = *mut SceneProxy;
@ -152,6 +172,16 @@ pub unsafe extern "C" fn PFCanvasFontContextCreateWithSystemSource() -> PFCanvas
Box::into_raw(Box::new(CanvasFontContext::from_system_source())) Box::into_raw(Box::new(CanvasFontContext::from_system_source()))
} }
#[no_mangle]
pub unsafe extern "C" fn PFCanvasFontContextCreateWithFonts(fonts: *const FKHandleRef,
font_count: usize)
-> PFCanvasFontContextRef {
let fonts = slice::from_raw_parts(fonts, font_count);
Box::into_raw(Box::new(CanvasFontContext::from_fonts(fonts.into_iter().map(|font| {
(**font).clone()
}))))
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn PFCanvasFontContextDestroy(font_context: PFCanvasFontContextRef) { pub unsafe extern "C" fn PFCanvasFontContextDestroy(font_context: PFCanvasFontContextRef) {
drop(Box::from_raw(font_context)) drop(Box::from_raw(font_context))
@ -248,6 +278,18 @@ pub unsafe extern "C" fn PFCanvasSetLineDashOffset(canvas: PFCanvasRef, new_offs
(*canvas).set_line_dash_offset(new_offset) (*canvas).set_line_dash_offset(new_offset)
} }
#[no_mangle]
pub unsafe extern "C" fn PFCanvasSetFontByPostScriptName(canvas: PFCanvasRef,
postscript_name: *const c_char,
postscript_name_len: usize) {
(*canvas).set_font_by_postscript_name(to_rust_string(&postscript_name, postscript_name_len))
}
#[no_mangle]
pub unsafe extern "C" fn PFCanvasSetFontSize(canvas: PFCanvasRef, new_font_size: f32) {
(*canvas).set_font_size(new_font_size)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn PFCanvasSetFillStyle(canvas: PFCanvasRef, fill_style: PFFillStyleRef) { pub unsafe extern "C" fn PFCanvasSetFillStyle(canvas: PFCanvasRef, fill_style: PFFillStyleRef) {
(*canvas).set_fill_style(*fill_style) (*canvas).set_fill_style(*fill_style)
@ -428,6 +470,46 @@ pub unsafe extern "C" fn PFGLRendererGetDevice(renderer: PFGLRendererRef) -> PFG
&mut (*renderer).device &mut (*renderer).device
} }
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalDestFramebufferCreateFullWindow(window_size: *const PFVector2I)
-> PFMetalDestFramebufferRef {
Box::into_raw(Box::new(DestFramebuffer::full_window((*window_size).to_rust())))
}
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalDestFramebufferDestroy(dest_framebuffer:
PFMetalDestFramebufferRef) {
drop(Box::from_raw(dest_framebuffer))
}
/// Takes ownership of `device` and `dest_framebuffer`, but not `resources`.
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalRendererCreate(device: PFMetalDeviceRef,
resources: PFResourceLoaderRef,
dest_framebuffer: PFMetalDestFramebufferRef,
options: *const PFRendererOptions)
-> PFMetalRendererRef {
Box::into_raw(Box::new(Renderer::new(*Box::from_raw(device),
&**resources,
*Box::from_raw(dest_framebuffer),
(*options).to_rust())))
}
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalRendererDestroy(renderer: PFMetalRendererRef) {
drop(Box::from_raw(renderer))
}
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalRendererGetDevice(renderer: PFMetalRendererRef) -> PFMetalDeviceRef {
&mut (*renderer).device
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn PFSceneProxyBuildAndRenderGL(scene_proxy: PFSceneProxyRef, pub unsafe extern "C" fn PFSceneProxyBuildAndRenderGL(scene_proxy: PFSceneProxyRef,
renderer: PFGLRendererRef, renderer: PFGLRendererRef,
@ -435,6 +517,29 @@ pub unsafe extern "C" fn PFSceneProxyBuildAndRenderGL(scene_proxy: PFSceneProxyR
(*scene_proxy).build_and_render(&mut *renderer, (*build_options).to_rust()) (*scene_proxy).build_and_render(&mut *renderer, (*build_options).to_rust())
} }
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFSceneProxyBuildAndRenderMetal(scene_proxy: PFSceneProxyRef,
renderer: PFMetalRendererRef,
build_options: *const PFBuildOptions) {
(*scene_proxy).build_and_render(&mut *renderer, (*build_options).to_rust())
}
// `metal`
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalDeviceCreate(layer: *mut CAMetalLayer)
-> PFMetalDeviceRef {
Box::into_raw(Box::new(MetalDevice::new(CoreAnimationLayerRef::from_ptr(layer))))
}
#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
#[no_mangle]
pub unsafe extern "C" fn PFMetalDeviceDestroy(device: PFMetalDeviceRef) {
drop(Box::from_raw(device))
}
// `renderer` // `renderer`
#[no_mangle] #[no_mangle]
@ -472,7 +577,7 @@ impl TextMetricsExt for TextMetrics {
} }
} }
// Helpers for `geometry` // Helpers for `content`
impl PFColorF { impl PFColorF {
#[inline] #[inline]
@ -488,6 +593,8 @@ impl PFColorU {
} }
} }
// Helpers for `geometry`
impl PFRectF { impl PFRectF {
#[inline] #[inline]
pub fn to_rust(&self) -> RectF { pub fn to_rust(&self) -> RectF {

View File

@ -10,6 +10,9 @@ crate-type = ["rlib", "staticlib"]
[dependencies] [dependencies]
font-kit = "0.2" font-kit = "0.2"
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"

View File

@ -17,15 +17,15 @@ use font_kit::loaders::default::Font;
use font_kit::properties::Properties; use font_kit::properties::Properties;
use font_kit::source::{Source, SystemSource}; use font_kit::source::{Source, SystemSource};
use font_kit::sources::mem::MemSource; use font_kit::sources::mem::MemSource;
use pathfinder_geometry::basic::line_segment::LineSegment2F; use pathfinder_content::color::ColorU;
use pathfinder_geometry::basic::vector::Vector2F; use pathfinder_content::dash::OutlineDash;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_content::outline::{ArcDirection, Contour, Outline};
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_content::stroke::{LineCap, LineJoin as StrokeLineJoin};
use pathfinder_geometry::color::ColorU; use pathfinder_content::stroke::{OutlineStrokeToFill, StrokeStyle};
use pathfinder_geometry::dash::OutlineDash; use pathfinder_geometry::line_segment::LineSegment2F;
use pathfinder_geometry::outline::{ArcDirection, Contour, Outline}; use pathfinder_geometry::vector::Vector2F;
use pathfinder_geometry::stroke::{LineCap, LineJoin as StrokeLineJoin}; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::stroke::{OutlineStrokeToFill, StrokeStyle}; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_renderer::paint::{Paint, PaintId}; use pathfinder_renderer::paint::{Paint, PaintId};
use pathfinder_renderer::scene::{PathObject, Scene}; use pathfinder_renderer::scene::{PathObject, Scene};
use pathfinder_text::{SceneExt, TextRenderMode}; use pathfinder_text::{SceneExt, TextRenderMode};
@ -536,7 +536,7 @@ pub enum TextAlign {
Center, Center,
} }
// We duplicate `pathfinder_geometry::stroke::LineJoin` here because the HTML canvas API treats the // We duplicate `pathfinder_content::stroke::LineJoin` here because the HTML canvas API treats the
// miter limit as part of the canvas state, while the native Pathfinder API treats the miter limit // miter limit as part of the canvas state, while the native Pathfinder API treats the miter limit
// as part of the line join. Pathfinder's choice is more logical, because the miter limit is // as part of the line join. Pathfinder's choice is more logical, because the miter limit is
// specific to miter joins. In this API, however, for compatibility we go with the HTML canvas // specific to miter joins. In this API, however, for compatibility we go with the HTML canvas

17
content/Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[package]
name = "pathfinder_content"
version = "0.1.0"
authors = ["Patrick Walton <pcwalton@mimiga.net>"]
edition = "2018"
[dependencies]
arrayvec = "0.4"
bitflags = "1.0"
log = "0.4"
smallvec = "0.6"
[dependencies.pathfinder_geometry]
path = "../geometry"
[dependencies.pathfinder_simd]
path = "../simd"

View File

@ -1,4 +1,4 @@
// pathfinder/geometry/src/clip.rs // pathfinder/content/src/clip.rs
// //
// Copyright © 2019 The Pathfinder Project Developers. // Copyright © 2019 The Pathfinder Project Developers.
// //
@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::basic::line_segment::LineSegment2F;
use crate::basic::vector::{Vector2F, Vector4F};
use crate::basic::rect::RectF;
use crate::outline::{Contour, PointFlags, PushSegmentFlags}; use crate::outline::{Contour, PointFlags, PushSegmentFlags};
use crate::segment::{CubicSegment, Segment}; use crate::segment::{CubicSegment, Segment};
use crate::util::lerp;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use pathfinder_geometry::line_segment::LineSegment2F;
use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::util::lerp;
use pathfinder_geometry::vector::{Vector2F, Vector4F};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt::Debug; use std::fmt::Debug;
use std::mem; use std::mem;

View File

@ -1,4 +1,4 @@
// pathfinder/geometry/src/dilation.rs // pathfinder/content/src/dilation.rs
// //
// Copyright © 2019 The Pathfinder Project Developers. // Copyright © 2019 The Pathfinder Project Developers.
// //
@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::basic::vector::Vector2F;
use crate::orientation::Orientation; use crate::orientation::Orientation;
use crate::outline::Contour; use crate::outline::Contour;
use pathfinder_geometry::vector::Vector2F;
pub struct ContourDilator<'a> { pub struct ContourDilator<'a> {
contour: &'a mut Contour, contour: &'a mut Contour,

View File

@ -1,4 +1,4 @@
// pathfinder/geometry/src/basic/mod.rs // pathfinder/content/src/lib.rs
// //
// Copyright © 2019 The Pathfinder Project Developers. // Copyright © 2019 The Pathfinder Project Developers.
// //
@ -8,10 +8,22 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
//! Basic geometry and linear algebra primitives, optimized with SIMD. //! Pathfinder's representation of a vector scene.
//!
//! This module also contains various path utilities.
pub mod line_segment; #[macro_use]
pub mod rect; extern crate bitflags;
pub mod transform2d; #[macro_use]
pub mod transform3d; extern crate log;
pub mod vector;
pub mod clip;
pub mod color;
pub mod dash;
pub mod orientation;
pub mod outline;
pub mod segment;
pub mod stroke;
pub mod transform;
mod dilation;

View File

@ -1,4 +1,4 @@
// pathfinder/geometry/src/outline.rs // pathfinder/content/src/outline.rs
// //
// Copyright © 2019 The Pathfinder Project Developers. // Copyright © 2019 The Pathfinder Project Developers.
// //
@ -10,16 +10,16 @@
//! A compressed in-memory representation of paths. //! A compressed in-memory representation of paths.
use crate::basic::line_segment::LineSegment2F;
use crate::basic::vector::Vector2F;
use crate::basic::rect::RectF;
use crate::basic::transform2d::Transform2DF;
use crate::basic::transform3d::Perspective;
use crate::clip::{self, ContourPolygonClipper, ContourRectClipper}; use crate::clip::{self, ContourPolygonClipper, ContourRectClipper};
use crate::dilation::ContourDilator; use crate::dilation::ContourDilator;
use crate::orientation::Orientation; use crate::orientation::Orientation;
use crate::segment::{Segment, SegmentFlags, SegmentKind}; use crate::segment::{Segment, SegmentFlags, SegmentKind};
use crate::unit_vector::UnitVector; use pathfinder_geometry::line_segment::LineSegment2F;
use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::transform3d::Perspective;
use pathfinder_geometry::unit_vector::UnitVector;
use pathfinder_geometry::vector::Vector2F;
use std::f32::consts::PI; use std::f32::consts::PI;
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
use std::mem; use std::mem;

View File

@ -1,4 +1,4 @@
// pathfinder/geometry/src/segment.rs // pathfinder/content/src/segment.rs
// //
// Copyright © 2019 The Pathfinder Project Developers. // Copyright © 2019 The Pathfinder Project Developers.
// //
@ -10,10 +10,10 @@
//! Line or curve segments, optimized with SIMD. //! Line or curve segments, optimized with SIMD.
use crate::basic::line_segment::LineSegment2F; use pathfinder_geometry::line_segment::LineSegment2F;
use crate::basic::vector::Vector2F; use pathfinder_geometry::transform2d::Transform2DF;
use crate::basic::transform2d::Transform2DF; use pathfinder_geometry::util::{self, EPSILON};
use crate::util::{self, EPSILON}; use pathfinder_geometry::vector::Vector2F;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
use std::f32::consts::SQRT_2; use std::f32::consts::SQRT_2;

View File

@ -1,4 +1,4 @@
// pathfinder/geometry/src/stroke.rs // pathfinder/content/src/stroke.rs
// //
// Copyright © 2019 The Pathfinder Project Developers. // Copyright © 2019 The Pathfinder Project Developers.
// //
@ -10,12 +10,12 @@
//! Utilities for converting path strokes to fills. //! Utilities for converting path strokes to fills.
use crate::basic::line_segment::LineSegment2F;
use crate::basic::vector::Vector2F;
use crate::basic::rect::RectF;
use crate::basic::transform2d::Transform2DF;
use crate::outline::{ArcDirection, Contour, Outline, PushSegmentFlags}; use crate::outline::{ArcDirection, Contour, Outline, PushSegmentFlags};
use crate::segment::Segment; use crate::segment::Segment;
use pathfinder_geometry::line_segment::LineSegment2F;
use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::vector::Vector2F;
use std::f32; use std::f32;
const TOLERANCE: f32 = 0.01; const TOLERANCE: f32 = 0.01;

124
content/src/transform.rs Normal file
View File

@ -0,0 +1,124 @@
// pathfinder/content/src/transform.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Utilities for transforming paths.
use crate::segment::Segment;
use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::transform3d::Perspective;
/// Transforms a path with a SIMD 2D transform.
pub struct Transform2DFPathIter<I>
where
I: Iterator<Item = Segment>,
{
iter: I,
transform: Transform2DF,
}
impl<I> Iterator for Transform2DFPathIter<I>
where
I: Iterator<Item = Segment>,
{
type Item = Segment;
#[inline]
fn next(&mut self) -> Option<Segment> {
// TODO(pcwalton): Can we go faster by transforming an entire line segment with SIMD?
let mut segment = self.iter.next()?;
if !segment.is_none() {
segment
.baseline
.set_from(&self.transform.transform_point(segment.baseline.from()));
segment
.baseline
.set_to(&self.transform.transform_point(segment.baseline.to()));
if !segment.is_line() {
segment
.ctrl
.set_from(&self.transform.transform_point(segment.ctrl.from()));
if !segment.is_quadratic() {
segment
.ctrl
.set_to(&self.transform.transform_point(segment.ctrl.to()));
}
}
}
Some(segment)
}
}
impl<I> Transform2DFPathIter<I>
where
I: Iterator<Item = Segment>,
{
#[inline]
pub fn new(iter: I, transform: &Transform2DF) -> Transform2DFPathIter<I> {
Transform2DFPathIter {
iter,
transform: *transform,
}
}
}
/// Transforms a path with a perspective projection.
pub struct PerspectivePathIter<I>
where
I: Iterator<Item = Segment>,
{
iter: I,
perspective: Perspective,
}
impl<I> Iterator for PerspectivePathIter<I>
where
I: Iterator<Item = Segment>,
{
type Item = Segment;
#[inline]
fn next(&mut self) -> Option<Segment> {
let mut segment = self.iter.next()?;
if !segment.is_none() {
segment.baseline.set_from(
&self
.perspective
.transform_point_2d(&segment.baseline.from()),
);
segment
.baseline
.set_to(&self.perspective.transform_point_2d(&segment.baseline.to()));
if !segment.is_line() {
segment
.ctrl
.set_from(&self.perspective.transform_point_2d(&segment.ctrl.from()));
if !segment.is_quadratic() {
segment
.ctrl
.set_to(&self.perspective.transform_point_2d(&segment.ctrl.to()));
}
}
}
Some(segment)
}
}
impl<I> PerspectivePathIter<I>
where
I: Iterator<Item = Segment>,
{
#[inline]
pub fn new(iter: I, perspective: &Perspective) -> PerspectivePathIter<I> {
PerspectivePathIter {
iter,
perspective: *perspective,
}
}
}

View File

@ -16,8 +16,8 @@ use jni::{JNIEnv, JavaVM};
use pathfinder_demo::window::{Event, SVGPath, View, Window, WindowSize}; use pathfinder_demo::window::{Event, SVGPath, View, Window, WindowSize};
use pathfinder_demo::DemoApp; use pathfinder_demo::DemoApp;
use pathfinder_demo::Options; use pathfinder_demo::Options;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_gl::GLVersion; use pathfinder_gl::GLVersion;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use std::cell::RefCell; use std::cell::RefCell;

View File

@ -22,6 +22,9 @@ features = ["png_codec"]
version = "0.4" version = "0.4"
features = ["release_max_level_warn"] features = ["release_max_level_warn"]
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../../geometry" path = "../../geometry"

View File

@ -14,10 +14,10 @@
// proper. // proper.
use crate::window::{OcularTransform, View}; use crate::window::{OcularTransform, View};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I, Vector4F}; use pathfinder_geometry::vector::{Vector2F, Vector2I, Vector4F};
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::basic::transform3d::{Perspective, Transform3DF}; use pathfinder_geometry::transform3d::{Perspective, Transform3DF};
use std::f32::consts::FRAC_PI_4; use std::f32::consts::FRAC_PI_4;
const NEAR_CLIP_PLANE: f32 = 0.01; const NEAR_CLIP_PLANE: f32 = 0.01;

View File

@ -22,11 +22,11 @@ use crate::device::{GroundProgram, GroundVertexArray};
use crate::ui::{DemoUIModel, DemoUIPresenter, ScreenshotInfo, ScreenshotType, UIAction}; use crate::ui::{DemoUIModel, DemoUIPresenter, ScreenshotInfo, ScreenshotType, UIAction};
use crate::window::{Event, Keycode, SVGPath, Window, WindowSize}; use crate::window::{Event, Keycode, SVGPath, Window, WindowSize};
use clap::{App, Arg}; use clap::{App, Arg};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::basic::transform3d::Transform3DF; use pathfinder_geometry::transform3d::Transform3DF;
use pathfinder_geometry::color::ColorU; use pathfinder_content::color::ColorU;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::Device; use pathfinder_gpu::Device;
use pathfinder_renderer::concurrent::scene_proxy::{RenderCommandStream, SceneProxy}; use pathfinder_renderer::concurrent::scene_proxy::{RenderCommandStream, SceneProxy};

View File

@ -14,12 +14,12 @@ use crate::camera::{Camera, Mode};
use crate::window::{View, Window}; use crate::window::{View, Window};
use crate::{BackgroundColor, DemoApp, UIVisibility}; use crate::{BackgroundColor, DemoApp, UIVisibility};
use image::ColorType; use image::ColorType;
use pathfinder_geometry::color::{ColorF, ColorU}; use pathfinder_content::color::{ColorF, ColorU};
use pathfinder_gpu::{ClearOps, DepthFunc, DepthState, Device, Primitive, RenderOptions}; use pathfinder_gpu::{ClearOps, DepthFunc, DepthState, Device, Primitive, RenderOptions};
use pathfinder_gpu::{RenderState, RenderTarget, TextureData, TextureFormat, UniformData}; use pathfinder_gpu::{RenderState, RenderTarget, TextureData, TextureFormat, UniformData};
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::transform3d::Transform3DF; use pathfinder_geometry::transform3d::Transform3DF;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_renderer::gpu::options::{DestFramebuffer, RendererOptions}; use pathfinder_renderer::gpu::options::{DestFramebuffer, RendererOptions};
use pathfinder_renderer::gpu::renderer::RenderMode; use pathfinder_renderer::gpu::renderer::RenderMode;
use pathfinder_renderer::gpu_data::RenderCommand; use pathfinder_renderer::gpu_data::RenderCommand;

View File

@ -11,8 +11,8 @@
use crate::camera::Mode; use crate::camera::Mode;
use crate::window::Window; use crate::window::Window;
use crate::{BackgroundColor, Options}; use crate::{BackgroundColor, Options};
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::Device; use pathfinder_gpu::Device;
use pathfinder_renderer::gpu::debug::DebugUIPresenter; use pathfinder_renderer::gpu::debug::DebugUIPresenter;

View File

@ -10,9 +10,9 @@
//! A minimal cross-platform windowing layer. //! A minimal cross-platform windowing layer.
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::transform3d::{Perspective, Transform3DF}; use pathfinder_geometry::transform3d::{Perspective, Transform3DF};
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use rayon::ThreadPoolBuilder; use rayon::ThreadPoolBuilder;
use std::path::PathBuf; use std::path::PathBuf;

View File

@ -20,6 +20,9 @@ crate-type = ["cdylib"]
[features] [features]
mocked = ["glutin"] mocked = ["glutin"]
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_demo] [dependencies.pathfinder_demo]
path = "../common" path = "../common"

View File

@ -10,10 +10,10 @@
use std::error::Error; use std::error::Error;
use std::io; use std::io;
use pathfinder_geometry::basic::point::Point2DI32; use pathfinder_geometry::point::Point2DI32;
use pathfinder_geometry::basic::rect::RectI32; use pathfinder_geometry::rect::RectI32;
use pathfinder_geometry::basic::transform3d::Perspective; use pathfinder_geometry::transform3d::Perspective;
use pathfinder_geometry::basic::transform3d::Transform3DF32; use pathfinder_geometry::transform3d::Transform3DF32;
use pathfinder_gl::GLVersion; use pathfinder_gl::GLVersion;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;

View File

@ -25,10 +25,10 @@ use crate::display::Display;
use crate::display::DisplayCamera; use crate::display::DisplayCamera;
use crate::display::DisplayError; use crate::display::DisplayError;
use pathfinder_geometry::basic::point::Point2DI32; use pathfinder_geometry::point::Point2DI32;
use pathfinder_geometry::basic::rect::RectI32; use pathfinder_geometry::rect::RectI32;
use pathfinder_geometry::basic::transform3d::Transform3DF32; use pathfinder_geometry::transform3d::Transform3DF32;
use pathfinder_geometry::basic::transform3d::Perspective; use pathfinder_geometry::transform3d::Perspective;
use pathfinder_gl::GLVersion; use pathfinder_gl::GLVersion;
use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::FilesystemResourceLoader;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;

View File

@ -15,13 +15,13 @@ use pathfinder_demo::Camera;
use pathfinder_demo::CameraTransform3D; use pathfinder_demo::CameraTransform3D;
use pathfinder_gl::GLDevice; use pathfinder_gl::GLDevice;
use pathfinder_renderer::gpu::renderer::Renderer; use pathfinder_renderer::gpu::renderer::Renderer;
use pathfinder_geometry::basic::point::Point2DI32; use pathfinder_geometry::point::Point2DI32;
use pathfinder_geometry::basic::point::Point2DF32; use pathfinder_geometry::point::Point2DF32;
use pathfinder_geometry::basic::point::Point3DF32; use pathfinder_geometry::point::Point3DF32;
use pathfinder_geometry::basic::rect::RectI32; use pathfinder_geometry::rect::RectI32;
use pathfinder_geometry::basic::transform2d::Transform2DF32; use pathfinder_geometry::transform2d::Transform2DF32;
use pathfinder_geometry::basic::transform3d::Transform3DF32; use pathfinder_geometry::transform3d::Transform3DF32;
use pathfinder_geometry::basic::transform3d::Perspective; use pathfinder_geometry::transform3d::Perspective;
use pathfinder_gpu::Device; use pathfinder_gpu::Device;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
use pathfinder_svg::BuiltSVG; use pathfinder_svg::BuiltSVG;

View File

@ -29,11 +29,11 @@ use pathfinder_demo::BackgroundColor;
use pathfinder_demo::Mode; use pathfinder_demo::Mode;
use pathfinder_demo::window::Event; use pathfinder_demo::window::Event;
use pathfinder_demo::window::SVGPath; use pathfinder_demo::window::SVGPath;
use pathfinder_geometry::basic::vector::Vector2F; use pathfinder_geometry::vector::Vector2F;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::color::ColorF; use pathfinder_content::color::ColorF;
use pathfinder_gl::GLDevice; use pathfinder_gl::GLDevice;
use pathfinder_gl::GLVersion; use pathfinder_gl::GLVersion;
use pathfinder_gpu::ClearParams; use pathfinder_gpu::ClearParams;

View File

@ -48,12 +48,12 @@ use pathfinder_demo::window::OcularTransform;
use pathfinder_demo::window::View; use pathfinder_demo::window::View;
use pathfinder_demo::window::Window; use pathfinder_demo::window::Window;
use pathfinder_demo::window::WindowSize; use pathfinder_demo::window::WindowSize;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::vector::Vector2F; use pathfinder_geometry::vector::Vector2F;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::transform3d::Perspective; use pathfinder_geometry::transform3d::Perspective;
use pathfinder_geometry::basic::transform3d::Transform3DF; use pathfinder_geometry::transform3d::Transform3DF;
use pathfinder_geometry::util; use pathfinder_geometry::util;
use pathfinder_gl::GLVersion; use pathfinder_gl::GLVersion;
use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::FilesystemResourceLoader;

View File

@ -13,8 +13,8 @@
use nfd::Response; use nfd::Response;
use pathfinder_demo::window::{Event, Keycode, SVGPath, View, Window, WindowSize}; use pathfinder_demo::window::{Event, Keycode, SVGPath, View, Window, WindowSize};
use pathfinder_demo::{DemoApp, Options}; use pathfinder_demo::{DemoApp, Options};
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader}; use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader};
use sdl2::event::{Event as SDLEvent, WindowEvent}; use sdl2::event::{Event as SDLEvent, WindowEvent};
use sdl2::keyboard::Keycode as SDLKeycode; use sdl2::keyboard::Keycode as SDLKeycode;

View File

@ -5,7 +5,7 @@ RUST_TARGET_DIR?=../../target
RUST_SRC_DIR?=../../c RUST_SRC_DIR?=../../c
RUSTFLAGS?=-C target-cpu=native RUSTFLAGS?=-C target-cpu=native
CFLAGS?=-Wall -g -I../../c/include CFLAGS?=-Wall -g -I../../c/build/include
LIBS?=-lpathfinder_c LIBS?=-lpathfinder_c
MKDIR?=mkdir -p MKDIR?=mkdir -p
RM?=rm RM?=rm
@ -15,7 +15,7 @@ UNAME=$(shell uname -s)
ifeq ($(UNAME),Darwin) ifeq ($(UNAME),Darwin)
# FIXME(pcwalton): Don't link against HarfBuzz!! # FIXME(pcwalton): Don't link against HarfBuzz!!
LIBS+=-framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework CoreText LIBS+=-framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework CoreText
LIBS+=-lharfbuzz LIBS+=-framework Metal -lharfbuzz
else else
LIBS+=-lGL LIBS+=-lGL
endif endif

View File

@ -11,6 +11,9 @@ glutin = "0.21"
[dependencies.pathfinder_canvas] [dependencies.pathfinder_canvas]
path = "../../canvas" path = "../../canvas"
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../../geometry" path = "../../geometry"

View File

@ -14,9 +14,9 @@ use glutin::dpi::PhysicalSize;
use glutin::{ContextBuilder, ControlFlow, Event, EventsLoop, GlProfile, GlRequest, KeyboardInput}; use glutin::{ContextBuilder, ControlFlow, Event, EventsLoop, GlProfile, GlRequest, KeyboardInput};
use glutin::{VirtualKeyCode, WindowBuilder, WindowEvent}; use glutin::{VirtualKeyCode, WindowBuilder, WindowEvent};
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, Path2D}; use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, Path2D};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_content::color::ColorF;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::color::ColorF; use pathfinder_geometry::rect::RectF;
use pathfinder_gl::{GLDevice, GLVersion}; use pathfinder_gl::{GLDevice, GLVersion};
use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::FilesystemResourceLoader;
use pathfinder_renderer::concurrent::rayon::RayonExecutor; use pathfinder_renderer::concurrent::rayon::RayonExecutor;

View File

@ -15,6 +15,9 @@ sdl2-sys = "0.32"
[dependencies.pathfinder_canvas] [dependencies.pathfinder_canvas]
path = "../../canvas" path = "../../canvas"
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../../geometry" path = "../../geometry"

View File

@ -11,9 +11,9 @@
use foreign_types::ForeignTypeRef; use foreign_types::ForeignTypeRef;
use metal::{CAMetalLayer, CoreAnimationLayerRef}; use metal::{CAMetalLayer, CoreAnimationLayerRef};
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, Path2D}; use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, Path2D};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_content::color::ColorF;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::color::ColorF; use pathfinder_geometry::rect::RectF;
use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::FilesystemResourceLoader;
use pathfinder_metal::MetalDevice; use pathfinder_metal::MetalDevice;
use pathfinder_renderer::concurrent::rayon::RayonExecutor; use pathfinder_renderer::concurrent::rayon::RayonExecutor;

View File

@ -12,6 +12,9 @@ sdl2-sys = "0.32"
[dependencies.pathfinder_canvas] [dependencies.pathfinder_canvas]
path = "../../canvas" path = "../../canvas"
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../../geometry" path = "../../geometry"

View File

@ -9,9 +9,9 @@
// except according to those terms. // except according to those terms.
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, Path2D}; use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, Path2D};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::color::ColorF; use pathfinder_content::color::ColorF;
use pathfinder_gl::{GLDevice, GLVersion}; use pathfinder_gl::{GLDevice, GLVersion};
use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::FilesystemResourceLoader;
use pathfinder_renderer::concurrent::rayon::RayonExecutor; use pathfinder_renderer::concurrent::rayon::RayonExecutor;

View File

@ -12,6 +12,9 @@ sdl2-sys = "0.32"
[dependencies.pathfinder_canvas] [dependencies.pathfinder_canvas]
path = "../../canvas" path = "../../canvas"
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../../geometry" path = "../../geometry"

View File

@ -9,8 +9,8 @@
// except according to those terms. // except according to those terms.
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, FillStyle, Path2D}; use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, FillStyle, Path2D};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::color::{ColorF, ColorU}; use pathfinder_content::color::{ColorF, ColorU};
use pathfinder_gl::{GLDevice, GLVersion}; use pathfinder_gl::{GLDevice, GLVersion};
use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::FilesystemResourceLoader;
use pathfinder_renderer::concurrent::rayon::RayonExecutor; use pathfinder_renderer::concurrent::rayon::RayonExecutor;

View File

@ -13,6 +13,9 @@ sdl2-sys = "0.32"
[dependencies.pathfinder_canvas] [dependencies.pathfinder_canvas]
path = "../../canvas" path = "../../canvas"
[dependencies.pathfinder_content]
path = "../../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../../geometry" path = "../../geometry"

View File

@ -10,8 +10,8 @@
use font_kit::handle::Handle; use font_kit::handle::Handle;
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, TextAlign}; use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, TextAlign};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::color::ColorF; use pathfinder_content::color::ColorF;
use pathfinder_gl::{GLDevice, GLVersion}; use pathfinder_gl::{GLDevice, GLVersion};
use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader}; use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader};
use pathfinder_renderer::concurrent::rayon::RayonExecutor; use pathfinder_renderer::concurrent::rayon::RayonExecutor;

View File

@ -0,0 +1,28 @@
[package]
name = "swf_basic"
version = "0.1.0"
authors = ["Jon Hardie <jon@hardiesoft.com>"]
edition = "2018"
[dependencies]
gl = "0.6"
sdl2 = "0.32"
sdl2-sys = "0.32"
swf-parser = "0.7.0"
swf-tree = "0.7.0"
[dependencies.pathfinder_geometry]
path = "../../geometry"
[dependencies.pathfinder_gl]
path = "../../gl"
[dependencies.pathfinder_gpu]
path = "../../gpu"
[dependencies.pathfinder_renderer]
path = "../../renderer"
[dependencies.pathfinder_swf]
path = "../../swf"

View File

@ -0,0 +1,136 @@
// pathfinder/examples/swf_basic/src/main.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::rect::RectF;
use pathfinder_gl::{GLDevice, GLVersion};
use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader};
use pathfinder_renderer::concurrent::rayon::RayonExecutor;
use pathfinder_renderer::concurrent::scene_proxy::SceneProxy;
use pathfinder_renderer::gpu::renderer::Renderer;
use pathfinder_renderer::gpu::options::{DestFramebuffer, RendererOptions};
use pathfinder_renderer::options::{RenderTransform, BuildOptions};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::video::GLProfile;
use pathfinder_renderer::scene::Scene;
use pathfinder_swf::{draw_paths_into_scene, process_swf_tags};
use std::env;
use std::fs::read;
use pathfinder_geometry::transform2d::Transform2DF;
fn main() {
let resource_loader = FilesystemResourceLoader::locate();
let swf_bytes;
if let Some(path) = env::args().skip(1).next() {
match read(path) {
Ok(bytes) => {
swf_bytes = bytes;
},
Err(e) => panic!(e)
}
} else {
// NOTE(jon): This is a version of the ghostscript tiger graphic flattened to a single
// layer with no overlapping shapes. This is how artwork is 'natively' created in the Flash
// authoring tool when an artist just draws directly onto the canvas (without 'object' mode
// turned on, which is the default).
// Subsequent shapes with different fills will knock out existing fills where they overlap.
// A downside of this in current pathfinder is that cracks are visible between shape fills -
// especially obvious if you set the context clear color to #ff00ff or similar.
// Common speculation as to why the swf format stores vector graphics in this way says that
// it is to save on file-size bytes, however in the case of our tiger, it results in a
// larger file than the layered version, since the overlapping shapes and strokes create
// a lot more geometry. I think a more likely explanation for the choice is that it was
// done to reduce overdraw in the software rasterizer running on late 90's era hardware?
// Indeed, this mode gives pathfinders' occlusion culling pass nothing to do!
// NOTE(jon): This is a version of the same graphic cut and pasted into the Flash authoring
// tool from the SVG version loaded in Illustrator. When layered graphics are pasted
// into Flash, by default they retain their layering, expressed as groups.
// They are still presented as being on a single timeline layer.
// They will be drawn back to front in much the same way as the SVG version.
let default_tiger = resource_loader.slurp("swf/tiger.swf").unwrap();
swf_bytes = Vec::from(&default_tiger[..]);
}
let (_, movie): (_, swf_tree::Movie) = swf_parser::parsers::movie::parse_movie(&swf_bytes[..]).unwrap();
// Set up SDL2.
let sdl_context = sdl2::init().unwrap();
let video = sdl_context.video().unwrap();
// Make sure we have at least a GL 3.0 context. Pathfinder requires this.
let gl_attributes = video.gl_attr();
gl_attributes.set_context_profile(GLProfile::Core);
gl_attributes.set_context_version(3, 3);
// process swf scene
// TODO(jon): Since swf is a streaming format, this really wants to be a lazy iterator over
// swf frames eventually.
let (library, stage) = process_swf_tags(&movie);
// Open a window.
let window_size = Vector2I::new(stage.width(), stage.height());
let window = video.window("Minimal example", window_size.x() as u32, window_size.y() as u32)
.opengl()
.allow_highdpi()
.build()
.unwrap();
let pixel_size = Vector2I::new(
window.drawable_size().0 as i32,
window.drawable_size().1 as i32
);
let device_pixel_ratio = pixel_size.x() as f32 / window_size.x() as f32;
// Create the GL context, and make it current.
let gl_context = window.gl_create_context().unwrap();
gl::load_with(|name| video.gl_get_proc_address(name) as *const _);
window.gl_make_current(&gl_context).unwrap();
// Create a Pathfinder renderer.
let mut renderer = Renderer::new(
GLDevice::new(GLVersion::GL3, 0),
&resource_loader,
DestFramebuffer::full_window(pixel_size),
RendererOptions { background_color: Some(stage.background_color()) }
);
// Clear to swf stage background color.
let mut scene = Scene::new();
scene.set_view_box(RectF::new(
Vector2F::default(),
Vector2F::new(
stage.width() as f32 * device_pixel_ratio,
stage.height() as f32 * device_pixel_ratio)
));
draw_paths_into_scene(&library, &mut scene);
// Render the canvas to screen.
let scene = SceneProxy::from_scene(scene, RayonExecutor);
let mut build_options = BuildOptions::default();
let scale_transform = Transform2DF::from_scale(
Vector2F::new(device_pixel_ratio, device_pixel_ratio)
);
build_options.transform = RenderTransform::Transform2D(scale_transform);
scene.build_and_render(&mut renderer, build_options);
window.gl_swap_window();
// Wait for a keypress.
let mut event_pump = sdl_context.event_pump().unwrap();
loop {
match event_pump.wait_event() {
Event::Quit {..} | Event::KeyDown { keycode: Some(Keycode::Escape), .. } => return,
_ => {}
}
}
}

View File

@ -5,11 +5,6 @@ edition = "2018"
authors = ["Patrick Walton <pcwalton@mimiga.net>"] authors = ["Patrick Walton <pcwalton@mimiga.net>"]
[dependencies] [dependencies]
arrayvec = "0.4"
bitflags = "1.0"
serde = "1.0"
serde_derive = "1.0"
smallvec = "0.6"
[dependencies.log] [dependencies.log]
version = "0.4" version = "0.4"

View File

@ -8,24 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
//! Utilities for Bézier curves. //! Basic geometry and linear algebra primitives, optimized with SIMD.
//!
//! These may be merged into upstream Lyon eventually.
#[macro_use] pub mod line_segment;
extern crate bitflags; pub mod rect;
#[macro_use] pub mod transform2d;
extern crate log; pub mod transform3d;
pub mod unit_vector;
pub mod basic;
pub mod clip;
pub mod color;
pub mod dash;
pub mod orientation;
pub mod outline;
pub mod segment;
pub mod stroke;
pub mod util; pub mod util;
pub mod vector;
mod dilation;
mod unit_vector;

View File

@ -10,8 +10,8 @@
//! Line segment types, optimized with SIMD. //! Line segment types, optimized with SIMD.
use crate::basic::vector::Vector2F; use crate::vector::Vector2F;
use crate::basic::transform2d::Matrix2x2F; use crate::transform2d::Matrix2x2F;
use crate::util; use crate::util;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
use std::ops::{Add, Sub}; use std::ops::{Add, Sub};

View File

@ -10,7 +10,7 @@
//! 2D axis-aligned rectangles, optimized with SIMD. //! 2D axis-aligned rectangles, optimized with SIMD.
use crate::basic::vector::{Vector2F, Vector2I}; use crate::vector::{Vector2F, Vector2I};
use pathfinder_simd::default::{F32x4, I32x4}; use pathfinder_simd::default::{F32x4, I32x4};
#[derive(Clone, Copy, Debug, PartialEq, Default)] #[derive(Clone, Copy, Debug, PartialEq, Default)]

View File

@ -10,11 +10,10 @@
//! 2D affine transforms. //! 2D affine transforms.
use crate::basic::line_segment::LineSegment2F; use crate::line_segment::LineSegment2F;
use crate::basic::vector::Vector2F; use crate::vector::Vector2F;
use crate::basic::rect::RectF; use crate::rect::RectF;
use crate::basic::transform3d::Transform3DF; use crate::transform3d::Transform3DF;
use crate::segment::Segment;
use crate::unit_vector::UnitVector; use crate::unit_vector::UnitVector;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
use std::ops::Sub; use std::ops::Sub;
@ -295,57 +294,3 @@ impl Transform2DF {
Vector2F(self.matrix.0.zwxy()).length() Vector2F(self.matrix.0.zwxy()).length()
} }
} }
/// Transforms a path with a SIMD 2D transform.
pub struct Transform2DFPathIter<I>
where
I: Iterator<Item = Segment>,
{
iter: I,
transform: Transform2DF,
}
impl<I> Iterator for Transform2DFPathIter<I>
where
I: Iterator<Item = Segment>,
{
type Item = Segment;
#[inline]
fn next(&mut self) -> Option<Segment> {
// TODO(pcwalton): Can we go faster by transforming an entire line segment with SIMD?
let mut segment = self.iter.next()?;
if !segment.is_none() {
segment
.baseline
.set_from(&self.transform.transform_point(segment.baseline.from()));
segment
.baseline
.set_to(&self.transform.transform_point(segment.baseline.to()));
if !segment.is_line() {
segment
.ctrl
.set_from(&self.transform.transform_point(segment.ctrl.from()));
if !segment.is_quadratic() {
segment
.ctrl
.set_to(&self.transform.transform_point(segment.ctrl.to()));
}
}
}
Some(segment)
}
}
impl<I> Transform2DFPathIter<I>
where
I: Iterator<Item = Segment>,
{
#[inline]
pub fn new(iter: I, transform: &Transform2DF) -> Transform2DFPathIter<I> {
Transform2DFPathIter {
iter,
transform: *transform,
}
}
}

View File

@ -10,10 +10,9 @@
//! 3D transforms that can be applied to paths. //! 3D transforms that can be applied to paths.
use crate::basic::vector::{Vector2F, Vector2I, Vector4F}; use crate::vector::{Vector2F, Vector2I, Vector4F};
use crate::basic::rect::RectF; use crate::rect::RectF;
use crate::basic::transform2d::Matrix2x2F; use crate::transform2d::Matrix2x2F;
use crate::segment::Segment;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
use std::ops::{Add, Neg}; use std::ops::{Add, Neg};
@ -372,65 +371,10 @@ impl Perspective {
} }
} }
/// Transforms a path with a perspective projection.
pub struct PerspectivePathIter<I>
where
I: Iterator<Item = Segment>,
{
iter: I,
perspective: Perspective,
}
impl<I> Iterator for PerspectivePathIter<I>
where
I: Iterator<Item = Segment>,
{
type Item = Segment;
#[inline]
fn next(&mut self) -> Option<Segment> {
let mut segment = self.iter.next()?;
if !segment.is_none() {
segment.baseline.set_from(
&self
.perspective
.transform_point_2d(&segment.baseline.from()),
);
segment
.baseline
.set_to(&self.perspective.transform_point_2d(&segment.baseline.to()));
if !segment.is_line() {
segment
.ctrl
.set_from(&self.perspective.transform_point_2d(&segment.ctrl.from()));
if !segment.is_quadratic() {
segment
.ctrl
.set_to(&self.perspective.transform_point_2d(&segment.ctrl.to()));
}
}
}
Some(segment)
}
}
impl<I> PerspectivePathIter<I>
where
I: Iterator<Item = Segment>,
{
#[inline]
pub fn new(iter: I, perspective: &Perspective) -> PerspectivePathIter<I> {
PerspectivePathIter {
iter,
perspective: *perspective,
}
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::basic::vector::Vector4F; use crate::vector::Vector4F;
use crate::basic::transform3d::Transform3DF; use crate::transform3d::Transform3DF;
#[test] #[test]
fn test_post_mul() { fn test_post_mul() {

View File

@ -10,7 +10,7 @@
//! A utility module that allows unit vectors to be treated like angles. //! A utility module that allows unit vectors to be treated like angles.
use crate::basic::vector::Vector2F; use crate::vector::Vector2F;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]

View File

@ -14,8 +14,8 @@
extern crate log; extern crate log;
use gl::types::{GLboolean, GLchar, GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint, GLvoid}; use gl::types::{GLboolean, GLchar, GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint, GLvoid};
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::{RenderTarget, BlendState, BufferData, BufferTarget, BufferUploadMode}; use pathfinder_gpu::{RenderTarget, BlendState, BufferData, BufferTarget, BufferUploadMode};
use pathfinder_gpu::{ClearOps, DepthFunc, Device, Primitive, RenderOptions, RenderState}; use pathfinder_gpu::{ClearOps, DepthFunc, Device, Primitive, RenderOptions, RenderState};

View File

@ -11,6 +11,9 @@ version = "0.21"
default-features = false default-features = false
features = ["png_codec"] features = ["png_codec"]
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"

View File

@ -12,10 +12,10 @@
use crate::resources::ResourceLoader; use crate::resources::ResourceLoader;
use image::ImageFormat; use image::ImageFormat;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_content::color::ColorF;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::transform3d::Transform3DF; use pathfinder_geometry::transform3d::Transform3DF;
use pathfinder_geometry::color::ColorF; use pathfinder_geometry::vector::Vector2I;
use pathfinder_simd::default::F32x4; use pathfinder_simd::default::F32x4;
use std::time::Duration; use std::time::Duration;

View File

@ -40,8 +40,8 @@ use metal::{SamplerDescriptor, SamplerState, StencilDescriptor, StructMemberRef,
use metal::{StructTypeRef, TextureDescriptor, Texture, TextureRef, VertexAttribute}; use metal::{StructTypeRef, TextureDescriptor, Texture, TextureRef, VertexAttribute};
use metal::{VertexAttributeRef, VertexDescriptor, VertexDescriptorRef}; use metal::{VertexAttributeRef, VertexDescriptor, VertexDescriptorRef};
use objc::runtime::{Class, Object}; use objc::runtime::{Class, Object};
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::{BlendState, BufferData, BufferTarget, BufferUploadMode, DepthFunc, Device}; use pathfinder_gpu::{BlendState, BufferData, BufferTarget, BufferUploadMode, DepthFunc, Device};
use pathfinder_gpu::{Primitive, RenderState, RenderTarget, ShaderKind, StencilFunc, TextureData}; use pathfinder_gpu::{Primitive, RenderState, RenderTarget, ShaderKind, StencilFunc, TextureData};
@ -1356,6 +1356,7 @@ impl FunctionExt for Function {
let encoder: *mut MTLArgumentEncoder = let encoder: *mut MTLArgumentEncoder =
msg_send![self.as_ptr(), newArgumentEncoderWithBufferIndex:buffer_index msg_send![self.as_ptr(), newArgumentEncoderWithBufferIndex:buffer_index
reflection:&mut reflection]; reflection:&mut reflection];
msg_send![reflection, retain];
(ArgumentEncoder::from_ptr(encoder), Argument::from_ptr(reflection)) (ArgumentEncoder::from_ptr(encoder), Argument::from_ptr(reflection))
} }
} }

View File

@ -18,6 +18,9 @@ smallvec = "0.6"
version = "0.4" version = "0.4"
features = ["release_max_level_warn"] features = ["release_max_level_warn"]
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"

View File

@ -17,9 +17,9 @@ use crate::scene::Scene;
use crate::tile_map::DenseTileMap; use crate::tile_map::DenseTileMap;
use crate::tiles::{self, TILE_HEIGHT, TILE_WIDTH, Tiler}; use crate::tiles::{self, TILE_HEIGHT, TILE_WIDTH, Tiler};
use crate::z_buffer::ZBuffer; use crate::z_buffer::ZBuffer;
use pathfinder_geometry::basic::line_segment::{LineSegment2F, LineSegmentU4, LineSegmentU8}; use pathfinder_geometry::line_segment::{LineSegment2F, LineSegmentU4, LineSegmentU8};
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::basic::rect::{RectF, RectI}; use pathfinder_geometry::rect::{RectF, RectI};
use pathfinder_geometry::util; use pathfinder_geometry::util;
use pathfinder_simd::default::{F32x4, I32x4}; use pathfinder_simd::default::{F32x4, I32x4};
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -24,7 +24,7 @@ use crate::gpu::renderer::Renderer;
use crate::gpu_data::RenderCommand; use crate::gpu_data::RenderCommand;
use crate::options::{BuildOptions, RenderCommandListener}; use crate::options::{BuildOptions, RenderCommandListener};
use crate::scene::Scene; use crate::scene::Scene;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_gpu::Device; use pathfinder_gpu::Device;
use std::sync::mpsc::{self, Receiver, Sender}; use std::sync::mpsc::{self, Receiver, Sender};
use std::thread; use std::thread;

View File

@ -16,8 +16,8 @@
//! The debug font atlas was generated using: https://evanw.github.io/font-texture-generator/ //! The debug font atlas was generated using: https://evanw.github.io/font-texture-generator/
use crate::gpu::renderer::{RenderStats, RenderTime}; use crate::gpu::renderer::{RenderStats, RenderTime};
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::Device; use pathfinder_gpu::Device;
use pathfinder_ui::{FONT_ASCENT, LINE_HEIGHT, PADDING, UIPresenter, WINDOW_COLOR}; use pathfinder_ui::{FONT_ASCENT, LINE_HEIGHT, PADDING, UIPresenter, WINDOW_COLOR};

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::color::ColorF; use pathfinder_content::color::ColorF;
use pathfinder_gpu::Device; use pathfinder_gpu::Device;
/// Options that influence rendering. /// Options that influence rendering.

View File

@ -14,10 +14,10 @@ use crate::gpu_data::{AlphaTileBatchPrimitive, FillBatchPrimitive, PaintData};
use crate::gpu_data::{RenderCommand, SolidTileBatchPrimitive}; use crate::gpu_data::{RenderCommand, SolidTileBatchPrimitive};
use crate::post::DefringingKernel; use crate::post::DefringingKernel;
use crate::tiles::{TILE_HEIGHT, TILE_WIDTH}; use crate::tiles::{TILE_HEIGHT, TILE_WIDTH};
use pathfinder_geometry::basic::vector::{Vector2I, Vector4F}; use pathfinder_geometry::vector::{Vector2I, Vector4F};
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::basic::transform3d::Transform3DF; use pathfinder_geometry::transform3d::Transform3DF;
use pathfinder_geometry::color::ColorF; use pathfinder_content::color::ColorF;
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::{BlendState, BufferData, BufferTarget, BufferUploadMode, ClearOps}; use pathfinder_gpu::{BlendState, BufferData, BufferTarget, BufferUploadMode, ClearOps};
use pathfinder_gpu::{DepthFunc, DepthState, Device, Primitive, RenderOptions, RenderState}; use pathfinder_gpu::{DepthFunc, DepthState, Device, Primitive, RenderOptions, RenderState};
@ -654,7 +654,7 @@ where
} }
} }
self.device.draw_arrays(4, &RenderState { self.device.draw_elements(6, &RenderState {
target: &self.dest_render_target(), target: &self.dest_render_target(),
program: &self.postprocess_program.program, program: &self.postprocess_program.program,
vertex_array: &self.postprocess_vertex_array.vertex_array, vertex_array: &self.postprocess_vertex_array.vertex_array,
@ -1451,7 +1451,7 @@ where
device.configure_vertex_attr(&vertex_array, &position_attr, &VertexAttrDescriptor { device.configure_vertex_attr(&vertex_array, &position_attr, &VertexAttrDescriptor {
size: 2, size: 2,
class: VertexAttrClass::Int, class: VertexAttrClass::Int,
attr_type: VertexAttrType::U16, attr_type: VertexAttrType::I16,
stride: 4, stride: 4,
offset: 0, offset: 0,
divisor: 0, divisor: 0,

View File

@ -12,9 +12,9 @@
use crate::options::BoundingQuad; use crate::options::BoundingQuad;
use crate::tile_map::DenseTileMap; use crate::tile_map::DenseTileMap;
use pathfinder_geometry::basic::line_segment::{LineSegmentU4, LineSegmentU8}; use pathfinder_geometry::line_segment::{LineSegmentU4, LineSegmentU8};
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use std::fmt::{Debug, Formatter, Result as DebugResult}; use std::fmt::{Debug, Formatter, Result as DebugResult};
use std::time::Duration; use std::time::Duration;

View File

@ -11,11 +11,11 @@
//! Options that control how rendering is to be performed. //! Options that control how rendering is to be performed.
use crate::gpu_data::RenderCommand; use crate::gpu_data::RenderCommand;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::basic::transform3d::Perspective; use pathfinder_geometry::transform3d::Perspective;
use pathfinder_geometry::basic::vector::{Vector2F, Vector4F}; use pathfinder_geometry::vector::{Vector2F, Vector4F};
use pathfinder_geometry::clip::PolygonClipper3D; use pathfinder_content::clip::PolygonClipper3D;
pub trait RenderCommandListener: Send + Sync { pub trait RenderCommandListener: Send + Sync {
fn send(&self, command: RenderCommand); fn send(&self, command: RenderCommand);

View File

@ -10,8 +10,8 @@
use crate::gpu_data::PaintData; use crate::gpu_data::PaintData;
use crate::scene::Scene; use crate::scene::Scene;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::color::ColorU; use pathfinder_content::color::ColorU;
const PAINT_TEXTURE_WIDTH: i32 = 256; const PAINT_TEXTURE_WIDTH: i32 = 256;
const PAINT_TEXTURE_HEIGHT: i32 = 256; const PAINT_TEXTURE_HEIGHT: i32 = 256;

View File

@ -16,11 +16,11 @@ use crate::options::{BuildOptions, PreparedBuildOptions};
use crate::options::{PreparedRenderTransform, RenderCommandListener}; use crate::options::{PreparedRenderTransform, RenderCommandListener};
use crate::paint::{Paint, PaintId}; use crate::paint::{Paint, PaintId};
use hashbrown::HashMap; use hashbrown::HashMap;
use pathfinder_geometry::basic::vector::Vector2F; use pathfinder_geometry::vector::Vector2F;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::color::ColorU; use pathfinder_content::color::ColorU;
use pathfinder_geometry::outline::Outline; use pathfinder_content::outline::Outline;
use std::io::{self, Write}; use std::io::{self, Write};
#[derive(Clone)] #[derive(Clone)]

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
#[derive(Debug)] #[derive(Debug)]
pub struct DenseTileMap<T> { pub struct DenseTileMap<T> {

View File

@ -12,11 +12,11 @@ use crate::builder::SceneBuilder;
use crate::gpu_data::{AlphaTileBatchPrimitive, BuiltObject, TileObjectPrimitive}; use crate::gpu_data::{AlphaTileBatchPrimitive, BuiltObject, TileObjectPrimitive};
use crate::paint::{self, PaintId}; use crate::paint::{self, PaintId};
use crate::sorted_vector::SortedVector; use crate::sorted_vector::SortedVector;
use pathfinder_geometry::basic::line_segment::LineSegment2F; use pathfinder_geometry::line_segment::LineSegment2F;
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_geometry::basic::rect::{RectF, RectI}; use pathfinder_geometry::rect::{RectF, RectI};
use pathfinder_geometry::outline::{Contour, Outline, PointIndex}; use pathfinder_content::outline::{Contour, Outline, PointIndex};
use pathfinder_geometry::segment::Segment; use pathfinder_content::segment::Segment;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::mem; use std::mem;

View File

@ -15,8 +15,8 @@ use crate::paint;
use crate::scene::PathObject; use crate::scene::PathObject;
use crate::tile_map::DenseTileMap; use crate::tile_map::DenseTileMap;
use crate::tiles; use crate::tiles;
use pathfinder_geometry::basic::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_geometry::rect::RectF;
use std::ops::Range; use std::ops::Range;
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};

View File

@ -19,7 +19,13 @@ in ivec2 aPosition;
out vec2 vTexCoord; out vec2 vTexCoord;
void main(){ void main(){
vTexCoord = vec2(aPosition); vec2 position = vec2(aPosition);
gl_Position = vec4(vec2(aPosition)* 2.0 - 1.0, 0.0, 1.0); vTexCoord = position;
gl_Position = vec4(vec2(position)* 2.0 - 1.0, 0.0, 1.0);
} }

View File

@ -27,6 +27,7 @@ void main(){
gl_Position = uNewTransform * vec4(position, 0.0, 1.0); gl_Position = uNewTransform * vec4(position, 0.0, 1.0);
} }

View File

@ -6,9 +6,9 @@ using namespace metal;
struct spvDescriptorSetBuffer0 struct spvDescriptorSetBuffer0
{ {
constant float4* uColor [[id(0)]]; texture2d<float> uTexture [[id(0)]];
texture2d<float> uTexture [[id(1)]]; sampler uTextureSmplr [[id(1)]];
sampler uTextureSmplr [[id(2)]]; constant float4* uColor [[id(2)]];
}; };
struct main0_out struct main0_out

View File

@ -8,12 +8,12 @@ using namespace metal;
struct spvDescriptorSetBuffer0 struct spvDescriptorSetBuffer0
{ {
constant float4* uKernel [[id(0)]]; texture2d<float> uGammaLUT [[id(0)]];
texture2d<float> uGammaLUT [[id(1)]]; sampler uGammaLUTSmplr [[id(1)]];
texture2d<float> uSource [[id(2)]]; constant float4* uKernel [[id(2)]];
constant float2* uSourceSize [[id(3)]]; texture2d<float> uSource [[id(3)]];
sampler uSourceSmplr [[id(4)]]; sampler uSourceSmplr [[id(4)]];
sampler uGammaLUTSmplr [[id(5)]]; constant float2* uSourceSize [[id(5)]];
constant int* uGammaCorrectionEnabled [[id(6)]]; constant int* uGammaCorrectionEnabled [[id(6)]];
constant float4* uBGColor [[id(7)]]; constant float4* uBGColor [[id(7)]];
constant float4* uFGColor [[id(8)]]; constant float4* uFGColor [[id(8)]];

View File

@ -18,8 +18,10 @@ struct main0_in
vertex main0_out main0(main0_in in [[stage_in]]) vertex main0_out main0(main0_in in [[stage_in]])
{ {
main0_out out = {}; main0_out out = {};
out.vTexCoord = float2(in.aPosition); float2 position = float2(in.aPosition);
out.gl_Position = float4((float2(in.aPosition) * 2.0) - float2(1.0), 0.0, 1.0); out.vTexCoord = position;
position.y = 1.0 - position.y;
out.gl_Position = float4((float2(position) * 2.0) - float2(1.0), 0.0, 1.0);
return out; return out;
} }

View File

@ -9,11 +9,11 @@ using namespace metal;
struct spvDescriptorSetBuffer0 struct spvDescriptorSetBuffer0
{ {
constant float2* uTileSize [[id(0)]]; constant float2* uTileSize [[id(0)]];
texture2d<float> uPaintTexture [[id(1)]]; constant float2* uViewBoxOrigin [[id(1)]];
constant float2* uViewBoxOrigin [[id(2)]]; constant float2* uFramebufferSize [[id(2)]];
sampler uPaintTextureSmplr [[id(3)]]; constant float2* uStencilTextureSize [[id(3)]];
constant float2* uFramebufferSize [[id(4)]]; texture2d<float> uPaintTexture [[id(4)]];
constant float2* uStencilTextureSize [[id(5)]]; sampler uPaintTextureSmplr [[id(5)]];
}; };
struct main0_out struct main0_out

View File

@ -9,10 +9,10 @@ using namespace metal;
struct spvDescriptorSetBuffer0 struct spvDescriptorSetBuffer0
{ {
constant float2* uTileSize [[id(0)]]; constant float2* uTileSize [[id(0)]];
texture2d<float> uPaintTexture [[id(1)]]; constant float2* uViewBoxOrigin [[id(1)]];
constant float2* uViewBoxOrigin [[id(2)]]; constant float2* uFramebufferSize [[id(2)]];
sampler uPaintTextureSmplr [[id(3)]]; texture2d<float> uPaintTexture [[id(3)]];
constant float2* uFramebufferSize [[id(4)]]; sampler uPaintTextureSmplr [[id(4)]];
}; };
struct main0_out struct main0_out

Binary file not shown.

BIN
resources/swf/tiger.swf Normal file

Binary file not shown.

View File

@ -17,6 +17,12 @@ in ivec2 aPosition;
out vec2 vTexCoord; out vec2 vTexCoord;
void main() { void main() {
vTexCoord = vec2(aPosition); vec2 position = vec2(aPosition);
gl_Position = vec4(vec2(aPosition) * 2.0 - 1.0, 0.0, 1.0); vTexCoord = position;
#ifdef PF_ORIGIN_UPPER_LEFT
// FIXME(pcwalton): This is wrong.
position.y = 1.0 - position.y;
#endif
gl_Position = vec4(vec2(position) * 2.0 - 1.0, 0.0, 1.0);
} }

View File

@ -8,6 +8,9 @@ authors = ["Patrick Walton <pcwalton@mimiga.net>"]
bitflags = "1.0" bitflags = "1.0"
usvg = "0.7" usvg = "0.7"
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"

View File

@ -13,14 +13,15 @@
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
use pathfinder_geometry::basic::line_segment::LineSegment2F; use pathfinder_content::color::ColorU;
use pathfinder_geometry::basic::vector::Vector2F; use pathfinder_content::outline::Outline;
use pathfinder_geometry::basic::rect::RectF; use pathfinder_content::segment::{Segment, SegmentFlags};
use pathfinder_geometry::basic::transform2d::{Transform2DF, Transform2DFPathIter}; use pathfinder_content::stroke::{LineCap, LineJoin, OutlineStrokeToFill, StrokeStyle};
use pathfinder_geometry::color::ColorU; use pathfinder_content::transform::Transform2DFPathIter;
use pathfinder_geometry::outline::Outline; use pathfinder_geometry::line_segment::LineSegment2F;
use pathfinder_geometry::segment::{Segment, SegmentFlags}; use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::stroke::{LineCap, LineJoin, OutlineStrokeToFill, StrokeStyle}; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::vector::Vector2F;
use pathfinder_renderer::paint::Paint; use pathfinder_renderer::paint::Paint;
use pathfinder_renderer::scene::{PathObject, Scene}; use pathfinder_renderer::scene::{PathObject, Scene};
use std::fmt::{Display, Formatter, Result as FormatResult}; use std::fmt::{Display, Formatter, Result as FormatResult};

24
swf/Cargo.toml Normal file
View File

@ -0,0 +1,24 @@
[package]
name = "pathfinder_swf"
version = "0.1.0"
authors = ["Jon Hardie <jon@hardiesoft.com>"]
edition = "2018"
[dependencies]
swf-parser = "0.7.0"
swf-tree = "0.7.0"
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry]
path = "../geometry"
[dependencies.pathfinder_renderer]
path = "../renderer"
[dependencies.pathfinder_gl]
path = "../gl"
[dependencies.pathfinder_gpu]
path = "../gpu"

206
swf/src/lib.rs Normal file
View File

@ -0,0 +1,206 @@
// pathfinder/swf/src/lib.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::ops::Add;
use pathfinder_content::color::{ColorU, ColorF};
use pathfinder_content::outline::{Outline, Contour};
use pathfinder_geometry::vector::Vector2F;
use pathfinder_content::stroke::{OutlineStrokeToFill, StrokeStyle};
use pathfinder_renderer::scene::{PathObject, Scene};
use swf_tree;
use swf_tree::tags::SetBackgroundColor;
use swf_tree::{Tag, SRgb8, Movie};
use crate::shapes::{GraphicLayers, PaintOrLine};
mod shapes;
type SymbolId = u16;
// In swf, most values are specified in a fixed point format known as "twips" or twentieths of
// a pixel. We store twips in their integer form, as if we were to convert them to floating point
// at the beginning of the pipeline it's easy to start running into precision errors when we add
// coordinate deltas and then try and compare coords for equality.
#[derive(Copy, Clone, Debug, PartialEq)]
struct Twips(i32);
impl Twips {
// Divide twips by 20 to get the f32 value, just to be used once all processing
// of the swf coords is completed and we want to output.
fn as_f32(&self) -> f32 {
self.0 as f32 / 20.0
}
}
impl Add for Twips {
type Output = Twips;
fn add(self, rhs: Twips) -> Self {
Twips(self.0 + rhs.0)
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
struct Point2<T> {
x: T,
y: T
}
impl Point2<Twips> {
fn as_f32(self: Point2<Twips>) -> Point2<f32> {
Point2 {
x: self.x.as_f32(),
y: self.y.as_f32(),
}
}
}
impl Add for Point2<Twips> {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Point2 { x: self.x + rhs.x, y: self.y + rhs.y }
}
}
enum Symbol {
Graphic(GraphicLayers),
// Timeline, // TODO(jon)
}
pub struct Stage {
// TODO(jon): Support some kind of lazy frames iterator.
// frames: Timeline,
background_color: SRgb8,
width: i32,
height: i32,
}
impl Stage {
pub fn width(&self) -> i32 {
self.width
}
pub fn height(&self) -> i32 {
self.height
}
pub fn background_color(&self) -> ColorF {
ColorU {
r: self.background_color.r,
g: self.background_color.g,
b: self.background_color.b,
a: 255,
}.to_f32()
}
}
pub struct SymbolLibrary(Vec<Symbol>);
impl SymbolLibrary {
fn add_symbol(&mut self, symbol: Symbol) {
self.0.push(symbol);
}
fn symbols(&self) -> &Vec<Symbol> {
&self.0
}
}
pub fn process_swf_tags(movie: &Movie) -> (SymbolLibrary, Stage) {
let mut symbol_library = SymbolLibrary(Vec::new());
let stage_width = Twips(movie.header.frame_size.x_max);
let stage_height = Twips(movie.header.frame_size.y_max);
// let num_frames = movie.header.frame_count;
let mut stage = Stage {
// frames: Timeline(Vec::new()), // TODO(jon)
background_color: SRgb8 {
r: 255,
g: 255,
b: 255
},
width: stage_width.as_f32() as i32,
height: stage_height.as_f32() as i32,
};
for tag in &movie.tags {
match tag {
Tag::SetBackgroundColor(SetBackgroundColor { color }) => {
stage.background_color = *color;
},
Tag::DefineShape(shape) => {
symbol_library.add_symbol(Symbol::Graphic(shapes::decode_shape(&shape)));
// We will assume that symbol ids just go up, and are 1 based.
let symbol_id: SymbolId = shape.id;
debug_assert!(symbol_id as usize == symbol_library.0.len());
}
_ => ()
}
}
(symbol_library, stage)
}
#[allow(irrefutable_let_patterns)]
pub fn draw_paths_into_scene(library: &SymbolLibrary, scene: &mut Scene) {
for symbol in library.symbols() {
// NOTE: Right now symbols only contain graphics.
if let Symbol::Graphic(graphic) = symbol {
for style_layer in graphic.layers() {
let mut path = Outline::new();
let paint_id = scene.push_paint(&style_layer.fill());
for shape in style_layer.shapes() {
let mut contour = Contour::new();
let Point2 { x, y } = shape.outline.first().unwrap().from.as_f32();
contour.push_endpoint(Vector2F::new(x, y));
for segment in &shape.outline {
let Point2 { x, y } = segment.to.as_f32();
match segment.ctrl {
Some(ctrl) => {
let Point2 { x: ctrl_x, y: ctrl_y } = ctrl.as_f32();
contour.push_quadratic(
Vector2F::new(ctrl_x, ctrl_y),
Vector2F::new(x, y)
);
}
None => {
contour.push_endpoint(Vector2F::new(x, y));
},
}
}
if shape.is_closed() {
// NOTE: I'm not sure if this really does anything in this context,
// since all our closed shapes already have coincident start and end points.
contour.close();
}
path.push_contour(contour);
}
if let PaintOrLine::Line(line) = style_layer.kind() {
let mut stroke_to_fill = OutlineStrokeToFill::new(&path, StrokeStyle {
line_width: line.width.as_f32(),
line_cap: line.cap,
line_join: line.join,
});
stroke_to_fill.offset();
path = stroke_to_fill.into_outline();
}
scene.push_path(PathObject::new(
path,
paint_id,
String::new()
));
}
}
}
}

625
swf/src/shapes.rs Normal file
View File

@ -0,0 +1,625 @@
// pathfinder/swf/src/shapes.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use pathfinder_renderer::paint::Paint;
use pathfinder_content::stroke::{LineJoin, LineCap};
use crate::{Twips, Point2};
use std::mem;
use std::cmp::Ordering;
use swf_tree::{
FillStyle,
StraightSRgba8,
LineStyle,
fill_styles,
JoinStyle,
CapStyle,
join_styles,
ShapeRecord,
shape_records,
Vector2D
};
use pathfinder_content::color::ColorU;
use swf_tree::tags::DefineShape;
#[derive(Clone, Copy, Debug)]
pub(crate) struct LineSegment {
pub(crate) from: Point2<Twips>,
pub(crate) to: Point2<Twips>,
pub(crate) ctrl: Option<Point2<Twips>>,
}
impl LineSegment {
fn reverse(&mut self) {
let tmp = self.from;
self.from = self.to;
self.to = tmp;
}
}
#[derive(Copy, Clone, PartialEq, Debug)]
pub(crate) enum LineDirection {
Left,
Right,
}
impl LineDirection {
fn reverse(&mut self) {
*self = match self {
LineDirection::Right => LineDirection::Left,
LineDirection::Left => LineDirection::Right
};
}
}
#[derive(Clone, Debug)]
pub(crate) struct Shape {
pub(crate) outline: Vec<LineSegment>, // Could be Vec<(start, end)>
direction: LineDirection,
reversed: bool,
}
impl Shape {
pub fn new_with_direction(direction: LineDirection) -> Shape {
Shape {
direction,
outline: Vec::new(),
reversed: false,
}
}
fn prepend_shape(&mut self, shape: &mut Shape) {
shape.append_shape(&self);
mem::swap(&mut self.outline, &mut shape.outline);
}
fn append_shape(&mut self, shape: &Shape) {
self.outline.extend_from_slice(&shape.outline);
}
fn add_line_segment(&mut self, segment: LineSegment) {
self.outline.push(segment);
}
#[inline]
fn len(&self) -> usize {
self.outline.len()
}
#[inline]
fn first(&self) -> &LineSegment {
&self.outline.first().unwrap()
}
#[inline]
fn last(&self) -> &LineSegment {
&self.outline.last().unwrap()
}
#[inline]
fn comes_before(&self, other: &Shape) -> bool {
self.last().to == other.first().from
}
#[inline]
fn comes_after(&self, other: &Shape) -> bool {
self.first().from == other.last().to
}
#[inline]
pub(crate) fn is_closed(&self) -> bool {
self.len() > 1 && self.comes_after(self)
}
fn reverse(&mut self) {
self.reversed = !self.reversed;
self.direction.reverse();
for segment in &mut self.outline {
segment.reverse();
}
self.outline.reverse();
}
}
pub(crate) struct SwfLineStyle {
color: Paint,
pub(crate) width: Twips,
pub(crate) join: LineJoin,
pub(crate) cap: LineCap,
}
pub(crate) enum PaintOrLine {
Paint(Paint),
Line(SwfLineStyle),
}
pub(crate) struct StyleLayer {
fill: PaintOrLine,
// TODO(jon): Maybe shapes are actually slices into a single buffer, then we don't
// need to realloc anything, we're just shuffling shapes around?
shapes: Vec<Shape>,
}
impl StyleLayer {
pub(crate) fn kind(&self) -> &PaintOrLine {
&self.fill
}
fn is_fill(&self) -> bool {
match &self.fill {
PaintOrLine::Paint(_) => true,
PaintOrLine::Line(_) => false,
}
}
pub(crate) fn fill(&self) -> Paint {
match &self.fill {
PaintOrLine::Paint(paint) => *paint,
PaintOrLine::Line(line) => line.color,
}
}
fn push_new_shape(&mut self, direction: LineDirection) {
if let Some(prev_shape) = self.shapes.last_mut() {
// Check that the previous shape was actually used, otherwise reuse it.
if prev_shape.len() != 0 {
self.shapes.push(Shape::new_with_direction(direction))
} else {
prev_shape.direction = direction;
}
} else {
self.shapes.push(Shape::new_with_direction(direction))
}
}
pub(crate) fn shapes(&self) -> &Vec<Shape> {
&self.shapes
}
fn shapes_mut(&mut self) -> &mut Vec<Shape> {
&mut self.shapes
}
fn current_shape_mut(&mut self) -> &mut Shape {
self.shapes.last_mut().unwrap()
}
fn consolidate_edges(&mut self) {
// Reverse left fill shape fragments in place.
{
self.shapes
.iter_mut()
.filter(|frag| frag.direction == LineDirection::Left)
.for_each(|frag| frag.reverse());
}
// Sort shapes into [closed...open]
if self.is_fill() {
// I think sorting is only necessary when we want to have closed shapes,
// lines don't really need this?
self.shapes.sort_unstable_by(|a, b| {
match (a.is_closed(), b.is_closed()) {
(true, true) | (false, false) => Ordering::Equal,
(true, false) => Ordering::Less,
(false, true) => Ordering::Greater,
}
});
}
// A cursor at the index of the first unclosed shape, if any.
let first_open_index = self.shapes
.iter()
.position(|frag| !frag.is_closed());
if let Some(first_open_index) = first_open_index {
if self.shapes.len() - first_open_index >= 2 {
// TODO(jon): This might be sped up by doing it in a way that we don't have
// to allocate more vecs?
// Also, maybe avoid path reversal, and just flag the path as reversed and iterate it
// backwards.
let unmatched_pieces = find_matches(first_open_index, &mut self.shapes, false);
if let Some(mut unmatched_pieces) = unmatched_pieces {
if self.is_fill() {
// If they didn't match before, they're probably parts of inner shapes
// and should be reversed again so they have correct winding
let unclosed = find_matches(0, &mut unmatched_pieces, true);
// If it's a shape we should always be able to close it.
debug_assert!(unclosed.is_none());
}
for dropped in &mut unmatched_pieces {
dropped.reverse();
}
self.shapes.extend_from_slice(&unmatched_pieces);
}
// FIXME(jon): Sometimes we don't get the correct winding of internal closed shapes,
// need to figure out why this happens.
}
}
}
}
fn get_new_styles<'a>(
fills: &'a Vec<FillStyle>,
lines: &'a Vec<LineStyle>
) -> impl Iterator<Item=PaintOrLine> + 'a {
// This enforces the order that fills and line groupings are added in.
// Fills always come first.
fills.iter().filter_map(|fill_style| {
match fill_style {
FillStyle::Solid(
fill_styles::Solid {
color: StraightSRgba8 {
r,
g,
b,
a
}
}
) => {
Some(PaintOrLine::Paint(Paint {
color: ColorU {
r: *r,
g: *g,
b: *b,
a: *a
}
}))
},
_ => unimplemented!("Unimplemented fill style")
}
}).chain(
lines.iter().filter_map(|LineStyle {
width,
fill,
join,
start_cap,
end_cap: _,
/*
TODO(jon): Handle these cases?
pub no_h_scale: bool,
pub no_v_scale: bool,
pub no_close: bool,
pub pixel_hinting: bool,
*/
..
}| {
if let FillStyle::Solid(fill_styles::Solid {
color: StraightSRgba8 {
r,
g,
b,
a
}
}) = fill {
// NOTE: PathFinder doesn't support different cap styles for start and end of
// strokes, so lets assume that they're always the same for the inputs we care about.
// Alternately, we split a line in two with a diff cap style for each.
// assert_eq!(start_cap, end_cap);
Some(PaintOrLine::Line(SwfLineStyle {
width: Twips(*width as i32),
color: Paint { color: ColorU { r: *r, g: *g, b: *b, a: *a } },
join: match join {
JoinStyle::Bevel => LineJoin::Bevel,
JoinStyle::Round => LineJoin::Round,
JoinStyle::Miter(join_styles::Miter { limit }) => {
LineJoin::Miter(*limit as f32)
},
},
cap: match start_cap {
CapStyle::None => LineCap::Butt,
CapStyle::Square => LineCap::Square,
CapStyle::Round => LineCap::Round,
},
}))
} else {
unimplemented!("unimplemented line fill style");
}
})
)
}
pub(crate) fn decode_shape(shape: &DefineShape) -> GraphicLayers {
let DefineShape {
shape,
// id,
// has_fill_winding, NOTE(jon): Could be important for some inputs?
// has_non_scaling_strokes,
// has_scaling_strokes,
..
} = shape;
let mut graphic = GraphicLayers::new();
let mut current_line_style = None;
let mut current_left_fill = None;
let mut current_right_fill = None;
let mut prev_pos = None;
let mut some_fill_set = false;
let mut both_fills_set;
let mut both_fills_same = false;
let mut both_fills_set_and_same = false;
// Create style groups for initially specified fills and lines.
for fills_or_line in get_new_styles(&shape.initial_styles.fill, &shape.initial_styles.line) {
match fills_or_line {
PaintOrLine::Paint(fill) => graphic.begin_fill_style(fill),
PaintOrLine::Line(line) => graphic.begin_line_style(line),
}
}
for record in &shape.records {
match record {
ShapeRecord::StyleChange(
shape_records::StyleChange {
move_to,
new_styles,
line_style,
left_fill,
right_fill,
}
) => {
// Start a whole new style grouping.
if let Some(new_style) = new_styles {
// Consolidate current style grouping and begin a new one.
graphic.end_style_group();
graphic.begin_style_group();
for fills_or_line in get_new_styles(&new_style.fill, &new_style.line) {
match fills_or_line {
PaintOrLine::Paint(fill) => graphic.begin_fill_style(fill),
PaintOrLine::Line(line) => graphic.begin_line_style(line),
}
}
}
// If there's a change in right fill
if let Some(fill_id) = right_fill {
if *fill_id == 0 {
current_right_fill = None;
} else {
current_right_fill = Some(*fill_id);
graphic
.with_fill_style_mut(*fill_id)
.unwrap()
.push_new_shape(LineDirection::Right);
}
}
// If there's a change in left fill
if let Some(fill_id) = left_fill {
if *fill_id == 0 {
current_left_fill = None;
} else {
current_left_fill = Some(*fill_id);
graphic
.with_fill_style_mut(*fill_id)
.unwrap()
.push_new_shape(LineDirection::Left);
}
}
some_fill_set = current_left_fill.is_some() || current_right_fill.is_some();
both_fills_set = current_left_fill.is_some() && current_right_fill.is_some();
both_fills_same = current_left_fill == current_right_fill;
both_fills_set_and_same = both_fills_set && both_fills_same;
// If there's a change in line style
if let Some(style_id) = line_style {
if *style_id == 0 {
current_line_style = None;
} else {
current_line_style = Some(*style_id);
graphic
.with_line_style_mut(*style_id)
.unwrap()
.push_new_shape(LineDirection::Right);
}
}
// Move to, start new shape fragments with the current styles.
if let Some(Vector2D { x, y }) = move_to {
let to: Point2<Twips> = Point2 { x: Twips(*x), y: Twips(*y) };
prev_pos = Some(to);
// If we didn't start a new shape for the current fill due to a fill
// style change earlier, we definitely want to start a new shape now,
// since each move_to command indicates a new shape fragment.
if let Some(current_right_fill) = current_right_fill {
graphic
.with_fill_style_mut(current_right_fill)
.unwrap()
.push_new_shape(LineDirection::Right);
}
if let Some(current_left_fill) = current_left_fill {
graphic
.with_fill_style_mut(current_left_fill)
.unwrap()
.push_new_shape(LineDirection::Left);
}
if let Some(current_line_style) = current_line_style {
// TODO(jon): Does the direction of this line depend on the current
// fill directions?
graphic
.with_line_style_mut(current_line_style)
.unwrap()
.push_new_shape(LineDirection::Right);
}
}
},
ShapeRecord::Edge(
shape_records::Edge {
delta,
control_delta,
}
) => {
let from = prev_pos.unwrap();
let to = Point2 {
x: from.x + Twips(delta.x),
y: from.y + Twips(delta.y)
};
prev_pos = Some(to);
let new_segment = LineSegment {
from,
to,
ctrl: control_delta.map(|Vector2D { x, y }| {
Point2 {
x: from.x + Twips(x),
y: from.y + Twips(y),
}
}),
};
if some_fill_set && !both_fills_same {
for fill_id in [
current_right_fill,
current_left_fill
].iter() {
if let Some(fill_id) = fill_id {
graphic
.with_fill_style_mut(*fill_id)
.unwrap()
.current_shape_mut()
.add_line_segment(new_segment);
}
}
} else if both_fills_set_and_same {
for (fill_id, direction) in [
(current_right_fill, LineDirection::Right),
(current_left_fill, LineDirection::Left)
].iter() {
// NOTE: If both left and right fill are set the same,
// then we don't record the edge as part of the current shape;
// it's will just be an internal stroke inside an otherwise solid
// shape, and recording these edges as part of the shape means that
// we can't determine the closed shape outline later.
if let Some(fill_id) = fill_id {
graphic
.with_fill_style_mut(*fill_id)
.unwrap()
.push_new_shape(*direction);
}
}
}
if let Some(current_line_style) = current_line_style {
graphic
.with_line_style_mut(current_line_style)
.unwrap()
.current_shape_mut()
.add_line_segment(new_segment);
}
}
}
}
// NOTE: Consolidate current group of styles, joining edges of shapes/strokes where
// possible and forming closed shapes. In swf, all filled shapes should always be closed,
// so there will always be a solution for joining shape line segments together so that
// the start point and end point are coincident.
graphic.end_style_group();
graphic
}
fn find_matches(
mut first_open_index: usize,
shapes: &mut Vec<Shape>,
reverse: bool
) -> Option<Vec<Shape>> {
let mut dropped_pieces = None;
while first_open_index < shapes.len() {
// Take the last unclosed value, and try to join it onto
// one of the other unclosed values.
let mut last = shapes.pop().unwrap();
if reverse {
last.reverse();
}
let mut found_match = false;
for i in first_open_index..shapes.len() {
let fragment = &mut shapes[i];
if last.comes_after(fragment) {
// NOTE(jon): We do realloc quite a bit here, I wonder if it's worth trying
// to avoid that? Could do it with another level of indirection, where an outline
// is a list of fragments.
// println!("app ({}, {})", last.reversed, fragment.reversed);
fragment.append_shape(&last);
found_match = true;
} else if last.comes_before(fragment) {
// println!("pre ({}, {})", last.reversed, fragment.reversed);
fragment.prepend_shape(&mut last);
found_match = true;
}
if found_match {
if fragment.is_closed() {
// Move the shape that was just closed to the left side of the current slice,
// and advance the cursor.
shapes.swap(first_open_index, i);
first_open_index += 1;
}
break;
}
}
if !found_match {
// Have we tried matching a reversed version of this segment?
// move last back onto the array, it will never be closed, presumably because
// it's a set of line segments rather than a shape that needs to be closed.
let dropped_pieces: &mut Vec<Shape> = dropped_pieces.get_or_insert(Vec::new());
dropped_pieces.push(last);
}
}
dropped_pieces
}
pub(crate) struct GraphicLayers {
style_layers: Vec<StyleLayer>,
base_layer_offset: usize,
stroke_layer_offset: Option<usize>,
}
impl GraphicLayers {
fn new() -> GraphicLayers {
GraphicLayers { style_layers: Vec::new(), stroke_layer_offset: None, base_layer_offset: 0 }
}
fn begin_style_group(&mut self) {
self.stroke_layer_offset = None;
self.base_layer_offset = self.style_layers.len();
}
fn begin_fill_style(&mut self, fill: Paint) {
self.style_layers.push(StyleLayer { fill: PaintOrLine::Paint(fill), shapes: Vec::new() })
}
fn begin_line_style(&mut self, line: SwfLineStyle) {
if self.stroke_layer_offset.is_none() {
self.stroke_layer_offset = Some(self.style_layers.len());
}
self.style_layers.push(StyleLayer { fill: PaintOrLine::Line(line), shapes: Vec::new() })
}
fn with_fill_style_mut(&mut self, fill_id: usize) -> Option<&mut StyleLayer> {
self.style_layers.get_mut(self.base_layer_offset + fill_id - 1)
}
fn with_line_style_mut(&mut self, line_id: usize) -> Option<&mut StyleLayer> {
self.style_layers.get_mut((self.stroke_layer_offset.unwrap() + line_id) - 1)
}
pub(crate) fn layers(&self) -> &Vec<StyleLayer> {
&self.style_layers
}
fn end_style_group(&mut self) {
for style_layer in &mut self.style_layers[self.base_layer_offset..] {
// There can be an unused style group at the end of each layer, which we should remove.
if let Some(last) = style_layer.shapes().last() {
if last.len() == 0 {
style_layer.shapes_mut().pop();
}
}
style_layer.consolidate_edges();
}
}
}

42
swf/src/timeline.rs Normal file
View File

@ -0,0 +1,42 @@
// pathfinder/swf/src/timeline.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct PlacementInfo {
symbol_id: u32,
translate_x: Twips,
translate_y: Twips,
}
struct Timeline(Vec<Frame>);
impl Timeline {
fn first(&self) -> &Frame {
&self.0[0]
}
fn last(&self) -> &Frame {
&self.0[self.0.len() - 1]
}
fn first_mut(&mut self) -> &mut Frame {
&mut self.0[0]
}
fn last_mut(&mut self) -> &mut Frame {
let last = self.0.len() - 1;
&mut self.0[last]
}
}
struct Frame {
duration_frames_initial: u16,
duration_remaining_frames: u16,
placements: Vec<PlacementInfo>
}

View File

@ -9,6 +9,9 @@ euclid = "0.19"
font-kit = "0.2" font-kit = "0.2"
lyon_path = "0.12" lyon_path = "0.12"
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"

View File

@ -13,10 +13,10 @@ use font_kit::error::GlyphLoadingError;
use font_kit::hinting::HintingOptions; use font_kit::hinting::HintingOptions;
use font_kit::loader::Loader; use font_kit::loader::Loader;
use lyon_path::builder::{FlatPathBuilder, PathBuilder}; use lyon_path::builder::{FlatPathBuilder, PathBuilder};
use pathfinder_geometry::basic::vector::Vector2F; use pathfinder_content::outline::{Contour, Outline};
use pathfinder_geometry::basic::transform2d::Transform2DF; use pathfinder_content::stroke::{OutlineStrokeToFill, StrokeStyle};
use pathfinder_geometry::outline::{Contour, Outline}; use pathfinder_geometry::transform2d::Transform2DF;
use pathfinder_geometry::stroke::{OutlineStrokeToFill, StrokeStyle}; use pathfinder_geometry::vector::Vector2F;
use pathfinder_renderer::paint::PaintId; use pathfinder_renderer::paint::PaintId;
use pathfinder_renderer::scene::{PathObject, Scene}; use pathfinder_renderer::scene::{PathObject, Scene};
use skribo::{FontCollection, Layout, TextStyle}; use skribo::{FontCollection, Layout, TextStyle};

View File

@ -13,6 +13,9 @@ serde_json = "1.0"
version = "0.1" version = "0.1"
features = ["serde"] features = ["serde"]
[dependencies.pathfinder_content]
path = "../content"
[dependencies.pathfinder_geometry] [dependencies.pathfinder_geometry]
path = "../geometry" path = "../geometry"

View File

@ -17,9 +17,9 @@
extern crate serde_derive; extern crate serde_derive;
use hashbrown::HashMap; use hashbrown::HashMap;
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I}; use pathfinder_content::color::ColorU;
use pathfinder_geometry::basic::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::color::ColorU; use pathfinder_geometry::vector::{Vector2F, Vector2I};
use pathfinder_gpu::resources::ResourceLoader; use pathfinder_gpu::resources::ResourceLoader;
use pathfinder_gpu::{BlendState, BufferData, BufferTarget, BufferUploadMode, Device, Primitive}; use pathfinder_gpu::{BlendState, BufferData, BufferTarget, BufferUploadMode, Device, Primitive};
use pathfinder_gpu::{RenderOptions, RenderState, RenderTarget, UniformData, VertexAttrClass}; use pathfinder_gpu::{RenderOptions, RenderState, RenderTarget, UniformData, VertexAttrClass};