add glyph provider API

This exposes a new uniform API for generating scene fragments for glyph outlines.
This commit is contained in:
Chad Brokaw 2022-05-02 04:15:48 -04:00
parent d243d38b04
commit ba7f85731c
6 changed files with 401 additions and 129 deletions

253
Cargo.lock generated
View file

@ -29,9 +29,9 @@ dependencies = [
[[package]]
name = "ansi_term"
version = "0.11.0"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
@ -48,7 +48,7 @@ version = "0.33.3+1.2.191"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4f1d82f164f838ae413296d1131aa6fa79b917d25bebaa7033d25620c09219"
dependencies = [
"libloading 0.7.1",
"libloading 0.7.3",
]
[[package]]
@ -58,7 +58,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12f91ce4c6be1a2ba99d3d6cd57d5bae9ac6d6f903b5ae53d6b1dee2edf872af"
dependencies = [
"ash",
"raw-window-handle",
"raw-window-handle 0.3.4",
"raw-window-metal",
]
@ -75,9 +75,9 @@ dependencies = [
[[package]]
name = "autocfg"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
@ -93,18 +93,18 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "bytemuck"
version = "1.7.2"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b"
checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc"
dependencies = [
"bytemuck_derive",
]
[[package]]
name = "bytemuck_derive"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54"
checksum = "562e382481975bc61d11275ac5e62a19abd00b0547d99516a415336f183dcd0e"
dependencies = [
"proc-macro2",
"quote",
@ -129,9 +129,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.72"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
@ -147,9 +147,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "2.33.3"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
@ -169,7 +169,7 @@ dependencies = [
"bitflags",
"block",
"cocoa-foundation",
"core-foundation 0.9.2",
"core-foundation 0.9.3",
"core-graphics 0.22.3",
"foreign-types",
"libc",
@ -184,7 +184,7 @@ checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [
"bitflags",
"block",
"core-foundation 0.9.2",
"core-foundation 0.9.3",
"core-graphics-types",
"foreign-types",
"libc",
@ -203,9 +203,9 @@ dependencies = [
[[package]]
name = "core-foundation"
version = "0.9.2"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
dependencies = [
"core-foundation-sys 0.8.3",
"libc",
@ -242,7 +242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [
"bitflags",
"core-foundation 0.9.2",
"core-foundation 0.9.3",
"core-graphics-types",
"foreign-types",
"libc",
@ -255,7 +255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [
"bitflags",
"core-foundation 0.9.2",
"core-foundation 0.9.3",
"foreign-types",
"libc",
]
@ -275,9 +275,9 @@ dependencies = [
[[package]]
name = "crc32fast"
version = "1.2.1"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if 1.0.0",
]
@ -298,9 +298,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -319,10 +319,11 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
version = "0.9.5"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"
checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"crossbeam-utils",
"lazy_static",
@ -332,9 +333,9 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
version = "0.3.2"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9"
checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -342,14 +343,20 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [
"cfg-if 1.0.0",
"lazy_static",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "darling"
version = "0.10.2"
@ -395,31 +402,20 @@ dependencies = [
"byteorder",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "dirs"
version = "3.0.2"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
@ -447,7 +443,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794"
dependencies = [
"libloading 0.7.1",
"libloading 0.7.3",
]
[[package]]
@ -490,9 +486,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.3"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if 1.0.0",
"libc",
@ -552,9 +548,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.107"
version = "0.2.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219"
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
[[package]]
name = "libloading"
@ -568,9 +564,9 @@ dependencies = [
[[package]]
name = "libloading"
version = "0.7.1"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0cf036d15402bea3c5d4de17b3fce76b3e4a56ebc1f577be0e7a72f7c607cf0"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
dependencies = [
"cfg-if 1.0.0",
"winapi",
@ -578,18 +574,19 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.4.5"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.14"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
dependencies = [
"cfg-if 1.0.0",
]
@ -611,9 +608,9 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "memchr"
version = "2.4.1"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memmap2"
@ -626,9 +623,9 @@ dependencies = [
[[package]]
name = "memoffset"
version = "0.6.4"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
@ -677,9 +674,9 @@ dependencies = [
[[package]]
name = "mio-misc"
version = "1.2.1"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ddf05411bb159cdb5801bb10002afb66cb4572be656044315e363460ce69dc2"
checksum = "b47412f3a52115b936ff2a229b803498c7b4d332adeb87c2f1498c9da54c398c"
dependencies = [
"crossbeam",
"crossbeam-queue",
@ -696,6 +693,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "moscato"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8372f6cdc8b2c431750a9c4edbc8d9c511ef1a68472aaa02500493414a407c64"
dependencies = [
"pinot",
]
[[package]]
name = "ndk"
version = "0.3.0"
@ -737,9 +743,9 @@ dependencies = [
[[package]]
name = "ndk-sys"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c44922cb3dbb1c70b5e5f443d63b64363a898564d739ba5198e3a9138442868d"
checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121"
[[package]]
name = "nix"
@ -767,41 +773,39 @@ dependencies = [
[[package]]
name = "nom"
version = "7.1.0"
version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
"memchr",
"minimal-lexical",
"version_check",
]
[[package]]
name = "ntapi"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
dependencies = [
"winapi",
]
[[package]]
name = "num_enum"
version = "0.5.4"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9bd055fb730c4f8f4f57d45d35cd6b3f0980535b056dc7ff119cee6a66ed6f"
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
dependencies = [
"derivative",
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.5.4"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "486ea01961c4a818096de679a8b740b26d9033146ac5291b1c98557658f8cdd9"
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
dependencies = [
"proc-macro-crate 1.1.0",
"proc-macro-crate 1.1.3",
"proc-macro2",
"quote",
"syn",
@ -828,9 +832,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.8.0"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
name = "owned_ttf_parser"
@ -896,7 +900,7 @@ dependencies = [
"piet-gpu-types",
"png",
"rand",
"raw-window-handle",
"raw-window-handle 0.3.4",
"roxmltree",
"swash",
"winit",
@ -923,7 +927,7 @@ dependencies = [
"cocoa-foundation",
"metal",
"objc",
"raw-window-handle",
"raw-window-handle 0.3.4",
"smallvec",
"winapi",
"wio",
@ -955,9 +959,11 @@ version = "0.1.0"
dependencies = [
"bytemuck",
"clap",
"moscato",
"piet",
"piet-gpu",
"piet-gpu-hal",
"pinot",
"png",
"rand",
"roxmltree",
@ -966,10 +972,16 @@ dependencies = [
]
[[package]]
name = "pkg-config"
version = "0.3.22"
name = "pinot"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f"
checksum = "6ba3013ff85036c414a4a3cf826135db204de2bd80d684728550e7130421809a"
[[package]]
name = "pkg-config"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "png"
@ -985,9 +997,9 @@ dependencies = [
[[package]]
name = "ppv-lite86"
version = "0.2.15"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "proc-macro-crate"
@ -1000,9 +1012,9 @@ dependencies = [
[[package]]
name = "proc-macro-crate"
version = "1.1.0"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83"
checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
dependencies = [
"thiserror",
"toml",
@ -1010,18 +1022,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.32"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.10"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
"proc-macro2",
]
@ -1069,11 +1081,21 @@ dependencies = [
[[package]]
name = "raw-window-handle"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76"
dependencies = [
"libc",
"raw-window-handle 0.4.3",
]
[[package]]
name = "raw-window-handle"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
dependencies = [
"cty",
]
[[package]]
@ -1085,26 +1107,27 @@ dependencies = [
"cocoa",
"core-graphics 0.22.3",
"objc",
"raw-window-handle",
"raw-window-handle 0.3.4",
]
[[package]]
name = "redox_syscall"
version = "0.2.10"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.0"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.6",
"redox_syscall",
"thiserror",
]
[[package]]
@ -1149,9 +1172,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.130"
version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
[[package]]
name = "smallvec"
@ -1202,9 +1225,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.81"
version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
dependencies = [
"proc-macro2",
"quote",
@ -1222,18 +1245,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.30"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.30"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [
"proc-macro2",
"quote",
@ -1242,9 +1265,9 @@ dependencies = [
[[package]]
name = "toml"
version = "0.5.8"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]
@ -1324,12 +1347,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]]
name = "walkdir"
version = "2.3.2"
@ -1465,7 +1482,7 @@ checksum = "79610794594d5e86be473ef7763f604f2159cbac8c94debd00df8fb41e86c2f8"
dependencies = [
"bitflags",
"cocoa",
"core-foundation 0.9.2",
"core-foundation 0.9.3",
"core-graphics 0.22.3",
"core-video-sys",
"dispatch",
@ -1481,7 +1498,7 @@ dependencies = [
"objc",
"parking_lot",
"percent-encoding",
"raw-window-handle",
"raw-window-handle 0.3.4",
"scopeguard",
"smithay-client-toolkit",
"wayland-client",
@ -1520,9 +1537,9 @@ dependencies = [
[[package]]
name = "xdg"
version = "2.4.0"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a23fe958c70412687039c86f578938b4a0bb50ec788e96bce4d6ab00ddd5803"
checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6"
dependencies = [
"dirs",
]

View file

@ -7,6 +7,8 @@ edition = "2021"
[dependencies]
bytemuck = { version = "1.7.2", features = ["derive"] }
smallvec = "1.8.0"
pinot = "0.1.5"
moscato = "0.1.2"
# remove these and move demo to another directory
piet-gpu = { path = "../piet-gpu" }

View file

@ -50,15 +50,8 @@ pub enum Extend {
Reflect,
}
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Space {
Object,
Global,
}
#[derive(Clone, Debug)]
pub struct LinearGradient {
pub space: Space,
pub start: Point,
pub end: Point,
pub stops: StopVec,
@ -67,7 +60,6 @@ pub struct LinearGradient {
#[derive(Clone, Debug)]
pub struct RadialGradient {
pub space: Space,
pub center0: Point,
pub radius0: f32,
pub center1: Point,
@ -78,7 +70,6 @@ pub struct RadialGradient {
#[derive(Clone, Debug)]
pub struct SweepGradient {
pub space: Space,
pub center: Point,
pub start_angle: f32,
pub end_angle: f32,

263
piet-scene/src/glyph/mod.rs Normal file
View file

@ -0,0 +1,263 @@
// Copyright 2022 The piet-gpu authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Also licensed under MIT license, at your choice.
pub use pinot;
use crate::brush::{Brush, Color};
use crate::path::Element;
use crate::scene::{build_fragment, Fill, Fragment};
use moscato::{Context, Scaler};
use pinot::{types::Tag, FontRef};
/// General context for creating scene fragments for glyph outlines.
pub struct GlyphContext {
ctx: Context,
}
impl GlyphContext {
/// Creates a new context.
pub fn new() -> Self {
Self {
ctx: Context::new(),
}
}
/// Creates a new provider for generating scene fragments for glyphs from
/// the specified font and settings.
pub fn new_provider<'a, V>(
&'a mut self,
font: &FontRef<'a>,
font_id: Option<u64>,
ppem: f32,
hint: bool,
variations: V,
) -> GlyphProvider<'a>
where
V: IntoIterator,
V::Item: Into<(Tag, f32)>,
{
let scaler = if let Some(font_id) = font_id {
self.ctx
.new_scaler_with_id(font, font_id)
.size(ppem)
.hint(hint)
.variations(variations)
.build()
} else {
self.ctx
.new_scaler(font)
.size(ppem)
.hint(hint)
.variations(variations)
.build()
};
GlyphProvider { scaler }
}
}
/// Generator for scene fragments containing glyph outlines for a specific
/// font.
pub struct GlyphProvider<'a> {
scaler: Scaler<'a>,
}
impl<'a> GlyphProvider<'a> {
/// Returns a scene fragment containing the commands to render the
/// specified glyph.
pub fn get(&mut self, gid: u16) -> Option<Fragment> {
let glyph = self.scaler.glyph(gid)?;
let path = glyph.path(0)?;
let mut fragment = Fragment::default();
let mut builder = build_fragment(&mut fragment);
builder.fill(
Fill::NonZero,
&Brush::Solid(Color::rgb8(255, 255, 255)),
None,
convert_path(path.elements()),
);
Some(fragment)
}
/// Returns a scene fragment containing the commands and resources to
/// render the specified color glyph.
pub fn get_color(&mut self, palette_index: u16, gid: u16) -> Option<Fragment> {
use crate::geometry::*;
use moscato::Command;
let glyph = self.scaler.color_glyph(palette_index, gid)?;
let mut fragment = Fragment::default();
let mut builder = build_fragment(&mut fragment);
for command in glyph.commands() {
match command {
Command::PushTransform(xform) => {
builder.push_transform(convert_transform(xform));
}
Command::PopTransform => builder.pop_transform(),
Command::PushClip(path_index) => {
let path = glyph.path(*path_index)?;
builder.push_layer(Default::default(), convert_path(path.elements()));
}
Command::PopClip => builder.pop_layer(),
Command::PushLayer(bounds) => {
let rect = Rect {
min: Point::new(bounds.min.x, bounds.min.y),
max: Point::new(bounds.max.x, bounds.max.y),
};
builder.push_layer(Default::default(), rect.elements());
}
Command::PopLayer => builder.pop_layer(),
Command::BeginBlend(bounds, mode) => {
let rect = Rect {
min: Point::new(bounds.min.x, bounds.min.y),
max: Point::new(bounds.max.x, bounds.max.y),
};
builder.push_layer(convert_blend(*mode), rect.elements())
}
Command::EndBlend => builder.pop_layer(),
Command::SimpleFill(path_index, brush, xform) => {
let path = glyph.path(*path_index)?;
let brush = convert_brush(brush);
let xform = xform.map(|xform| convert_transform(&xform));
builder.fill(Fill::NonZero, &brush, xform, convert_path(path.elements()));
}
Command::Fill(brush, xform) => {
// TODO: this needs to compute a bounding box for
// the parent clips
}
}
}
Some(fragment)
}
}
fn convert_path(
path: impl Iterator<Item = moscato::Element> + Clone,
) -> impl Iterator<Item = Element> + Clone {
use crate::geometry::Point;
path.map(|el| match el {
moscato::Element::MoveTo(p0) => Element::MoveTo(Point::new(p0.x, p0.y)),
moscato::Element::LineTo(p0) => Element::LineTo(Point::new(p0.x, p0.y)),
moscato::Element::QuadTo(p0, p1) => {
Element::QuadTo(Point::new(p0.x, p0.y), Point::new(p1.x, p1.y))
}
moscato::Element::CurveTo(p0, p1, p2) => Element::CurveTo(
Point::new(p0.x, p0.y),
Point::new(p1.x, p1.y),
Point::new(p2.x, p2.y),
),
moscato::Element::Close => Element::Close,
})
}
fn convert_blend(mode: moscato::CompositeMode) -> crate::scene::Blend {
use crate::scene::{Blend, Compose, Mix};
use moscato::CompositeMode;
let mut mix = Mix::Normal;
let mut compose = Compose::SrcOver;
match mode {
CompositeMode::Clear => compose = Compose::Clear,
CompositeMode::Src => compose = Compose::Copy,
CompositeMode::Dest => compose = Compose::Dest,
CompositeMode::SrcOver => {}
CompositeMode::DestOver => compose = Compose::DestOver,
CompositeMode::SrcIn => compose = Compose::SrcIn,
CompositeMode::DestIn => compose = Compose::DestIn,
CompositeMode::SrcOut => compose = Compose::SrcOut,
CompositeMode::DestOut => compose = Compose::DestOut,
CompositeMode::SrcAtop => compose = Compose::SrcAtop,
CompositeMode::DestAtop => compose = Compose::DestAtop,
CompositeMode::Xor => compose = Compose::Xor,
CompositeMode::Plus => compose = Compose::Plus,
CompositeMode::Screen => mix = Mix::Screen,
CompositeMode::Overlay => mix = Mix::Overlay,
CompositeMode::Darken => mix = Mix::Darken,
CompositeMode::Lighten => mix = Mix::Lighten,
CompositeMode::ColorDodge => mix = Mix::ColorDodge,
CompositeMode::ColorBurn => mix = Mix::ColorBurn,
CompositeMode::HardLight => mix = Mix::HardLight,
CompositeMode::SoftLight => mix = Mix::SoftLight,
CompositeMode::Difference => mix = Mix::Difference,
CompositeMode::Exclusion => mix = Mix::Exclusion,
CompositeMode::Multiply => mix = Mix::Multiply,
CompositeMode::HslHue => mix = Mix::Hue,
CompositeMode::HslSaturation => mix = Mix::Saturation,
CompositeMode::HslColor => mix = Mix::Color,
CompositeMode::HslLuminosity => mix = Mix::Luminosity,
}
Blend { mix, compose }
}
fn convert_transform(xform: &moscato::Transform) -> crate::geometry::Affine {
crate::geometry::Affine {
xx: xform.xx,
yx: xform.yx,
xy: xform.xy,
yy: xform.yy,
dx: xform.dx,
dy: xform.dy,
}
}
fn convert_brush(brush: &moscato::Brush) -> crate::brush::Brush {
use crate::brush::*;
use crate::geometry::*;
match brush {
moscato::Brush::Solid(color) => Brush::Solid(Color {
r: color.r,
g: color.g,
b: color.b,
a: color.a,
}),
moscato::Brush::LinearGradient(grad) => Brush::LinearGradient(LinearGradient {
start: Point::new(grad.start.x, grad.start.y),
end: Point::new(grad.end.x, grad.end.y),
stops: convert_stops(&grad.stops),
extend: convert_extend(grad.extend),
}),
moscato::Brush::RadialGradient(grad) => Brush::RadialGradient(RadialGradient {
center0: Point::new(grad.center0.x, grad.center0.y),
center1: Point::new(grad.center1.x, grad.center1.y),
radius0: grad.radius0,
radius1: grad.radius1,
stops: convert_stops(&grad.stops),
extend: convert_extend(grad.extend),
}),
}
}
fn convert_stops(stops: &[moscato::ColorStop]) -> crate::brush::StopVec {
use crate::brush::Stop;
stops
.iter()
.map(|stop| Stop {
offset: stop.offset,
color: Color {
r: stop.color.r,
g: stop.color.g,
b: stop.color.b,
a: stop.color.a,
},
})
.collect()
}
fn convert_extend(extend: moscato::ExtendMode) -> crate::brush::Extend {
use crate::brush::Extend::*;
match extend {
moscato::ExtendMode::Pad => Pad,
moscato::ExtendMode::Repeat => Repeat,
moscato::ExtendMode::Reflect => Reflect,
}
}

View file

@ -16,6 +16,7 @@
pub mod brush;
pub mod geometry;
pub mod glyph;
pub mod path;
pub mod resource;
pub mod scene;

View file

@ -308,7 +308,6 @@ fn test_scene1(scene: &mut Scene, rcx: &mut ResourceContext) {
let mut fragment = Fragment::default();
let mut b = build_fragment(&mut fragment);
let linear = Brush::LinearGradient(LinearGradient {
space: Space::Global,
start: Point::new(0., 0.),
end: Point::new(200., 100.),
extend: Extend::Pad,
@ -329,7 +328,6 @@ fn test_scene1(scene: &mut Scene, rcx: &mut ResourceContext) {
.into(),
});
let radial = Brush::RadialGradient(RadialGradient {
space: Space::Global,
center0: Point::new(50., 50.),
center1: Point::new(50., 50.),
radius0: 0.,