diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f8acba..4c26e7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,11 @@ env: # If the compilation fails, then the version specified here needs to be bumped up to reality. # Be sure to also update the rust-version property in the workspace Cargo.toml file, # plus all the README.md files of the affected packages. - RUST_MIN_VER: "1.75" + RUST_MIN_VER: "1.82" # List of packages that will be checked with the minimum supported Rust version. # This should be limited to packages that are intended for publishing. RUST_MIN_VER_PKGS: "-p velato" - # Rationale # # We don't run clippy with --all-targets because then even --lib and --bins are compiled with diff --git a/CHANGELOG.md b/CHANGELOG.md index 343d583..bda445a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,11 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe ## [Unreleased] -This release has an [MSRV][] of 1.75. +This release has an [MSRV][] of 1.82. + +### Changed + +- Updated to `vello` 0.4 ([#49][] by [@simbleau][]). ## [0.4.0] - 2024-11-21 @@ -75,6 +79,7 @@ This release has an [MSRV][] of 1.75. [#17]: https://github.com/linebender/velato/pull/17 [#19]: https://github.com/linebender/velato/pull/19 [#42]: https://github.com/linebender/velato/pull/42 +[#49]: https://github.com/linebender/velato/pull/49 [Unreleased]: https://github.com/linebender/velato/compare/v0.3.0...HEAD [0.4.0]: https://github.com/linebender/velato/compare/v0.3.1...v0.4.0 diff --git a/Cargo.lock b/Cargo.lock index 32ac47a..6fbd806 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,18 +208,18 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bit-set" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bit_field" @@ -282,9 +282,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" dependencies = [ "bytemuck_derive", ] @@ -297,7 +297,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -410,7 +410,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -429,6 +429,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c387f6cef110ee8eaf12fca5586d3d303c07c594f4a5f02c768b6470b70dbd" + [[package]] name = "color_quant" version = "1.1.0" @@ -441,37 +447,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" -[[package]] -name = "com" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6" -dependencies = [ - "com_macros", -] - -[[package]] -name = "com_macros" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5" -dependencies = [ - "com_macros_support", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "com_macros_support" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "combine" version = "4.6.7" @@ -631,17 +606,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" -[[package]] -name = "d3d12" -version = "22.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017" -dependencies = [ - "bitflags 2.6.0", - "libloading", - "winapi", -] - [[package]] name = "devserver_lib" version = "0.4.2" @@ -662,7 +626,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -819,9 +783,9 @@ dependencies = [ [[package]] name = "font-types" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3971f9a5ca983419cdc386941ba3b9e1feba01a0ab888adf78739feb2798492" +checksum = "11c3a23a5a151afb1f74ea797f8c300dee41eff9ee3cb1bf94ed316d860c46b3" dependencies = [ "bytemuck", ] @@ -844,7 +808,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -963,9 +927,9 @@ dependencies = [ [[package]] name = "glow" -version = "0.13.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1" +checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483" dependencies = [ "js-sys", "slotmap", @@ -1003,14 +967,13 @@ dependencies = [ [[package]] name = "gpu-allocator" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7" +checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd" dependencies = [ "log", "presser", "thiserror 1.0.69", - "winapi", "windows", ] @@ -1077,21 +1040,6 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" -[[package]] -name = "hassle-rs" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" -dependencies = [ - "bitflags 2.6.0", - "com", - "libc", - "libloading", - "thiserror 1.0.69", - "widestring", - "winapi", -] - [[package]] name = "heck" version = "0.5.0" @@ -1242,7 +1190,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1250,6 +1198,9 @@ name = "id-arena" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +dependencies = [ + "rayon", +] [[package]] name = "idna" @@ -1414,10 +1365,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1636,9 +1588,9 @@ dependencies = [ [[package]] name = "naga" -version = "22.1.0" +version = "23.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd5a652b6faf21496f2cfd88fc49989c8db0825d1f6746b1a71a6ede24a63ad" +checksum = "364f94bc34f61332abebe8cad6f6cd82a5b65cff22c828d05d0968911462ca4f" dependencies = [ "arrayvec", "bit-set", @@ -1751,7 +1703,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1840,10 +1792,11 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "peniko" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a648c93f502a0bef0a9cb47fa1335994958a2744667d3f82defe513f276741a" +checksum = "2ec061f435b573ff602b2c5690f1a5bfcf461327194654cfbfce4412b95cf2a1" dependencies = [ + "color", "kurbo", "smallvec", ] @@ -2036,9 +1989,9 @@ dependencies = [ [[package]] name = "read-fonts" -version = "0.22.5" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a04b892cb6f91951f144c33321843790c8574c825aafdb16d815fd7183b5229" +checksum = "f6f9e8a4f503e5c8750e4cd3b32a4e090035c46374b305a15c70bad833dca05f" dependencies = [ "bytemuck", "font-types", @@ -2176,6 +2129,12 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + [[package]] name = "ryu" version = "1.0.18" @@ -2197,12 +2156,14 @@ version = "0.0.0" dependencies = [ "anyhow", "byte-unit", + "bytemuck", "clap", "getrandom", "image", "inquire", "instant", "rand", + "skrifa", "ureq", "velato", "vello", @@ -2241,29 +2202,29 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" dependencies = [ "itoa", "memchr", @@ -2279,7 +2240,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2326,9 +2287,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "skrifa" -version = "0.22.3" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1c44ad1f6c5bdd4eefed8326711b7dbda9ea45dfd36068c427d332aa382cbe" +checksum = "e92bf3f3af711d696eff796a4f28136927d40eb8108002b6f7919dc0cee27a5d" dependencies = [ "bytemuck", "read-fonts", @@ -2443,17 +2404,6 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce5d813d71d82c4cbc1742135004e4a79fd870214c155443451c139c9470a0aa" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.87" @@ -2473,7 +2423,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2509,11 +2459,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl 2.0.11", ] [[package]] @@ -2524,18 +2474,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2723,26 +2673,25 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror 2.0.3", + "thiserror 2.0.11", "vello", "wasm-bindgen-test", ] [[package]] name = "vello" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc44dd4eb9af6a41551b9a82c93d068bd832693d6f78ab118ad19780d8e1202e" +checksum = "aa359d6cc48a5afec128b6a3829116700c33bd6d4a9ce81efd0b1e6ac55e9777" dependencies = [ "bytemuck", "futures-intrusive", "log", "peniko", "png", - "raw-window-handle", "skrifa", "static_assertions", - "thiserror 1.0.69", + "thiserror 2.0.11", "vello_encoding", "vello_shaders", "wgpu", @@ -2750,9 +2699,9 @@ dependencies = [ [[package]] name = "vello_encoding" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8110c14702a4e17f9200f6e3c4fe05dda5a22bf031ae4feafed4a61429f66fb2" +checksum = "847f24259aa73e1d5baf453856034f471eeffbf006072e41f7c8397da4f89f65" dependencies = [ "bytemuck", "guillotiere", @@ -2763,13 +2712,13 @@ dependencies = [ [[package]] name = "vello_shaders" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cad02d6f29f2212a6ee382a8fec6f9977d0cceefacf07f8e361607ffe3988d" +checksum = "88db8f16a08862b63bbbf90666d367187ff15d3bb157f3d83798497914f2c94f" dependencies = [ "bytemuck", "naga", - "thiserror 1.0.69", + "thiserror 2.0.11", "vello_encoding", ] @@ -2791,15 +2740,16 @@ dependencies = [ [[package]] name = "walrus" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68aa3c7b80be75c8458fc087453e5a31a226cfffede2e9b932393b2ea1c624a" +checksum = "ba3fbafa56a918167d111b23f6cd12c094bd85b3f41dc6ce390ed4c44b14bc1e" dependencies = [ "anyhow", "gimli", "id-arena", "leb128", "log", + "rayon", "walrus-macro", "wasm-encoder", "wasmparser", @@ -2814,7 +2764,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2825,35 +2775,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-cli-support" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b21cf9e89b196d78ff95c442a8076cc417171001e75dc062fe2c421cd2a0f9" +checksum = "21e1a4a49abe9cd6f762fc65fac2ef5732afeeb66be369d2f71a85b165a533cf" dependencies = [ "anyhow", "base64", @@ -2862,7 +2812,6 @@ dependencies = [ "serde", "serde_json", "tempfile", - "unicode-ident", "walrus", "wasm-bindgen-externref-xform", "wasm-bindgen-multi-value-xform", @@ -2874,9 +2823,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-externref-xform" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9f5eaefdb356e4266ca53d76526f5500e1e3b0961da8ee932193f08ada25ec7" +checksum = "940542c5cdbe96c35f98b5da5c65fb9d18df55a0cb1d81fc5ca4acc4fda4d61c" dependencies = [ "anyhow", "walrus", @@ -2885,21 +2834,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2907,22 +2857,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-multi-value-xform" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22689c6bbdc7f3a9110f1aa21873398a7ab2c50474ba9a45595c9ffde49c0cd" +checksum = "64b5ad2e97adde0c3e4369c38e0dbaee329ad8f6cc2ee8e01d1d0b13bd8b14cf" dependencies = [ "anyhow", "walrus", @@ -2931,20 +2881,21 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-bindgen-test" -version = "0.3.45" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d381749acb0943d357dcbd8f0b100640679883fcdeeef04def49daf8d33a5426" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" dependencies = [ - "console_error_panic_hook", "js-sys", "minicov", - "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", @@ -2952,20 +2903,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.45" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] name = "wasm-bindgen-threads-xform" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d3c6389a7c8fa49ee4f55847d01b74c640a60387598952cdf3211b8499520c" +checksum = "1cbdf2d55a50f7edc9dd9aecae7a3a40e9736fda851bd8816f98a86167c8c277" dependencies = [ "anyhow", "walrus", @@ -2974,9 +2925,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-wasm-conventions" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b4d6bf2704173b57d7f319316593a35f2102e18bc92251d96909f89e7d4595" +checksum = "b1c24fcaa34d2d84407122cfb1d3f37c3586756cf462be18e049b49245a16c08" dependencies = [ "anyhow", "leb128", @@ -2987,9 +2938,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-wasm-interpreter" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b123244c6bf9e7abbb6ad9aa98ed86f927b55ee9d95b5552dd9346910341d5e2" +checksum = "33f24921401faadd6944206f9d6837d07bbb5ff766ed51ad34528089f66550e0" dependencies = [ "anyhow", "log", @@ -2999,18 +2950,18 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.212.0" +version = "0.214.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501940df4418b8929eb6d52f1aade1fdd15a5b86c92453cb696e3c906bd3fc33" +checksum = "ff694f02a8d7a50b6922b197ae03883fbf18cdb2ae9fbee7b6148456f5f44041" dependencies = [ "leb128", ] [[package]] name = "wasmparser" -version = "0.212.0" +version = "0.214.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d28bc49ba1e5c5b61ffa7a2eace10820443c4b7d1c0b144109261d14570fdf8" +checksum = "5309c1090e3e84dad0d382f42064e9933fdaedb87e468cc239f0eabea73ddcb6" dependencies = [ "ahash", "bitflags 2.6.0", @@ -3131,9 +3082,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -3166,9 +3117,9 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "wgpu" -version = "22.1.0" +version = "23.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d1c4ba43f80542cf63a0a6ed3134629ae73e8ab51e4b765a67f3aa062eb433" +checksum = "80f70000db37c469ea9d67defdc13024ddf9a5f1b89cb2941b812ad7cde1735a" dependencies = [ "arrayvec", "cfg_aliases", @@ -3191,9 +3142,9 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "22.1.0" +version = "23.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0348c840d1051b8e86c3bcd31206080c5e71e5933dabd79be1ce732b0b2f089a" +checksum = "d63c3c478de8e7e01786479919c8769f62a22eec16788d8c2ac77ce2c132778a" dependencies = [ "arrayvec", "bit-vec", @@ -3216,9 +3167,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "22.0.0" +version = "23.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f" +checksum = "89364b8a0b211adc7b16aeaf1bd5ad4a919c1154b44c9ce27838213ba05fd821" dependencies = [ "android_system_properties", "arrayvec", @@ -3226,15 +3177,14 @@ dependencies = [ "bit-set", "bitflags 2.6.0", "block", + "bytemuck", "cfg_aliases", "core-graphics-types", - "d3d12", "glow", "glutin_wgl_sys", "gpu-alloc", "gpu-allocator", "gpu-descriptor", - "hassle-rs", "js-sys", "khronos-egl", "libc", @@ -3256,26 +3206,21 @@ dependencies = [ "wasm-bindgen", "web-sys", "wgpu-types", - "winapi", + "windows", + "windows-core", ] [[package]] name = "wgpu-types" -version = "22.0.0" +version = "23.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9d91f0e2c4b51434dfa6db77846f2793149d8e73f800fa2e41f52b8eac3c5d" +checksum = "610f6ff27778148c31093f3b03abc4840f9636d58d597ca2f5977433acfe0068" dependencies = [ "bitflags 2.6.0", "js-sys", "web-sys", ] -[[package]] -name = "widestring" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" - [[package]] name = "winapi" version = "0.3.9" @@ -3309,9 +3254,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.52.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ "windows-core", "windows-targets 0.52.6", @@ -3319,10 +3264,55 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.52.0" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ + "windows-result", "windows-targets 0.52.6", ] @@ -3714,7 +3704,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", "synstructure", ] @@ -3736,7 +3726,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -3756,7 +3746,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", "synstructure", ] @@ -3785,7 +3775,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3cc5ece..f9fc432 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 OR MIT" repository = "https://github.com/linebender/velato" # Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml, with the relevant README.md files # and with the MSRV in the `Unreleased` section of CHANGELOG.md. -rust-version = "1.75" +rust-version = "1.82" [package] name = "velato" @@ -90,7 +90,7 @@ clippy.wildcard_dependencies = "warn" [workspace.dependencies] # NOTE: Make sure to keep this in sync with the version badge in README.md -vello = { version = "0.3.0", default-features = false } +vello = { version = "0.4.0", default-features = false } [lints] workspace = true diff --git a/README.md b/README.md index f7e2ffe..694bdd0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Linebender Zulip](https://img.shields.io/badge/Linebender-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu) [![dependency status](https://deps.rs/repo/github/linebender/velato/status.svg)](https://deps.rs/repo/github/linebender/velato) [![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license) -[![vello version](https://img.shields.io/badge/vello-v0.3.0-purple.svg)](https://crates.io/crates/vello)\ +[![vello version](https://img.shields.io/badge/vello-v0.4.0-purple.svg)](https://crates.io/crates/vello)\ [![Crates.io](https://img.shields.io/crates/v/velato.svg)](https://crates.io/crates/velato) [![Docs](https://docs.rs/velato/badge.svg)](https://docs.rs/velato) [![Build status](https://github.com/linebender/velato/workflows/CI/badge.svg)](https://github.com/linebender/velato/actions) @@ -87,7 +87,7 @@ There is also a web demo [available here](https://linebender.github.io/velato) o ## Minimum supported Rust Version (MSRV) -This version of Velato has been verified to compile with **Rust 1.75** and later. +This version of Velato has been verified to compile with **Rust 1.82** and later. Future versions of Velato might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. diff --git a/examples/scenes/Cargo.toml b/examples/scenes/Cargo.toml index d0fa417..b7635aa 100644 --- a/examples/scenes/Cargo.toml +++ b/examples/scenes/Cargo.toml @@ -16,7 +16,9 @@ anyhow = "1" clap = { version = "4.5.1", features = ["derive"] } image = "0.24.9" rand = "0.8.5" +skrifa = "0.26.4" instant = "0.1" +bytemuck = { version = "1.21.0", features = ["derive"] } # Used for the `download` command [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/examples/scenes/src/lib.rs b/examples/scenes/src/lib.rs index 30d8be1..5bdad70 100644 --- a/examples/scenes/src/lib.rs +++ b/examples/scenes/src/lib.rs @@ -28,7 +28,7 @@ mod simple_text; mod test_scenes; use std::path::PathBuf; -use anyhow::{anyhow, Result}; +use anyhow::Result; use clap::{Args, Subcommand}; #[cfg(not(target_arch = "wasm32"))] use download::Download; @@ -38,7 +38,7 @@ pub use simple_text::RobotoText; pub use test_scenes::test_scenes; use vello::kurbo::Vec2; -use vello::peniko::Color; +use vello::peniko::{color, Color}; use vello::Scene; pub struct SceneParams<'a> { @@ -145,6 +145,6 @@ impl Command { } } -fn parse_color(s: &str) -> Result { - Color::parse(s).ok_or(anyhow!("'{s}' is not a valid color")) +fn parse_color(s: &str) -> Result { + color::parse_color(s).map(|c| c.to_alpha_color()) } diff --git a/examples/scenes/src/simple_text.rs b/examples/scenes/src/simple_text.rs index e48486d..a1bfd75 100644 --- a/examples/scenes/src/simple_text.rs +++ b/examples/scenes/src/simple_text.rs @@ -1,11 +1,11 @@ // Copyright 2022 the Velato Authors // SPDX-License-Identifier: Apache-2.0 OR MIT +use skrifa::raw::FontRef; +use skrifa::MetadataProvider; use std::sync::Arc; use vello::kurbo::Affine; use vello::peniko::{Blob, Brush, BrushRef, Font, StyleRef}; -use vello::skrifa::raw::FontRef; -use vello::skrifa::MetadataProvider; use vello::{Glyph, Scene}; // This is very much a hack to get things working. @@ -68,7 +68,7 @@ impl RobotoText { let brush = brush.into(); let style = style.into(); let axes = font_ref.axes(); - let font_size = vello::skrifa::instance::Size::new(size); + let font_size = skrifa::instance::Size::new(size); let var_loc = axes.location(variations.iter().copied()); let charmap = font_ref.charmap(); let metrics = font_ref.metrics(font_size, &var_loc); @@ -81,7 +81,7 @@ impl RobotoText { .font_size(size) .transform(transform) .glyph_transform(glyph_transform) - .normalized_coords(var_loc.coords()) + .normalized_coords(bytemuck::cast_slice(var_loc.coords())) .brush(brush) .draw( style, @@ -129,7 +129,7 @@ impl RobotoText { } fn to_font_ref(font: &Font) -> Option> { - use vello::skrifa::raw::FileRef; + use skrifa::raw::FileRef; let file_ref = FileRef::new(font.data.as_ref()).ok()?; match file_ref { FileRef::Font(font) => Some(font), diff --git a/examples/with_winit/Cargo.toml b/examples/with_winit/Cargo.toml index 9ab7ce9..5813c8c 100644 --- a/examples/with_winit/Cargo.toml +++ b/examples/with_winit/Cargo.toml @@ -20,7 +20,7 @@ path = "src/main.rs" workspace = true [dependencies] -vello = { workspace = true, features = ["buffer_labels", "wgpu"] } +vello = { workspace = true, features = [ "wgpu"] } scenes = { path = "../scenes" } anyhow = "1" clap = { version = "4.5.1", features = ["derive"] } diff --git a/examples/with_winit/src/stats.rs b/examples/with_winit/src/stats.rs index 8741ab6..4da1134 100644 --- a/examples/with_winit/src/stats.rs +++ b/examples/with_winit/src/stats.rs @@ -43,7 +43,7 @@ impl Snapshot { scene.fill( Fill::NonZero, offset, - &Brush::Solid(Color::rgba8(0, 0, 0, 200)), + &Brush::Solid(Color::from_rgba8(0, 0, 0, 200)), None, &Rect::new(0., 0., width, height), ); @@ -130,9 +130,9 @@ impl Snapshot { let s = Affine::scale_non_uniform(1., -h); #[allow(clippy::match_overlapping_arm)] let color = match *sample { - ..=16_667 => Color::rgb8(100, 143, 255), - ..=33_334 => Color::rgb8(255, 176, 0), - _ => Color::rgb8(220, 38, 127), + ..=16_667 => Color::from_rgb8(100, 143, 255), + ..=33_334 => Color::from_rgb8(255, 176, 0), + _ => Color::from_rgb8(220, 38, 127), }; scene.fill( Fill::NonZero, diff --git a/src/import/converters.rs b/src/import/converters.rs index d16ca04..ede6dde 100644 --- a/src/import/converters.rs +++ b/src/import/converters.rs @@ -337,9 +337,12 @@ fn conv_gradient_colors( stops.push( ( values[0] as f32, - runtime::model::fixed::Color::rgba( - values[1], values[2], values[3], values[4], - ), + runtime::model::fixed::Color::new([ + values[1] as f32, + values[2] as f32, + values[3] as f32, + values[4] as f32, + ]), ) .into(), ); @@ -723,56 +726,55 @@ pub fn conv_pos( } } -#[allow(clippy::get_first)] pub fn conv_pos_point(value: &schema::animated_properties::position::Position) -> Value { conv_pos(value, |x| { - Point::new( - x.get(0).copied().unwrap_or(0.0), - x.get(1).copied().unwrap_or(0.0), - ) + let (x0, x1) = match x.get(0..=1) { + Some([x0, x1]) => (*x0, *x1), + _ => (0.0, 0.0), + }; + Point::new(x0, x1) }) } -#[allow(clippy::get_first)] pub fn conv_multi_point( value: &schema::animated_properties::multi_dimensional::MultiDimensional, ) -> Value { conv_multi(value, |x| { - Point::new( - x.get(0).copied().unwrap_or(0.0), - x.get(1).copied().unwrap_or(0.0), - ) + let (x0, x1) = match x.get(0..=1) { + Some([x0, x1]) => (*x0, *x1), + _ => (0.0, 0.0), + }; + Point::new(x0, x1) }) } -#[allow(clippy::get_first)] pub fn conv_color(value: &schema::animated_properties::color_value::ColorValue) -> Value { conv_multi_color(value, |x| { - Color::rgb( - x.get(0).copied().unwrap_or(0.0), - x.get(1).copied().unwrap_or(0.0), - x.get(2).copied().unwrap_or(0.0), - ) + let (x0, x1, x2) = match x.get(0..=2) { + Some([x0, x1, x2]) => (*x0, *x1, *x2), + _ => (0.0, 0.0, 0.0), + }; + Color::new([x0 as f32, x1 as f32, x2 as f32, 1.0]) }) } -#[allow(clippy::get_first)] pub fn conv_vec2(value: &MultiDimensional) -> Value { conv_multi(value, |x| { - Vec2::new( - x.get(0).copied().unwrap_or(0.0), - x.get(1).copied().unwrap_or(0.0), - ) + let (x0, x1) = match x.get(0..=1) { + Some([x0, x1]) => (*x0, *x1), + _ => (0.0, 0.0), + }; + Vec2::new(x0, x1) }) } -#[allow(clippy::get_first)] pub fn conv_size(value: &MultiDimensional) -> Value { conv_multi(value, |x| { - Size::new( - x.get(0).copied().unwrap_or(0.0), - x.get(1).copied().unwrap_or(0.0), - ) + let (x0, x1) = match x.get(0..=1) { + Some([x0, x1]) => (*x0, *x1), + _ => (0.0, 0.0), + }; + Size::new(x0, x1) }) } diff --git a/src/lib.rs b/src/lib.rs index 82de791..964635c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,9 +69,16 @@ clippy::missing_assert_message, clippy::missing_errors_doc, clippy::exhaustive_enums, - clippy::todo + clippy::todo, + reason = "Deferred" +)] +#![cfg_attr( + test, + allow( + unused_crate_dependencies, + reason = "Some dev dependencies are only used in tests" + ) )] -#![cfg_attr(test, allow(unused_crate_dependencies))] // Some dev dependencies are only used in tests pub(crate) mod import; pub(crate) mod runtime; diff --git a/src/runtime/model/animated.rs b/src/runtime/model/animated.rs index 2bcec92..d6e49d5 100644 --- a/src/runtime/model/animated.rs +++ b/src/runtime/model/animated.rs @@ -376,7 +376,10 @@ impl ColorStops { let g = v0.get(j + 2)?.tween(v1.get(j + 2)?, t, &easing); let b = v0.get(j + 3)?.tween(v1.get(j + 3)?, t, &easing); let a = v0.get(j + 4)?.tween(v1.get(j + 4)?, t, &easing); - let stop = peniko::ColorStop::from((offset as f32, peniko::Color::rgba(r, g, b, a))); + let stop = peniko::ColorStop::from(( + offset as f32, + peniko::Color::new([r as f32, g as f32, b as f32, a as f32]), + )); stops.push(stop); } Some(stops) @@ -404,7 +407,10 @@ impl Brush { /// Evaluates the animation at the specified time. pub fn evaluate(&self, alpha: f64, frame: f64) -> fixed::Brush { match self { - Self::Solid(value) => value.evaluate(frame).multiply_alpha(alpha as f32).into(), + Self::Solid(value) => value + .evaluate_or(frame, peniko::Color::TRANSPARENT) + .multiply_alpha(alpha as f32) + .into(), Self::Gradient(value) => value.evaluate(frame), } } diff --git a/src/runtime/model/fixed.rs b/src/runtime/model/fixed.rs index 59fe964..e344d31 100644 --- a/src/runtime/model/fixed.rs +++ b/src/runtime/model/fixed.rs @@ -59,26 +59,3 @@ impl Repeater { * Affine::translate((-self.anchor_point.x, -self.anchor_point.y)) } } - -// TODO: probably move this to peniko. The better option is to add an alpha -// parameter to the draw methods in vello. This is already handled at the -// encoding level. -pub(crate) fn brush_with_alpha(brush: &Brush, alpha: f64) -> Brush { - if alpha == 1.0 { - brush.clone() - } else { - match brush { - Brush::Solid(color) => color.multiply_alpha(alpha as f32).into(), - Brush::Gradient(gradient) => Brush::Gradient(peniko::Gradient { - kind: gradient.kind, - extend: gradient.extend, - stops: gradient - .stops - .iter() - .map(|stop| stop.multiply_alpha(alpha as f32)) - .collect(), - }), - _ => unreachable!(), - } - } -} diff --git a/src/runtime/model/mod.rs b/src/runtime/model/mod.rs index 39f65ad..e310301 100644 --- a/src/runtime/model/mod.rs +++ b/src/runtime/model/mod.rs @@ -15,33 +15,87 @@ pub use value::{Animated, Easing, EasingHandle, Time, Tween, Value, ValueRef}; pub(crate) use spline::SplineToPath; -macro_rules! simple_value { - ($name:ident) => { - #[allow(clippy::large_enum_variant)] - #[derive(Clone, Debug)] - pub enum $name { - Fixed(fixed::$name), - Animated(animated::$name), +#[derive(Clone, Debug)] +#[cfg_attr( + not(target_arch = "wasm32"), + expect( + clippy::large_enum_variant, + reason = "Deferred. Furthermore, for some reason, only on wasm32, this isn't triggering clippy." + ) +)] +pub enum Transform { + Fixed(fixed::Transform), + Animated(animated::Transform), +} +impl Transform { + pub fn is_fixed(&self) -> bool { + matches!(self, Self::Fixed(_)) + } + pub fn evaluate(&self, frame: f64) -> ValueRef { + match self { + Self::Fixed(value) => ValueRef::Borrowed(value), + Self::Animated(value) => ValueRef::Owned(value.evaluate(frame)), } + } +} - impl $name { - pub fn is_fixed(&self) -> bool { - matches!(self, Self::Fixed(_)) - } - pub fn evaluate(&self, frame: f64) -> ValueRef { - match self { - Self::Fixed(value) => ValueRef::Borrowed(value), - Self::Animated(value) => ValueRef::Owned(value.evaluate(frame)), - } - } +#[derive(Clone, Debug)] +pub enum Stroke { + Fixed(fixed::Stroke), + Animated(animated::Stroke), +} +impl Stroke { + pub fn is_fixed(&self) -> bool { + matches!(self, Self::Fixed(_)) + } + pub fn evaluate(&self, frame: f64) -> ValueRef { + match self { + Self::Fixed(value) => ValueRef::Borrowed(value), + Self::Animated(value) => ValueRef::Owned(value.evaluate(frame)), } - }; + } } -simple_value!(Transform); -simple_value!(Stroke); -simple_value!(Repeater); -simple_value!(ColorStops); +#[derive(Clone, Debug)] +#[cfg_attr( + not(target_arch = "wasm32"), + expect( + clippy::large_enum_variant, + reason = "Deferred. Furthermore, for some reason, only on wasm32, this isn't triggering clippy." + ) +)] +pub enum Repeater { + Fixed(fixed::Repeater), + Animated(animated::Repeater), +} +impl Repeater { + pub fn is_fixed(&self) -> bool { + matches!(self, Self::Fixed(_)) + } + pub fn evaluate(&self, frame: f64) -> ValueRef { + match self { + Self::Fixed(value) => ValueRef::Borrowed(value), + Self::Animated(value) => ValueRef::Owned(value.evaluate(frame)), + } + } +} + +#[derive(Clone, Debug)] +pub enum ColorStops { + Fixed(fixed::ColorStops), + Animated(animated::ColorStops), +} +impl ColorStops { + pub fn is_fixed(&self) -> bool { + matches!(self, Self::Fixed(_)) + } + pub fn evaluate(&self, frame: f64) -> ValueRef { + match self { + Self::Fixed(value) => ValueRef::Borrowed(value), + Self::Animated(value) => ValueRef::Owned(value.evaluate(frame)), + } + } +} #[derive(Clone, Debug)] pub enum Brush { @@ -60,7 +114,7 @@ impl Brush { if alpha == 1.0 { ValueRef::Borrowed(value) } else { - ValueRef::Owned(fixed::brush_with_alpha(value, alpha)) + ValueRef::Owned(value.to_owned().multiply_alpha(alpha as _)) } } Self::Animated(value) => ValueRef::Owned(value.evaluate(alpha, frame)), diff --git a/src/runtime/model/value.rs b/src/runtime/model/value.rs index 8a41119..3a3cc2b 100644 --- a/src/runtime/model/value.rs +++ b/src/runtime/model/value.rs @@ -13,17 +13,27 @@ pub enum Value { Animated(Animated), } +impl Value { + /// Returns the value at a specified frame. + pub fn evaluate(&self, frame: f64) -> T { + match self { + Self::Fixed(fixed) => fixed.clone(), + Self::Animated(animated) => animated.evaluate_or(frame, T::default()), + } + } +} + impl Value { /// Returns true if the value is fixed. pub fn is_fixed(&self) -> bool { matches!(self, Self::Fixed(_)) } - /// Returns the value at a specified frame. - pub fn evaluate(&self, frame: f64) -> T { + /// Returns the value at a specified frame, with a fallback default. + pub fn evaluate_or(&self, frame: f64, default: T) -> T { match self { Self::Fixed(fixed) => fixed.clone(), - Self::Animated(animated) => animated.evaluate(frame), + Self::Animated(animated) => animated.evaluate_or(frame, default), } } } @@ -41,7 +51,7 @@ pub enum ValueRef<'a, T> { Owned(T), } -impl<'a, T> AsRef for ValueRef<'a, T> { +impl AsRef for ValueRef<'_, T> { fn as_ref(&self) -> &T { match self { Self::Borrowed(value) => value, @@ -50,7 +60,7 @@ impl<'a, T> AsRef for ValueRef<'a, T> { } } -impl<'a, T: Clone> ValueRef<'a, T> { +impl ValueRef<'_, T> { pub fn into_owned(self) -> T { match self { Self::Borrowed(value) => value.clone(), @@ -139,8 +149,8 @@ pub struct Animated { impl Animated { /// Returns the value at the specified frame. - pub fn evaluate(&self, frame: f64) -> T { - self.evaluate_inner(frame).unwrap_or_default() + pub fn evaluate_or(&self, frame: f64, default: T) -> T { + self.evaluate_inner(frame).unwrap_or(default) } fn evaluate_inner(&self, frame: f64) -> Option { @@ -155,7 +165,7 @@ impl Animated { } /// Something that can be interpolated with an easing function. -pub trait Tween: Clone + Default { +pub trait Tween: Clone { fn tween(&self, other: &Self, t: f64, easing: &Easing) -> Self; } @@ -202,10 +212,12 @@ impl Tween for kurbo::Size { impl Tween for peniko::Color { fn tween(&self, other: &Self, t: f64, easing: &Easing) -> Self { - let r = (self.r as f64 / 255.0).tween(&(other.r as f64 / 255.0), t, easing); - let g = (self.g as f64 / 255.0).tween(&(other.g as f64 / 255.0), t, easing); - let b = (self.b as f64 / 255.0).tween(&(other.b as f64 / 255.0), t, easing); - let a = (self.a as f64 / 255.0).tween(&(other.a as f64 / 255.0), t, easing); - peniko::Color::rgba(r, g, b, a) + let [r1, g1, b1, a1] = self.components; + let [r2, g2, b2, a2] = other.components; + let r = (r1 as f64).tween(&(r2 as f64), t, easing); + let g = (g1 as f64).tween(&(g2 as f64), t, easing); + let b = (b1 as f64).tween(&(b2 as f64), t, easing); + let a = (a1 as f64).tween(&(a2 as f64), t, easing); + peniko::Color::new([r as f32, g as f32, b as f32, a as f32]) } } diff --git a/src/runtime/render.rs b/src/runtime/render.rs index a121ea1..7f4e754 100644 --- a/src/runtime/render.rs +++ b/src/runtime/render.rs @@ -66,7 +66,7 @@ impl Renderer { scene.pop_layer(); } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments, reason = "Deferred")] fn render_layer( &mut self, animation: &Composition, @@ -351,7 +351,7 @@ impl Batch { for draw in self.draws.iter().rev() { // Some nastiness to avoid cloning the brush if unnecessary let modified_brush = if draw.alpha != 1.0 { - Some(fixed::brush_with_alpha(&draw.brush, draw.alpha)) + Some(draw.brush.clone().multiply_alpha(draw.alpha as _)) } else { None }; diff --git a/src/schema/animation/mod.rs b/src/schema/animation/mod.rs index 3bf691e..de682f7 100644 --- a/src/schema/animation/mod.rs +++ b/src/schema/animation/mod.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT // todo motion-blur -#[allow(clippy::module_inception)] +#[expect(clippy::module_inception, reason = "Schema uses this format")] pub mod animation; // todo user-metadata pub mod composition; diff --git a/src/schema/assets/image.rs b/src/schema/assets/image.rs index 10e4b0c..4a17a2b 100644 --- a/src/schema/assets/image.rs +++ b/src/schema/assets/image.rs @@ -42,7 +42,7 @@ where } // Function signature must match Serde's Serialize trait, so need to suppress Clippy. -#[allow(clippy::trivially_copy_pass_by_ref)] +#[expect(clippy::trivially_copy_pass_by_ref, reason = "Deferred")] pub fn seq_to_str(v: &Option, serializer: S) -> Result where S: Serializer, diff --git a/src/schema/helpers/transform.rs b/src/schema/helpers/transform.rs index 5b32eff..4c8dbe6 100644 --- a/src/schema/helpers/transform.rs +++ b/src/schema/helpers/transform.rs @@ -56,7 +56,7 @@ pub enum AnyTransformP { /// The possible values of "r" in a [`Transform`]. #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] #[serde(untagged)] -#[allow(clippy::large_enum_variant)] +#[expect(clippy::large_enum_variant, reason = "Deferred")] pub enum AnyTransformR { /// Rotation in degrees, clockwise Rotation(FloatValue), diff --git a/src/schema/layers/mod.rs b/src/schema/layers/mod.rs index a1c9b5b..5769853 100644 --- a/src/schema/layers/mod.rs +++ b/src/schema/layers/mod.rs @@ -26,16 +26,14 @@ pub enum AnyLayer { /// Static rectangle filling the canvas with a single color SolidColor(SolidColorLayer), - /// Renders an Image - // todo Image - - /// No contents, only used for parenting - + /// No contents, only used for parenting. /// Has an array of shapes Shape(ShapeLayer), - // Renders Text - // todo Text + + /// Null Null(NullLayer), + // unimplemented - Text(TextLayer), + // unimplemented - Image(ImageLayer), // unimplemented - Audio(AudioLayer), // unimplemented - VideoPlaceholder(VideoPlaceholderLayer) // unimplemented - Video(VideoLayer) @@ -147,7 +145,7 @@ mod tests { ) }); - #[allow(deprecated)] + #[expect(deprecated, reason = "Uses deprecated attributes")] static LAYER: Lazy = Lazy::new(|| { AnyLayer::Shape(ShapeLayer { properties: VisualLayer { diff --git a/src/schema/shapes/mod.rs b/src/schema/shapes/mod.rs index cba8d8d..75169cb 100644 --- a/src/schema/shapes/mod.rs +++ b/src/schema/shapes/mod.rs @@ -51,7 +51,13 @@ use serde::{Deserialize, Serialize}; /// share the properties in `shapes::common::Properties`. #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)] #[serde(tag = "ty")] -#[allow(clippy::large_enum_variant)] +#[cfg_attr( + not(target_arch = "wasm32"), + expect( + clippy::large_enum_variant, + reason = "Deferred. Furthermore, for some reason, only on wasm32, this isn't triggering clippy." + ) +)] pub enum AnyShape { /// A group is a shape that can contain other shapes (including other /// groups)